evilstreak / markdown-js

A Markdown parser for javascript
7.69k stars 863 forks source link

Markdown 2 support. #93

Closed Serhioromano closed 11 years ago

Serhioromano commented 11 years ago

Hello,

I am one of the initiators of markdown 2 project. http://markdown2.github.io/site/

Please note it is not yet officially announced and site has many spelling mistakes since most people who is working on it are not native English language speakers. You are welcome to participate and clone our site and fix everything you find.

But this is not the point. Right now we are working on online markdown 2 parser to serve as demo and we need something like markdown.js but with support of version 2. This is not only reason. We also want to work with parser developers to understand how we can improve Markdown 2 markup to make it well readable and easily parsed. You input on Markdown 2 during parser development will be of a great value and we will be able to adjust markup to perfection.

Although we have Regex specialist in the team who helps us to make markup which is easy to parse.

Do you think it will be possible to start working on new markdown.js with Markdown2 support?

ashb commented 11 years ago

You could implement this by creating a new Markdown dialect - shouldn't be that much work if you've already got the regexs.

I like the idea of providing a more rigid spec for markdown, but unfortunately I question some of the design decisions - there is lots of prior art that you could have reused for some elements (for instance, config/global attrs from Maruku, keyboard keys clashes with existing way of providing links, Specifying language for code blocks is similar but incompatibly with Maruku/GFM.)

Whilst your md2 spec has these issues and mixes syntax with implementation this isn't something I would consider implementing. Sorry

Serhioromano commented 11 years ago

but unfortunately I question some of the design decisions

That is why we want to start working with parser developers. let's discuss it and we will adjust syntax to what would everyone accept.

Please correct me if I am wrong. You want that some syntax was reused from Maruku? As i know Maruku uses PHP Markdown extra. Is this what you mean?

To me codes like this

~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.html #example-1}
<p>paragraph <b>emphasis</b>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Are more like Markdown programming language. i mean you program with Markdown to produce HTML. And those are good i believe to exists as extras like it is now. But our target just to extend current Markdown and add there some essential additions but without turning it into HTML programming language. We wat plain text documents to be very readable in plain text.

Anyway could you please post here our example and what it could look like in your opinion? That would help me to understand the idea behind your post. because I am not absolutely clear what you mean. Just give me few examples.

ashb commented 11 years ago

I think it comes down to having wildly different ideas about what is 'essential' - for instance keyboard keys is not something I've ever needed.

Hmmm maybe I was thinking of Github Flavoured Markdown not Maruku about the code blocks. The only difference between GFM and your proposal is brackets around the langauge, but its makes them incompatible:

```php
<?php echo("hi")

vs
<?php echo("hi")


My major concern is that you haven't given enough though to what is already out there, and that you are proposing some things that are incompatible with the unambigious parts of Markdown (i.e. link references vs keyboard keys).

Further thoughts: 
- declaring the language of a code block is fine, but the actual pretty printing of that has nothing to do with a Markdown specification - it's entirely up to the implementation/toolchain what is done with that metadata.
- specifying the exact HTML produced also is overly specific; you should instead specify the intent (i.e. "this markup should be rendered as superscript" - someone could very well achieve that by using CSS rules rather than <sup><small>
- `<!-- md-disqus shortname=myname -->` and `<!-- md-idebate acct=myname -->` are very odd additions. Why just those two? Why not make it something more extensible/implementation dependant? This probably comes down to I never write whole webpages with markdown - just the interesting text portion of it.
- video media - similar here to the above, both overly specified in terms of html produced and not extensible
- js bin, codepen, gists - shouldn't even be in the specification. Nice feature, but not specification.
- bootstrap - what if my page doesn't use bootstrap.css?
- alerts - Same as my last point about comments.
- config - In an html comment I'm unsure about, But this should just be generic key/value and shouldn't mandate or specify what keys are valid or what meanings values have.
Serhioromano commented 11 years ago

Highlight Language definition I agree. I will change.

My major concern is that you haven't given enough though to what is already out there

I also agree. If you look for things there are a lot of Markdown extras all around. But that only confirm that 1.0.1 version that we have now is not enough and it should be advanced. What we want to make official Markdown 2 version so that all clients support it. Not only you get some extra with some client but you might be sure if you write document this way it will be processes with any processor just like with current standard Markdown 1.0.1.

<!-- md-disqus shortname=myname -->, media why I chose this? I wanted it to be hidden in HTML in case md2 document is parsed with md1 parser. Another important part is readability. Of course user can add HTML and CSS but then user may use <b> instead of ** and this applies to rest. The purpose is not only create flexible HTML from text but plain text should remain plain text. The less inline HTML we have in markdown the better.

Another important point that some md parsers clean HTML and strip tags like <script> or <iframe>. But this what is used by all media and videos. I think it would be much cleaner to have

{media}(youtube::p50wC4Ut5CE)

Than

<iframe width="560" height="315" src="http://www.youtube.com/embed/p50wC4Ut5CE" frameborder="0" allowfullscreen></iframe>

Although this media syntax is not final. There was number of options and I do not know what to use finaly. I need suggestions. I was thinking on

There was also other options but it required discussion. What do you think?

bootstrap - what if my page doesn't use bootstrap.css?

Right. Now we are working on config specification. The bootstrap section will only produce markup according to config. So user will have options markup as Bootstrap, Foundation may be some other but I do not know any yet. And if you do not use any of those, you will just need to add some CSS styles. Right now it is only 5 CSS classes.

config - In an html comment I'm unsure about, But this should just be generic key/value and shouldn't mandate or specify what keys are valid or what meanings values have.

Why? I mean anyone can add any keys he wants for his own purposes but what is wrong to have standard md rendering options? What if I use bootstrap and I want all tables to have table class? Or what if I want to load bootstrap? What if i want be sure it's css is loaded on my article? May be not bootstrap as you already mentioned but there is obviously need for config section to tell parser how to create HTML.

Why in HTML comment? Again in case it is parsed with old MD parser it is invisible.