Skip to content

Commit

Permalink
fix(concealer): footnote pattern should be matched against full string
Browse files Browse the repository at this point in the history
  • Loading branch information
champignoom committed Jan 23, 2024
1 parent 28cbafb commit a886a2e
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions lua/neorg/modules/core/concealer/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -389,16 +389,17 @@ local function get_ordered_index(bufid, prefix_node)
end

local superscript_digits = {
"",
"¹",
"²",
"³",
"",
"",
"",
"",
"",
"",
["0"] = "",
["1"] = "¹",
["2"] = "²",
["3"] = "³",
["4"] = "",
["5"] = "",
["6"] = "",
["7"] = "",
["8"] = "",
["9"] = "",
["-"] = "",
}

---@class core.concealer
Expand Down Expand Up @@ -454,11 +455,12 @@ module.public = {
footnote_concealed = function(config, bufid, node)
local link_title_node = node:next_named_sibling()
local link_title = vim.treesitter.get_node_text(link_title_node, bufid)
if config.numeric_superscript and link_title:match("%d+") then
if config.numeric_superscript and link_title:match("^[-0-9]+$") then
vim.print(link_title)
local t = {}
for i = 1, #link_title do
local d = link_title:sub(i, i):byte() - 0x30
table.insert(t, superscript_digits[d + 1])
local d = link_title:sub(i, i)
table.insert(t, superscript_digits[d])
end
local superscripted_title = table.concat(t)
local row_start_0b, col_start_0b, _, _ = link_title_node:range()
Expand Down

0 comments on commit a886a2e

Please sign in to comment.