Skip to content

Commit 38a14a4

Browse files
authored
Merge pull request #483 from ImmanuelHaffner/fix/emoji-tostring-width
fix(tostring): resolve emoji shorthands to Unicode for correct table column widths
2 parents ed989a2 + e8606ae commit 38a14a4

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

lua/markview/renderers/markdown/tostring.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,16 @@ md_str.emoji = function (match)
245245
end
246246

247247
local removed = string.gsub(match, "^:", ""):gsub(":$", "");
248+
249+
--- Resolve to the actual Unicode emoji so that
250+
--- strdisplaywidth() returns the correct on-screen
251+
--- width (typically 2) instead of the shortcode name
252+
--- length (e.g. "rocket" = 6).
253+
local symbols = require("markview.symbols");
254+
if symbols.shorthands and symbols.shorthands[removed] then
255+
return symbols.shorthands[removed];
256+
end
257+
248258
return removed;
249259

250260
---|fE

0 commit comments

Comments
 (0)