aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-08-27 22:00:42 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2016-08-27 22:00:42 +0200
commitd29a6238968c963c8fba829d23a605d3e780118e (patch)
tree71976e6511bdf5cecd1a9a430fa00ef72ab341ba
parent500de5e979650807bf4b2e9be4538bbd364b5241 (diff)
downloadpandoc-d29a6238968c963c8fba829d23a605d3e780118e.tar.gz
Man writer: allow section numbers that are not a single digit.
Closes #3089.
-rw-r--r--src/Text/Pandoc/Writers/Man.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs
index 5c7d760ac..caf26d515 100644
--- a/src/Text/Pandoc/Writers/Man.hs
+++ b/src/Text/Pandoc/Writers/Man.hs
@@ -41,7 +41,6 @@ import Data.Maybe (fromMaybe)
import Text.Pandoc.Pretty
import Text.Pandoc.Builder (deleteMeta)
import Control.Monad.State
-import Data.Char ( isDigit )
type Notes = [[Block]]
data WriterState = WriterState { stNotes :: Notes
@@ -62,10 +61,11 @@ pandocToMan opts (Pandoc meta blocks) = do
let title' = render' titleText
let setFieldsFromTitle =
case break (== ' ') title' of
- (cmdName, rest) -> case reverse cmdName of
- (')':d:'(':xs) | isDigit d ->
- defField "title" (reverse xs) .
- defField "section" [d] .
+ (cmdName, rest) -> case break (=='(') cmdName of
+ (xs, '(':ys) | not (null ys) &&
+ last ys == ')' ->
+ defField "title" xs .
+ defField "section" (init ys) .
case splitBy (=='|') rest of
(ft:hds) ->
defField "footer" (trim ft) .