add a ton of new pages, format.c cleanup, improve css

This commit is contained in:
opFez 2021-07-31 16:29:39 +02:00
parent ece80e2d81
commit a8dd8088e7
12 changed files with 146 additions and 26 deletions

1
TODO Normal file
View File

@ -0,0 +1 @@
Add support for quoting.

View File

@ -176,7 +176,7 @@ format(FILE *input, FILE *output)
char c, lastc = '\n';
while ((c = fgetc(input)) != EOF) {
if (c == '\\') {
if (c == '\\') { /* escaped character */
fputc(fgetc(input), output);
}
else if (c == '*' && lastc == '\n') { /* heading */
@ -194,7 +194,7 @@ format(FILE *input, FILE *output)
fputc('\n', output);
fprintf(output, "<p>");
}
else if (c == '\n') {
else if (c == '\n') { /* just a new line, same paragraph */
fputc(' ', output);
}
else {
@ -219,9 +219,7 @@ main(int argc, char *argv[])
if (!argc)
die("No filename provided, exiting.");
FILE *in_initial = fopen(argv[1], "r");
FILE *in_collapsed = collapse_paragraphs(in_initial);
fclose(in_initial);
FILE *in = fopen(argv[1], "r");
FILE *out;
if (argc == 2) {
@ -237,12 +235,11 @@ main(int argc, char *argv[])
out = fopen(argv[2], "w");
}
FILE *in = fopen(argv[1], "r");
write_file(out, "resources/header.html");
format(in, out);
write_file(out, "resources/footer.html");
fclose(in);
fclose(out);
fclose(in_collapsed);
}

5
gen.sh
View File

@ -15,9 +15,10 @@ gen_site_index() {
cat resources/footer.html >> $indexfile
}
# Generating html pages from writan sources
for file in site-src/*; do
bn=$(basename $file .src)
echo "Converting $bn..."
bn=$(basename $file .wtn)
echo "$file -> site/$bn.html"
./format $file site/$bn.html
done

View File

@ -1,13 +1,26 @@
:root {
--fg: #ddd;
--bg: #111;
}
body {
color: #ddd;
background: #000;
color: var(--fg);
background: var(--bg);
font-family: serif;
margin: 2em;
max-width: 40%;
}
a {
color: #ddd;
color: var(--fg);
text-decoration: none;
}
a:hover {
color: #000;
background: #ddd;
color: var(--bg);
background: var(--fg);
}
pre {
font-size: 14px;
}

View File

@ -1,10 +0,0 @@
* Codex
Codex is a wiki engine written in C99 and POSIX shell script.
It's inspired by {https://wiki.xxiivv.com/site/ XXIIVV},
{https://pbat.ch/wiki pbat.ch} and similar personal wikis.
It uses a simple {writan formatting language} to generate its pages.
{https://tildegit.org/opfez/codex Source}

10
site-src/codex.wtn Normal file
View File

@ -0,0 +1,10 @@
* Codex
Codex is a wiki engine written in C99 and POSIX shell script.
It's inspired by {https://wiki.xxiivv.com/site/ XXIIVV}, {https://pbat.ch/wiki
pbat.ch} and similar personal wikis.
It uses a simple {writan formatting language} to generate its pages.
{https://tildegit.org/opfez/codex Source}

6
site-src/haskell.wtn Normal file
View File

@ -0,0 +1,6 @@
* Haskell
Haskell is a purely functional, lazy, strongly and statically typed, general
purpose programming language based on the typed {lambda-calculus lambda
calculus}. It famously uses monads to express I/O interactions. Many of its
strengths come from its powerful type system.

View File

@ -0,0 +1,32 @@
* Lambda calculus
The lambda calculus is a formal system for expressing computation using function
application and abstraction invented by Alonzo Church in the 1930s. It is a
universal model of computation.
** Constructing lambda terms
Lambda calculus is based on constructing lambda terms and reducing them. It only
has three methods of creating such terms.
1. Variables
2. Function construction
3. Function application
For instance, the identity function is expressed as λx.x. Here, λx constructs a
new function which takes an argument x. When applied it evaluates to the
expression following the period. λx.x is therefore the function that takes one
argument and evaluates to that argument. An example of applying this function is
(λx.x) y → y.
** Reduction
There are two ways of reducing an expression, α-conversion and
β-reduction. α-conversion is simply renaming the bound variables in an
expression. This doesn't change the expression, but can be used to avoid naming
collisions. Because of α-conversion, two functions such as λx.x and λy.y are
said to be α-equivalent. β-reduction is replacing the arguments of a function
with the values they are bound to in an expression. For instance ((λx.λy.xy) f
g) will be β-reduced to f applied to g.

62
site-src/lisp.wtn Normal file
View File

@ -0,0 +1,62 @@
* Lisp
<blockquote>\[Lisp\] has assisted a number of our most gifted fellow humans in
thinking previously impossible thoughts.</blockquote>
- Edsger Dijkstra
Lisp is a family of {programming-languages programming languages} which uses
s-expressions for expressing both source code and data. Its syntax is fully
parenthesized and features prefix notation.
Some dialects of Lisp include Common Lisp, Scheme and Clojure.
** Prefix notation
A Lisp form consists of an operator followed by zero or more operands.
[(operator operand1 operand2 ...)]
The operator will be evaluated first, then the operands. Finally, the form will
evaluate to the result of applying the operands to the operator. This is the
basic evaluation model for Lisp.
** Lisp-1 vs Lisp-2
Dialects of Lisp generally fall into one of two categories, Lisp-1 or
Lisp-2. The difference between them is the number of namespaces they have. A
Lisp-1 shares the same namespace for variables and functions, while a Lisp-2 has
separate namespaces for each. Scheme is an example of a Lisp-1 and Common Lisp
is an example of a Lisp-2. Lisp-1's tend to be more elegant since they can share
the assignment operators for both.
** Macros
Since Lisp dialects are generally homoiconic, they lend themselves particularly
well to macro systems. Invocations of macros are replaced at compile time with
another Lisp form.
An example in Common Lisp:
[;; Example definition of let using a lambda for creating a local context
(defmacro my-let (bindings &body body)
(let ((vars (mapcar #'car bindings))
(vals (mapcar #'cadr bindings)))
`((lambda ,vars ,@body) ,@vals)))
;; Example invocation:
(my-let ((a 1)
(b 2))
(+ a b))
;; This is expanded at compile time to the following form:
((lambda (a b)
(+ a b))
1 2)
]
{https://tildegit.org/opfez/lisp-hacks Various Common Lisp hacks}
{http://www.phyast.pitt.edu/~micheles/syntax-rules.pdf JRM's syntax-rules primer
for the merely eccentric}

View File

@ -0,0 +1,6 @@
* Programming languages
Programming languages are formal languages used to express computational logic.
{lisp Lisp}
{haskell Haskell}

View File

@ -3,8 +3,10 @@
Writan is the formatting language used to generate pages for the {codex}. It
only has a few distinct formatting rules.
To get an overview over how it works, take a look at the
{../resources/writan-example.txt example document}.
It uses the file extension ".wtn".
To get an overview over how it works, take a look at the {../resources/writan-example.txt
example document}.
{https://tildegit.org/opfez/codex/branch/master/format.c Source code of the
formatter}