Class: Paru::PandocFilter::Math
- Defined in:
- lib/paru/filter/math.rb
Overview
A Math Inline node with the type of math node and the mathematical contents
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#ast_contents ⇒ Object
Create an AST representation of this Math node.
-
#display! ⇒ Object
Make this Math node’s content display as a block.
-
#display? ⇒ Boolean
Should this math be displayed as a block?.
-
#has_inline? ⇒ Boolean
Has this Math node inline contents?.
-
#has_string? ⇒ Boolean
Has this Math node string contents?.
-
#initialize(contents) ⇒ Math
constructor
Create a new Math node with contents.
-
#inline! ⇒ Object
Convert this Math node’s content to Inline.
-
#inline? ⇒ Boolean
Is this an inline node?.
Constructor Details
#initialize(contents) ⇒ Math
Create a new Math node with contents
40 41 42 |
# File 'lib/paru/filter/math.rb', line 40 def initialize(contents) @math_type, @string = contents end |
Instance Attribute Details
#math_type ⇒ Hash
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/paru/filter/math.rb', line 34 class Math < Inline attr_accessor :math_type, :string # Create a new Math node with contents # # @param contents [Array] an array with the type and contents def initialize(contents) @math_type, @string = contents end # Is this an inline node? # # @return [Boolean] true if math type is "InlineMath", false # otherwise def inline? @math_type['t'] == 'InlineMath' end # Convert this Math node's content to Inline def inline! @math_type = { 't' => 'InlineMath' } end # Should this math be displayed as a block? # # @return [Boolean] true if type is "DisplayMath" def display? @math_type['t'] == 'DisplayMath' end # Make this Math node's content display as a block def display! @math_type = { 't' => 'DisplayMath' } end # Create an AST representation of this Math node def ast_contents [ @math_type, @string ] end # Has this Math node string contents? # # @return [Boolean] true def has_string? true end # Has this Math node inline contents? # # @return [Boolean] false def has_inline? false end end |
#string ⇒ String
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/paru/filter/math.rb', line 34 class Math < Inline attr_accessor :math_type, :string # Create a new Math node with contents # # @param contents [Array] an array with the type and contents def initialize(contents) @math_type, @string = contents end # Is this an inline node? # # @return [Boolean] true if math type is "InlineMath", false # otherwise def inline? @math_type['t'] == 'InlineMath' end # Convert this Math node's content to Inline def inline! @math_type = { 't' => 'InlineMath' } end # Should this math be displayed as a block? # # @return [Boolean] true if type is "DisplayMath" def display? @math_type['t'] == 'DisplayMath' end # Make this Math node's content display as a block def display! @math_type = { 't' => 'DisplayMath' } end # Create an AST representation of this Math node def ast_contents [ @math_type, @string ] end # Has this Math node string contents? # # @return [Boolean] true def has_string? true end # Has this Math node inline contents? # # @return [Boolean] false def has_inline? false end end |
Instance Method Details
#ast_contents ⇒ Object
Create an AST representation of this Math node
74 75 76 77 78 79 |
# File 'lib/paru/filter/math.rb', line 74 def ast_contents [ @math_type, @string ] end |
#display! ⇒ Object
Make this Math node’s content display as a block
67 68 69 70 71 |
# File 'lib/paru/filter/math.rb', line 67 def display! @math_type = { 't' => 'DisplayMath' } end |
#display? ⇒ Boolean
Should this math be displayed as a block?
62 63 64 |
# File 'lib/paru/filter/math.rb', line 62 def display? @math_type['t'] == 'DisplayMath' end |
#has_inline? ⇒ Boolean
Has this Math node inline contents?
91 92 93 |
# File 'lib/paru/filter/math.rb', line 91 def has_inline? false end |
#has_string? ⇒ Boolean
Has this Math node string contents?
84 85 86 |
# File 'lib/paru/filter/math.rb', line 84 def has_string? true end |
#inline! ⇒ Object
Convert this Math node’s content to Inline
53 54 55 56 57 |
# File 'lib/paru/filter/math.rb', line 53 def inline! @math_type = { 't' => 'InlineMath' } end |
#inline? ⇒ Boolean
Is this an inline node?
48 49 50 |
# File 'lib/paru/filter/math.rb', line 48 def inline? @math_type['t'] == 'InlineMath' end |