diff --git a/README b/README index 827d1559e..4db74fdd1 100644 --- a/README +++ b/README @@ -793,6 +793,12 @@ depending on the output format, but include: : color for citation links in LaTeX documents `links-as-notes` : causes links to be printed as footnotes in LaTeX documents +`section` +: section number in man pages +`header` +: header in man pages +`footer` +: footer in man pages Variables may be set at the command line using the `-V/--variable` option. This allows users to include custom variables in their diff --git a/data/templates b/data/templates index 050ea0fa8..0d246e8af 160000 --- a/data/templates +++ b/data/templates @@ -1 +1 @@ -Subproject commit 050ea0fa8dc51d1e722f8e88b7ce9a792474082f +Subproject commit 0d246e8af51f5a07f8460e790bcbd926d421c829 diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs index b417565ce..31c044ba4 100644 --- a/src/Text/Pandoc/Writers/Man.hs +++ b/src/Text/Pandoc/Writers/Man.hs @@ -39,6 +39,7 @@ import Data.List ( isPrefixOf, intersperse, intercalate ) import Text.Pandoc.Pretty import Text.Pandoc.Builder (deleteMeta) import Control.Monad.State +import Data.Char ( isDigit ) type Notes = [[Block]] data WriterState = WriterState { stNotes :: Notes @@ -56,13 +57,20 @@ pandocToMan opts (Pandoc meta blocks) = do else Nothing let render' = render colwidth titleText <- inlineListToMan opts $ docTitle meta - let (cmdName, rest) = break (== ' ') $ render' titleText - let (title', section) = case reverse cmdName of - (')':d:'(':xs) | d `elem` ['0'..'9'] -> - (reverse xs, [d]) - xs -> (reverse xs, "\"\"") - let description = hsep $ - map (doubleQuotes . text . trim) $ splitBy (== '|') rest + let title' = render' titleText + let setFieldsFromTitle = + case break (== ' ') title' of + (cmdName, rest) -> case reverse cmdName of + (')':d:'(':xs) | isDigit d -> + setField "title" (reverse xs) . + setField "section" [d] . + case splitBy (=='|') rest of + (ft:hds) -> + setField "footer" (trim ft) . + setField "header" + (trim $ concat hds) + [] -> id + _ -> setField "title" title' metadata <- metaToJSON (fmap (render colwidth) . blockListToMan opts) (fmap (render colwidth) . inlineListToMan opts) @@ -73,9 +81,7 @@ pandocToMan opts (Pandoc meta blocks) = do let main = render' $ body $$ notes' $$ text "" hasTables <- liftM stHasTables get let context = setField "body" main - $ setField "title" title' - $ setField "section" section - $ setField "description" (render' description) + $ setFieldsFromTitle $ setField "has-tables" hasTables $ foldl (\acc (x,y) -> setField x y acc) metadata (writerVariables opts) diff --git a/tests/writer.man b/tests/writer.man index f0a6f348a..54baaf791 100644 --- a/tests/writer.man +++ b/tests/writer.man @@ -1,4 +1,4 @@ -.TH Pandoc "" "July 17, 2006" "Test Suite" +.TH "Pandoc Test Suite" "" "July 17, 2006" "" "" .PP This is a set of tests for pandoc. Most of them are adapted from John Gruber's markdown test suite.