On the mastodon thread for Karl Voit’s Markdown is a disaster interview live in an hour https://toobnix.org/w/gXLXQqxf5MYg1NDF2Ua6oA <- hopefully the right link, watch the Mastodon / that interview thread,
Edit: Karl Voit Episode archive: https://communitymedia.video/w/i7G3W41S91Z1DyoQuoMswF
NB: CHAT ON #emacsconf on IRC during the peertube LIVE.
I suggested that because Common lisp’s FORMAT uses single character-ish directives it was similar to markdown’s *, #, [..], - and so forth. And asked if someone could find McDermott’s http://cs-www.cs.yale.edu/homes/dvm/format-stinks.html .
Jack Daniel (McCLIM, Embeddable common lisp, (Mastodon)) dug it up for me.
Read the thread; we are not-quite-ubiquitously an org over MD crowd, though as Vassil Nikolov says, for worse or better markdown seems to be the lingua franca. Elias wrote good notes.
The wikipedia article above is very good. The only complete omission I noticed is ~@<newline>.
Anyway, I still wrote this note earlier. If you are unfamiliar with ~? and ~/pkg:thing/ it might help you. I "implement markdown" in it.
Let’s perform the common lisp beginner’s exercise of formatting time output, in a way that clearly illustrates why people hate common lisp’s formatted output.
#| my personal emacs setup.
• (setq inferior-lisp-program "ecl")
• (slime)
• (setq eepitch-buffer-name "*slime-repl ECL*")
|#
then
CL-USER> (format
t
"~{~{~:[~1*~^~;~1:*~a~a~]~}~^~1:*~{~:[~;, ~]~1*~}~}.~%"
'((8 am)
(0 UTC)
(Sunday 7th)
(nil "-th day")
(nil "-th day")
(foo bar)))
8AM, 0UTC, SUNDAY7TH, FOOBAR.
NIL
CL-USER>
Now, you do sometimes see or foolishly write these “line noise” oneliners. In my case, mine looks especially bad because it does-the-impossible.
The impossible thing is that I want to skip (any list) that begins with nil - (nil something), or otherwise print its first two elements. This would be well and good but after iterating through the list I need to know if I was “meant to” add a comma or not. You’re meant to use escape upwards at the tail of iteration, not after the iteration finishes, like the dark magic I have invoked.
Format uses control characters (always with their meaning escaped/prefixed by a ~), which is basically what markdown does but without the escape tilde, so whether a character is a directive or not has to be inferred from context. I guess lisp also has iteration and conditional characters, which markdown doesn’t.
My point is that markdown basically has character format directives. Another difference is that in markdown, a directive is written repeatedly to indicate its level **really strong**, whereas lisp formatted output uses prefix arguements between the tilde and control character: “~2d” ("~d" with pad-2).
(format t "~@{~?~}" ; i.e. format everything that follows
"# *~a*~%" ; Markdown bold heading 1 of:
'("A sane lisp formatted output example to resemble markdown")
"~@(~a.~)~%" ; Add normal capitalisation and a full stop to
'("this is string is a sentence")
"~@(~@{~a~^ ~}.~)" ; Add normal capitalisation and a full stop
'(this list is also a sentence)) ; and spaces to ⬅
Iterating over format-this directives lets us write in the usual left-to-right, top-to-bottom way, rather than front-loading all the control directives, and then somehow matching up arguements to them. Both org-mode and markdown are written left to right and top to bottom.
A feature of ANSI CL is that the directive can be use this function on the stream and arguement and modifiers. Since I’m arguing markdown resembles common lisp formatted output, let’s implement common lisp formatted output markdown by way of checking.
(uiop:define-package :md)
(defun md::|#|
(stream arg colon atsign &optional (depth 1))
"md::|#| is the admittedly annoying md for 'heading'.
Use with FORMATting ~2/md:#/ on arg '|something| to get
## Something
Adds the implied newline."
(format stream
"~,,v,'#a ~a~%"
depth ""
arg))
(export 'md::|#| :md)
CL-USER> (format t "~@{~?~}"
"~3/md:#/" '(foo)
"~2/md:#/" '(bar)
"~a~%"
'("A literal string
Possibly containing newlines.")
"~3/md:#/" '(baz))
### FOO
## BAR
A literal string
Possibly containing newlines.
### BAZ
NIL
CL-USER>
Well, I think I demonstrated common lisp’s formatted output, and that markdown’s controls can be implemented like ~/md:#/ for markdown’s # in ANSI standard common lisp’s formatted output control character directive language.
On reflection, markdown and ANSI common lisp’s formatted output seem to be very different, even though both use single character directives.
A program that implements markdown is vanishingly small whereas an implementation of .org syntax is clearly a large and serious endeavour, not to speak of org’s extensive functionalities.
There are approaches such as the common lisp org parser, cl-org-mode, or directly implementing emacs lisp sufficiently to use most of the emacs lisp org-mode package, such as Ramin’s schemacs and akaber’s cl-el.
Another contrast is between ANSI CL and html on one hand as being the result of a standards committee process, whereas both orgmode and markdown are whatever orgmode and markdown are. The difficulty of implementing orgmode means there is mostly just the one emacs orgmode, closely developed with emacs itself,
whereas most web framework projects have their own extension (“flavor”) of markdown as their particular needs overflow markdown’s #-for-heading, *bold*-for-bold-bold. (Such as my friend Aral’s https://kitten.small-web.org/ ).
Peertube Archive of Karl Voit’s episode: https://communitymedia.video/w/i7G3W41S91Z1DyoQuoMswF
https://toobnix.org/w/gXLXQqxf5MYg1NDF2Ua6oA HOPEFULLY THE RIGHT LINK INSTEAD WATCH THE THREAD
https://gamerplus.org/@screwlisp/115142459996919932
See you in 45 minutes everyone.
screwlisp proposes kittens