Autodetect key:value as visible metadata

For things like

 Author:     Bane Liciea
 Title:      Why you should hire me
 Date:       32-4-2002
 Layout:     Resume

It really should be easy to see that this should not be rendered as

Author: Bane Liciea Title: Why you should hire me Date: 32-4-2002 Layout: Resume

but rather it should be treated as if there is a
at the start of each key:value pair

Just autodetect that a few words plus : indicate that there should be a line break at the start of that sentence.


Weirder examples:

e.g.

 Author:     Bane 
  Liciea
 Title:      Why you should 
  hire me
 Date:       32-4-2002
 Layout:     Resume

or

 Author:
   Bane Liciea
 Title:
   Why you should hire me
 Date:       
   32-4-2002
 Layout:
   Resume

Should be smart enough to know that it should be seen as:

 Author:     Bane Liciea
 Title:      Why you should hire me
 Date:       32-4-2002
 Layout:     Resume

Btw, does it mean anything that I often do single line description like this?

Dog :~ An animal with two legs

edit: Hmmm… it’s more for http://talk.commonmark.org/t/description-list/

Well, if you have line breaks set to render as <br>, you’d get what you expect:

 Author:     Bane Liciea
 Title:      Why you should hire me
 Date:       32-4-2002
 Layout:     Resume

Well there is argument in this thread that linebreaks <br> shouldn’t be automatically added.

There is the start | signifier for indicating proses/<br> should be treated differently in discussion. But in the context of key:value, it’s much better to not have to use start | or end \ signifier.

Still, alignment would be off for the key-value pairs.

Perhaps this is another call for table layout extensions later?

That seems a lot less dangerous than trying to infer key-value pairs based on colons and short leading words.

3 Likes

Note the section of the spec on soft line breaks states:

A renderer may also provide an option to render soft line breaks as hard line breaks.

This would likely be applied in the user’s settings or as a setting for the entire app. But the default in CommonMark is still soft line breaks, consistent with the Daring Fireball spec.

Archie Markup Language (from the New York Times labs) is “a structured text format optimized for human writability”, which does this: get key: value pairs from a document in natural language (formatted e.g. in Common Mark).

It would be interesting to add similar behavior to Common Mark: tokenize strings that conform to the rules defined in ArchieML, write the keys+values as metadata to the AST (in addition to any present YAML front- and/or back-matter), and render these strings differently from ordinary paragraphs (i.e. insert linebreaks automatically, etc.).

1 Like