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
This commit is contained in:
fiddlosopher 2007-07-21 20:30:40 +00:00
parent 6d8f0e29d9
commit 2f7a38e1ab
2 changed files with 24 additions and 14 deletions

21
README
View file

@ -645,16 +645,25 @@ title block appears in the document, the title prefix will be used by
itself as the HTML title. itself as the HTML title.
The man page writer extracts a title, man page section number, and The man page writer extracts a title, man page section number, and
other header and footer information from the title line. These should other header and footer information from the title line. The title
be separated by pipe characters (`|`), as follows: is assumed to be the first word on the title line, which may optionally
end with a (single-digit) section number in parentheses. (There should
be no space between the title and the parentheses.) Anything after
this is assumed to be additional footer and header text. A single pipe
character (`|`) should be used to separate the footer text from the header
text. Thus,
% title | section number (1-9) | footer left | header center % pandoc(1)
For example, will yield a man page with the title `pandoc` and section 1.
% pandoc | 1 | Pandoc User Manuals | Version 4.0 % pandoc(1) Pandoc User Manuals
The middle of the man page footer is used for the date. will also have "Pandoc User Manuals" in the footer.
% pandoc(1) Pandoc User Manuals | Version 4.0
will also have "Version 4.0" in the header.
Markdown in HTML blocks Markdown in HTML blocks
----------------------- -----------------------

View file

@ -69,15 +69,16 @@ metaToMan :: WriterOptions -- ^ Options, including Man header
-> Meta -- ^ Meta with bibliographic information -> Meta -- ^ Meta with bibliographic information
-> State WriterState (Doc, Doc) -> State WriterState (Doc, Doc)
metaToMan options (Meta title authors date) = do metaToMan options (Meta title authors date) = do
titleParts <- mapM (inlineListToMan options) $ map normalizeSpaces $ titleText <- inlineListToMan options title
splitBy (Str "|") title let (cmdName, rest) = break (== ' ') $ render titleText
let titleParts' = map doubleQuotes titleParts let (title', section) = case reverse cmdName of
let (title', section, rest) = case titleParts' of (')':d:'(':xs) | d `elem` ['0'..'9'] ->
[] -> (text "\"\"", text "\"\"", []) (text (reverse xs), text [d])
[x] -> (x, text "\"\"", []) xs -> (text (reverse xs), empty)
(x:y:zs) -> (x, y, zs) let extras = map (doubleQuotes . text . removeLeadingTrailingSpace) $
splitBy '|' rest
let head = (text ".TH") <+> title' <+> section <+> let head = (text ".TH") <+> title' <+> section <+>
doubleQuotes (text date) <+> hsep rest doubleQuotes (text date) <+> hsep extras
let foot = case length authors of let foot = case length authors of
0 -> text $ "" 0 -> text $ ""
1 -> text $ ".SH AUTHOR\n" ++ joinWithSep ", " authors 1 -> text $ ".SH AUTHOR\n" ++ joinWithSep ", " authors