Permalink
Browse files

indent paragraphs beginning with defn-indent line

This allows you to write multi-paragraph definitions for terms.
  • Loading branch information...
sunaku committed Nov 3, 2011
1 parent f4896f4 commit ea1b9f675e376fe0936bdc3cd9ebf126449aef60
Showing with 12 additions and 5 deletions.
  1. +7 −4 README.markdown
  2. +5 −1 lib/redcarpet-manpage.rb
View
@@ -40,10 +40,13 @@ Specification
Although your input documents are written in [Markdown], RedcarpetManpage
introduces the following additional conventions to simplify common tasks:
-1. Paragraphs beginning with bold/italic and followed by at least
- one two-space indented line are considered to be definitions.
- The first line of such a paragraph is the term being defined and
- the subsequent two-space indented lines are the definition body.
+1. Paragraphs beginning with bold/italic and followed by a two-space indented
+ line are considered to be definitions. The first line of such a paragraph
+ is the term being defined and the subsequent two-space indented lines are
+ the definition body.
+
+2. Paragraphs beginning with a two-space indented line are considered to be a
+ part of multi-paragraph definitions.
------------------------------------------------------------------------------
Usage
View
@@ -81,9 +81,13 @@ def postprocess document
gsub(/^(\.IP.*)\n\.PP/, '\1').
# paragraphs beginning with bold/italic and followed by
- # at least one definition-indented line are definitions
+ # a definition-indented line are considered definitions
gsub(/^\.PP(?=\n\\f.+\n#{DEFINITION_INDENT}\S)/, '.TP').
+ # paragraphs beginning with a definition-indented line
+ # are considered a part of multi-paragraph definitions
+ gsub(/^\.PP(?=\n#{DEFINITION_INDENT}\S)/, '.IP').
+
# make indented paragraphs occupy less space on screen:
# roff will fit the second line of the paragraph along
# side the first line if it has enough room to do so!

0 comments on commit ea1b9f6

Please sign in to comment.