Closed MasouShizuka closed 1 month ago
Thank you very much for reporting this issue and providing very clear examples!
I had not tested this on any languages outside of English, definitely a miss on my part.
I've corrected it in this commit: https://github.com/MeanderingProgrammer/markdown.nvim/commit/7f90f522750111c32b0515814398514d58f66b23, by using strdisplaywidth
which is similar to strwidth
, for tables as well as a couple other lingering places that were less likely to be a problem.
I should definitely be uniformly using strdisplaywidth
in all string length calculation rather than the Lua #
.
I tested it on your example and it seems to work as expected, lmk if you face any issues.
Thanks again!
After I tried the plugin, I found that when the cell text length of each column of the table is the same, the plugin will add lines above and below the table. For
ascii
characters, this calculation is correct.But for other characters, such as Chinese, this is not so good. Because for Chinese characters, Lua will count the length of the character as 3, such as:
行
. However, with a mono font,行
actually takes up 2 characters of width.For example, the following table will add lines, but it actually doesn’t look good:
Although the following table has the same width, lines cannot be added:
Perhaps should use the
strwidth
function to calculate text length: