Class: Coradoc::Markdown::Math
- Defined in:
- lib/coradoc/markdown/model/math.rb
Overview
Represents a math block (block or inline)
Block math syntax: $$…$$ on its own lines Inline math syntax: $$…$$ within text
Examples:
$$\lambda_\alpha > 5$$
$$1 + 1$$
Class Method Summary collapse
-
.block(content) ⇒ Math
Create a block math element.
-
.inline(content) ⇒ Math
Create an inline math element.
Instance Method Summary collapse
-
#inline? ⇒ Boolean
Check if this is inline math.
-
#to_md ⇒ String
Convert to Markdown.
Methods inherited from Base
#serialize_content, #to_h, visit, #visit
Class Method Details
.block(content) ⇒ Math
Create a block math element
35 36 37 |
# File 'lib/coradoc/markdown/model/math.rb', line 35 def self.block(content) new(content: content, inline: false) end |
.inline(content) ⇒ Math
Create an inline math element
28 29 30 |
# File 'lib/coradoc/markdown/model/math.rb', line 28 def self.inline(content) new(content: content, inline: true) end |
Instance Method Details
#inline? ⇒ Boolean
Check if this is inline math
21 22 23 |
# File 'lib/coradoc/markdown/model/math.rb', line 21 def inline? inline == true end |
#to_md ⇒ String
Convert to Markdown
41 42 43 44 45 46 47 |
# File 'lib/coradoc/markdown/model/math.rb', line 41 def to_md if inline? "$$#{content}$$" else "$$\n#{content}\n$$" end end |