git.iko.soy/typeable/pandoc
on master help sign in
Changed system for indicating man page title, section,
2f7a38efiddlosopher
README+15−6
@@ -645,16 +645,25 @@ title block appears in the document, the title prefix will be used by
645itself as the HTML title.
645itself as the HTML title.
646
646
647The man page writer extracts a title, man page section number, and
647The man page writer extracts a title, man page section number, and
648−other header and footer information from the title line. These should
648+other header and footer information from the title line. The title
649−be separated by pipe characters (`|`), as follows:
649+is assumed to be the first word on the title line, which may optionally
650+end with a (single-digit) section number in parentheses. (There should
651+be no space between the title and the parentheses.) Anything after
652+this is assumed to be additional footer and header text. A single pipe
653+character (`|`) should be used to separate the footer text from the header
654+text. Thus,
650
655
651− % title | section number (1-9) | footer left | header center
656+ % pandoc(1)
652
657
653−For example,
658+will yield a man page with the title `pandoc` and section 1.
654
659
655− % pandoc | 1 | Pandoc User Manuals | Version 4.0
660+ % pandoc(1) Pandoc User Manuals
656
661
657−The middle of the man page footer is used for the date.
662+will also have "Pandoc User Manuals" in the footer.
663+
664+ % pandoc(1) Pandoc User Manuals | Version 4.0
665+
666+will also have "Version 4.0" in the header.
658
667
659Markdown in HTML blocks
668Markdown in HTML blocks
660-----------------------
669-----------------------
src/Text/Pandoc/Writers/Man.hs+9−8
@@ -69,15 +69,16 @@ metaToMan :: WriterOptions -- ^ Options, including Man header
69 -> Meta -- ^ Meta with bibliographic information
69 -> Meta -- ^ Meta with bibliographic information
70 -> State WriterState (Doc, Doc)
70 -> State WriterState (Doc, Doc)
71metaToMan options (Meta title authors date) = do
71metaToMan options (Meta title authors date) = do
72− titleParts <- mapM (inlineListToMan options) $ map normalizeSpaces $
72+ titleText <- inlineListToMan options title
73− splitBy (Str "|") title
73+ let (cmdName, rest) = break (== ' ') $ render titleText
74− let titleParts' = map doubleQuotes titleParts
75− let (title', section, rest) = case titleParts' of
74+ let (title', section) = case reverse cmdName of
75+ (')':d:'(':xs) | d `elem` ['0'..'9'] ->
76− [] -> (text "\"\"", text "\"\"", [])
76+ (text (reverse xs), text [d])
77− [x] -> (x, text "\"\"", [])
77+ xs -> (text (reverse xs), empty)
78− (x:y:zs) -> (x, y, zs)
78+ let extras = map (doubleQuotes . text . removeLeadingTrailingSpace) $
79+ splitBy '|' rest
79 let head = (text ".TH") <+> title' <+> section <+>
80 let head = (text ".TH") <+> title' <+> section <+>
80− doubleQuotes (text date) <+> hsep rest
81+ doubleQuotes (text date) <+> hsep extras
81 let foot = case length authors of
82 let foot = case length authors of
82 0 -> text $ ""
83 0 -> text $ ""
83 1 -> text $ ".SH AUTHOR\n" ++ joinWithSep ", " authors
84 1 -> text $ ".SH AUTHOR\n" ++ joinWithSep ", " authors