Module: Md2Man::Document
Constant Summary collapse
- PARAGRAPH_INDENT =
block-level processing
/^\s*$|^ (?=\S)/
Instance Method Summary collapse
- #block_code(code, language) ⇒ Object
-
#codespan(code) ⇒ Object
————————————————————————— span-level processing —————————————————————————.
- #indented_paragraph(text) ⇒ Object
- #normal_paragraph(text) ⇒ Object
-
#paragraph(text) ⇒ Object
This method blocks Redcarpet’s default behavior, which cannot be accessed using super() due to the limitation of how Redcarpet is implemented in C.
- #postprocess(document) ⇒ Object
-
#preprocess(document) ⇒ Object
————————————————————————— document-level processing —————————————————————————.
- #reference(input_match, output_match) ⇒ Object
- #tagged_paragraph(text) ⇒ Object
Instance Method Details
#block_code(code, language) ⇒ Object
60 61 62 |
# File 'lib/md2man/document.rb', line 60 def block_code code, language decode_references code, true end |
#codespan(code) ⇒ Object
span-level processing
68 69 70 |
# File 'lib/md2man/document.rb', line 68 def codespan code decode_references (code || ' '), true end |
#indented_paragraph(text) ⇒ Object
48 49 50 |
# File 'lib/md2man/document.rb', line 48 def indented_paragraph text warn "md2man/document: indented_paragraph not implemented: #{text.inspect}" end |
#normal_paragraph(text) ⇒ Object
56 57 58 |
# File 'lib/md2man/document.rb', line 56 def normal_paragraph text warn "md2man/document: normal_paragraph not implemented: #{text.inspect}" end |
#paragraph(text) ⇒ Object
This method blocks Redcarpet’s default behavior, which cannot be accessed using super() due to the limitation of how Redcarpet is implemented in C. See github.com/vmg/redcarpet/issues/51 for the complete details.
We don’t call super() here deliberately: to replace paragraph nodes with normal_paragraph, tagged_paragraph, or indented_paragraph as appropriate.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/md2man/document.rb', line 31 def paragraph text head, *body = text.lines.to_a head_indented = head =~ PARAGRAPH_INDENT body_indented = !body.empty? && body.all? {|s| s =~ PARAGRAPH_INDENT } if head_indented || body_indented text = text.gsub(PARAGRAPH_INDENT, '') if head_indented && (body_indented || body.empty?) indented_paragraph text else tagged_paragraph text end else normal_paragraph text.chomp end end |
#postprocess(document) ⇒ Object
14 15 16 |
# File 'lib/md2man/document.rb', line 14 def postprocess document decode_references document end |
#preprocess(document) ⇒ Object
document-level processing
9 10 11 12 |
# File 'lib/md2man/document.rb', line 9 def preprocess document @references = {} encode_references document end |
#reference(input_match, output_match) ⇒ Object
72 73 74 |
# File 'lib/md2man/document.rb', line 72 def reference input_match, output_match warn "md2man/document: reference not implemented: #{input_match}" end |
#tagged_paragraph(text) ⇒ Object
52 53 54 |
# File 'lib/md2man/document.rb', line 52 def tagged_paragraph text warn "md2man/document: tagged_paragraph not implemented: #{text.inspect}" end |