jgm / djot

A light markup language
https://djot.net
MIT License
1.73k stars 43 forks source link

Document Construction #317

Closed Gavin-Holt closed 1 month ago

Gavin-Holt commented 1 month ago

Hi,

I am enjoying exploring djot, many thanks for providing several implementations and a great help file (works well off-line). I have used djot as a pure Lua library to call from CivetWeb/Scite/Micro - where finding compatible DLLs is hell. Also I have downloaded the compiled rust version jotdown.exe to process local files.

Previously, I have used MultiMarkdown.exe, which adds transclusion for document construction. This is useful, but causes the inevitable problems with local/absolute paths.

Upon reflection, I would support leaving djot as a markup syntax, following the oft mentioned UNIX philosophy - "write programs that do one thing and do it well".

Perhaps a dedicated preprocessor is the better home for file transclusion? I am preprocessing with upp.exe as I like scripting in Lua:

REM Windows Batch File - associated with my djot files

REM Check %1 in not null
if [%1]==[] (
echo No parameters passed
goto End
)

REM Change to parameter file location
cd /D "%~dp1"

REM Pipe file through upp and jotdown
upp.exe -p . "%1" | jotdown.exe - > %~dpnx1.html

REM Finesse with sed
sed.exe -i "s/>\s*£/ style=""text-align:right""&/g"  %~dpnx1.html
sed.exe -i "s/<table>/<table class='sortable'>/g"  %~dpnx1.html

REM Launch in default browser
shelexec.exe  %~dpnx1.html

:End

Kind Regards Gavin Holt

jgm commented 1 month ago

Yes, I think this is an important question to consider. The drawback of a preprocessor is that it's ignorant of the djot syntax context. For example, if your symbol to include a file is %%myfile.txt, then the preprocessor will include it even if it occurs inside a djot code block or comment.

Gavin-Holt commented 1 month ago

Hi,

The upp.exe preprocessor only uses two identifiers:

I don't use JQuery, or I would be in deep trouble!

So as long as there are no sadness emojis :( in my markdown, I should be safe!

Kind Regards Gavin Holt