git.iko.soy/typeable/pandoc
on master help sign in
Man writer: give more fine-grained control in template.

Now the `title`, `section`, `header`, and `footer` can all be set individually in metadata. The `description` variable has been removed. Quotes have been added so that spaces are allowed in the title. If you have a title that begins COMMAND(1) footer here | header here pandoc will parse it as before into a title, section, header, and footer. But you can also specify these elements explicitly. Closes #885.

commitdd96213c055d72b65e0c70552d9b4e3a824ba3ee authorJohn MacFarlane <fiddlosopher@gmail.com> dateThu 27 Jun 2013, 19:32 (13 years ago) parent82e46bf
4 files changed+24−12
README+6 data/templates+1−1 src/Text/Pandoc/Writers/Man.hs+16−10 tests/writer.man+1−1
README+6
@@ -793,6 +793,12 @@ depending on the output format, but include:
793793: color for citation links in LaTeX documents
794794`links-as-notes`
795795: causes links to be printed as footnotes in LaTeX documents
796+`section`
797+: section number in man pages
798+`header`
799+: header in man pages
800+`footer`
801+: footer in man pages
796802
797803Variables may be set at the command line using the `-V/--variable`
798804option. This allows users to include custom variables in their
data/templates+1−1

Submodule changed.

src/Text/Pandoc/Writers/Man.hs+16−10
@@ -39,6 +39,7 @@ import Data.List ( isPrefixOf, intersperse, intercalate )
3939import Text.Pandoc.Pretty
4040import Text.Pandoc.Builder (deleteMeta)
4141import Control.Monad.State
42+import Data.Char ( isDigit )
4243
4344type Notes = [[Block]]
4445data WriterState = WriterState { stNotes :: Notes
@@ -56,13 +57,20 @@ pandocToMan opts (Pandoc meta blocks) = do
5657 else Nothing
5758 let render' = render colwidth
5859 titleText <- inlineListToMan opts $ docTitle meta
59− let (cmdName, rest) = break (== ' ') $ render' titleText
60− let (title', section) = case reverse cmdName of
61− (')':d:'(':xs) | d `elem` ['0'..'9'] ->
62− (reverse xs, [d])
63− xs -> (reverse xs, "\"\"")
64− let description = hsep $
65− map (doubleQuotes . text . trim) $ splitBy (== '|') rest
60+ let title' = render' titleText
61+ let setFieldsFromTitle =
62+ case break (== ' ') title' of
63+ (cmdName, rest) -> case reverse cmdName of
64+ (')':d:'(':xs) | isDigit d ->
65+ setField "title" (reverse xs) .
66+ setField "section" [d] .
67+ case splitBy (=='|') rest of
68+ (ft:hds) ->
69+ setField "footer" (trim ft) .
70+ setField "header"
71+ (trim $ concat hds)
72+ [] -> id
73+ _ -> setField "title" title'
6674 metadata <- metaToJSON
6775 (fmap (render colwidth) . blockListToMan opts)
6876 (fmap (render colwidth) . inlineListToMan opts)
@@ -73,9 +81,7 @@ pandocToMan opts (Pandoc meta blocks) = do
7381 let main = render' $ body $$ notes' $$ text ""
7482 hasTables <- liftM stHasTables get
7583 let context = setField "body" main
76− $ setField "title" title'
77− $ setField "section" section
78− $ setField "description" (render' description)
84+ $ setFieldsFromTitle
7985 $ setField "has-tables" hasTables
8086 $ foldl (\acc (x,y) -> setField x y acc)
8187 metadata (writerVariables opts)
tests/writer.man+1−1
@@ -1,4 +1,4 @@
1−.TH Pandoc "" "July 17, 2006" "Test Suite"
1+.TH "Pandoc Test Suite" "" "July 17, 2006" "" ""
22.PP
33This is a set of tests for pandoc.
44Most of them are adapted from John Gruber's markdown test suite.