9 ms·
Is there a formal grammar defined? I don't see one here. They mention peg-markdown which does use a formal grammar - or at least, multimarkdown does, which is t
by peterkelly 12y ago
Is there a formal grammar defined? I don't see one here. They mention peg-markdown which does use a formal grammar - or at least, multimarkdown does, which is the one I've looked at.
Here's the link to MultiMarkdown's grammar:
https://github.com/fletcher/MultiMarkdown-4/blob/master/parser.leg https://github.com/fletcher/MultiMarkdown-4/blob/master/pars...
It's littered with implementation code, but with this stripped out it would make a good basis from which people can write parser generators from (that don't depend on the specific implementation details of MultiMarkdown's internal representation).
As far as I'm concerned, a formal definition should be an absolute requirement for any official spec. The "spec" as presented simply looks like a large collection of examples, informally specified in prose.
What's really needed is a grammar you can use for parser generators, corresponding to a schema for an object model.
It's late here, I may have missed something, so feel free to correct me if if this is the case ;)
- imsky 12y agoThe closest Standard Markdown provides is the re2c "source" that gets converted: https://github.com/jgm/stmd/blob/master/src/scanners.re https://github.com/jgm/stmd/blob/master/src/scanners.re I agree that a universal PEG would be great, perhaps this is the project to base that grammar on.
- codinghorror 12y agodefinitely raise that on http://talk.standardmarkdown.com http://talk.standardmarkdown.com
- peterkelly 12y agoWill do. I'm currently trying to get a project started to convert between various file formats typically used for writing/word processing (https://github.com/uxproductivity/DocFormats https://github.com/uxproductivity/DocFormats). Markdown is one of the languages I hope to add, and I've been planning to use the Multimarkdown grammar. But if I can make a convincing argument on the list for using something like this, it will make things a lot easier for everyone hopefully.
- zokier 12y ago> a project started to convert between various file formats typically used for writing/word processing (https://github.com/uxproductivity/DocFormats https://github.com/uxproductivity/DocFormats). sounds bit like Pandoc: http://johnmacfarlane.net/pandoc/ http://johnmacfarlane.net/pandoc/
- peterkelly 12y agoIt's very much like Pandoc, but with two (three?) major differences: 1. Uses the Apache License (Pandoc is GPL). The code for this project is part of a commercial, closed-source project (and needs to continue to remain part of this project) so sadly this rules out Pandoc on legal grounds. I've also had interest from others in seeing such a library unencumbered with the GPL restrictions. 2. It's written in C, not Haskell. The commercial product (UX Write) runs on iOS, and I'm not aware of any Haskell compilers for iOS. I think there are some efforts underway, but at least when I began this two years ago C seemed the natural way to go. 3. It does non-destrctuctive updates, meaning you can make a change to the target file, and then update the source based on the modifications. Doing so will leave any elements in the source document which were unable to survive the translation intact. I'm not sure if Pandoc does this.
- Argorak 12y ago> I'm not aware of any Haskell compilers for iOS Use GHC. http://www.infoq.com/news/2014/04/ghc-7-8-1 http://www.infoq.com/news/2014/04/ghc-7-8-1
- GlennS 12y agoFor HTML to Markdown this works in Pandoc, because HTML elements are valid Markdown. Haven't tried with other target formats. One option if you can run Haskell code somewhere is to use the Pandoc library, which will produce an in-memory structure that you can manipulate as the user makes edits.
- belorn 12y agoHave you had any interest from others in seeing your commercial project unencumbered from legal restrictions? That would open up your options considerable.
- roryokane 12y agoHere is the thread about creating a formal grammar: http://talk.standardmarkdown.com/t/standard-markdown-formal-grammar/46 http://talk.standardmarkdown.com/t/standard-markdown-formal-...
- maxerickson 12y agoI wonder if this has anything to do with it: https://github.com/jgm/peg-markdown/issues/28 https://github.com/jgm/peg-markdown/issues/28
- swift 12y agoThat's gotta just be a flaw in the implementation, if the title of the issue ("Exponential parsing") is accurate. Any PEG can be parsed in linear time and space.
- BruceIV 12y agoTL;DR Packrat trades guaranteed linear memory usage for worst-case polynomial time; the worst-case almost never comes up in non-contrived input, so it's a reasonable implementation decision to go with the less memory-hungry naive implementation. Depends on the algorithm; the naive recursive algorithm takes worst-case exponential time, while the packrat algorithm guarantees linear time. However, for most sensible[1] inputs, the recursive algorithm runs in linear time and constant space, while packrat takes about the same time, but with linear space usage. [1] Where "sensible" is defined to be "amount of backtracking is bounded by a fixed small constant, as is grammar nesting depth" - conditions that hold for most human-generated files matching useful grammars (I've been working on a new PEG parsing algorithm; it doesn't work so well, but the results I've been getting in testing about the existing algorithms are quite interesting.)
- maxerickson 12y agoI don't know much of these things. I was thinking more that maybe some aspect of markdown was not easily expressed using a PEG (it's the same implementer behind both the parser in Pandoc and this project) .
- phpnode 12y agoKeeping track of indent levels is not easy with PEGs but can be dealt with by pre processing
- dj-wonk 12y agoSo, to summarize, we have a new standard with the name "Standard" in it without a formal grammar definition. Oops. Unit tests are not enough.
- MBCook 12y ago> The "spec" as presented simply looks like a large collection of examples, informally specified in prose. Which is exactly what Markdown's spec consisted of: http://daringfireball.net/projects/markdown/syntax http://daringfireball.net/projects/markdown/syntax
- peterkelly 12y agoAnd this is the root cause of all the ambiguities that have resulted in incompatibilities in different implementations. This project seems to be repeating the same mistakes, albeit with more clarity in the description and a more extensive set of examples.
- codezero 12y agoI generally agree with the sentiment that this is going to just add more confusion, but since I've recently been writing a bunch of Markdown docs and exploring different static site generators, I've found that most link back to Markdown.pl as their "source" and despite that, each is using a different middle-man Markdown parser which has different output. It's one thing to say, for example, that you support Markdown, or MultiMarkdown, or Pagedown style, but another when you just say Markdown and link back to the original, and produce different output. This seems pervasive, and a Standard Markdown that is "one Markdown to rule them all" would be helpful. Of course, others have pointed out that this spec lacks a formal grammar, and that it also lacks a number of other Markdown elements, so it would need to become a lot more well defined and a lot more mature to be useful.
- stevekemp 12y agoAgreed. I wrote http://markdownshare.com/ http://markdownshare.com/ and found it a nightmare to pick a Perl module to handle the formatting, and know what was included and not. I welcome a standard, although this particular "standard" seems inadequate - due to lack of grammar and test-suite.
- sopooneo 12y agoHow other than prose would you define it? I expect you know what you're talking about and I want to understand.