You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(I think I took this photo in June, everything's way bigger now, but the
402
+
camera's in the other room and I can't be bothered)
403
+
404
+
** static site generation
405
+
Anyway, I got some time to start thinking about my static site generator more
406
+
concretely. Working name (because I needed a directory name in my projects
407
+
folder) is /kishin/ (記伸), coming from "memory" (記憶) and "extend" (伸びる),
408
+
inspired by the word memex.
409
+
410
+
Earlier I was considering writing my input files in Markdown, but more and more
411
+
I'm starting to think that it's not much more work to just write plain html (my
412
+
current emacs setup seems to have a good amount of snippets already set up in
413
+
=html-mode=). The job of the static site generator will be to:
414
+
- do basic templating (separating out the header, footer, etc. from content)
415
+
- handle media (organization of images, automatically generating thumbnails,
416
+
etc.)
417
+
- handle timestamps, tags, backlinks, or more generally metadata linking and
418
+
display
419
+
- run any processing modules that I end up writing (math rendering, syntax
420
+
highlighting)
421
+
422
+
In terms of parsing html, I'm not sure how much heavy lifting I'll actually have
423
+
to do. For now I'm thinking I'll try out the tree-sitter html parser. I'd love
424
+
to be dependency-free and write a bespoke parser, but I should probably ease
425
+
myself into the intricacies of string parsing and data structures in =c=. In any
426
+
case, I've wanted to play with tree-sitter ever since I watched Max Brunsfeld's
427
+
[[https://www.youtube.com/watch?v=Jes3bD6P0To][strange loop]] talk on it.
428
+
429
+
Actually, now that I think about it for a moment, tree-sitter might be the way
430
+
to go if I want to do any syntax highlighting for my code blocks...
431
+
432
+
** tree-sitter
433
+
As a complete newbie to the =c= programming world, I couldn't make heads or tails
434
+
of the [[https://tree-sitter.github.io/tree-sitter/using-parsers/1-getting-started.html][getting started]] page in the tree-sitter documentation. After being
435
+
confused for a solid half-hour, here's what I ended up doing, which worked:
436
+
1. cloned both the [[https://github.com/tree-sitter/tree-sitter][tree-sitter]] and [[https://github.com/tree-sitter/tree-sitter-html][tree-sitter-html]] sources, built them with
437
+
=make=, and copied the resulting =libtree-sitter.a= and =libtree-sitter-html.a=
438
+
files into my =lib/= folder.
439
+
2. copied tree-sitter's =tree-sitter/lib/src/*= as well as
440
+
=tree-sitter/lib/include/tree_sitter/api.h= into my =include/tree-sitter/=
441
+
3. made sure my =Makefile= knew about these static libraries and the inner include
442
+
path
443
+
444
+
I don't know if this is what I was supposed to do, but I'm able to use
445
+
tree-sitter from my =main.c=, so it'll do for now. I copied the example code from
446
+
the tree-sitter documentation and started playing around with traversing the
0 commit comments