Class: Coradoc::Markdown::Admonition
- Defined in:
- lib/coradoc/markdown/model/admonition.rb
Overview
Admonition block — a callout like NOTE, WARNING, TIP, etc.
Markdown has no native admonition syntax (GFM Alerts since Dec 2023
notwithstanding — see admonition/gfm_alert strategy). The
admonition_style config option selects the output form:
:github → > **NOTE:** text (broad compat)
:gfm_alert → > [!NOTE]\n> text (GFM native since 2024)
:container → :::note\n... \n::: (VitePress / markdown-it)
:html → <div class="note">...</div>
Type is stored lowercase. Content is raw Markdown text (already serialized). Title is optional.
Constant Summary collapse
- ALLOWED_TYPES =
%w[note tip warning important caution].freeze
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Mixed inline content (strings and inline model objects) carried from the CoreModel children so serializers can preserve cross references, code spans, etc.
Instance Method Summary collapse
-
#initialize(admonition_type:, content:, title: nil, children: [], **rest) ⇒ Admonition
constructor
A new instance of Admonition.
Methods inherited from Base
Constructor Details
#initialize(admonition_type:, content:, title: nil, children: [], **rest) ⇒ Admonition
Returns a new instance of Admonition.
32 33 34 35 36 37 38 |
# File 'lib/coradoc/markdown/model/admonition.rb', line 32 def initialize(admonition_type:, content:, title: nil, children: [], **rest) super @admonition_type = admonition_type.to_s.downcase @content = content @title = title @children = Array(children) end |
Instance Attribute Details
#children ⇒ Object (readonly)
Mixed inline content (strings and inline model objects) carried
from the CoreModel children so serializers can preserve cross
references, code spans, etc. When empty, fall back to content.
30 31 32 |
# File 'lib/coradoc/markdown/model/admonition.rb', line 30 def children @children end |