Franklin.jl icon indicating copy to clipboard operation
Franklin.jl copied to clipboard

Suggestion for Including Code

Open alfaromartino opened this issue 2 years ago • 2 comments

Thanks for this great package!! I had a suggestion after working for several months with Franklin (actually PkgPage). Everything runs quite smoothly for me, except when it comes to including code. So far, there are two options for doing this: i) introducing code directly into the text, or ii) creating a code file that is eventually called in the text.

I thought that a third option would be valuable: writing a file with ALL scripts to include, with tags to separate them. MWE This is how you'd write the code 01

This is how you'd include the code on text 02

This option is especially useful if you've worked on a project and want to create a website explaining the code snippets (or if you wrote code without the intention of creating a website, creating an ideal alternative to Jupyter) More generally, I think it'd also make writing the code more smoothly.

Thanks again for all your work!

alfaromartino avatar Feb 22 '23 05:02 alfaromartino

Hello @alfaromartino thanks for the feedback, just to check, are you aware that Franklin does handle literate files (docs: https://franklinjl.org/extras/literate/) and would this kind of address your point of

This option is especially useful if you've worked on a project and want to create a website explaining the code snippets (or if you wrote code without the intention of creating a website, creating an ideal alternative to Jupyter)

As an aside, Franklin.jl is in a frozen state, the new version (currently available at Xranklin.jl) is a complete rewrite and will be the next Franklin version 0.11 (and eventually 1.0) so for now I won't be making any major changes or additions to Franklin.jl 0.10 while that's not in. On the constructive side, the next version will give you access to the parser and you could define your own parsing rules. In your specific case though, it would be a bit awkward because the # clashes with the tag for header in Markdown.

tlienart avatar Feb 22 '23 07:02 tlienart

I know that it could handle Literate but, since I never used it, I ignored it. It seems that it's what I was describing!!! I'll take a lookn into it. It seems it's not automatic, but it can address this.

I'm aware of Xranklin. The comment was to provide some feedback, just in case it was useful for Xranklin ( the # was just an example, to give a same feeling as the references to headers). In fact, I use PkgPage, and it'd be great if Xranklin could have some package similar to PkgPage!

Thanks for your work!

alfaromartino avatar Feb 22 '23 09:02 alfaromartino