Skip to content

Comment on Augmenting the Markdown Language for Great Python Graphical Interfaces

Comments

Every time I see people doing something with Markdown, I wish they just replace it with support for Djot[0] instead. It is a Markdown alternative by the creator of Pandoc and CommonMark that fixes all of the most egregious mistakes, while being legible and visually pleasant as-is. It is also syntactically similar to Markdown, which should ease adoption.

[0] https://github.com/jgm/djot

When the markup’s first design goal is to be parsable in linear time (and then proceeds to have a bunch of rules to support that goal instead of flexibility for humans) I don’t think there is much chance of catching on as a general markup language.

Markdown was originally a loose formalization of how people already wrote text only emails. It was how _people_ wrote, not how to optimize for the computer.

It's not like all humans are born knowing how to read and write Markdown. A standard that is slightly less flexible or intuitive for (some) humans while enabling vastly more machine applications could be a win.

Could be, but mostly isn't. This thread and others like it are always full of folks lamenting that some other markup language isn't as popular or well-supported or both, even though said language has more features, a better spec, and got there first.

Maybe Markdown just hit the sweet spot. But I actually suspect it's something else: as soon as it's very convenient to have machines ingesting and producing a language, it becomes tempting to create tooling that is unnecessarily strict in what it will accept while at the same time spitting out markup that is unusually difficult for humans to read. A sort of specialized violation of the Robustness Principle.

The most famous example of this was probably XHTML, but even HTML5 suffers from it. And so we end up with stuff like Markdown because HTML tooling is too hostile to work with directly, and AsciiDoc because DocBook XML is similarly awful. They don't have to be, but...

Sadly there doesn't seem to be a Python implementation.

Unfortunately, not all, ignoring the linebreak is one of the most

Not sure, but isn't using _ instead of the more intuitive /italics/ a big mistake on the syntax side?

Lots of things use underscore for italics, if you asked me to guess I'd certainly try it first (and asterisk for bold).

... in fact I just tried it and underscore apparently works in WhatsApp, TIL.

OTOH /italics/ reads to me as a regular expression, which ... is apparently not what you meant.

(as ever, "intuitive" varies wildly between people, and the trick is to pick the option that's intuitive for the highest possible percentage of your expected user base)

/ intuition is pretty simple: slanted mark for slanted text

What's that wild intuition of underscores???

Also, why would you ever read it as a regex in a human /text/ markup language?

At least in English, typographic conventions have historically equated underlining with italics, and the reason the underscore key is present on your keyboard is because it was used on typewriters to format text that would have been italicized in printed text.

Surrounding text with underscores to indicate italicization is intuitive to anyone who is familiar with that convention.

Personally, I find surrounding text with forward slashes exactly wrong for italicization, because I mentally apply a skew-transform to the text to make the slashes into vertical lines, which leaves the text itself slanted in the wrong direction. Backslashes would make more sense, and also avoid looking like regular expressions. But literally no one uses that convention and we do not need a new one.

I've described what intuition is, you haven't addressed it, familiarity with convention is not intuition, it's just knowledge. And given that convention is unintuitive (_ for underlining would be, and on typewriters underscores were also used to, you know, underscore text), that's a bad convention

Also, this /convention/ already exists and used, despite its low popularity (eg orgmode or Bear note app), so you're also literally wrong here

He said the convention that doesn't exist was -backslashes-.

Also, intuition is "understanding without conscious reasoning," so remembering a convention IMO counts.

Consider e.g. parental intuition of noticing subconsciously it's too quiet and immediately going to find out what the kids have done.

For UI, consider the floppy disk icon often used for 'save' - it's considered intuitive because the vast majority of users already recognise it without having to think about it, even if they've never had a system with a 3.5" drive themselves.

"Intuition is the ability to acquire knowledge, without recourse to conscious reasoning or needing an explanation" per wiki The convention is the precise rule that _ is italics, so no, you aquire no knowledge, you need to already possess that knowledge and remember that precise rule.

On the other hand, if you know that _ is __underline__, - is --strikethrough--, then you can acquire knowledge (guess) that / is /italics/ because the principle is the same - formatting text follows symbol's shape (though it's not a perfect mach since / transforms text, not adds new symbols unlike _ or - ). But that's still intuition (* for bold would not fit here)

