Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experiment with adding more JS translations of the python source examples #44

Open
quackingduck opened this issue Feb 10, 2016 · 4 comments · Fixed by #52
Open

Experiment with adding more JS translations of the python source examples #44

quackingduck opened this issue Feb 10, 2016 · 4 comments · Fixed by #52

Comments

@quackingduck
Copy link
Member

@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.

@richardartoul
Copy link
Collaborator

@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.pyfiles 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?

@quackingduck
Copy link
Member Author

Hmmm... Oz, might have changed how the multi-language stuff is supposed to work. @ozan ?

@ozan
Copy link
Contributor

ozan commented Mar 12, 2016

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.

@ozan
Copy link
Contributor

ozan commented Mar 12, 2016

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 :)

@ozan ozan reopened this Mar 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants