I'm using python and using markdown. Is there a simple way to add a custom syntax? I want something like [ABC]
expands to a certain tag or something.
or do I use regex?
Many Markdown processors support syntax highlighting for fenced code blocks. This feature allows you to add color highlighting for whatever language your code was written in. To add syntax highlighting, specify a language next to the backticks before the fenced code block.
in HTML will appear as <div class=Heading 1> Markdown also allows for raw HTML. There is no need to put any syntax around the code, but it needs to stand alone in the source document with no content above or below. A good example of using raw HTML in a Markdown document is when embedding a Youtube video.
Code Blocks To produce a code block in Markdown, simply indent every line of the block by at least 4 spaces or 1 tab. For example, given this input: This is a normal paragraph: This is a code block. A code block continues until it reaches a line that is not indented (or the end of the article).
To add a Python code chunk to an R Markdown document, you can use the chunk header ```{python} , e.g., ```{python} print("Hello Python!") ```
It appears that you can write extensions for Python-Markdown, which is probably the best approach.
If you are using some other Markdown implementation (or, you know, just for the heck of it) you could pre-process the text to implement your own tags (converting them to HTML) before handing it off to Markdown. This could be done using a regex or by any method you like. Within reasonable limits, Markdown should leave your HTML alone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With