-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Including code snippets in callouts #471
Comments
This comes close to working, but removes the newlines rather than replace them with
|
I got it to work but it was pretty tedious:
For a nested blockquote that would be
If it is somehow possible to create a function for this, a numerical argument would be enough to know how many |
What you do here is pretty smart, @ocaisa. I haven't heard of Liquid functions so what you propose might be the best one can do if they want to include code from a file in a callout box. By the way, can't one replace
|
Not as smart as I hoped, I hadn't noticed but it is leaving behind a |
Ok, the whitespace was indeed the problem. I got it to work by creating my own liquid plugin:
which is stored in an
I would have liked to simplify this to be able to create |
If # num -- "depth"
input.map { |line| "> " * num + line}.join("\n") E.g. %w[one two three].map{ |line| "> " * 3 + line }.join("\n")
=> "> > > one\n> > > two\n> > > three" if "one\ntwo\nthree".split("\n").map{ |line| "> " * 3 + line }.join("\n")
=> "> > > one\n> > > two\n> > > three" I have to note that the code you provided above didn't work for me as expected for some reason. Perhaps it has to do with double empty lines in the python code snippet that I used. |
Thanks, that worked for me. For completeness I'll give my final solution. I created
Note that for the filter to be picked up, you must restart the server (with I can then use the filter in my lesson with
|
Great job! Note, you can
|
@maxim-belkin I leave it to you to decide whether to close this or not, thanks for the help. |
Thanks, @ocaisa. I'd like to keep it open for now. It might be beneficial for the community to integrate this into the main template. It'll tie us more to the Shopify Liquid so we'd have to review this carefully. |
This is a never-ending story! It turns out that while I could served the site locally, it didn't pick up my plugin when I served on GitHub (or when I tried to use the remote Carpentries theme), so I had to go back and try to do it using standard filters. I managed to get it working this time but it is very very picky about the syntax:
|
Yes, GitHub works in "safe" mode and does not enable plugins. It is possible to workaround this by using GitHub Actions but your solution is nothing short of brilliant, so GitHub Actions can wait! Great stuff! |
and don't forget about using ~~~ instead of ``` |
Not sure if this is the right place to report this, but it doesn't seem to be possible to include code snippets in a callout (or any special blockquote), for example:
will not render correctly if
in.lj
contains multiple lines.I imagine this is because the snippet is directly inserted including the line breaks. Is there a fix for this?
The text was updated successfully, but these errors were encountered: