Class: Asciidoctor::Rhrev::XrefSanitizerPreprocessor
- Inherits:
-
Extensions::Preprocessor
- Object
- Extensions::Preprocessor
- Asciidoctor::Rhrev::XrefSanitizerPreprocessor
- Defined in:
- lib/asciidoctor/rhrev/processors.rb
Overview
Preprocessor to sanitize xref syntax before parsing This fixes Antora Assembler’s xref:page:::anchor[] syntax that triggers warnings
Instance Method Summary collapse
Instance Method Details
#process(document, reader) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/asciidoctor/rhrev/processors.rb', line 6 def process document, reader # Convert xref:page:::anchor[] to <<page:::anchor>> # This prevents "unknown name for block macro" warnings lines = reader.read_lines sanitized = lines.map do |line| if line.match?(/xref:[\w-]+:::[^\[\]]+\[\]/) line.gsub(/xref:([\w-]+:::[^\[\]]+)\[\]/, '<<\1>>') elsif line.match?(/xref:[\w-]+----[^\[\]]+\[\]/) line.gsub(/xref:([\w-]+----[^\[\]]+)\[\]/, '<<\1>>') else line end end reader.restore_lines sanitized reader end |