Commit 6f4f6f36 authored by Marco Cavalli's avatar Marco Cavalli
Browse files

fix: prevent creation of wrong links

parent d7dcd70c
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -74,6 +74,10 @@ function Substitute(el, word)
            local startIndex, endIndex, number = textWithoutWord:gsub("‑", "-"):find(pattern) --check if number is in the same Str elem
            if not number then
                startIndex, endIndex, number = textWithoutWord:gsub("‑", "-"):find(annexPattern) --check if number is in the same Str elem
                if number and elem.text:sub(1, 1):match("%a") and elem.text:sub(2,2):match("%a") then
                    --this is not a clause number, it is something else
                    number = nil
                end
            end
            if not precedentChar:match("~") then
                if number then --create link
@@ -90,6 +94,10 @@ function Substitute(el, word)
                    number = succ.text:gsub("‑", "-"):match(pattern)
                    if not number then
                        number = succ.text:gsub("‑", "-"):match(annexPattern)
                        if number and succ.text:sub(1, 1):match("%a") and succ.text:sub(2,2):match("%a") then
                            --this is not a clause number, it is something else
                            number = nil
                        end
                    end
                    if succ.t == "Str" and number then                                        --we continue searching
                        local succ_succ = el.content
@@ -181,6 +189,10 @@ function MultipleClauses(el)
                if number == nil then
                    --check if it is an annex clause number
                    startIndex, endIndex, number = elem.text:find(annexPattern)
                    if number and elem.text:sub(1, 1):match("%a") and elem.text:sub(2,2):match("%a") then
                        --this is not a clause number, it is something else
                        number = nil
                    end
                end

                if elem.text:match("^,$") or elem.text:match("and") then