From 4d3ffc4acae529571e3514b88b6c7b4c2481d202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Star=C3=BD=20Novotn=C3=BD?= Date: Wed, 3 Apr 2024 12:28:11 +0200 Subject: [PATCH 1/2] Add default renderers for unnumbered sections in LaTeX Based on https://github.com/istqborg/istqb_product_base/pull/23. Closes #401. --- markdown.dtx | 82 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 60 insertions(+), 22 deletions(-) diff --git a/markdown.dtx b/markdown.dtx index 6ea0a2db..0fb016b4 100644 --- a/markdown.dtx +++ b/markdown.dtx @@ -34677,35 +34677,73 @@ end % \par % \begin{markdown} % -% If identifier attributes appear at the beginning of a section, we make them -% produce the `\label` macro. +% If identifier attributes appear after a heading, we make them produce +% `\label` macros. If the `.unnumbered` class name (or the `{-}` shorthand) +% appears after a heading the heading and all its subheadings will be +% unnumbered. % % \end{markdown} % \begin{macrocode} \ExplSyntaxOn \seq_new:N \l_@@_header_identifiers_seq -\markdownSetup{ - rendererPrototypes = { - headerAttributeContextBegin = { - \seq_clear:N \l_@@_header_identifiers_seq - \markdownSetup - { - renderers = { - attributeIdentifier = { - \seq_put_right:Nn - \l_@@_header_identifiers_seq - { ##1 } +\bool_new:N \l_@@_header_unnumbered_bool +\markdownSetup + { + rendererPrototypes = { + headerAttributeContextBegin = { + \seq_clear:N \l_@@_header_identifiers_seq + \markdownSetup + { + rendererPrototypes = { + attributeIdentifier = { + \seq_put_right:Nn + \l_@@_header_identifiers_seq + { ##1 } + }, + attributeClassName = { + \bool_if:nT + { + \str_if_eq_p:nn + { ##1 } + { unnumbered } && + ! \l_@@_header_unnumbered_bool + } + { + \group_begin: + \bool_set_true:N + \l_@@_header_unnumbered_bool + \c@secnumdepth = 0 +% \end{macrocode} +% \begin{markdown} +% +% Count the number of nested sections, so that we only start numbering sections +% again when the top-level unnumbered section has ended. +% +% \end{markdown} +% \begin{macrocode} + \markdownSetup + { + rendererPrototypes = { + sectionBegin = { + \group_begin: + }, + sectionEnd = { + \group_end: + }, + }, + } + } + }, }, - }, - } - }, - headerAttributeContextEnd = { - \seq_map_inline:Nn - \l_@@_header_identifiers_seq - { \label { ##1 } } + } + }, + headerAttributeContextEnd = { + \seq_map_inline:Nn + \l_@@_header_identifiers_seq + { \label { ##1 } } + }, }, - }, -} + } \ExplSyntaxOff \markdownSetup{rendererPrototypes={ superscript = {\textsuperscript{#1}}, From 20518d1821fd38f42d38aa0b6831987a55bb8428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Star=C3=BD=20Novotn=C3=BD?= Date: Wed, 3 Apr 2024 12:34:19 +0200 Subject: [PATCH 2/2] Update `CHANGES.md` and acknowledge @istqborg --- CHANGES.md | 6 ++++++ README.md | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 29205aee..a5b029f7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,12 @@ ## 3.5.0 +Default Renderer Prototypes: + +- Add default renderers for unnumbered sections in LaTeX. + (#401, istqborg/istqb_product_base#23, #430, reported by @felinecrp, + sponsored by @istqborg) + ## 3.4.3 Fixes: diff --git a/README.md b/README.md index 76ad39d7..7e04ebfd 100644 --- a/README.md +++ b/README.md @@ -274,7 +274,7 @@ Acknowledgements | [][fimu] | I gratefully acknowledge the funding from the [Faculty of Informatics][fimu] at the [Masaryk University][mu] in Brno, Czech Republic, for the development of the Markdown package in projects [MUNI/33/12/2015][], [MUNI/33/1784/2020][], [MUNI/33/0776/2021][], [MUNI/33/1654/2022][], and [MUNI/33/1658/2022][]. | | [][overleaf] | Extensive user documentation for the Markdown package was kindly written by [Lian Tze Lim][liantze] and published by [Overleaf][]. | | [][omedym] | Support for content slicing (Lua options [`shiftHeadings`][option-shift-headings] and [`slice`][option-slice]) and pipe tables (Lua options [`pipeTables`][option-pipe-tables] and [`tableCaptions`][option-table-captions]) was graciously sponsored by [David Vins][dvins] and [Omedym][]. | -| [][istqb] | Fixes for issues [#359][issue-359], [#368][issue-368], and [#424][issue-424] were graciously sponsored by the [International Software Testing Qualifications Board (ISTQB)][istqb]. | +| [][istqb] | Fixes for issues [#359][issue-359], [#368][issue-368], [#401][issue-401], and [#424][issue-424] were graciously sponsored by the [International Software Testing Qualifications Board (ISTQB)][istqb]. | [dvins]: https://github.com/dvins "David Vins" [fimu]: https://www.fi.muni.cz/index.html.en "Faculty of Informatics, Masaryk University" @@ -284,6 +284,7 @@ Acknowledgements [issue-359]: https://github.com/witiko/markdown/issues/359 "First item of a fancy list forms a separate list" [issue-368]: https://github.com/witiko/markdown/issues/368 "Tables nested in list items have empty lines" + [issue-401]: https://github.com/witiko/markdown/issues/401 "Create an unnumbered section" [issue-424]: https://github.com/witiko/markdown/issues/424 "E-mail addresses are incorrectly interpreted as bracketed citations" [option-pipe-tables]: https://mirrors.ctan.org/macros/generic/markdown/markdown.html#pipe-tables "Markdown Package User Manual"