Closed fmaida closed 5 years ago
You could use cog in a markdown file (HTML comments will be useful). But I'm not sure there's a way to combine the HTML comments, Python comments, and Markdown triple-backticks in a way that will keep all of the software happy and produce the right result.
Thank you.
I was playing around and made the following that seems to work :) https://gist.github.com/janto/2f779791b95e46c4abe7c9211af7a19b
(unable to paste the code here since the markdown gets interpreted)
which will give:
This is a markdown file with some cog wrapped Python code...
def f():
return "cog is awesome"
result = f()
which results in output like this
result: 'cog is awesome'
Markdown ends :)
My version 2 that is shorter and gives color highlighting of python code in my editor: https://gist.github.com/janto/c5176c5dc3968bdca146e59245ed4788
Hello, I'm sorry to bother you but would it be possible to use cog with python snippets put between fenced code, inside a markdown file ?
For example can this markdown file:
Be translated into this:
And then, getting this final output from a markdown parser:
This is my source code
and this is the result: