Skip to content

Commit b3662c5

Browse files
committed
Merge branch 'IS788'
2 parents 198863c + d3e9fe0 commit b3662c5

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/MarkdownDetector.lua

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,19 @@ function MarkdownDetector.isMarkdown(text)
9393
end
9494

9595
-- Setext headers (underlines)
96-
if i > 1 and lines[i-1]:len() > 0 and
97-
(line:match("^===+$") or line:match("^---+$")) then
98-
indicators.setext_headers = indicators.setext_headers + 1
99-
dbg.print{"Found setext header underline: '", line, "'"}
96+
-- Look back through empty lines to find the header text
97+
if i > 1 and (line:match("^===+$") or line:match("^---+$")) then
98+
-- Find the most recent non-empty line before this one
99+
local headerFound = false
100+
for j = i - 1, 1, -1 do
101+
if lines[j]:len() > 0 then
102+
-- Found non-empty line - this is a setext header
103+
indicators.setext_headers = indicators.setext_headers + 1
104+
dbg.print{"Found setext header underline: '", line, "' with header: '", lines[j], "'"}
105+
headerFound = true
106+
break
107+
end
108+
end
100109
end
101110

102111
-- Lists (only count lists with minimal indentation: 0-3 spaces)

0 commit comments

Comments
 (0)