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