Skip to content

Commit

Permalink
feat: \pretsec_get_cur_lv:N
Browse files Browse the repository at this point in the history
with the rename of other get functions
  • Loading branch information
LogCreative committed Jul 6, 2023
1 parent 07ecd9f commit d1dd304
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion source/presenter.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
%
% Additional sectioning handlers are implemented in package \pkg{pretsec}.
% \begin{macrocode}
\RequirePackage{pretsec}
\RequirePackage { pretsec }
% \end{macrocode}
%
% Introduce package \pkg{geometry}.
Expand Down
5 changes: 3 additions & 2 deletions source/pretfg.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,9 @@
{ style = \l_@@_fg_headline_style_tl }
{
\AssignTemplateKeys
\group_begin:
\l_@@_fg_headline_style_tl \pretsec_cur_title:
\pretsec_get_cur_title:N \l_tmpa_tl
\group_begin:
\l_@@_fg_headline_style_tl \l_tmpa_tl
\group_end:
\hfil
}
Expand Down
30 changes: 24 additions & 6 deletions source/pretsec.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,17 @@
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\pretsec_get_name_lv:nN}
% \begin{macro}{\pretsec_get_name_lv:nN, \pretsec_get_name_lv:VN}
% Get the level of the sectioning name and store it to the variable.
% \begin{arguments}
% \item sectioning name
% \item sectioning name (token list or variable)
% \item output sectioning level (variable)
% \end{arguments}
% \begin{macrocode}
\cs_new:Npn \pretsec_get_name_lv:nN #1#2 {
\prop_get:NnN \g_@@_name_lv_prop { #1 } #2
}
\cs_generate_variant:Nn \pretsec_get_name_lv:nN { VN }
% \end{macrocode}
% \end{macro}
% \begin{macro}{\pretsec_get_lv_name:nN}
Expand Down Expand Up @@ -128,11 +129,28 @@
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\pretsec_cur_name:, \pretsec_cur_title:}
% Macro of current sectioning name or the current sectioning title.
% \begin{macro}{
% \pretsec_get_cur_name:N, \pretsec_get_cur_lv:N, \pretsec_get_cur_title:N
% }
% Get the current sectioning name, or level, or title and store it to the
% variable.
% \begin{texnote}
% \cs{pretsec_get_cur_lv:N} is implemented by calling \cs{pretsec_get_name_lv:VN}
% to look up the \cs{g_@@_cur_name_tl}, where the current level is not stored
% directly compared with other functions. Since when using variable as the key
% for the property list, \cs{prop_get:NVN} is more recommended instead of
% \cs{prop_get:NnN} where improper process of the token list will end up
% \cs{q_no_value} as the return result. What's more, only looking up when using
% will reduce the cost compared with looking up when storing (which is more
% frequent).
% \end{texnote}
% \begin{macrocode}
\cs_new:Nn \pretsec_cur_name: { \g_@@_cur_name_tl }
\cs_new:Nn \pretsec_cur_title: { \g_@@_cur_title_tl }
\cs_new:Npn \pretsec_get_cur_name:N #1
{ \tl_set_eq:NN #1 \g_@@_cur_name_tl }
\cs_new:Npn \pretsec_get_cur_lv:N #1
{ \pretsec_get_name_lv:VN \g_@@_cur_name_tl #1 }
\cs_new:Npn \pretsec_get_cur_title:N #1
{ \tl_set_eq:NN #1 \g_@@_cur_title_tl }
% \end{macrocode}
% \end{macro}
%
Expand Down

0 comments on commit d1dd304

Please sign in to comment.