Skip to content

Commit

Permalink
Merge pull request #509 from Witiko/fix/hard-line-breaks-in-fancy-lis…
Browse files Browse the repository at this point in the history
…t-items

Fix hard line breaks in fancy list items
  • Loading branch information
Witiko authored Nov 3, 2024
2 parents 430079d + 3ea47bc commit bbed72f
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 20 deletions.
5 changes: 4 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# Changes

## 3.8.1
## 3.8.1 (2024-11-03)

Fixes:

- Fix backslashes at the ends of hybrid documents.
(#502, #503, contributed by @lostenderman)

- Fix hard line breaks in fancy list items.
(#508, #509, contributed by @lostenderman)

## 3.8.0 (2024-10-31)

Development:
Expand Down
36 changes: 17 additions & 19 deletions markdown.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -30357,7 +30357,7 @@ function M.reader.new(writer, options)
* -V("EndlineExceptions")
+ parsers.check_optional_indent
* -V("EndlineExceptions")
* -parsers.starter) / "")
* -V("ListStarter")) / "")
* parsers.spacechar^0 / "\n"

parsers.link_and_emph_content
Expand Down Expand Up @@ -30896,6 +30896,8 @@ function M.reader.new(writer, options)
parsers.html_interrupting = parsers.fail
end

parsers.ListStarter = parsers.starter

parsers.EndlineExceptions
= parsers.blankline -- paragraph break
+ parsers.eof -- end of document
Expand All @@ -30913,7 +30915,7 @@ function M.reader.new(writer, options)
* -V("EndlineExceptions")
+ parsers.check_optional_indent
* -V("EndlineExceptions")
* -parsers.starter) / function(_) return end
* -V("ListStarter")) / function(_) return end
* parsers.spacechar^0

parsers.Endline = parsers.endline
Expand All @@ -30927,36 +30929,38 @@ function M.reader.new(writer, options)
* -V("NoSoftLineBreakEndlineExceptions")
+ parsers.check_optional_indent
* -V("NoSoftLineBreakEndlineExceptions")
* -parsers.starter)
* -V("ListStarter"))
* parsers.spacechar^0
/ writer.space

parsers.EndlineBreak = parsers.backslash * parsers.Endline
parsers.EndlineBreak = parsers.backslash * parsers.endline
/ writer.hard_line_break

parsers.OptionalIndent
= parsers.spacechar^1 / writer.space

parsers.Space = parsers.spacechar^2 * parsers.Endline
parsers.Space = parsers.spacechar^2 * parsers.endline
/ writer.hard_line_break
+ parsers.spacechar^1
* parsers.Endline^-1
* parsers.endline^-1
* parsers.eof / self.expandtabs
+ parsers.spacechar^1 * parsers.Endline
+ parsers.spacechar^1 * parsers.endline
/ writer.soft_line_break
+ parsers.spacechar^1
* -parsers.newline / self.expandtabs
+ parsers.spacechar^1

parsers.NoSoftLineBreakSpace
= parsers.spacechar^2 * parsers.Endline
= parsers.spacechar^2 * parsers.endline
/ writer.hard_line_break
+ parsers.spacechar^1
* parsers.Endline^-1
* parsers.endline^-1
* parsers.eof / self.expandtabs
+ parsers.spacechar^1 * parsers.Endline
+ parsers.spacechar^1 * parsers.endline
/ writer.soft_line_break
+ parsers.spacechar^1
* -parsers.newline / self.expandtabs
+ parsers.spacechar^1

parsers.NonbreakingEndline
= parsers.endline
Expand Down Expand Up @@ -31466,6 +31470,7 @@ end
Paragraph = parsers.Paragraph,
Plain = parsers.Plain,

ListStarter = parsers.ListStarter,
EndlineExceptions = parsers.EndlineExceptions,
NoSoftLineBreakEndlineExceptions
= parsers.NoSoftLineBreakEndlineExceptions,
Expand Down Expand Up @@ -32762,17 +32767,10 @@ M.extensions.fancy_lists = function()
local FancyList
= join_table_with_func(FancyListOfType, markers_table)

local Endline = parsers.newline
* (parsers.check_minimal_indent
* -parsers.EndlineExceptions
+ parsers.check_optional_indent
* -parsers.EndlineExceptions
* -starter)
* parsers.spacechar^0
/ writer.soft_line_break
local ListStarter = starter

self.update_rule("OrderedList", FancyList)
self.update_rule("Endline", Endline)
self.update_rule("ListStarter", ListStarter)
end
}
end
Expand Down
23 changes: 23 additions & 0 deletions tests/testfiles/regression/github/issue-508-fancy-lists.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
if: format == 'context-mkiv' or template == 'input'
---
\markdownSetup{fancyLists=true}
<<<
a. foo
b. bar
bar
c. baz
>>>
BEGIN document
BEGIN fancyOlBeginTight
- numstyle: LowerAlpha
- numdelim: Period
END fancyOlBeginTight
fancyOlItemWithNumber: 1
fancyOlItemEnd
fancyOlItemWithNumber: 2
softLineBreak
fancyOlItemEnd
fancyOlItemWithNumber: 3
fancyOlItemEnd
fancyOlEndTight
END document
34 changes: 34 additions & 0 deletions tests/testfiles/regression/github/issue-508-non-fancy-lists.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
if: format == 'context-mkiv' or template == 'input'
---
<<<
- foo
- bar
bar
- baz

1. foo
2. bar
bar
3. baz
>>>
BEGIN document
ulBeginTight
ulItem
ulItemEnd
ulItem
softLineBreak
ulItemEnd
ulItem
ulItemEnd
ulEndTight
interblockSeparator
olBeginTight
olItemWithNumber: 1
olItemEnd
olItemWithNumber: 2
softLineBreak
olItemEnd
olItemWithNumber: 3
olItemEnd
olEndTight
END document

0 comments on commit bbed72f

Please sign in to comment.