Inserts a piece of code from code source

Additional Information

Maintainers: mick2nd
Minimum app version:2.2
Downloads: This version:2362
Last updated:2022-09-13T14:36:11Z

Code Section Joplin Plugin

This plug-in displays a piece of source code. It reads this source code from a source file which is appended to the note. The code is selected by supporting a code definition inside a code definition block.

The code definition looks as follows:

"lang": "python",
"begin": 1,
"end": 50,
"expandTabs": true,
"tabSize": 4,
"lineNumbers": false

Several entries can be omitted and will be replaced by their defaults. The source language and the source itself are mandatory.

The inserted code will be displayed using the default renderer for that language including syntax highlighting.

This could look like this:

Python Source Code


  1. Append a code source to the note
  2. Immediately following it add a codesection describing the code to be displayed
  3. The description has the shape of a JSON string
  4. The "src" attribute identifies the code source (its id followed by extension)
  5. Alternatively you could copy and paste the code insertion into the quotes of src


  1. The resource folder is not recognized after the start of Joplin. Workaround: Invoke the settings and then leave them
  2. Only local sources in the resource folder can be displayed, no web content
  3. The plugin uses synchroneous file access to read the source, no asynchroneous access

Release Notes


  • Fixed the bug where resource folder was not recognized. Workaround is no longer needed (see Problems 1.).


  • Added a context menu command to insert a template of a code section
  • Added a few properties to the code section description:
    • scale: a scale factor in percent as 80% or absolute font size
    • spacing: the line spacing, default is 130% of the font size
    • height: the height of the code section window, may be "auto", "fill", a value in pixels ("400px") or a factor in percent relating to the window height


  • Changed architecture of the plugin
  • Code Sections are printed now with export to pdf