Beauty of orgmode syntax
The beauty of org syntax
This article will be about org syntax, not emacs org mode as a PKM system.
Both orgmode and markdown syntax allow us to format plain text in a computer AND human understandable way. For example, in markdown, adding # at the beggining creates a header, ## creates subheaders. writing
- [ ] creates a open task, - [x] represents a complete task. It is human readable, but software can render it nicely as html. For example, this blogpost and lifelab is formatted in markdown!**Markdown
One of the biggest pain points I had with markdown is the lack of structure and the need to constantly parse the text to process data. I hate parsing data because I am secretly awful at regex and feel embarassed when I need to write parsers. Since the markdown syntax is permissive, Users can do anything with it, and this makes it hard to make a system that can make sense of any markdown. There are too many ways to do things in markdown!
LifeLab was a overcorrection of this pet peeve. I have strict separation of data types (text blocks, data blocks, code blocks, image blocks, tasks) in the UI and database. While markdown syntax allows you to represent tasks, I wanted them to be separate blocks for the database querying.
If you want to aggregate tasks from a lot of notes and show them in another view or sidebar, and then complete them from the UI, you need to do a search and replace action to find the task in the original note and replace
- [ ] with - [x], but what if you have recurring tasks with same name? In lifelab, each block has a UUID so this is solved. When we transclude task blocks and complete one, we mark the right one in O(1) time.
***Less flexibility is good for software, but pretty painful for wetware
One thing I noticed is the immense friction caused by this, especially the difficulty of converting a particular block to another. If I want to make a task, I have to either click 'add' and then 'task' buttons on the top right, or start a markdown task with /task to tranform it into a task block in the UI. If I have some existing text, I can't turn it into a task at will. Vice versa, I can't use completed tasks as documentation of a certain project.
**Orgmode
In org, there is a feature that I really like which combines tasks, text blocks and data blocks in 1 very elegant format. It uses astericks to create headlines with infinite nesting (org is an outliner), and something called drawers to append any key/value pairs or tags into the headline that emacs knows how to hide.
* this is a headline! this is text relating to the headline above ** This is a subheadline! * TODO this is a TASK! * DONE this is a complete task! * This is a headline which contains data! It is hidden by default in emacs! :PROPERTIES: :KEY: value :END:
**What can we do about it?
I went ahead and made a demo web app using htmx to simulate org mode and I quite enjoyed it. Every headline + it's text content is a entry in sqlite. So each entry can be either a headline with text, a TASK with text, a DONE task with text or any of the above with key-value metadata. For the Org demo, I had to implement arbitrary nesting (which is an absolute nightmare to do with sqlite)
It was so much denser than my current block based approach! The same amount of content was expressed in less lines of pure text.
I wonder if having every block have a headline would help? It would be similar to orgmode headlines and would be able to represent task. By adding - [ ] to the title, we turn it a task, keeping the existing text! But that forces the user to give every block a title. For metadata, in emacs the property drawers are hand editable. In lifelab, you need to click into metadata to show a table view. Further, maybe the title can also contain all tags, which would be parsed and stored. For data blocks, the title could have autocomplete and match with available schemas, making the title both informative and functional.
I include a read only html demo just to demonstrate the orgmode syntax.
An interactive Org-mode editor
This standalone HTML prototype explores Org-mode-style editing. The runnable demo follows; its complete source is stored in the HTML block.
Emacs-free orgmode?
I started implementing a emacs-free org mode editor written in textual but there is a clash between extensibility (in emacs you can do anything) and performance. Maybe I should give neovim orgmode a try.