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(s) ⇒ Object
95 96 97 98 99 100 |
# File 'lib/asciidoctor/standoc/macros.rb', line 95 def init_indent(s) /^(?<prefix>[ \t]*)(?<suffix>.*)$/ =~ s prefix = prefix.gsub(/\t/, "\u00a0\u00a0\u00a0\u00a0") .gsub(/ /, "\u00a0") prefix + suffix end |
#process(parent, reader, attrs) ⇒ Object
116 117 118 119 120 121 122 |
# File 'lib/asciidoctor/standoc/macros.rb', line 116 def process(parent, reader, attrs) attrs["role"] = "pseudocode" lines = reader.lines.map { |m| init_indent(m) } ret = create_block(parent, :example, supply_br(lines), attrs, content_model: :compound) ret end |
#supply_br(lines) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/asciidoctor/standoc/macros.rb', line 102 def supply_br(lines) ignore = false lines.each_with_index do |l, i| /^(--+|====+|\|===|\.\.\.\.+|\*\*\*\*+|\+\+\+\++|\`\`\`\`+|____\+)$/.match(l) && (ignore = !ignore) next if l.empty? || l.match(/ \+$/) next if /^\[.*\]$/.match(l) next if ignore next if i == lines.size - 1 || i < lines.size - 1 && lines[i + 1].empty? lines[i] += " +" end lines end |