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
38 39 40 |
# File 'lib/paru/filter/math.rb', line 38 def initialize(contents) @math_type, @string = contents end |
Instance Attribute Details
#math_type ⇒ Hash
32 33 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 |
# File 'lib/paru/filter/math.rb', line 32 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?() "InlineMath" == @math_type[t] 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?() "DisplayMath" == @math_type[t] 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
32 33 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 |
# File 'lib/paru/filter/math.rb', line 32 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?() "InlineMath" == @math_type[t] 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?() "DisplayMath" == @math_type[t] 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
72 73 74 75 76 77 |
# File 'lib/paru/filter/math.rb', line 72 def ast_contents() [ @math_type, @string ] end |
#display! ⇒ Object
Make this Math node's content display as a block
65 66 67 68 69 |
# File 'lib/paru/filter/math.rb', line 65 def display!() @math_type = { "t" => "DisplayMath" } end |
#display? ⇒ Boolean
Should this math be displayed as a block?
60 61 62 |
# File 'lib/paru/filter/math.rb', line 60 def display?() "DisplayMath" == @math_type[t] end |
#has_inline? ⇒ Boolean
Has this Math node inline contents?
89 90 91 |
# File 'lib/paru/filter/math.rb', line 89 def has_inline?() false end |
#has_string? ⇒ Boolean
Has this Math node string contents?
82 83 84 |
# File 'lib/paru/filter/math.rb', line 82 def has_string?() true end |
#inline! ⇒ Object
Convert this Math node's content to Inline
51 52 53 54 55 |
# File 'lib/paru/filter/math.rb', line 51 def inline!() @math_type = { "t" => "InlineMath" } end |
#inline? ⇒ Boolean
Is this an inline node?
46 47 48 |
# File 'lib/paru/filter/math.rb', line 46 def inline?() "InlineMath" == @math_type[t] end |