git.iko.soy/typeable/pandoc
on master help sign in
Changed system for indicating man page title, section,

header and footer. Documented in README. git-svn-id: https://pandoc.googlecode.com/svn/trunk@745 788f1e2b-df1e-0410-8736-df70ead52e1b

commit2f7a38e1ab54d564555856a9354d1462ff8ca815 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSat 21 Jul 2007, 20:30 (19 years ago) parent6d8f0e2
2 files changed+24−14
README+15−6 src/Text/Pandoc/Writers/Man.hs+9−8
README+15−6
@@ -645,16 +645,25 @@ title block appears in the document, the title prefix will be used by
645645itself as the HTML title.
646646
647647The man page writer extracts a title, man page section number, and
648−other header and footer information from the title line. These should
649−be separated by pipe characters (`|`), as follows:
648+other header and footer information from the title line. The title
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,
650655
651− % title | section number (1-9) | footer left | header center
656+ % pandoc(1)
652657
653−For example,
658+will yield a man page with the title `pandoc` and section 1.
654659
655− % pandoc | 1 | Pandoc User Manuals | Version 4.0
660+ % pandoc(1) Pandoc User Manuals
656661
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.
658667
659668Markdown in HTML blocks
660669-----------------------
src/Text/Pandoc/Writers/Man.hs+9−8
@@ -69,15 +69,16 @@ metaToMan :: WriterOptions -- ^ Options, including Man header
6969 -> Meta -- ^ Meta with bibliographic information
7070 -> State WriterState (Doc, Doc)
7171metaToMan options (Meta title authors date) = do
72− titleParts <- mapM (inlineListToMan options) $ map normalizeSpaces $
73− splitBy (Str "|") title
74− let titleParts' = map doubleQuotes titleParts
75− let (title', section, rest) = case titleParts' of
76− [] -> (text "\"\"", text "\"\"", [])
77− [x] -> (x, text "\"\"", [])
78− (x:y:zs) -> (x, y, zs)
72+ titleText <- inlineListToMan options title
73+ let (cmdName, rest) = break (== ' ') $ render titleText
74+ let (title', section) = case reverse cmdName of
75+ (')':d:'(':xs) | d `elem` ['0'..'9'] ->
76+ (text (reverse xs), text [d])
77+ xs -> (text (reverse xs), empty)
78+ let extras = map (doubleQuotes . text . removeLeadingTrailingSpace) $
79+ splitBy '|' rest
7980 let head = (text ".TH") <+> title' <+> section <+>
80− doubleQuotes (text date) <+> hsep rest
81+ doubleQuotes (text date) <+> hsep extras
8182 let foot = case length authors of
8283 0 -> text $ ""
8384 1 -> text $ ".SH AUTHOR\n" ++ joinWithSep ", " authors