Module: Asciidoctor::LaTeX::TeXBlock
- Defined in:
- lib/asciidoctor/latex/tex_block.rb
Constant Summary
- INNER_TYPES =
The list of “inner environments” whose enclosing escaped braces are not to be stripped.
["array", "matrix", "none"]
Class Method Summary (collapse)
-
+ (Object) environmemt_type_of_match(m)
Return the environment type from an element of the array produced by get_tex_blocks – each element is a three-element array with the tex block as the middle element.
-
+ (Object) environment_type(str)
Return the environment type of a tex block.
-
+ (Object) get_tex_blocks(str)
Find blocks delmited by [ … ].
-
+ (Object) process_environments(str)
Transform the input string by stripping or passing each tex block as required.
-
+ (Object) process_tex_block(m, str)
Transform the input string for a given block m.
-
+ (Object) restore_match_data(m)
Return the block as-is – do not strip delimiters.
-
+ (Object) strip_match_data(m)
Return the block sans delimiters.
Class Method Details
+ (Object) environmemt_type_of_match(m)
Return the environment type from an element of the array produced by get_tex_blocks – each element is a three-element array with the tex block as the middle element.
67 68 69 |
# File 'lib/asciidoctor/latex/tex_block.rb', line 67 def self.environmemt_type_of_match m environment_type m[1] end |
+ (Object) environment_type(str)
Return the environment type of a tex block. Thus, if str = [beginfoo ho ho ho endfoo], the string “foo” is returned.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/asciidoctor/latex/tex_block.rb', line 51 def self.environment_type str rx_env_block = /\\begin\{(.*?)\}/ m = str.match rx_env_block if m env_type = m[1] else env_type = 'none' end env_type end |
+ (Object) get_tex_blocks(str)
Find blocks delmited by [ … ]
42 43 44 45 |
# File 'lib/asciidoctor/latex/tex_block.rb', line 42 def self.get_tex_blocks str rx_tex_block = /(\\\[)(.*?)(\\\])/m str.scan rx_tex_block end |
+ (Object) process_environments(str)
Transform the input string by stripping or passing each tex block as required
95 96 97 98 99 100 101 |
# File 'lib/asciidoctor/latex/tex_block.rb', line 95 def self.process_environments str tbs = get_tex_blocks str tbs.each do |tb| str = process_tex_block tb, str end str end |
+ (Object) process_tex_block(m, str)
Transform the input string for a given block m
83 84 85 86 87 88 89 90 91 |
# File 'lib/asciidoctor/latex/tex_block.rb', line 83 def self.process_tex_block m, str block_type = environmemt_type_of_match m if INNER_TYPES.include? block_type output = str else output = str.gsub restore_match_data(m), strip_match_data(m) end output end |
+ (Object) restore_match_data(m)
Return the block as-is – do not strip delimiters.
73 74 75 |
# File 'lib/asciidoctor/latex/tex_block.rb', line 73 def self.restore_match_data m m.join() end |
+ (Object) strip_match_data(m)
Return the block sans delimiters
78 79 80 |
# File 'lib/asciidoctor/latex/tex_block.rb', line 78 def self.strip_match_data m m[1] end |