4 ms·
I do not have anything online at the moment to show, but a small document processor i wrote some time ago used a @-based syntax which was essentially a tree of
by Crinus 8y ago
I do not have anything online at the moment to show, but a small document processor i wrote some time ago used a @-based syntax which was essentially a tree of named nodes with attributes - essentially the same thing as XML, but with a simpler syntax that was something like:
@Foo; is a standalone empty node named Foo
@Foo[aa] has a "aa" attribute without a value
@Foo[bb=cc] has a "bb" attribute with "cc" value
@Foo[dd="hello, world",ee] has "dd" attribute with "hello, world" value and "ee" attribute without value
@Foo{blah} has a "blah" text child
@Foo{blah @Bar;} has "blah" and Bar children
@Foo Bar shortcut for @Foo{Bar}
@Foo{!{...}!} has ... as unprocessed content
So you can type something like @P{This is a @I nice @Link[target=foo]{example} of @TT{code} @Smile;.} which would be sort of equivalent to XML <P>This is a <I>nice</I> <Link target="foo">example</Link> of <TT>code</TT> <Smile/></P> (but with less repetition, especially for longer documents).
In my processor the tree is passed to a script that does the actual handling by going through the nodes, children, etc and creating the output text (HTML or whatever) - the processor itself has no knowledge of specific node names, any meaning lies in the scripts.
My biggest issue with the above though is that i do not like editing markup by hand, so at some point i want to replace all the above with a GUI tool that does the same job but in a more graphical way without the need for (visible to the user) markup syntax (so the above example would be edited as just text but with the "nice", "example" and "code" bits having representational styling).
- enriquto 8y agohaving to close paragraphs is useless. It moves to the user of the markup a concern that is only of interest to the implementor. That should we exactly the other way round. I prefer html5, where you can leave tags open as if there's no tomorrow.
- Crinus 8y agoThis is just the way i have the scripts setup since it makes more sense for me for paragraphs to be full nodes that contain their children content, but it is trivial to make empty P nodes act as paragraph separators.
- enriquto 8y agoIt is not a trivial matter when you are writing the markup manually. If you require to open and close paragraphs it becomes very cumbersome for no real gain (just a tiny amount of convenience for the programmer of the parser). The ideal case is TeX, where paragraphs are separated by a blank line.
- Crinus 8y agoWith trivial i meant that it is trivial to have a script that makes @P; a separator (or start marker) if you prefer to work that way. I made the system script-driven with a generic syntax exactly because i didn't want to hardcode any specific way of working with the nodes. As for TeX, i personally dislike markup languages where whitespace is treated in a special way since this is source code, which often needs some style of its own and sometimes that depends on context. To me seeing where a paragraph - or any other "long" element - begins and ends can be helpful and if anything, i consider the lack of syntax for this in my markup as a negative (but i couldn't come up with a clean and unambiguous syntax for adding an optional "closing" bit). I compensate for that using comments (which look like @# Blah until the end of line), but it is a workaround. And also FWIW i prefer to have the markup map to the underlying tree of nodes clearly than introduce "magic" that in some cases can make things harder even for writers. Keep in mind though that this is for long(ish) documents, like a large tutorial, guide, manual, etc not short comments like this one here. For anything that is around the size of a common blog post or shorter, something more adhoc like Markdown is probably better.
- enriquto 8y ago> As for TeX, i personally dislike markup languages where whitespace is treated in a special way since this is source code just to nitpick: except for APL, white space is treated in a special way in all programming languages to separate tokens :) Using it to separate text (words and paragraphs) makes perfect sense in this context.
- Crinus 8y ago
- smartmic 8y agoLooks a little bit like the Lout typesetting system on a first glance. https://en.wikipedia.org/wiki/Lout_(software) https://en.wikipedia.org/wiki/Lout_(software)
- Crinus 8y agoYes, it was mainly inspired by Lout (although i think there is a much older system that used a similar syntax - and GNU TexInfo also uses something similar, but i didn't knew about that at the time), however IIRC Lout doesn't use a generic syntax.
- neilv 8y agoIn a case of great minds think alike (you, Eli Barzilay, and Matthew Flatt), this (especially the square brackets and curly braces purposes) is remarkably similar to what Racket ended up using, for the @-reader syntax that's used by Scribble document processing: https://docs.racket-lang.org/scribble/reader.html#%28part._.The_.Scribble_.Syntax_at_a_.Glance%29 https://docs.racket-lang.org/scribble/reader.html#%28part._.... I made an Emacs mode for it: https://www.neilvandyke.org/scribble-emacs/ https://www.neilvandyke.org/scribble-emacs/