Skip to content

Commit

Permalink
Add default renderers for unnumbered sections in LaTeX
Browse files Browse the repository at this point in the history
  • Loading branch information
Witiko committed Apr 3, 2024
1 parent 56d2f6b commit 4d3ffc4
Showing 1 changed file with 60 additions and 22 deletions.
82 changes: 60 additions & 22 deletions markdown.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -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}},
Expand Down

0 comments on commit 4d3ffc4

Please sign in to comment.