From e3de50fb68ade37b1f2a255a181d9e9d6b2e9819 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 1 Dec 2026 15:04:57 +0100 Subject: Work on document formats and move interesting projects there --- blog/content/notes/tech/document-formats.gmi | 123 ++++++++++++++++++++------- 1 file changed, 92 insertions(+), 31 deletions(-) (limited to 'blog/content/notes/tech/document-formats.gmi') diff --git a/blog/content/notes/tech/document-formats.gmi b/blog/content/notes/tech/document-formats.gmi index 32144ec4..63ced6cd 100644 --- a/blog/content/notes/tech/document-formats.gmi +++ b/blog/content/notes/tech/document-formats.gmi @@ -1,31 +1,33 @@ # Document formats -Most of the time, when writing a document, I want a document format with the following properties: +## Existing formats -* Fast to write using a plain text editor -* Easy to parse into an AST +### Gemtext -An AST is a programming-friendly representation of a document. ASTs reduce the effort required to write tools such as a program that validates links in a document. Ideally, ASTs contain information to track a document element to the position it occupies in the original document. With this information, if you write a tool such as a spell checker, then you can highlight misspelled works precisely in the original document. +=> https://geminiprotocol.net/docs/gemtext-specification.gmi -On top of that, some features that I don't always need: +Gemtext is an extremely minimalistic markup language designed for use with the Gemini protocol (an extremely minimalistic protocol similar to HTTP) as an alternative to the web. -* Math support -* Sophisticated code blocks. For example, being able to highlight arbitrary parts of code blocks (not syntax highlighting). -* Diagram support +Gemtext has no inline links or formatting and many other limitations. On the other hand, because gemtext is so simple, implementing anything on top of gemtext tends to require very little effort. Therefore, if Gemtext has sufficient power for your document, you can likely implement any kind of system on top of it in a reasonable amount of time. -## Existing formats +This document is gemtext-native for use in my own minimalistic publishing system. + +If you are primarily writing prose and the limitations of gemtext are not a problem, the I would recommend starting from Gemtext. Even if you later hit some limitation, you should be able to convert to any other format without much effort. (Although likely you will want to rethink your content a bit once you are no longer under the gemtext constraints.) + +=> ../../gemini See also my Gemini start page ### Markdown -* Easy to write using a plain text editor -* Has good AST parsers with position information -* Has math support -* Does not support sophisticated code blocks -* There are many extensions with support for math, diagrams, and many others -* Is very popular and supported everywhere -* However, there is a wide variety of variants and quirks -* Especifically, because Markdown was not designed with parsing in mind, so tools based on different parsers can have differences in behavior -* Markdown is irrevocably coupled to HTML, and HTML is recommeded for "extensibility" and for markup not covered by Markdown itself. +Markdown is the most popular plain text format. Many are familiar with it or can learn the basics without excessive effort. A lot of software can deal with Markdown, although with significant differences in specifics. A few Markdown standards exist, but different software follows different standards, with different extensions and quirks. + +* Markdown has good AST parsers with position information (but not all parsers and software have this). +* There is a lot of Markdown software with support for math (frequently using LaTeX syntax), diagrams, and others. +* Markdown does not support sophisticated code blocks. +* Although many Markdown software supports print (particularly PDF), Markdown was designed for HTML output and many implementations use HTML for some features, so print often does not support all features. + +=> https://pandoc.org/ Pandoc is the most popular Markdown software. +=> https://hedgedoc.org/ HedgeDoc is a collaborative browser-based real-time Markdown editor with cute attributed blockquotes for commenting. +=> https://liascript.github.io/ LiaScript is an interactive course builder that uses Markdown and can export to SCORM, ePUB and others. ### Djot @@ -33,8 +35,8 @@ On top of that, some features that I don't always need: It is very similar to Markdown, except: -* It is designed for parsing, so independent parsing implementations are very compatible with each other -* It is not so popular, so there are less extension and tool support +* It is designed for parsing, so independent parsing implementations are very compatible with each other. +* It is not so popular, so there are less extensions and tool support. ### AsciiDoc @@ -42,10 +44,10 @@ It is very similar to Markdown, except: Compared to Markdown: -* It's more complex to write, but mostly because it's different and more powerful -* There are attempts to write better parsers, but good parsers with position information are not available yet -* Supports sophisticated code blocks -* It has a smaller ecosystem than Markdown, but many good quality tools such as Antora +* It's more complex to write, but mostly because it's different and more powerful. +* There are attempts to write better parsers, but good parsers with position information are not available yet. +* Supports sophisticated code blocks. +* It has a smaller ecosystem than Markdown, but many good quality tools such as Antora. ### Typst @@ -54,8 +56,9 @@ Compared to Markdown: Checks all my boxes, except: * It is designed for parsing and it has an AST, but it is not easy to access -* Currently Typst is very oriented towards generating paged documents (e.g. PDF) +* Currently Typst is very oriented towards generating paged documents in PDF format. There is some experimental HTML support. * It includes a full programming language, which is mostly good (very extensible), but this might increase complexity undesirably +* Changing styling is complex. Typst is very new and is not yet very popular. @@ -87,14 +90,72 @@ A Markdown-like closely tied to the Lean programming language. => https://github.com/spc476/MOPML Someone created its own lightweight format using Lua and PEGs. => https://tratt.net/laurie/blog/2020/which_parsing_approach.html "Which parsing approach" has information about choosing parsing approaches. -## About gemtext +## Desirable properties -=> https://geminiprotocol.net/docs/gemtext-specification.gmi +### Plain text input -Gemtext is an extremely minimalistic markup language designed for use with the Gemini protocol (an extremely minimalistic protocol similar to HTTP). +Many document preparation formats are "what you see is what you get" (WYSIWYG). They show your document as it will appear when published. -The Gemini protocol and gemtext are intentionally designed to limit their power, in my opinion as a comment on the web. +This is convenient, but this tends to hide the document structure, which makes editing harder. -This document is gemtext-native for use in my own minimalistic publishing system. +Most document formats discussed here are based on plain text. You write using a plain text editor, adding formatting with text. For example, many formats support adding bold by wrapping the bolded text in asterisks. + +With plain text document formats, you always see the document structure while editing, which makes some formatting easier. + +However, controlling exact layout might be complex. Although when working with multiple publishing formats (such as the web or print), frequently exact layout control is not desirable. + +### Manipulable + +Sometimes you want to process your document. For example, use a spell checker or extract links from a document to validate them. + +Some document formats can be parsed into a programming-friendly representation. These representations are sometimes called abstract syntax trees (AST) or similar terms. + +With such representations, writing programs that process documents is simpler and more productive. + +For some purposes, this representation should contain information that allows to correlate any part of the document to the position in the original source. With this information, programs can be more powerful. For example, a spell checker can provide your editor where misspellings are, and your editor can highlight them in real time. + +### Output formats + +Some time ago, most documents were meant for print. But increasingly people expect documents to be usable in electronic devices such as computers, tablets, phones, or e-ink readers. + +Electronic devices have different screen sizes, which means document layout should not be fixed. + +Also, while printed documents need to be paged and this can add some difficulties (such as having to break long text or tables over several lines or pages), many electronic devices let the reader scale and scroll the document eliminating some of those problems. + +HTML and ePUB are interesting formats for electronic devices. ePUB are designed for offline use and e-ink devices, although outside e-ink devices ePUB tends to be inconvenient (most readers won't have ePUB readers outside their e-ink devices). HTML is convenient for online publishing on the web, because most readers have web browsers. However, offline use of HTML tends to be even more problematic than ePUB. + +PDF is the most popular document format. Most readers can use PDF easily and offline support might be even more convenient than HTML. Despite PDF rarely being authored to be adaptable to different screen sizes, PDFs are convenient even for electronic devices outside print. + +Output formats might have unexpected properties. For example, copying content from PDF documents is often results in broken formatting. + +### Math and other complex content + +Prose is easy to input on a keyboard or by most alternative means. However, maths, diagrams and other kinds of content cannot be typed in easily. + +For maths, Donald Knuth created in 1978 the TeX document preparation system with outstanding support for maths. With TeX, you can write most maths with plain text. Many people who write mathematical documents are familiar with writing maths with TeX. Many modern document preparation formats use the TeX syntax for writing math. + +For code blocks, sometimes marking up parts of code blocks can be helpful for readers, for example to distinguish inputs from outputs or to annotate with comments. + +### Styling, formatting and layout + +A useful property of a document preparation system is how much work you need to publish a pleasant-looking document or to tune the output to your requirements. + +Some document preparation systems provide great-looking output by default, while others might require more work. + +However, sometimes you need to publish documents that follow a particular branding. Different document preparation systems might make it easier or harder to adapt their output to a branding. + +### Collaboration + +When preparing documents with a group of people, we might adjust our requirements. + +For example, document preparation systems might require more or less setup to use; from just visiting a website in your browser, to requiring manual installation of software or using a terminal. + +Additionally, real-time collaboration features such as concurrent editing and commenting might help in many cases. + +On some cases, using more sophisticated collaboration features such as using existing code review systems might provide more power (but maybe requiring more effort). + +### Accessibility + +Documents should be accessible by anyone, including those who use a screenreader or text to voice systems to hear documents aloud. -I also use it as a statement, although the limitations of gemtext can be significant in technical writing. For example, gemtext has no inline links, no inline verbatim code, only three levels of headings, etc. +Document complexity, such as the use of maths, diagrams or complex structure, can cause accessibility to become more complex. -- cgit v1.2.3