Class: Asciidoctor::Standoc::PseudocodeBlockMacro
- Inherits:
-
Extensions::BlockProcessor
- Object
- Extensions::BlockProcessor
- Asciidoctor::Standoc::PseudocodeBlockMacro
- Defined in:
- lib/asciidoctor/standoc/macros.rb
Instance Method Summary collapse
Instance Method Details
#init_indent(line) ⇒ Object
70 71 72 73 74 75 |
# File 'lib/asciidoctor/standoc/macros.rb', line 70 def init_indent(line) /^(?<prefix>[ \t]*)(?<suffix>.*)$/ =~ line prefix = prefix.gsub(/\t/, "\u00a0\u00a0\u00a0\u00a0") .gsub(/ /, "\u00a0") prefix + suffix end |
#process(parent, reader, attrs) ⇒ Object
91 92 93 94 95 96 |
# File 'lib/asciidoctor/standoc/macros.rb', line 91 def process(parent, reader, attrs) attrs["role"] = "pseudocode" lines = reader.lines.map { |m| init_indent(m) } create_block(parent, :example, supply_br(lines), attrs, content_model: :compound) end |
#supply_br(lines) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/asciidoctor/standoc/macros.rb', line 77 def supply_br(lines) ignore = false lines.each_with_index do |l, i| /^(--+|====+|\|===|\.\.\.\.+|\*\*\*\*+|\+\+\+\++|````+|____\+)$/ .match(l) && (ignore = !ignore) next if l.empty? || l.match(/ \+$/) || /^\[.*\]$/.match?(l) || ignore next if i == lines.size - 1 || i < lines.size - 1 && lines[i + 1].empty? lines[i] += " +" end lines end |