The other bad analogies don't help resolve it, so best stick to the topic

From my point of view, you acquire the knowledge that this system also follows the convention by guessing that it does and trying it (though I was quoting a dictionary rather than a wiki; I usually do for word definitions).

I appreciate that you don't find the analogies convincing, but they do express how I (and many others) see the situation, and declaring it a failure to stick to the topic because it doesn't fit how -you- see things is unconstructive at best.

Underscores indicate emphasis, just like underlining would, but in text you usually get italics (I'd note that this is often an <em> tag so it being italics is a browser default style).

Plus underscores get used -lots- of places for italics; I've yet to see the / form in the wild.

A markup language being (as here) used for technical purposes can easily be interpreted according to geek writing conventions.

So the intuition for _ would be underlining! Pretty simple. Where would your intuition jump to for underlining in markdown if _ is italics?

Em is just another bad term - which of the emphasis styles do you mean?

Re popularity - so what? How does widespread bad turns into intuitive good?

Bear notes used / for italics, also Orgmode (is that geek enough for you?)

Where would your intuition jump to for underlining in markdown if _ is italics?

You have you know the fact that actual underlining had been traditionally used as a substitute for italics in hand-written and typewritten papers.

As in, in a citation, when you give a title of a book, you underline it, unless using a word processor with fonts, in which case you use italics.

Learned this in high school.

Did they teach you in high school the relevance of that history? Does the fact that it'd been traditionally used as a substitute mean you can't use underlining now, so it should not event exist in markup?

It's pretty obvious that underlining is something that rarely appears in print. It is mainly an annotation device: something added to finished print, by hand.

When was the last time you saw underlines in a book that weren't added by a previous reader?

Underlines are bad typography that should be used sparingly, if ever.

It's even more obvious that we're not talking about print, but a markup language anyone can outside of book publishing. So why do you want to prevent a "previous reader" from using said annotation device for the little note he's creating/editing?

Sorry, how did we get here from explaining the intuition behind _..._ denoting italics?

We got here because you mentioned all the irrelevant stuff your learned in high school, and when I pointed that out, you mentioned some more, now about the whole underline, which I used as an example of how there is no intuition behind _ since that intuition is "taken" by underlines (that's why you needed to criticize underlines)

I second this. I discovered Djot last year and it's been my preferred markdown ever since. Very extensible, easily parsable.

Why not just HTML?

Too annoying to write by hand. also too annoying to read the raw text. Markdown is easy to write by hand and looks good enough without a viewer.

This is an eminently solvable problem. I've been writing my personal website in a variation of HTML for a while now which is perfectly easy to write and read.

  {main
   {h1 Title}
   {p
    Paragraph 1.
    {{a {href google.com}} Here is a link.}}
   {p
    Paragraph 2, now with {b bold} text.}}
The nice thing about HTML/XML is that it's a clear data-structure, so you can essentially read it in any format you like and convert that to the underlying tree structure without much issue. That's why it's been so successful, basically the same philosophy as a lisp. Why someone would look at that and think "let's go back to a document with no clear structure" is beyond me.

You solved it with s expressions.

Replace the braces with parens and you can parse that into a tree with only a handful of lisp macros.

The braces are quite deliberate. Firstly, parens are used often in writing and it would be a pain to have to escape them. Secondly, it integrates much easier with the Scheme code of my site generator this way. I can write in a file, something like:

  (define (code-block file-name)
    {pre {{code {class block}}
          #(cmd "highlight" (thisdir (string-append "posts/" file-name))
                "-O" "html" "--inline-css" "--fragment"
                "--line-numbers" "--line-number-length" "3")}})
And it fits quite nicely with surrounding code. The mapping of these curly expressions to Scheme ones is relatively simple, though there is a special case for joining words to brackets.
  {a {b} #c #@d} => `("a" ("b") ,c ,@d)
  {a {b}c} => `("a" ("b") join "c")

Sure, I didn't mean to imply that you didn't know what you were doing. I was just adding more context for those readers who don't know what an s-expression is.

FWIW, my first static blogging system (circa 2003) did almost exactly the same thing you are doing (except that I used `[]` for lists, not `{}`). IIRC, it was maybe 5-6 macros+functions (and some readtable magic) to turn every `[foo ...]` into `<foo> ... </foo>`, with support for attributes using `:name=value` syntax and a list of exceptions for non-closing tags such as `<br>`, etc.

I redid something like that recently, in C, and it turned out to be unreasonably larger to write than in Clisp.

TBH, these days it's better to simply stick to markdown, because the tooling is much better (previews as you type, tools to automatically generate the html, inline HTML for what markdown won't do, etc).

Apart from the p tag, that gets annoying when you have long stretches of prose, I find plain html5 much less annoying than markdown. Moreover, tables and hyperlinks are clearer and easier to type in html5 than in any markdown flavor.

Easier to type? Sure, but I don't think HTML5 tables are easier to read than markdown tables

Thanks to optional closing tags, html5 tables are quite neat:

  <table>
    <tr>
      <td>first row, first column
      <td>first row, second column
      <td>first row, third column
    <tr>
      <td>second row, first column
      <td>second row, second column
      <td>second row, third column
  </table>
Does it get any better in markdown?

I'll convert your example to GFM.

  | first row, first column  | first row, second column  | first row, third column  |
  | ------------------------ | ------------------------- | ------------------------ |
  | second row, first column | second row, second column | second row, third column |
To me, this is more readable than the HTML version.

It's not fun to manually reformat those tables for readability. If I add something to the `second row, second column`, I have to add extra spaces to the `first row, second column`, or it will look janky.

  | first row, first column  | first row, second column  | first row, third column  |
  | ------------------------ | ------------------------- | ------------------------ |
  | second row, first column | exceptionally long second row, that makes second column look worse | second row, third column |

The fact that you need to list columns in rows already makes it NOT a table

Both are diffult to read and work with.

both are difficult to work with since it's not the job of a data format, but table editing tooling on top of that, but the markdown tables that look like tables aren't difficult to read unlike HTML

It depends on the intent. Markdown is meant to be readable on its own. If you don't plan on reading Markdown files in some sort of plain text editor, then the benefit of Markdown is greatly diminished.

Also, no one has implemented a really good experience for writing HTML, not for webpages, but simple documents. It could be really easy to write HTML mostly by hand if an editor could dynamically convert Markdown-like syntax into HTML tags on the fly. That way, the resulting document is definitely HTML, and not up to the interpretation of some flavor of Markdown.

Such an editor can also do things to try and soft-preview what emphasis the HTML represents. Here's an example of an experiment I worked on in this direction a long time ago: https://codepen.io/Ravenstine/pen/gyMVNx

^^ Never mind the pompous attitude I had when I wrote the placeholder text for it.

Markdown lacks prompting for inputs and running javascript but is easier to write and offers a quicker update, preview, deploy cycle. Preview and deploy is often a simple save vs. a build and deploy process. By extending markdown to support prompting for inputs and running javascript, you close some of the gaps and get the best of both worlds.

Too verbose for some applications is one reason not

Why not just asciidoctor?

Why not XML?

The laundry list of problems that can land in one's lap going down the road of XML publishing is considerable. Many are non-negotiable, particularly on git-based version control or on modern computing environments with locked down Java versions. It would be boorish of me to cite all of them, one after the other, so try this exercise instead:

Using an XML specification of your choice, working from a simple desktop computer, and with no money for fifty thousand dollar "end-to-end publishing solutions", perform the following: publish a document that uses conditional processing to show two different outputs for two different audiences while using a shared set of document components.

<kitchen_timer/>

What did you end up using? Anything neat?

I'm going to bet you don't find anything at all.

The tooling in XML publishing is weird, locked down, horrible, or all three plus some. Plus a lot. So, even if we pretend XML publishing is the bee's knees, it loses the speed test, it can't work on vanilla computers/requires admin rights constantly, and new writers train up on Asciidoc, from zero, in four hours. At a glacial, defense-industry-standard-for-fifty-year-old pace. Git probably provokes more existential crises in training than the markup does. Nothing compared to the business side, of course, but this is the defense business, and it's all madness.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.