Display line numbers
Choose whether to display line numbers within a code block globally with the parameter
codeLineNumbers setting to
1[params] 2... 3codeLineNumbers = true # Shows line numbers for all code blocks globally. 4...
Limit code block height
You can globally control the number of lines which are displayed by default for your code blocks. Code which has the number of lines exceed this value will dynamically cause two code block expansion buttons to appear, allowing the user to expand to full length and contract. This is useful when sharing code or scripts with tens or hundreds of lines where you wish to control how many are displayed. Under params in
config.toml file, add a value as follows:
1[params] 2... 3codeMaxLines = 10 # Maximum number of lines to be shown by default across all articles. 4...
If the value already exists, change it to the desired number. This will apply globally.
If you need more granular control, this parameter can be overridden at the blog article level. Add the same value to your article frontmatter as follows:
1... 2codeMaxLines = 15 # Maximum number of lines to be shown in code blocks in this blog post. 3...
codeMaxLines is specified both in
config.toml and in the article frontmatter, the value specified in the article frontmatter will apply to the given article. In the above example, the global default is
10 and yet the article value is
15 so code blocks in this article will auto-collapse after 15 lines.
codeMaxLines is not specified anywhere, an internal default value of
100 will be assumed.