~strahinja/slweb

ref: fc3052bb6a8a6077e1f07d39fed2d6c52a4a8e90 slweb/index.slw -rw-r--r-- 4.4 KiB
fc3052bbСтрахиња Радић index.slw: Add formatting a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
---
site-name: slweb - Simple static website generator
site-desc: Simple static website generator
stylesheet: /slweb/index.css
stylesheet: /slweb/katex.min.css
favicon-url: /slweb/favicon.ico
image: https://strahinja.srht.site/slweb/logo-social.webp
canonical: https://strahinja.srht.site/slweb/
meta: index-meta.csv
---
{main}
# slweb

**slweb** is a static website generator which aims at being simplistic. It
transforms custom Markdown-like syntax into HTML.


## Q&A

{dl}
{dt}
**Q:** Is this suckless?{/dt}
{dd}
**A:** No. SGML, and by extension, HTML, isn't suckless.{/dd}

{dt}
**Q:** Why do you call it “simple” then?{/dt}
{dd}
**A:** Because one is not the synonym for the other.{/dd}

{dt}
**Q:** Why not make a website generator as a shell script?{/dt}
{dd}
**A:** slweb _was_ a shell script in its conception (check its history of
commits in git). However, I wanted to implement Markdown links with link ids
`\[like]\[this]`. This requires multiple passes by the parser and is better
implemented as a full-blown program in C anyway. The other reason was that sed
and awk have limits, which some of my pages hit.

`\[this]: https://some.site`{/dd}

{dt}
**Q:** My static website generator is “truly simple”, this is not
simple!{/dt}
{dd}
**A:** Good for you. By the way, that is a statement and not a question.{/dd}
{/dl}


## Prerequisites

* C compiler (**GCC**-compatible) - `${SLWEB_CC:-gcc -g}`
* **gzip**


## Optional dependencies

* [KaTeX][katex] for math mode
* **git** (for `{git-log}`)
* **identify** from [ImageMagick][imgmg] (for `<img width="" height="">`)


## Install

```
$ git clone https://git.sr.ht/~strahinja/slweb
$ cd slweb
$ su
```

Then, if you have [apenwarr/redo][aredo]:

```
# redo install
```

if you don't:

```
# ./do install
```

You can specify any compiler which uses (or tolerates) `-Wall`, `-std=c99`,
`-c`, `-g` and `-o` like GNU C, most notably **tcc**(1), by setting the
`SLWEB_CC` environment variable. For example:

```
$ SLWEB_CC=tcc redo -j10
```

In the case of **tcc**, the tradeoff is that the debug information is limited
compared to **gcc**, but the compilation time is significantly shorter.


## Examples

See the [`examples/`][examp] directory in this repository.

Given the file `index.slw` in the current directory:

```
---
site-name: Test website
site-desc: My first website in slweb
---

{main}
# Hello world

This is an \_example_ of a statically generated HTML.

{/main}
```

after using the command:

```
$ slweb index.slw > index.html
```

file `index.html` contains:

```
&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
    &lt;title&gt;Test website&lt;/title&gt;
    &lt;meta charset="utf8" /&gt;
    &lt;meta name="description" content="My first website in slweb" /&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1" /&gt;
    &lt;meta name="generator" content="slweb" /&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;main&gt;
&lt;h1&gt;Hello world&lt;/h1&gt;

&lt;p&gt;This is an &lt;em&gt;example&lt;/em&gt; of a statically generated HTML.&lt;/p&gt;

&lt;/main&gt;
&lt;/body&gt;
&lt;/html&gt;
```

## TODO (checklist)

See the file [`TODO`][mtodo] for more information.


## Bugs and limitations

Bugs can be reported using the [ticket tracker][issue]. See the manpage (`man
slweb`) after installing **slweb** for more information.


## License

slweb - Simple static website generator.  
Copyright (C) 2020, 2021 Страхиња Радић

This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version. 

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details. 

You should have received a copy of the GNU General Public License along with
this program. If not, see &lt;[https://www.gnu.org/licenses/][licen]&gt;. 

{git-log}

{made-by}
{/main}


[aredo]: https://github.com/apenwarr/redo
[examp]: https://git.sr.ht/~strahinja/slweb/tree/master/item/examples
[imgmg]: https://imagemagick.org
[issue]: https://todo.sr.ht/~strahinja/slweb
[mtodo]: https://git.sr.ht/~strahinja/slweb/tree/master/item/TODO
[katex]: https://katex.org
[licen]: https://www.gnu.org/licenses