Homepage    |    Wiki    |    GitHub    |    Twitter

Plugin: Code Section Joplin Content Plugin

I wrote this plugin to enable the display of a code section from a source file. The code source file must be appended to the markdown document. A fence in JSON style, containing info about source, language, begin, end ..., describes which content is to be displayed.

A code description looks as follows:

```codesection
{
"lang": "python",
"src": "CODE-SOURCE-APPENDIX",
"begin": 1,
"end": 50,
"expandTabs": true,
"tabSize": 4,
"lineNumbers": false,
}
```

The rendered code could look as follows:

The plugin works in a way similar as the Listings package of Latex.

For more information look at the GitHub repository at Code Section Plugin. You can download the plugin from there. I will add the plugin to the Joplin Plugin repository soon.

6 Likes

Thanks for making a plugin! Can you explain how this would be better than just adding in the code into the text? Other than the line numbers.

I feel, the author wanted to make an advanced codeblock for more professional use that suits his environment.

It seems that the plugin is used to display only part of the attached source code file. This way you can use Joplin as a scratchpad for future changes in a code, without touching the main source code in a git repo.

Additionally you can present these pieces of code during lectures, focusing only on small parts at a time but leaving the whole code file untouched and runnable. At least, I find it very distracting, when professors scroll like madmen to show specific class of a monolithic code project. This plugin might help with it.

3 Likes

Got it. That makes sense. I didn't catch that you could specify line numbers. Seems kind of fragile, though, if the source changes.