@@ -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