Repository navigation
Closed
Description
marked is great, but it lacks of ability to extend it with new syntax constructions.
Inspired by asciidoc I suggest to support some macro construction like inline-macro and block-macro (wrapper) to extend it by user
One example of usage, just thoughts:
inline-macro
{{userpic(id=42)}}
block macro
{{image-slider(effect=fade) {



}}}
Nested macros:
{{media-slider(effect=slide) {

{{video-frame(type="youtube", id="asdasd")}}

}}}
And nested block macros:
{{aligner(type=left) {
{{image-slider(effect=fade) {



}}}
}}}
And it would be possible to extend it this way:
marked.registerMacro('image-slider', function (params) {
return '<div class="my-slider">%s</div>';
});
All examples are born just now, and please, don't hit me, but this feature could make markdown infinitely extensible and flexible.
Metadata
Metadata
Assignees
Labels
No labels
Activity
howardroark commentedon Aug 6, 2014
I'm going to have to +1 where your head is at.
I think the code and assets powering each
macrowould be an excellent bower package. From there it would only be a matter of including it in your bower file along with marked. The GitHub home of each macro could house all of the operational instructions. The macro's core javascript would just have to register itself with marked before marked runs. After that marked would just convert the Markdown macros into HTML and fire a callback. The register macro part should likely be supplied a callback which signals the macro to do its own DOM work.I would vote against the complexity of the nesting though. Markdown is meant for writing, not really as a catch all replacement for HTML. It may be a stretch to assume that someone without development experience could wrangle how to use those blocks. Instead what it if macros always expect just a string, maybe a developer uses the aid of Jison to deal with it.
Perhaps a scientific writer could benefit from a handy venn diagram macro...
The macro code could turn the output html to an SVG object. Likely it would search for a unique

dataattribute after marked ran the callback.Or a youtube video... {{youtube: id}}
golyshevd commentedon Aug 6, 2014
But no one writer will be forced to put macro in macro, right? But it is feature :)
What string? All braces content like here?
Probably optionally. I think it should have the only one way to pass parameters for macro. At least it should have default behavior.
Did you mean somewhat like that?
macro is just subrenderer, if you do not want generate some details in macro you just should do it after rendering
Yes!
There are many cases where markdown would might be more rich. But it is impossible to support an unique syntax for each case. Therefore I think that it is not so bad idea.
anko commentedon Aug 11, 2014
It's not
marked's job to extend Markdown.How about
and pass the result of that to
marked?golyshevd commentedon Aug 12, 2014
@anko thanks for idea, just published https://www.npmjs.org/package/macroed but separate macro processor
howardroark commentedon Aug 12, 2014
Good point @anko, the Unix philosophy causes great things.
I will check this out @golyshevd! It's awesome how inspired you were to whip this up so quickly :)
I plan to start a project that focuses on scientific writing with Markdown. The idea is to have it be a UI that harnesses GitHub OAUTH and hosts papers with GitHub Pages. Just looking to see what open-source is out there to build it all.
I think your implementation would work. An intelligent person should be able to grasp the idea of syntax. I just think it would be very cool if there was a universal macro syntax that enabled scientists the ability to turn written math into graphs.
This project inspired me...
https://github.com/vitoravelino/js-sequence-diagrams
I turned it into a service that let's you make sequence diagrams in Markdown. Still needs syntax though to manage the GET params. I'd love to convert it into a macro that accepted plain text with line breaks. I suppose your code could offer that if I made use of the
%svalue.
golyshevd commentedon Aug 12, 2014
@howardroark it is so unstable and just now, we refactor macro syntax to easier indent oriented. The current solution is so poor and it is so conflicting with markdown as post/pre processor. But tomorrow we should complete writing the code, tests and documentation. Our writers marking up so difficult articles and need flexible solution. Comimg soon=)
howardroark commentedon Aug 12, 2014
@golyshevd I'll keep watching the repo. Good luck!
golyshevd commentedon Aug 14, 2014
@howardroark look at that (it is still beta)