# HG changeset patch # User Tuomo Valkonen # Date 1594050983 18000 # Node ID 3c71c525cec2f0590f66dc67fb00d451221c3c39 # Parent 3b937ef20faa030018371bfa1388f011a76f47bf Use markdown-it as default markdown parser. diff -r 3b937ef20faa -r 3c71c525cec2 .hgignore --- a/.hgignore Mon Jul 06 09:36:27 2020 -0500 +++ b/.hgignore Mon Jul 06 10:56:23 2020 -0500 @@ -1,2 +1,6 @@ syntax: glob example/out/ +node_modules/ +package-lock.json + + diff -r 3b937ef20faa -r 3c71c525cec2 README.md --- a/README.md Mon Jul 06 09:36:27 2020 -0500 +++ b/README.md Mon Jul 06 10:56:23 2020 -0500 @@ -2,20 +2,35 @@ # lgen This is a very simple website templating engine based on markdown and Lua, -written by Tuomo Valkonen 〈〉. +written by Tuomo Valkonen ⟨⟩. It is not particularly supported or maintained; it was created back in 2009 to build [my own website](http://tuomov.iki.fi/). The engine is still being used for that purpose. I decided to put the code online in 2017 after -having had to spend some time to convert it to Lua 5.3 from which the -module() function had been removed. +having had to spend some time to convert it from earlier versions to [Lua 5.3][Lua] from which the `module()` function had been removed. -Features (see the included example): +## Features + +For details see the included example. * Embedded Lua code with the ltp engine. - * Advanced markdown features, including syntax highlighting of code blocks, via Pandoc - (select `renderer: pandoc` in the page meta section). + * Advanced markdown features, including syntax highlighting of code blocks + and LaTeX mathematics via + [markdown-it][] and [KaTeX][] or [Pandoc][]. Markdown-it is now the default renderer. To select lua-markdown, use `renderer: lua-markdown` in the page YAML meta section. Use `renderer: pandoc` for Pandoc. + +## Installation + +You need to install [Lua 5.3][Lua]. +To use [markdown-it][], you need to install [NodeJS][] and then execute `npm install` to install in the top directory of this project. + +## License Aside from the included `compat_env.lua` and the ltp engine (which is has not updated to Lua 5.3, and requires on the compat_env module), the code is in the public domain. + +[KaTeX]: https://katex.org/ +[markdown-it]: https://github.com/markdown-it/markdown-it +[Pandoc]: https://pandoc.org/ +[Lua]: http://www.lua.org/ +[NodeJS]: https://nodejs.org/en/ diff -r 3b937ef20faa -r 3c71c525cec2 example/src/style/default.css --- a/example/src/style/default.css Mon Jul 06 09:36:27 2020 -0500 +++ b/example/src/style/default.css Mon Jul 06 10:56:23 2020 -0500 @@ -1,9 +1,6 @@ - -@import "pandoc.css"; body { font-family: Optima, Linux Biolinum, Candara, sans-serif; - #font-weight: 300; background: #ffffff; color: #000000; margin: 10px 40px 40px 40px; @@ -359,4 +356,4 @@ background: #ff9900; } -@import "pandoc.css"; +.katex { font-size: normal; } diff -r 3b937ef20faa -r 3c71c525cec2 example/src/style/pandoc.css --- a/example/src/style/pandoc.css Mon Jul 06 09:36:27 2020 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -/* Extracted manually from `pandoc -s some-file-with-syntax-highlighting` */ -code{white-space: pre-wrap;} -span.smallcaps{font-variant: small-caps;} -span.underline{text-decoration: underline;} -div.column{display: inline-block; vertical-align: top; width: 50%;} -div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} -ul.task-list{list-style: none;} -pre > code.sourceCode { white-space: pre; position: relative; } -pre > code.sourceCode > span { display: inline-block; line-height: 1.25; } -pre > code.sourceCode > span:empty { height: 1.2em; } -code.sourceCode > span { color: inherit; text-decoration: inherit; } -div.sourceCode { margin: 1em 0; } -pre.sourceCode { margin: 0; } -@media screen { -div.sourceCode { overflow: auto; } -} -@media print { -pre > code.sourceCode { white-space: pre-wrap; } -pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; } -} -pre.numberSource code - { counter-reset: source-line 0; } -pre.numberSource code > span - { position: relative; left: -4em; counter-increment: source-line; } -pre.numberSource code > span > a:first-child::before - { content: counter(source-line); - position: relative; left: -1em; text-align: right; vertical-align: baseline; - border: none; display: inline-block; - -webkit-touch-callout: none; -webkit-user-select: none; - -khtml-user-select: none; -moz-user-select: none; - -ms-user-select: none; user-select: none; - padding: 0 4px; width: 4em; - color: #aaaaaa; - } -pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; } -div.sourceCode - { } -@media screen { -pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; } -} -code span.al { color: #ff0000; font-weight: bold; } /* Alert */ -code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */ -code span.at { color: #7d9029; } /* Attribute */ -code span.bn { color: #40a070; } /* BaseN */ -code span.bu { } /* BuiltIn */ -code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */ -code span.ch { color: #4070a0; } /* Char */ -code span.cn { color: #880000; } /* Constant */ -code span.co { color: #60a0b0; font-style: italic; } /* Comment */ -code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */ -code span.do { color: #ba2121; font-style: italic; } /* Documentation */ -code span.dt { color: #902000; } /* DataType */ -code span.dv { color: #40a070; } /* DecVal */ -code span.er { color: #ff0000; font-weight: bold; } /* Error */ -code span.ex { } /* Extension */ -code span.fl { color: #40a070; } /* Float */ -code span.fu { color: #06287e; } /* Function */ -code span.im { } /* Import */ -code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */ -code span.kw { color: #007020; font-weight: bold; } /* Keyword */ -code span.op { color: #666666; } /* Operator */ -code span.ot { color: #007020; } /* Other */ -code span.pp { color: #bc7a00; } /* Preprocessor */ -code span.sc { color: #4070a0; } /* SpecialChar */ -code span.ss { color: #bb6688; } /* SpecialString */ -code span.st { color: #4070a0; } /* String */ -code span.va { color: #19177c; } /* Variable */ -code span.vs { color: #4070a0; } /* VerbatimString */ -code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */ diff -r 3b937ef20faa -r 3c71c525cec2 example/src/subpage/index.html.lg --- a/example/src/subpage/index.html.lg Mon Jul 06 09:36:27 2020 -0500 +++ b/example/src/subpage/index.html.lg Mon Jul 06 10:56:23 2020 -0500 @@ -1,6 +1,6 @@ --- title: This is a sub-page of an lgen test page -renderer: pandoc +renderer: markdown-it --- With the pandoc-renderer in this page, we can use GitHub-flavoured markdown, @@ -12,3 +12,7 @@ end ``` +We can also do math $x^2$ with KaTeX +$$ + \sum_{k=1}^\infty \frac{1}{k} = \infty. +$$ diff -r 3b937ef20faa -r 3c71c525cec2 example/tmpl/page.template --- a/example/tmpl/page.template Mon Jul 06 09:36:27 2020 -0500 +++ b/example/tmpl/page.template Mon Jul 06 10:56:23 2020 -0500 @@ -1,10 +1,14 @@ - + + + +