Open dflogeras opened 4 years ago
I also tried this on the beginning of the document and at the end , and it is simply not working.:
<!--
Local Variables: classesDict = {"table":"table"}
markdown-extras: "attr_list", "attr_plus", "html-classes":classesDict
End:
-->
and I tried the one-liner ( and I know, it is boring) it does also not work
<!-- markdown-extras: code-friendly, footnotes -->
It looks like the fenced-code-blocks does also not work and the use-file-vars
Have you tried passing in the use_file_vars
kwarg?
import markdown2
text = """<!-- markdown-extras: code-friendly, footnotes -->
This markdown text will be converted with the "code-friendly" and "footnotes"
extras enabled."""
markdown2.markdown(text, use_file_vars=True)
EDIT:
After peeking into the source code it turns out that even though the wiki states that emacs var one-liners use <!-- [stuff] -->
, the function _get_emacs_vars
looks for one-liners like -*- [stuff] -*-
. When using the latter syntax, it is not removed from the final HTML and when using the former syntax it is not detected correctly
@Crozzers
Interesting, after your comment regarding -*- I think I found the missing link (or at least for me wishing to run from the command line).
I embedded this:
<!-- -*- markdown-extras: yadda,yadda -*- -->
Then executed the standalone module using
markdown2 --use-file-vars=doesntmatter myfile.md
instead of the documented way:
markdown2 -x use-file-vars myfile.md
And that both takes effect, and also doesn't appear in the final html. It's a bit weird, and not sure why --use-file-vars takes an arg, but it works here for me.
It's a bit weird, and not sure why --use-file-vars takes an arg
The use_file_vars
"extra" doesn't get passed in via the extras
dictionary, it gets passed as a separate kwarg, as you can see from the snippet below:
https://github.com/trentm/python-markdown2/blob/bc175ad7a65ce24f5fb781dd0c12577078cc6109/lib/markdown2.py#L160-L163
In any case, I've submitted a pull request that should take one-liners (like -*- [stuff] -*-
) and wrap them in HTML comment tags so that they don't appear (visible) in the final HTML output
Hello, the documentation here:
https://github.com/trentm/python-markdown2/wiki/Extras
Indicates you can embed which extras you would like enabled in a comment. I've tried that verbatim and it doesn't seem to work for me. After looking in the code, it appears to me (not an expert by any means) that it also wants to see the emacs tokens '-*-' before and after the comment. I also tried that, to no avail.
Finally, the help indicates that "use-file-vars: Look for an Emacs-style markdown-extras file variable to turn on Extras." might be necessary although the code seems to not use it. I tried for fun, but still nothing.
Some clarification would be greatly appreciated, I like the idea of this feature so I can stop trying to remember "how did I process this particular file?" and just embed it.