revolunet / sublimetext-markdown-preview

markdown preview and build plugin for sublime text 2/3
MIT License
2.31k stars 362 forks source link

Can't get transclusion to work on MMD on windows 10 #410

Closed pdeffebach closed 6 years ago

pdeffebach commented 6 years ago

The how-to guide for MMD has a section on file transclusion, that is including an external document and having the markdown parser also parse that.

I have tried to do this in sublime text using Multi-markdown, but it doesn't render. This what my code looks like.

# This is a title #

This is some text about. 

{{subtest.txt}}

Will just render {{subtest.txt}} instead of its contents.

Am I doing something wrong?

facelessuser commented 6 years ago

Are you using a Multi-Markdown parser? The default Python Markdown parser does not support this as it is not Markdown, but an extension to Markdown. See original spec: https://daringfireball.net/projects/markdown/syntax.

GitHub parser which is supported out of the box also does not support that syntax. If you setup Markdown Preview to use the Multi-Markdown binary to parse, you may be able to do this.

The next release will allow Python Markdown to use more 3rd party extensions, so you could then use something like https://github.com/cmacmackin/markdown-include/ or https://facelessuser.github.io/pymdown-extensions/extensions/snippets/ (which I wrote), but neither currently support the Multi-markdown notation. The first example I listed seems to have a infinite recursion issue, but the one I wrote does not. If none of those suite you, you could write your own transclusion extension for Python Markdown as soon as I get around to finishing up the next release.

Anyways, the next version is really just waiting for me to finish up documentation, and double check everything and cleanup. I keep getting side tracked by various other projects, but I am hoping to get it done soon.

pdeffebach commented 6 years ago

I think I am using the multimarkdown parser. That is, in the bottom right hand corner of sublime text I have multimarkdown selected. Then I press command-m.

Thanks for your help on this.

In general, is the multi-markdown spec too "out there" for common adoption? If common mark solidifies without a good deal of multimarkdown functionality, is it likely to not make the cut as the default "commonmark + extra features" flavor?

facelessuser commented 6 years ago

I think I am using the multimarkdown parser. That is, in the bottom right hand corner of sublime text I have multimarkdown selected. Then I press command-m.

Syntax highlighting is not the same as what parser is being used. Markdown Preview uses Python Markdown, and optionally GitHub's (via GitHub's web API). To use the MultiMarkdown, you'd have to setup (in the settings) for Markdown Preview to use that instead.

In general, is the multi-markdown spec too "out there" for common adoption?

What is "common adoption"? Are you free to use MultiMarkdown? Yes. If you want MultiMarkdown features, I'd just use that as your parser by setting it up in the settings.

If common mark solidifies without a good deal of multimarkdown functionality, is it likely to not make the cut as the default "commonmark + extra features" flavor?

The default doesn't matter. Most likely the default will continue to the Python Markdown as it is native to the plugin which is written in Python. But if you have a CommonMark command line app you wish to redirect your content to, you can in the settings.

pdeffebach commented 6 years ago

Thanks for the help. I didn't realize it didn't automatically detect the parser. This was confusion about the interoperability between markdownediting and markdownpreview. I will download the multimarkdown parser and see if I can get it to work.

I'm just curious how standardized the syntax of markdown is likely to get. Will we see a flavor of markdown, and associated syntax for things like file inclusion, dominate in the next few years?

facelessuser commented 6 years ago

I'm just curious how standardized the syntax of markdown is likely to get. Will we see a flavor of markdown, and associated syntax for things like file inclusion, dominate in the next few years?

The original author of the Markdown syntax hasn't seen a reason to update the spec (the one I linked you to earlier).

CommonMark is a community effort to standardize their own form of Markdown because programmers can't stand ambiguous cases 🙂 . CommonMark is not Markdown, but a superset of Markdown. MultiMarkdown is also a superset with its own added features. GitHub also has their own tooled to how its users utilize it.

If you are someone who really wants a "standard" Markdown, then maybe CommonMark is the way to go. I imagine you can install it and point Markdown Preview to the command line app. Or if MultiMarkdown is what you prefer, just use that. If you are looking for Python Markdown to support file inclusion, I linked you to two extensions that do what you want, and very soon (next release) the ability to utilize these will be available. If you are specifically looking for {file.txt} format, you will be able to write your own extension for Python Markdown, or use MultiMarkdown. It's also possible you can make a request on one of the existing file inclusion extensions, and maybe they will add that format.

facelessuser commented 6 years ago

As there is no actionable item for this project, I'll close this issue.