Attach UUIDs to Discussion Text (#37)
Three backticks will break the discussion tree, this MR specifically adds custom UUIDs to each text node to avoid this issue.
This commit is contained in:
committed by
GitHub
parent
4f1a0f9c57
commit
6bb7575c6d
@@ -137,8 +137,14 @@ end
|
|||||||
M.build_note_body = function(note)
|
M.build_note_body = function(note)
|
||||||
local text_nodes = {}
|
local text_nodes = {}
|
||||||
for bodyLine in note.body:gmatch("[^\n]+") do
|
for bodyLine in note.body:gmatch("[^\n]+") do
|
||||||
table.insert(text_nodes, NuiTree.Node({ text = bodyLine, is_body = true }, {}))
|
local line = u.attach_uuid(bodyLine)
|
||||||
|
table.insert(text_nodes, NuiTree.Node({
|
||||||
|
text = line.text,
|
||||||
|
id = line.id,
|
||||||
|
is_body = true
|
||||||
|
}, {}))
|
||||||
end
|
end
|
||||||
|
|
||||||
local noteHeader = "@" ..
|
local noteHeader = "@" ..
|
||||||
note.author.username .. " " .. u.format_date(note.created_at)
|
note.author.username .. " " .. u.format_date(note.created_at)
|
||||||
|
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ local current_file_path = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Function to join two tables
|
-- Function to join two tables
|
||||||
function join_tables(table1, table2)
|
local function join_tables(table1, table2)
|
||||||
for _, value in ipairs(table2) do
|
for _, value in ipairs(table2) do
|
||||||
table.insert(table1, value)
|
table.insert(table1, value)
|
||||||
end
|
end
|
||||||
@@ -253,6 +253,20 @@ function join_tables(table1, table2)
|
|||||||
return table1
|
return table1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local random = math.random
|
||||||
|
local function uuid()
|
||||||
|
local template = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
|
||||||
|
return string.gsub(template, '[xy]', function(c)
|
||||||
|
local v = (c == 'x') and random(0, 0xf) or random(8, 0xb)
|
||||||
|
return string.format('%x', v)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
local attach_uuid = function(str)
|
||||||
|
return { text = str, id = uuid() }
|
||||||
|
end
|
||||||
|
|
||||||
|
M.attach_uuid = attach_uuid
|
||||||
M.join_tables = join_tables
|
M.join_tables = join_tables
|
||||||
M.get_relative_file_path = get_relative_file_path
|
M.get_relative_file_path = get_relative_file_path
|
||||||
M.get_current_line_number = get_current_line_number
|
M.get_current_line_number = get_current_line_number
|
||||||
|
|||||||
Reference in New Issue
Block a user