[writan] make implicit links better

This commit is contained in:
opfez 2021-08-21 19:52:20 +02:00
parent c6628b5bce
commit 0ba2202cec
8 changed files with 40 additions and 42 deletions

View File

@ -136,7 +136,12 @@ void
get_link(FILE *input, char *out)
{
char c;
while (((c = fgetc(input)) != ' ') && c != '\n') {
/* some links add the initial { for some reason */
if (fgetc(input) != '{')
fseek(input, -1L, SEEK_CUR);
while (((c = fgetc(input)) != ' ') && c != '\n' && c != '}') {
if (c == EOF)
die("End of file encountered while parsing link.");
*(out)++ = c;
@ -161,20 +166,19 @@ emit_internal_implicit_link(FILE *input, FILE *output)
{
fseek(input, -1, SEEK_CUR);
char link[1024];
char page[1024];
char *page_ptr = page;
get_link(input, link);
while ((*(page_ptr++) = fgetc(input)) != '}');
*(page_ptr - 1) = '\0';
memcpy(page, link, 1024);
char pagename[1024];
size_t i;
for (i = 0; page[i] != '\0'; i++) {
pagename[i] = (page[i] == '-' ? ' ' : page[i]);
}
pagename[i] = '\0';
for (size_t i = 0; link[i] != '\0'; i++)
if (link[i] >= 'A' && link[i] <= 'Z') link[i] = link[i] + 32;
fprintf(output, "<a href=\"%s.html\">{%s}</a>", page, pagename);
for (size_t i = 0; page[i] != '\0'; i++)
if (page[i] == '-') page[i] = ' ';
fprintf(output, "<a href=\"%s.html\">{%s}</a>", link, page);
}
bool

5
gen.sh
View File

@ -2,7 +2,10 @@
# Strip the CSS file of whitespace to reduce file size
echo "Generating CSS"
tr -d " \t\n\r" < resources/style-formatted.css > resources/style.css
sed "s/FG/#ddd/g" < resources/style-formatted.css |
sed "s/BG/#111/g" |
sed "s/CODEBG/#1a1a1a/g" |
tr -d " \t\n\r" > resources/style.css
# Generate HTML pages from Writan sources
echo "Generating pages"

View File

@ -1,15 +1,6 @@
:root {
--fg: #ddd;
--bg: #111;
--code-bg: #1a1a1a;
/* --bg: #eee; */
/* --fg: #111; */
/* --code-bg: #dedede */
}
body {
color: var(--fg);
background: var(--bg);
color: FG;
background: BG;
font-family: serif;
margin: 2em;
max-width: 50em;
@ -18,22 +9,22 @@ body {
}
a {
color: var(--fg);
color: FG;
text-decoration: none;
}
a:hover {
color: var(--bg);
background: var(--fg);
color: BG;
background: FG;
}
pre {
background: var(--code-bg);
background: BG;
padding: 0.5em;
}
code {
background: var(--code-bg);
background: CODEBG;
padding: 0.2em;
}

View File

@ -1,9 +1,9 @@
* C
The C {programming-language} was developed at Bell Labs in the 1970s to
implement the original UNIX kernel and userland. It's a general purpose,
imperative systems programming language with a weak, static typing dicipline
(due to void* and dynamic type casts).
The C {programming-languages programming language} was developed at Bell Labs in
the 1970s to implement the original UNIX kernel and userland. It's a general
purpose, imperative systems programming language with a static, weak typing
dicipline (due to void* and dynamic type casts).
It is an extremely portable language, with compilers available on most systems.

View File

@ -6,7 +6,7 @@ GNU Emacs. Others include edwin for the MIT/GNU Scheme system and Zmacs for the
Open Genera OS.
Emacs editors are configured through some programming language, usually a
dialect of {lisp Lisp}. This is what gives them their powerful extension
dialect of {Lisp}. This is what gives them their powerful extension
properties. GNU Emacs and XEmacs uses Emacs Lisp, a Common Lisp inspired
dialect. Because of its extensibility, Emacs has become a target for
applications on its own, trancending the original intent of being merely a text

View File

@ -1,6 +1,6 @@
* Index
Welcome to {codex Codex}.
Welcome to {Codex}.
{site-index Full list of pages in Codex}
@ -8,6 +8,6 @@ Welcome to {codex Codex}.
** Topics
{computation Computation}
{language Language}
{aesthetic Aesthetic}
{Computation}
{Language}
{Aesthetic}

View File

@ -2,6 +2,6 @@
Programming languages are formal languages used to express computational logic.
{c C}
{lisp Lisp}
{haskell Haskell}
{Lisp}
{C}
{Haskell}

View File

@ -1,7 +1,7 @@
* Writan
Writan is the formatting language used to generate pages for {codex Codex}. It
only has a few distinct formatting rules.
Writan is the formatting language used to generate pages for {Codex}. It only
has a few distinct formatting rules.
It uses the file extension ".wtn".