git.iko.soy/typeable/pandoc
on master help sign in
Man reader: improve handling of .IP.
0962b30John MacFarlane
src/Text/Pandoc/Readers/Man.hs+19−5
@@ -407,12 +407,14 @@ parseBlockQuote = blockQuote <$> continuation
407
407
408data ListType = Ordered ListAttributes
408data ListType = Ordered ListAttributes
409 | Bullet
409 | Bullet
410+ | Definition T.Text
410
411
411listTypeMatches :: Maybe ListType -> ListType -> Bool
412listTypeMatches :: Maybe ListType -> ListType -> Bool
412listTypeMatches Nothing _ = True
413listTypeMatches Nothing _ = True
413listTypeMatches (Just Bullet) Bullet = True
414listTypeMatches (Just Bullet) Bullet = True
414listTypeMatches (Just (Ordered (_,x,y))) (Ordered (_,x',y'))
415listTypeMatches (Just (Ordered (_,x,y))) (Ordered (_,x',y'))
415 = x == x' && y == y'
416 = x == x' && y == y'
417+listTypeMatches (Just (Definition _)) (Definition _) = True
416listTypeMatches (Just _) _ = False
418listTypeMatches (Just _) _ = False
417
419
418listItem :: PandocMonad m => Maybe ListType -> ManParser m (ListType, Blocks)
420listItem :: PandocMonad m => Maybe ListType -> ManParser m (ListType, Blocks)
@@ -427,20 +429,28 @@ listItem mbListType = try $ do
427 Right (start, listtype, listdelim)
429 Right (start, listtype, listdelim)
428 | cs == cs' -> Ordered (start, listtype, listdelim)
430 | cs == cs' -> Ordered (start, listtype, listdelim)
429 | otherwise -> Ordered (start, listtype, DefaultDelim)
431 | otherwise -> Ordered (start, listtype, DefaultDelim)
432+ Left _
433+ | cs == "\183" || cs == "-" || cs == "*" || cs == "+"
430− Left _ -> Bullet
434+ -> Bullet
435+ | otherwise -> Definition cs
431 guard $ listTypeMatches mbListType lt
436 guard $ listTypeMatches mbListType lt
437+ skipMany memptyLine
432 inls <- option mempty parseInlines
438 inls <- option mempty parseInlines
439+ skipMany memptyLine
433 continuations <- mconcat <$> many continuation
440 continuations <- mconcat <$> many continuation
434 return (lt, para inls <> continuations)
441 return (lt, para inls <> continuations)
435 [] -> mzero
442 [] -> mzero
436
443
437parseList :: PandocMonad m => ManParser m Blocks
444parseList :: PandocMonad m => ManParser m Blocks
438parseList = try $ do
445parseList = try $ do
439− (lt, x) <- listItem Nothing
446+ x@(lt, _) <- listItem Nothing
440− xs <- map snd <$> many (listItem (Just lt))
447+ xs <- many (listItem (Just lt))
448+ let toDefItem (Definition t, bs) = (B.text t, [bs])
449+ toDefItem _ = mempty
441 return $ case lt of
450 return $ case lt of
442− Bullet -> bulletList (x:xs)
451+ Bullet -> bulletList $ map snd (x:xs)
443− Ordered lattr -> orderedListWith lattr (x:xs)
452+ Ordered lattr -> orderedListWith lattr $ map snd (x:xs)
453+ Definition _ -> definitionList $ map toDefItem (x:xs)
444
454
445continuation :: PandocMonad m => ManParser m Blocks
455continuation :: PandocMonad m => ManParser m Blocks
446continuation =
456continuation =
@@ -453,11 +463,15 @@ definitionListItem :: PandocMonad m
453 => ManParser m (Inlines, [Blocks])
463 => ManParser m (Inlines, [Blocks])
454definitionListItem = try $ do
464definitionListItem = try $ do
455 mmacro "TP" -- args specify indent level, can ignore
465 mmacro "TP" -- args specify indent level, can ignore
466+ skipMany memptyLine
456 term <- parseInline
467 term <- parseInline
468+ skipMany memptyLine
457 moreterms <- many $ try $ do
469 moreterms <- many $ try $ do
458 mmacro "TQ"
470 mmacro "TQ"
459 parseInline
471 parseInline
472+ skipMany memptyLine
460 inls <- option mempty parseInlines
473 inls <- option mempty parseInlines
474+ skipMany memptyLine
461 continuations <- mconcat <$> many continuation
475 continuations <- mconcat <$> many continuation
462 return ( mconcat (intersperse B.linebreak (term:moreterms))
476 return ( mconcat (intersperse B.linebreak (term:moreterms))
463 , [para inls <> continuations])
477 , [para inls <> continuations])
test/command/6858.mdnew file+52
@@ -0,0 +1,52 @@
1+```
2+% pandoc -t markdown -f man
3+.TH FvwmAnimate 1 "Date" Fvwm "Fvwm Modules"
4+.UC
5+.SH NAME
6+\fBFvwmAnimate\fP \- the fvwm animate module
7+.SH SYNOPSIS
8+Module FvwmAnimate [ModuleAlias]
9+
10+.IP "*FvwmAnimate: Color \fBcolor\fP"
11+
12+Tells \fBFvwmAnimate\fP what color to draw with.
13+The color is "XOR'ed" (exclusive ORed) onto the background.
14+
15+.IP "*FvwmAnimate: Pixmap \fBpixmap\fP"
16+
17+Tells \fBFvwmAnimate\fP to use \fBpixmap\fP to draw with. This can be useful
18+if \fB*FvwmAnimate: Color\fP gives poor results.
19+^D
20+# NAME
21+
22+**FvwmAnimate** - the fvwm animate module
23+
24+# SYNOPSIS
25+
26+Module FvwmAnimate \[ModuleAlias\]
27+
28+\*FvwmAnimate: Color color
29+
30+: Tells **FvwmAnimate** what color to draw with. The color is
31+ \"XOR\'ed\" (exclusive ORed) onto the background.
32+
33+\*FvwmAnimate: Pixmap pixmap
34+
35+: Tells **FvwmAnimate** to use **pixmap** to draw with. This can be
36+ useful if **\*FvwmAnimate: Color** gives poor results.
37+```
38+
39+```
40+% pandoc -t markdown -f man
41+.IP "\[bu]"
42+
43+hi
44+
45+.IP "\[bu]"
46+
47+there
48+^D
49+- hi
50+
51+- there
52+```