Open quackingduck opened 8 years ago
@quackingduck So I've been messing around with this for a few hours and I'm stuck. I think I more or less completely understand the litpy-plugin.js file, but I've been experimenting with /book/analysis/an-anagram-detection-example.md
and changing
<!-- litpy analysis/anagrams.py -->
to
<div data-language="python">
<!-- litpy analysis/anagrams.py -->
</div>
Based on what I understand this will do a bulk replace of <!-- litpy analysis/anagrams.py -->
with the contents of /book/analysis/anagrams.py
(after its pre-processed by your regex/string manipulation functions in /litpy-plugin.js
In addition, accordin to the markdown-it specification, as long as you provide an empty space between the <div>
tag and the markdown code, it will still be processed by the markdown parser. Example
And in fact it does kind of work. If I add the line **hello**
to /book/analysis/anagrams.py
it will render properly as bolded text, however, it seems like all the newlines in the /book/analysis/anagrams.py
files are completely ignored by the Markdown parser (despite still being present in the rendered HTML!). This messes up the markdown because some things (like headers) rely upon the newline character. So instead of seeing a proper heading like this
<h1> This is the best heading ever </h1>
Other content
You end up with
This is the best heading ever-------------- Other content
Do you have any ideas why this might be happening / am I even approaching this problem correctly?
Hmmm... Oz, might have changed how the multi-language stuff is supposed to work. @ozan ?
Ah, yeah this is just because the markdown specification says that markdown inside of block-level html tags shouldn't be parsed. I'm gonna change how the language switching is specified to work around it.
Oops, reopening in case @richardartoul has any questions. Does #52 make sense? Your anagram example is up now, so should be a better starting point for you :)
@richardartoul
Check out
/book/recursion/dynamic-programming.md
for an example of chapter with both python and js source code. However the build system doesn't support "literate" js at the moment. Check out/litpy-plugin.js
for what it'd take to support that style.