Skip to content

Commit

Permalink
Merge pull request #496 from Witiko/fix/hard-line-break-in-blockquote
Browse files Browse the repository at this point in the history
Fix hard line breaks in blockquotes
  • Loading branch information
Witiko authored Sep 23, 2024
2 parents f949754 + 5c62f22 commit a5cb278
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 20 deletions.
7 changes: 5 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Development:
adds a new file `markdown-unicode-data.lua`, which must be properly
installed with the rest of the Markdown package.

- Add renderers `warning` and `error` that represent warnings and errors
produced by the markdown parser. (#452, #473, #496)

Fixes:

- Properly load LaTeX themes when `theme` or `import` is used in
Expand All @@ -21,6 +24,8 @@ Fixes:
prototype. (#500)
- Correctly handle backslashes in `\markdownOptionOutputDir` on Windows.
(#492, #500, reported by @l0th3r)
- Fix hard line breaks in blockquotes.
(#494, #495, reported by @l0th3r, #496, contributed by @lostenderman)

## 3.7.0 (2024-08-30)

Expand All @@ -32,8 +37,6 @@ Development:
(istqborg/istqb_product_base#46, #440, #451, sponsored by @istqborg)
- Add option `ensureJekyllData` for processing standalone YAML files.
(#452, #473, sponsored by @istqborg)
- Add renderers `warning` and `error` that represent warnings and errors
produced by the markdown parser. (#452, #473)
- Support user-defined LaTeX environments with LaTeX markup.
(#20, #477, suggested by @cdupont)

Expand Down
68 changes: 52 additions & 16 deletions markdown.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -20097,7 +20097,16 @@ following text:

The \mdef{markdownRendererWarning} and \mdef{markdownRendererError} macros
represent warnings and errors produced by the markdown parser. Both macros
receive a single parameter with the text of the warning or error.
receive four parameters:

1. The fully escaped text of the warning or error that can be directly typeset
2. The raw text of the warning or error that can be used outside typesetting
for e.g. logging the warning or error.
3. The fully escaped text with more details about the warning or error that
can be directly typeset. Can be empty, unlike the first two parameters.
4. The raw text with more details about the warning or error that can be used
outside typesetting for e.g. logging the warning or error. Can be empty,
unlike the first two parameters.

% \end{markdown}
%
Expand All @@ -20118,14 +20127,14 @@ receive a single parameter with the text of the warning or error.
\prop_gput:Nnn
\g_@@_renderer_arities_prop
{ warning }
{ 1 }
{ 4 }
\seq_gput_right:Nn
\g_@@_renderers_seq
{ error }
\prop_gput:Nnn
\g_@@_renderer_arities_prop
{ error }
{ 1 }
{ 4 }
\ExplSyntaxOff
% \end{macrocode}
% \par
Expand Down Expand Up @@ -25758,24 +25767,28 @@ function M.writer.new(options)
% \begin{markdown}
%
% Define \luamdef{writer->warning} as a function that will transform an input
% warning `t` to the output format.
% warning `t` with optional more warning text `m` to the output format.
%
% \end{markdown}
% \begin{macrocode}
function self.warning(t)
return {"\\markdownRendererWarning{", self.identifier(t), "}"}
function self.warning(t, m)
return {"\\markdownRendererWarning{", self.escape(t), "}{",
escape_minimal(t), "}{", self.escape(m or ""), "}{",
escape_minimal(m or ""), "}"}
end
% \end{macrocode}
% \par
% \begin{markdown}
%
% Define \luamdef{writer->error} as a function that will transform an input
% error `t` to the output format.
% error text `t` with optional more error text `m` to the output format.
%
% \end{markdown}
% \begin{macrocode}
function self.error(t)
return {"\\markdownRendererError{", self.identifier(t), "}"}
function self.error(t, m)
return {"\\markdownRendererError{", self.escape(t), "}{",
escape_minimal(t), "}{", self.escape(m or ""), "}{",
escape_minimal(m or ""), "}"}
end
% \end{macrocode}
% \par
Expand Down Expand Up @@ -28824,8 +28837,11 @@ function M.reader.new(writer, options)
end
local res = lpeg.match(grammar(), str)
if res == nil then
return writer.error(format("%s failed on:\n%s",
name, str:sub(1,20)))
return writer.error(
format("Parser `%s` failed to process the input text.", name),
format("Here are the first 20 characters of the remaining "
.. "unprocessed text: `%s`.", str:sub(1,20))
)
else
return res
end
Expand Down Expand Up @@ -29680,7 +29696,7 @@ function M.reader.new(writer, options)
parsers.link_and_emph_content
= Ct( Cg(Cc("content"), "type")
* Cg(Cs(( parsers.link_emph_precedence
+ parsers.backslash * parsers.any
+ parsers.backslash * parsers.linechar
+ parsers.link_and_emph_endline
+ (parsers.linechar
- parsers.blankline^2
Expand Down Expand Up @@ -31144,7 +31160,7 @@ end
input = uni_algos.normalize.NFKD(input)
else
return writer.error(
format("Unknown normalization form %s", form))
format("Unknown normalization form %s.", form))
end
end
% \end{macrocode}
Expand Down Expand Up @@ -33762,7 +33778,7 @@ M.extensions.jekyll_data = function(expect_jekyll_data,
else
local error = self.error(format(
"Unexpected type %s for value of "
.. "YAML key %s", typ, k))
.. "YAML key %s.", typ, k))
table.insert(buf, error)
end
end
Expand Down Expand Up @@ -34739,8 +34755,28 @@ end
\ExplSyntaxOff
\def\markdownRendererSectionBeginPrototype{}%
\def\markdownRendererSectionEndPrototype{}%
\let\markdownRendererWarningPrototype\markdownWarning
\let\markdownRendererErrorPrototype\markdownError
\ExplSyntaxOn
\cs_gset:Npn
\markdownRendererWarningPrototype
#1#2#3#4
{
\tl_set:Nn
\l_tmpa_tl
{ #2 }
\tl_if_empty:nF
{ #4 }
{
\tl_put_right:Nn
\l_tmpa_tl
{ \iow_newline: #4 }
}
\exp_args:NV
\markdownWarning
\l_tmpa_tl
}
\ExplSyntaxOff
\def\markdownRendererErrorPrototype#1#2#3#4{%
\markdownError{#2}{#4}}%
% \end{macrocode}
% \par
% \begin{markdown}
Expand Down
5 changes: 4 additions & 1 deletion tests/support/keyval-setup.tex
Original file line number Diff line number Diff line change
Expand Up @@ -194,5 +194,8 @@
(ellipsis|nbsp|*Brace|*Sign|ampersand|underscore|hash|circumflex|backslash|tilde|pipe|replacementCharacter) += {\GOBBLE},
(ticked|halfTicked|unticked)Box += {\GOBBLE},
warning|error = {%
\TYPE{#0: #1}},
\TYPE{BEGIN #0}%
\TYPE{- text: #1}%
\TYPE{- more: #3}%
\TYPE{END #0}},
}%
10 changes: 10 additions & 0 deletions tests/testfiles/regression/github/issue-495.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<<<
> **TITLE** \
> Lorem ipsum dolor sit amet
>>>
BEGIN document
blockQuoteBegin
strongEmphasis: TITLE
hardLineBreak
blockQuoteEnd
END document
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@ abstract: |
---
>>>
BEGIN document
error: parse_blocks failed on: title: The document
BEGIN error
- text: Parser `parse(underscore)blocks` failed to process the input text.
- more: Here are the first 20 characters of the remaining unprocessed text: `title: The document `.
END error
END document

0 comments on commit a5cb278

Please sign in to comment.