aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTuongNM <[email protected]>2025-09-12 11:44:34 +0200
committerGitHub <[email protected]>2025-09-12 11:44:34 +0200
commit5eb25ab4481eb6ab3b4aafff9ce1fd4086e58b52 (patch)
treedcd51eeb5048cc9b34dbc346856c2ab7cd7f2675
parentc93acab035e9f7f3576199ce1bf4009cc4530dcf (diff)
Markdown reader: Fix simple table alignment (#11136)
Take wide characters into account when determining the alignment.
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs2
-rw-r--r--test/command/6021.md54
2 files changed, 55 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 0605281db..f6c05cf33 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -1243,7 +1243,7 @@ alignType strLst len =
let nonempties = filter (not . T.null) $ map trimr strLst
(leftSpace, rightSpace) =
case sortOn T.length nonempties of
- (x:_) -> (T.head x `elem` [' ', '\t'], T.length x < len)
+ (x:_) -> (T.head x `elem` [' ', '\t'], realLength x < len)
[] -> (False, False)
in case (leftSpace, rightSpace) of
(True, False) -> AlignRight
diff --git a/test/command/6021.md b/test/command/6021.md
new file mode 100644
index 000000000..d7e7e3cbe
--- /dev/null
+++ b/test/command/6021.md
@@ -0,0 +1,54 @@
+```
+% pandoc -t native
+Oxide 石英
+------- ------
+SiO2 100
+^D
+[ Table
+ ( "" , [] , [] )
+ (Caption Nothing [])
+ [ ( AlignLeft , ColWidthDefault )
+ , ( AlignRight , ColWidthDefault )
+ ]
+ (TableHead
+ ( "" , [] , [] )
+ [ Row
+ ( "" , [] , [] )
+ [ Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "Oxide" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "\30707\33521" ] ]
+ ]
+ ])
+ [ TableBody
+ ( "" , [] , [] )
+ (RowHeadColumns 0)
+ []
+ [ Row
+ ( "" , [] , [] )
+ [ Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "SiO2" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "100" ] ]
+ ]
+ ]
+ ]
+ (TableFoot ( "" , [] , [] ) [])
+]
+```