diff --git a/Development/talagan_ReaImGui Markdown.lua b/Development/talagan_ReaImGui Markdown.lua
index 03736de04..903bcf4c9 100644
--- a/Development/talagan_ReaImGui Markdown.lua
+++ b/Development/talagan_ReaImGui Markdown.lua
@@ -1,13 +1,16 @@
--[[
@description ReaImGui Markdown : A Markdown rendering library for ReaImGui
-@version 0.1.13
+@version 0.1.14
@author Ben 'Talagan' Babut
@license MIT
@donation https://www.paypal.com/donate/?business=3YEZMY9D6U8NC&no_recurring=1¤cy_code=EUR
@links
Forum Thread https://forum.cockos.com/showthread.php?t=301055
@changelog
- - [Bug Fix] Fix potential style parameter gardening for dynamic styles (wrong deepCopy implementation)
+ - [Feature] Better handling of consecutive empty lines
+ - [Rework] Reworked default style
+ - [Bug Fix] List bullet not sized accordingly to list entry
+ - [Bug Fix] Code block would always add empty line at the end
@metapackage
@provides
[nomain] talagan_ReaImGui Markdown/reaimgui_markdown/**/*.lua
diff --git a/Development/talagan_ReaImGui Markdown/actions/talagan_ReaImGui Markdown Demo.lua b/Development/talagan_ReaImGui Markdown/actions/talagan_ReaImGui Markdown Demo.lua
index f459d3ae9..5727c5424 100644
--- a/Development/talagan_ReaImGui Markdown/actions/talagan_ReaImGui Markdown Demo.lua
+++ b/Development/talagan_ReaImGui Markdown/actions/talagan_ReaImGui Markdown Demo.lua
@@ -55,12 +55,6 @@ if use_debugger then
end
-if do_unit_tests then
- -- Reqiore stuff for the profiler to work.
- local UnitTest = require "reaimgui_markdown/markdown-test"
- UnitTest()
-end
-
-- We override Reaper's defer method for two reasons :
-- We want the full trace on errors
-- We want the debugger to pause on errors
@@ -75,6 +69,13 @@ reaper.defer = function(c)
end)
end
+if do_unit_tests then
+ -- Reqiore stuff for the profiler to work.
+ local UnitTest = require "reaimgui_markdown/markdown-test"
+ UnitTest()
+end
+
+
local entry = [[
# This is a header level 1
## This is a header level 2
diff --git a/Development/talagan_ReaImGui Markdown/reaimgui_markdown/markdown-ast.lua b/Development/talagan_ReaImGui Markdown/reaimgui_markdown/markdown-ast.lua
index bc332c77e..45356f23a 100644
--- a/Development/talagan_ReaImGui Markdown/reaimgui_markdown/markdown-ast.lua
+++ b/Development/talagan_ReaImGui Markdown/reaimgui_markdown/markdown-ast.lua
@@ -658,6 +658,7 @@ local function ParseMarkdown(markdown)
local table_headers = {}
local expected_columns = 0
local raw_rows = {}
+ local consecutive_empty_lines = 0
local function finalize_table()
if in_table and (#raw_rows > 0 or #table_headers > 0) then
@@ -702,7 +703,13 @@ local function ParseMarkdown(markdown)
-- Code block
if trimmed_line:match(RX_CODEBLOCK) then
finalize_table()
+ consecutive_empty_lines = 0
if in_code_block then
+ -- Remove trailing newline when closing code block
+ local code_node = ast.children[#ast.children]
+ if code_node.value:sub(-1) == "\n" then
+ code_node.value = code_node.value:sub(1, -2)
+ end
in_code_block = false
else
in_code_block = true
@@ -711,10 +718,12 @@ local function ParseMarkdown(markdown)
i = i + 1
elseif in_code_block then
ast.children[#ast.children].value = ast.children[#ast.children].value .. line .. "\n"
+ consecutive_empty_lines = 0
i = i + 1
-- Headers
elseif trimmed_line:match(RX_HEADER) then
finalize_table()
+ consecutive_empty_lines = 0
local level = #trimmed_line:match("^#+")
if level <= 6 then
local content = trimmed_line:match(RX_HEADER_CONTENT)
@@ -725,6 +734,7 @@ local function ParseMarkdown(markdown)
-- Blockquote - use trimmed_line for detection but pass original lines
elseif trimmed_line:match(RX_BLOCKQUOTE) then
finalize_table()
+ consecutive_empty_lines = 0
-- Store original lines but with leading spaces trimmed for blockquote parsing
local trimmed_lines = {}
for idx, l in ipairs(lines) do
@@ -738,6 +748,7 @@ local function ParseMarkdown(markdown)
-- Lists
elseif trimmed_line:match(RX_UNORDERED_LIST) or trimmed_line:match(RX_ORDERED_LIST) then
finalize_table()
+ consecutive_empty_lines = 0
local lists, new_i = parse_list(lines, i, #lines, 0, markdown)
for _, list in ipairs(lists) do
table.insert(ast.children, list)
@@ -750,6 +761,7 @@ local function ParseMarkdown(markdown)
end
-- Table
elseif trimmed_line:match(RX_TABLE_LINE) then
+ consecutive_empty_lines = 0
local cells = {}
for cell in line:gmatch("[^|]+") do
table.insert(cells, trim(cell))
@@ -786,14 +798,21 @@ local function ParseMarkdown(markdown)
i = i + 1
elseif trimmed_line:match(RX_SEPARATOR) then
finalize_table()
+ consecutive_empty_lines = 0
table.insert(ast.children, new_node("Separator"))
i = i + 1
- elseif line == "" then
+ elseif trimmed_line == "" then
finalize_table()
+ consecutive_empty_lines = consecutive_empty_lines + 1
+ -- Only create VerticalSpace from the 2nd consecutive empty line onwards
+ if consecutive_empty_lines >= 2 then
+ table.insert(ast.children, new_node("VerticalSpace"))
+ end
i = i + 1
else
-- Paragraph
finalize_table()
+ consecutive_empty_lines = 0
local paragraph_lines = {}
local j = i
diff --git a/Development/talagan_ReaImGui Markdown/reaimgui_markdown/markdown-html.lua b/Development/talagan_ReaImGui Markdown/reaimgui_markdown/markdown-html.lua
index 9a91f3d9a..580481f95 100644
--- a/Development/talagan_ReaImGui Markdown/reaimgui_markdown/markdown-html.lua
+++ b/Development/talagan_ReaImGui Markdown/reaimgui_markdown/markdown-html.lua
@@ -40,6 +40,8 @@ local function ASTToHtml(ast)
return ''
elseif node.type == "LineBreak" then
return "
\n"
+ elseif node.type == "VerticalSpace" then
+ return "
\n"
elseif node.type == "Separator" then
return "
This is pure code **and this** should not try to do |clever|things|
-
+This is pure code **and this** should not try to do |clever|things|
]]
dotest(entry, wanted)
@@ -656,11 +655,9 @@ code line 2
[x] not checkbox
```]],
expected_html = [[code line 1
-code line 2
-
+code line 2
**not bold**
-[x] not checkbox
-
+[x] not checkbox
]]
},