You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
you can also provide just | without a title to not have any title set, which in case of admonition boxes would only display the content without a title section.
Nested blocks (i.e. an admonition box inside a tab block) requires a different number of / than its "parent" block.
So f.e. when the parent is /// would the nested block require at least //// to work.
Benefits
Main benefit is removal of indentation, which can make the markdown file harder to read due to understanding 4+ spaces as a code block.
Below are some examples using a details element with a nested admonition element:
/// details | Lorem ipsum
type: question
Hello World!
//// admonition | Lorem ipsum
type: info
Hello **again** World!
////
///
Rendered markdown:
/// details | Lorem ipsum
type: question
Hello World!
//// admonition | Lorem ipsum
type: info
Hello again World!
////
///
Downsides
One downside can be seen with the examples provided. Namely that by default there is no distinct name for each admonition type set due to the same syntax being used for multiple blocks.
You would need to define type: <type> as an option, which is done by indenting the lines after the opening block with 4 spaces and leaving an empty line after to separate it clearly.
However, blocks allow you to configure types that should be registered as block name to specify a specific type.
As an example, adding info to blocks.admonition's types setting would allow me to use
/// info | title
///
...to display an admonition box of type info.
The same system applies to the other blocks as this is a global setting.
Since quite a while does PyDownX provide a
blocks
extension containing replacements for already existing extensions.As an example,
blocks.admonition
can be used as a drop-in replacement for the Python Markdown'sadmonition
extension.Structure
The structure of a block:
you can also provide just
|
without a title to not have any title set, which in case of admonition boxes would only display the content without a title section.Nested blocks (i.e. an admonition box inside a tab block) requires a different number of
/
than its "parent" block.So f.e. when the parent is
///
would the nested block require at least////
to work.Benefits
Main benefit is removal of indentation, which can make the markdown file harder to read due to understanding 4+ spaces as a code block.
Below are some examples using a details element with a nested admonition element:
Current setup
Input:
Rendered markdown:
??? question | "Lorem ipsum"
Hello World!
Blocks setup
Input:
Rendered markdown:
/// details | Lorem ipsum
type: question
Hello World!
//// admonition | Lorem ipsum
type: info
Hello again World!
////
///
Downsides
One downside can be seen with the examples provided. Namely that by default there is no distinct name for each admonition type set due to the same syntax being used for multiple blocks.
You would need to define
type: <type>
as an option, which is done by indenting the lines after the opening block with 4 spaces and leaving an empty line after to separate it clearly.However, blocks allow you to configure
types
that should be registered as block name to specify a specific type.As an example, adding
info
toblocks.admonition
'stypes
setting would allow me to use...to display an admonition box of type info.
The same system applies to the other blocks as this is a global setting.
More info
blocks.admonition
blocks.details
blocks.tab
The text was updated successfully, but these errors were encountered: