notekit icon indicating copy to clipboard operation
notekit copied to clipboard

Markdown restrictions

Open fbruetting opened this issue 4 years ago • 7 comments

  • I just can indent lists with 1, 2 or 3 spaces. Neither tabs nor more spaces do work (at least I loose the markup, so I guess it doesn’t work). Also, I cannot start items with the + sign.
  • Headings just work up to a level of ###, as soon as I add a fourth hash sign, these also don’t work.

Do you rely on some markdown parser/library or did you program everything on your own? The first option seems to be the case here, so I would recommend the usage of some popular parser. I also tested quite some other Markdown editors – sadly most of them seem to parse Markdown on their own, which results in a lot of missing features and bugs.

fbruetting avatar Nov 10 '19 15:11 fbruetting

Markdown is processed by GtkSourceView's syntax highlighting engine (the same one that's used by gedit/pluma and - I think - Geany, among others). I use a modified version of the Markdown syntax definition that the official package ships with (see sourceview/markdown.lang.in), which unfortunately is not very accurate; while I fix some of the issues with it, I've never gotten around to get all of them (in part because there doesn't seem to be a particularly clear markdown specification out there to begin with...). See this document for a specification of what the parser supports. (The only Markdown construct I found it seemingly impossible to implement so far was the alternative convention for specifying headings by putting =s or -s below them.)

I don't know if you are actually supposed to be able to indent lists with more than 3 spaces - isn't there some rule that says that 4 spaces of indentation denote a preformatted code block?

blackhole89 avatar Nov 10 '19 19:11 blackhole89

Ok, I will check that in the coming days. Thanks!

I don't know if you are actually supposed to be able to indent lists with more than 3 spaces - isn't there some rule that says that 4 spaces of indentation denote a preformatted code block?

Some engines accept that. Like GitHub, which accepts infinite spaces and tabs. One more reason to use tabs, where you can do infinite amounts of indentations then. 😕️

Also this could be done relative to the indentation above. So when you indent by two spaces and the next line not by four (which would be one indentation) but by 6, then the relative difference is four spaces and that would mark the begin of a code block.

fbruetting avatar Nov 11 '19 00:11 fbruetting

From all the Markdown editors I tried so far, Mark Text was the best and has by far the best parser! Maybe you can reuse that?

fbruetting avatar Nov 20 '19 00:11 fbruetting

It's an electron app, so the parser is written in JavaScript and renders to HTML. Unfortunately, that means that I can't reuse any of it.

Some engines accept that. Like GitHub, which accepts infinite spaces and tabs. One more reason to use tabs, where you can do infinite amounts of indentations then.

So are four-character indentation blocks never assumed to be preformatted code in Github, or are they interpreted differently if a (less-indented) list precedes them? If it's the latter, that might be a little hairy in GtkSourceView's highlighting engine.

blackhole89 avatar Apr 19 '20 00:04 blackhole89

0 spaces 2 spaces 4 spaces 6 spaces 8 spaces

  • 0 spaces with asterisk
    • 2 spaces with asterisk
      • 4 spaces with asterisk
        • 6 spaces with asterisk
          • 8 spaces with asterisk

0 tabs 1 tab 2 tabs

  • 0 tabs with asterisk
    • 1 tab with asterisk
      • 2 tabs with asterisk

Guess in GH code blocks are just available via backticks. Additionally, if tabs are handled separately, you could enable code blocks by prepending any amount of tabs with 4 (or 8?) spaces?


Maybe that could also be achieved by the space-indentation diff to the reference indentation? Like two-space indentation after an asterisk for alignment, like here:

  • Just an asterisk Text prepended by two spaces gets aligned.
    • 2 spaces in front 4 spaces in front
      • 1 tab 1 tab + 2 spaces

fbruetting avatar Apr 19 '20 01:04 fbruetting

I'd be quite happy to get rid of the four-space code blocks and only support triple-backtick ones for my own part, but I'd like to know if there is anyone who depends on indent code before doing that.

(Generally, there are a lot of dubious design decisions in Markdown - personally, I find it weird that both single asterisks and underscores denote italics and you need double asterisks/underscores for boldface - but there is some value in remaining compatible with the standard too, however dubious it may be.)

blackhole89 avatar Apr 19 '20 02:04 blackhole89

I say go for backtick-only. Without some built-in editor feature like indenting/unindenting an entire highlighted block at once, the four-space codeblocks are downright aggravating. I'm pretty sure that feature was mainly meant for plain-text file-format markdown where it's written in a dedicated and personalized text editor.

different55 avatar Apr 23 '20 21:04 different55