Man reader: improve handling of .IP.
We now better handle `.IP` when it is used with non-bullet, non-numbered lists, creating a definition list. We also skip blank lines like groff itself. Closes #6858.
This commit is contained in:
parent
3f278f580e
commit
0962b30d84
2 changed files with 71 additions and 5 deletions
|
@ -407,12 +407,14 @@ parseBlockQuote = blockQuote <$> continuation
|
|||
|
||||
data ListType = Ordered ListAttributes
|
||||
| Bullet
|
||||
| Definition T.Text
|
||||
|
||||
listTypeMatches :: Maybe ListType -> ListType -> Bool
|
||||
listTypeMatches Nothing _ = True
|
||||
listTypeMatches (Just Bullet) Bullet = True
|
||||
listTypeMatches (Just (Ordered (_,x,y))) (Ordered (_,x',y'))
|
||||
= x == x' && y == y'
|
||||
listTypeMatches (Just (Definition _)) (Definition _) = True
|
||||
listTypeMatches (Just _) _ = False
|
||||
|
||||
listItem :: PandocMonad m => Maybe ListType -> ManParser m (ListType, Blocks)
|
||||
|
@ -427,20 +429,28 @@ listItem mbListType = try $ do
|
|||
Right (start, listtype, listdelim)
|
||||
| cs == cs' -> Ordered (start, listtype, listdelim)
|
||||
| otherwise -> Ordered (start, listtype, DefaultDelim)
|
||||
Left _ -> Bullet
|
||||
Left _
|
||||
| cs == "\183" || cs == "-" || cs == "*" || cs == "+"
|
||||
-> Bullet
|
||||
| otherwise -> Definition cs
|
||||
guard $ listTypeMatches mbListType lt
|
||||
skipMany memptyLine
|
||||
inls <- option mempty parseInlines
|
||||
skipMany memptyLine
|
||||
continuations <- mconcat <$> many continuation
|
||||
return (lt, para inls <> continuations)
|
||||
[] -> mzero
|
||||
|
||||
parseList :: PandocMonad m => ManParser m Blocks
|
||||
parseList = try $ do
|
||||
(lt, x) <- listItem Nothing
|
||||
xs <- map snd <$> many (listItem (Just lt))
|
||||
x@(lt, _) <- listItem Nothing
|
||||
xs <- many (listItem (Just lt))
|
||||
let toDefItem (Definition t, bs) = (B.text t, [bs])
|
||||
toDefItem _ = mempty
|
||||
return $ case lt of
|
||||
Bullet -> bulletList (x:xs)
|
||||
Ordered lattr -> orderedListWith lattr (x:xs)
|
||||
Bullet -> bulletList $ map snd (x:xs)
|
||||
Ordered lattr -> orderedListWith lattr $ map snd (x:xs)
|
||||
Definition _ -> definitionList $ map toDefItem (x:xs)
|
||||
|
||||
continuation :: PandocMonad m => ManParser m Blocks
|
||||
continuation =
|
||||
|
@ -453,11 +463,15 @@ definitionListItem :: PandocMonad m
|
|||
=> ManParser m (Inlines, [Blocks])
|
||||
definitionListItem = try $ do
|
||||
mmacro "TP" -- args specify indent level, can ignore
|
||||
skipMany memptyLine
|
||||
term <- parseInline
|
||||
skipMany memptyLine
|
||||
moreterms <- many $ try $ do
|
||||
mmacro "TQ"
|
||||
parseInline
|
||||
skipMany memptyLine
|
||||
inls <- option mempty parseInlines
|
||||
skipMany memptyLine
|
||||
continuations <- mconcat <$> many continuation
|
||||
return ( mconcat (intersperse B.linebreak (term:moreterms))
|
||||
, [para inls <> continuations])
|
||||
|
|
52
test/command/6858.md
Normal file
52
test/command/6858.md
Normal file
|
@ -0,0 +1,52 @@
|
|||
```
|
||||
% pandoc -t markdown -f man
|
||||
.TH FvwmAnimate 1 "Date" Fvwm "Fvwm Modules"
|
||||
.UC
|
||||
.SH NAME
|
||||
\fBFvwmAnimate\fP \- the fvwm animate module
|
||||
.SH SYNOPSIS
|
||||
Module FvwmAnimate [ModuleAlias]
|
||||
|
||||
.IP "*FvwmAnimate: Color \fBcolor\fP"
|
||||
|
||||
Tells \fBFvwmAnimate\fP what color to draw with.
|
||||
The color is "XOR'ed" (exclusive ORed) onto the background.
|
||||
|
||||
.IP "*FvwmAnimate: Pixmap \fBpixmap\fP"
|
||||
|
||||
Tells \fBFvwmAnimate\fP to use \fBpixmap\fP to draw with. This can be useful
|
||||
if \fB*FvwmAnimate: Color\fP gives poor results.
|
||||
^D
|
||||
# NAME
|
||||
|
||||
**FvwmAnimate** - the fvwm animate module
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
Module FvwmAnimate \[ModuleAlias\]
|
||||
|
||||
\*FvwmAnimate: Color color
|
||||
|
||||
: Tells **FvwmAnimate** what color to draw with. The color is
|
||||
\"XOR\'ed\" (exclusive ORed) onto the background.
|
||||
|
||||
\*FvwmAnimate: Pixmap pixmap
|
||||
|
||||
: Tells **FvwmAnimate** to use **pixmap** to draw with. This can be
|
||||
useful if **\*FvwmAnimate: Color** gives poor results.
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -t markdown -f man
|
||||
.IP "\[bu]"
|
||||
|
||||
hi
|
||||
|
||||
.IP "\[bu]"
|
||||
|
||||
there
|
||||
^D
|
||||
- hi
|
||||
|
||||
- there
|
||||
```
|
Loading…
Reference in a new issue