From 2f7a38e1ab54d564555856a9354d1462ff8ca815 Mon Sep 17 00:00:00 2001 From: fiddlosopher Date: Sat, 21 Jul 2007 20:30:40 +0000 Subject: 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 --- src/Text/Pandoc/Writers/Man.hs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs index f0cc3c707..318fb056a 100644 --- a/src/Text/Pandoc/Writers/Man.hs +++ b/src/Text/Pandoc/Writers/Man.hs @@ -69,15 +69,16 @@ metaToMan :: WriterOptions -- ^ Options, including Man header -> Meta -- ^ Meta with bibliographic information -> State WriterState (Doc, Doc) metaToMan options (Meta title authors date) = do - titleParts <- mapM (inlineListToMan options) $ map normalizeSpaces $ - splitBy (Str "|") title - let titleParts' = map doubleQuotes titleParts - let (title', section, rest) = case titleParts' of - [] -> (text "\"\"", text "\"\"", []) - [x] -> (x, text "\"\"", []) - (x:y:zs) -> (x, y, zs) + titleText <- inlineListToMan options title + let (cmdName, rest) = break (== ' ') $ render titleText + let (title', section) = case reverse cmdName of + (')':d:'(':xs) | d `elem` ['0'..'9'] -> + (text (reverse xs), text [d]) + xs -> (text (reverse xs), empty) + let extras = map (doubleQuotes . text . removeLeadingTrailingSpace) $ + splitBy '|' rest let head = (text ".TH") <+> title' <+> section <+> - doubleQuotes (text date) <+> hsep rest + doubleQuotes (text date) <+> hsep extras let foot = case length authors of 0 -> text $ "" 1 -> text $ ".SH AUTHOR\n" ++ joinWithSep ", " authors -- cgit v1.2.3