Fix regression in grid tables for wide characters.
In the translation from String to Text, a char-width-sensitive splitAt' was dropped. This commit reinstates it. Closes #7214.
This commit is contained in:
parent
e227496d3a
commit
20cd33e5a4
2 changed files with 41 additions and 5 deletions
|
@ -153,12 +153,20 @@ splitTextBy isSep t
|
|||
in first : splitTextBy isSep (T.dropWhile isSep rest)
|
||||
|
||||
splitTextByIndices :: [Int] -> T.Text -> [T.Text]
|
||||
splitTextByIndices ns = splitTextByRelIndices (zipWith (-) ns (0:ns))
|
||||
splitTextByIndices ns = splitTextByRelIndices (zipWith (-) ns (0:ns)) . T.unpack
|
||||
where
|
||||
splitTextByRelIndices [] t = [t]
|
||||
splitTextByRelIndices (x:xs) t =
|
||||
let (first, rest) = T.splitAt x t
|
||||
in first : splitTextByRelIndices xs rest
|
||||
splitTextByRelIndices [] cs = [T.pack cs]
|
||||
splitTextByRelIndices (x:xs) cs =
|
||||
let (first, rest) = splitAt' x cs
|
||||
in T.pack first : splitTextByRelIndices xs rest
|
||||
|
||||
-- Note: don't replace this with T.splitAt, which is not sensitive
|
||||
-- to character widths!
|
||||
splitAt' :: Int -> [Char] -> ([Char],[Char])
|
||||
splitAt' _ [] = ([],[])
|
||||
splitAt' n xs | n <= 0 = ([],xs)
|
||||
splitAt' n (x:xs) = (x:ys,zs)
|
||||
where (ys,zs) = splitAt' (n - charWidth x) xs
|
||||
|
||||
ordNub :: (Ord a) => [a] -> [a]
|
||||
ordNub l = go Set.empty l
|
||||
|
|
28
test/command/7214.md
Normal file
28
test/command/7214.md
Normal file
|
@ -0,0 +1,28 @@
|
|||
```
|
||||
% pandoc
|
||||
+------------+----------+------------------+
|
||||
|日本語 | の文字列 | words in english |
|
||||
+------------+----------+------------------+
|
||||
|abc defghij | def | xyz |
|
||||
+------------+----------+------------------+
|
||||
^D
|
||||
<table style="width:60%;">
|
||||
<colgroup>
|
||||
<col style="width: 18%" />
|
||||
<col style="width: 15%" />
|
||||
<col style="width: 26%" />
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td>日本語</td>
|
||||
<td>の文字列</td>
|
||||
<td>words in english</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td>abc defghij</td>
|
||||
<td>def</td>
|
||||
<td>xyz</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
```
|
Loading…
Add table
Reference in a new issue