aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorNils Carlson <nils@nilscarlson.se>2020-09-25 00:43:43 +0000
committerGitHub <noreply@github.com>2020-09-24 17:43:43 -0700
commit1ad7a047d58a629ab7d29ea74dcb752d82d3dc11 (patch)
treee719a3919ba1354fc46a53194f16a1be48baaf7b /src/Text
parenta331c69b4935b03d42f88f5346b700c795e09346 (diff)
downloadpandoc-1ad7a047d58a629ab7d29ea74dcb752d82d3dc11.tar.gz
DocBook reader: Implement table cell alignment (#6698)
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/DocBook.hs17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/DocBook.hs b/src/Text/Pandoc/Readers/DocBook.hs
index 5c9687f94..0635884ad 100644
--- a/src/Text/Pandoc/Readers/DocBook.hs
+++ b/src/Text/Pandoc/Readers/DocBook.hs
@@ -943,11 +943,6 @@ parseBlock (Elem e) =
$ filterChildren isRow b
Nothing -> mapM (parseRow colnames)
$ filterChildren isRow e'
- let toAlignment c = case findAttr (unqual "align") c of
- Just "left" -> AlignLeft
- Just "right" -> AlignRight
- Just "center" -> AlignCenter
- _ -> AlignDefault
let toWidth c = do
w <- findAttr (unqual "colwidth") c
n <- safeRead $ "0" <> T.filter (\x ->
@@ -1005,6 +1000,14 @@ parseBlock (Elem e) =
-- we also attach the label as a class, so it can be styled properly
return $ divWith (attrValue "id" e,[label],[]) (title <> b)
+toAlignment :: Element -> Alignment
+toAlignment c = case findAttr (unqual "align") c of
+ Just "left" -> AlignLeft
+ Just "right" -> AlignRight
+ Just "center" -> AlignCenter
+ _ -> AlignDefault
+
+
parseMixed :: PandocMonad m => (Inlines -> Blocks) -> [Content] -> DB m Blocks
parseMixed container conts = do
let (ils,rest) = break isBlockElement conts
@@ -1036,7 +1039,9 @@ parseEntry cn el = do
case (mStrt, mEnd) of
(Just start, Just end) -> colDistance start end
_ -> 1
- (fmap (cell AlignDefault 1 (toColSpan el)) . parseMixed plain . elContent) el
+ let colSpan = toColSpan el
+ let align = toAlignment el
+ (fmap (cell align 1 colSpan) . (parseMixed plain) . elContent) el
getInlines :: PandocMonad m => Element -> DB m Inlines
getInlines e' = trimInlines . mconcat <$>