| 1 |
% Loading the class |
| 2 |
|
| 3 |
\NeedsTeXFormat{LaTeX2e}[2025-11-01] |
| 4 |
\ProvidesExplClass{beerydoc}{2026-02-17}{0.0.0}{} |
| 5 |
\prop_gput:Nnn \g_msg_module_type_prop { beerydoc } { Class } |
| 6 |
|
| 7 |
\msg_new:nnn { beerydoc } { l3kernel } |
| 8 |
{ |
| 9 |
The~ beerydoc~ class~ could~ not~ load. \\ |
| 10 |
This~ class~ requires~ |
| 11 |
L3~ programming~ layer~ version~ 2024-12-09~ or~ newer. |
| 12 |
} |
| 13 |
\msg_new:nnn { beerydoc } { luatex } |
| 14 |
{ The~ beerydoc~ class~ could~ not~ load. \\ This~ class~ requires~ LuaTeX. } |
| 15 |
|
| 16 |
\IfExplAtLeastF { 2024-12-09 } { \msg_critical:nn { beerydoc } { l3kernel } } |
| 17 |
\sys_if_engine_luatex:F { \msg_critical:nn { beerydoc } { luatex } } |
| 18 |
|
| 19 |
\LoadClass { article } |
| 20 |
|
| 21 |
\keys_define:nn { beerydoc } |
| 22 |
{ |
| 23 |
showframe .code:n = { \PassOptionsToPackage { showframe } { geometry } } |
| 24 |
, showframe .value_forbidden:n = true |
| 25 |
, showframe .usage:n = load |
| 26 |
} |
| 27 |
\ProcessKeyOptions |
| 28 |
|
| 29 |
\RequirePackage { fontscale } |
| 30 |
\fontscalesetup { musical } |
| 31 |
\RenewDocumentCommand \printfontsizecommand { } |
| 32 |
{ |
| 33 |
\mode_if_math:TF |
| 34 |
{ |
| 35 |
\msg_error:nnn { beerydoc } { math-mode-invalid } |
| 36 |
{ printfontsizecommand } |
| 37 |
} |
| 38 |
{ \__beerydoc_print_name: } |
| 39 |
} |
| 40 |
\cs_new_protected:Npn \__beerydoc_print_name: |
| 41 |
{ |
| 42 |
\exp_args:Ne \cs |
| 43 |
{ |
| 44 |
\dim_case:nnF { \l_fontscale_size_dim } |
| 45 |
{ |
| 46 |
{ \l_fontscale_tiny_size_dim } { tiny } |
| 47 |
{ \l_fontscale_scriptsize_size_dim } { scriptsize } |
| 48 |
{ \l_fontscale_footnotesize_size_dim } { footnotesize } |
| 49 |
{ \l_fontscale_small_size_dim } { small } |
| 50 |
{ \l_fontscale_normalsize_size_dim } { normalsize } |
| 51 |
{ \l_fontscale_large_size_dim } { large } |
| 52 |
{ \l_fontscale_Large_size_dim } { Large } |
| 53 |
{ \l_fontscale_LARGE_size_dim } { LARGE } |
| 54 |
{ \l_fontscale_huge_size_dim } { huge } |
| 55 |
{ \l_fontscale_Huge_size_dim } { Huge } |
| 56 |
} |
| 57 |
{ undefined } |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
\RequirePackage { siunitx } |
| 62 |
\sisetup { list-final-separator = { ,~ and~ } , mode = math } |
| 63 |
\RequirePackage { mathtools } |
| 64 |
\DeclarePairedDelimiter\abs{\lvert}{\rvert} |
| 65 |
\cs_set_eq:NN \muskipeval \muskip_eval:n |
| 66 |
\RequirePackage { xcolor } |
| 67 |
|
| 68 |
% Font selection |
| 69 |
|
| 70 |
\RequirePackage { lmodern } |
| 71 |
\RequirePackage { scaletextbullet } |
| 72 |
\settextbulletfactor { 0.4 } |
| 73 |
|
| 74 |
% Some variables |
| 75 |
|
| 76 |
\fp_const:Nn \c_beerydoc_golden_ratio_fp { 1.6180 3398 8749 8948 } |
| 77 |
\tl_const:Nn \c_beerydoc_alphabet_lowercase_tl { abcdefghijklmnopqrstuvwxyz } |
| 78 |
\tl_const:Nn \c_beerydoc_alphabet_uppercase_tl { ABCDEFGHIJKLMNOPQRSTUVWXYZ } |
| 79 |
\str_const:Nn \c_beerydoc_digits_str { 0123456789 } |
| 80 |
\tl_const:Nn \c_beerydoc_pangram_tl |
| 81 |
{ The~ quick~ brown~ fox~ jumps~ over~ the~ lazy~ dog. } |
| 82 |
|
| 83 |
\hbox_set:Nn \l_tmpa_box { \c_beerydoc_alphabet_lowercase_tl } |
| 84 |
\dim_const:Nn \c_beerydoc_alphabet_dim { \box_wd:N \l_tmpa_box } |
| 85 |
|
| 86 |
\dim_const:Nn \c_beerydoc_big_dim { \l_fontscale_normalsize_baselineskip_skip } |
| 87 |
\dim_const:Nn \c_beerydoc_med_dim { \c_beerydoc_big_dim / 2 } |
| 88 |
\dim_const:Nn \c_beerydoc_small_dim { \c_beerydoc_big_dim / 4 } |
| 89 |
\dim_log:N \c_beerydoc_big_dim |
| 90 |
\dim_log:N \c_beerydoc_med_dim |
| 91 |
\dim_log:N \c_beerydoc_small_dim |
| 92 |
|
| 93 |
\skip_const:Nn \c_beerydoc_big_skip |
| 94 |
{ |
| 95 |
\c_beerydoc_big_dim |
| 96 |
plus \dim_eval:n { \c_beerydoc_big_dim / 2 } |
| 97 |
minus \dim_eval:n { \c_beerydoc_big_dim / 3 } |
| 98 |
} |
| 99 |
\skip_const:Nn \c_beerydoc_med_skip { \c_beerydoc_big_skip / 2 } |
| 100 |
\skip_const:Nn \c_beerydoc_small_skip { \c_beerydoc_big_skip / 4 } |
| 101 |
\setlength \bigskipamount { \skip_use:N \c_beerydoc_big_skip } |
| 102 |
\setlength \medskipamount { \skip_use:N \c_beerydoc_med_skip } |
| 103 |
\setlength \smallskipamount { \skip_use:N \c_beerydoc_small_skip } |
| 104 |
\skip_log:N \c_beerydoc_big_skip |
| 105 |
\skip_log:N \c_beerydoc_med_skip |
| 106 |
\skip_log:N \c_beerydoc_small_skip |
| 107 |
|
| 108 |
\tl_const:Ne \c__beerydoc_math_subscript_underscore_tl |
| 109 |
{ \char_generate:nn { `_ } { 8 } } |
| 110 |
\group_begin: |
| 111 |
\char_set_catcode_active:N | |
| 112 |
\tl_const:Nn \c__beerydoc_active_vert_tl { | } |
| 113 |
\char_set_active_eq:NN _ \scan_stop: |
| 114 |
\tl_const:Ne \c__beerydoc_active_underscore_tl |
| 115 |
{ \char_generate:nn { `_ } { 13 } } |
| 116 |
\char_set_active_eq:nN { `\^^I } \scan_stop: |
| 117 |
\tl_const:Ne \c__beerydoc_active_tab_tl |
| 118 |
{ \char_generate:nn { `\^^I } { 13 } } |
| 119 |
\group_end: |
| 120 |
|
| 121 |
\tl_new:N \l__beerydoc_key_tl |
| 122 |
\tl_new:N \l__beerydoc_value_tl |
| 123 |
\tl_new:N \l__beerydoc_cs_tl |
| 124 |
\tl_new:N \l__beerydoc_meta_tl |
| 125 |
\tl_new:N \l__beerydoc_hook_tl |
| 126 |
\tl_new:N \l__beerydoc_socket_tl |
| 127 |
|
| 128 |
\coffin_new:N \l__beerydoc_code_coffin |
| 129 |
\bool_new:N \l__beerydoc_code_bool |
| 130 |
|
| 131 |
\tl_new:N \l__beerydoc_code_names_tl |
| 132 |
\clist_new:N \l__beerydoc_code_names_clist |
| 133 |
\coffin_new:N \l__beerydoc_code_names_coffin |
| 134 |
\dim_new:N \l__beerydoc_code_names_dim |
| 135 |
\bool_new:N \l__beerydoc_code_names_long_bool |
| 136 |
|
| 137 |
\coffin_new:N \l__beerydoc_code_descr_coffin |
| 138 |
\dim_new:N \l__beerydoc_code_descr_yoffset_dim |
| 139 |
|
| 140 |
\bool_new:N \l__beerydoc_syntax_bool |
| 141 |
\box_new:N \g__beerydoc_syntax_box |
| 142 |
\coffin_new:N \l__beerydoc_syntax_coffin |
| 143 |
\dim_new:N \l__beerydoc_syntax_yoffset_dim |
| 144 |
|
| 145 |
\box_new:N \l__beerydoc_footnote_box |
| 146 |
\coffin_new:N \l__beerydoc_footnote_coffin |
| 147 |
|
| 148 |
% Custom macros |
| 149 |
|
| 150 |
\cs_generate_variant:Nn \tl_replace_once:Nnn { No } |
| 151 |
\cs_generate_variant:Nn \tl_replace_all:Nnn { No } |
| 152 |
\prg_generate_conditional_variant:Nnn \str_if_eq:nn { ne , Ve , e , eV } |
| 153 |
{ p , T , F , TF } |
| 154 |
|
| 155 |
\cs_new_protected:Npn \__beerydoc_langle: { \ensuremath { \langle } } |
| 156 |
\cs_new_protected:Npn \__beerydoc_rangle: { \ensuremath { \rangle } } |
| 157 |
|
| 158 |
\cs_new:Npe \alphabet { \c_beerydoc_alphabet_lowercase_tl } |
| 159 |
\cs_new:Npe \digits { \c_beerydoc_digits_str } |
| 160 |
\cs_new:Npe \pangram { \c_beerydoc_pangram_tl } |
| 161 |
|
| 162 |
\NewDocumentCommand \key { m } |
| 163 |
{ |
| 164 |
\mode_if_math:TF |
| 165 |
{ \msg_error:nnn { beerydoc } { math-mode-invalid } { key } } |
| 166 |
{ \__beerydoc_key_value:n {#1} } |
| 167 |
} |
| 168 |
\cs_new_protected:Npn \__beerydoc_key_value:n #1 |
| 169 |
{ |
| 170 |
\tl_if_in:nnTF {#1} { = } |
| 171 |
{ \__beerydoc_key_value:w #1 \q_stop } |
| 172 |
{ \__beerydoc_key:n {#1} } |
| 173 |
} |
| 174 |
\cs_new_protected:Npn \__beerydoc_key_value:w #1 = #2 \q_stop |
| 175 |
{ |
| 176 |
\tl_if_blank:nTF {#1} |
| 177 |
{ \__beerydoc_value:n {#2} } |
| 178 |
{ |
| 179 |
\__beerydoc_key:n {#1} |
| 180 |
\__beerydoc_key_value_equal: |
| 181 |
\__beerydoc_value:n {#2} |
| 182 |
} |
| 183 |
} |
| 184 |
\cs_new_protected:Npn \__beerydoc_key:n #1 |
| 185 |
{ |
| 186 |
\group_begin: |
| 187 |
\tl_set:Nn \l__beerydoc_key_tl {#1} |
| 188 |
\tl_replace_all:Nnn \l__beerydoc_key_tl { / } { \slash } |
| 189 |
\ttfamily |
| 190 |
\l__beerydoc_key_tl \@ |
| 191 |
\group_end: |
| 192 |
} |
| 193 |
\cs_new_protected:Npn \__beerydoc_key_value_equal: |
| 194 |
{ |
| 195 |
\bool_if:NTF \l__beerydoc_syntax_bool |
| 196 |
{ ~=~ } { \ensuremath { \, = \, } \allowbreak } |
| 197 |
} |
| 198 |
\cs_new_protected:Npn \__beerydoc_value:n #1 |
| 199 |
{ |
| 200 |
\group_begin: |
| 201 |
\tl_set:Nn \l__beerydoc_value_tl {#1} |
| 202 |
\__beerydoc_value_replace_spaces: |
| 203 |
\cs_set_eq:NN \choices \__beerydoc_value_choices:n |
| 204 |
\ttfamily |
| 205 |
\l__beerydoc_value_tl \@ |
| 206 |
\group_end: |
| 207 |
} |
| 208 |
\cs_new_protected:Npn \__beerydoc_value_replace_spaces: |
| 209 |
{ |
| 210 |
\tl_replace_all:NVn \l__beerydoc_value_tl \c_catcode_active_space_tl |
| 211 |
{ \textvisiblespace } |
| 212 |
\tl_replace_all:Nnn \l__beerydoc_value_tl { ~ } { \textvisiblespace } |
| 213 |
} |
| 214 |
\cs_new_protected:Npn \__beerydoc_value_choices:n #1 |
| 215 |
{ \clist_use:nn {#1} { \__beerydoc_value_choices_separator: } } |
| 216 |
\cs_new_protected:Npn \__beerydoc_value_choices_separator: |
| 217 |
{ \ensuremath { \, \vert \, } } |
| 218 |
|
| 219 |
\NewDocumentCommand \cs { m } |
| 220 |
{ |
| 221 |
\mode_if_math:TF |
| 222 |
{ \msg_error:nnn { beerydoc } { math-mode-invalid } { cs } } |
| 223 |
{ \__beerydoc_cs:n {#1} } |
| 224 |
} |
| 225 |
\cs_new_protected:Npn \__beerydoc_cs:n #1 |
| 226 |
{ |
| 227 |
\group_begin: |
| 228 |
\tl_set:Nn \l__beerydoc_cs_tl {#1} |
| 229 |
\tl_replace_all:NVn \l__beerydoc_cs_tl \c__beerydoc_active_vert_tl { | } |
| 230 |
\__beerydoc_cs_replace_underscore: |
| 231 |
\__beerydoc_cs_replace_spaces: |
| 232 |
\__beerydoc_cs_hyphenation: |
| 233 |
\ttfamily |
| 234 |
\c_backslash_str \l__beerydoc_cs_tl \@ |
| 235 |
\group_end: |
| 236 |
} |
| 237 |
\cs_new_protected:Npn \__beerydoc_cs_replace_underscore: |
| 238 |
{ |
| 239 |
\tl_map_inline:nn |
| 240 |
{ |
| 241 |
\c__beerydoc_math_subscript_underscore_tl |
| 242 |
\c_underscore_str |
| 243 |
\c__beerydoc_active_underscore_tl |
| 244 |
} |
| 245 |
{ \tl_replace_all:NVn \l__beerydoc_cs_tl ##1 { _ } } |
| 246 |
\tl_replace_all:Nnn \l__beerydoc_cs_tl { \_ } { _ } |
| 247 |
} |
| 248 |
\cs_new_protected:Npn \__beerydoc_cs_replace_spaces: |
| 249 |
{ |
| 250 |
\tl_replace_all:NVn \l__beerydoc_cs_tl \c_catcode_active_space_tl |
| 251 |
{ \textvisiblespace } |
| 252 |
\tl_replace_all:Nnn \l__beerydoc_cs_tl { ~ } { \textvisiblespace } |
| 253 |
} |
| 254 |
\cs_new_protected:Npn \__beerydoc_cs_hyphenation: |
| 255 |
{ |
| 256 |
\bool_if:NF \l__beerydoc_syntax_bool |
| 257 |
{ |
| 258 |
\tl_if_in:NnT \l__beerydoc_cs_tl { _ } |
| 259 |
{ |
| 260 |
\tl_regex_replace_all:NNn \l__beerydoc_cs_tl |
| 261 |
\c__beerydoc_cs_hyphenation_regex { \1 \c{-} \2 } |
| 262 |
} |
| 263 |
} |
| 264 |
} |
| 265 |
\regex_const:Nn \c__beerydoc_cs_hyphenation_regex { ([^\_]\_+)([^\_]) } |
| 266 |
\cs_new_protected:Npn \__beerydoc_cs:N #1 |
| 267 |
{ \exp_args:Ne \__beerydoc_cs:n { \cs_to_str:N #1 } } |
| 268 |
|
| 269 |
\NewDocumentCommand \meta { m } { \__beerydoc_meta:n {#1} } |
| 270 |
\cs_new_protected:Npn \__beerydoc_meta:n #1 |
| 271 |
{ \mode_if_math:TF { \text } { \use:n } { \__beerydoc_meta_aux:n {#1} } } |
| 272 |
\cs_new_protected:Npn \__beerydoc_meta_aux:n #1 |
| 273 |
{ |
| 274 |
\group_begin: |
| 275 |
\tl_set:Nn \l__beerydoc_meta_tl {#1} |
| 276 |
\__beerydoc_meta_replace_underscore: |
| 277 |
\ttfamily \slshape |
| 278 |
\__beerydoc_langle: |
| 279 |
\l__beerydoc_meta_tl |
| 280 |
\__beerydoc_rangle: |
| 281 |
\group_end: |
| 282 |
} |
| 283 |
\cs_new_protected:Npn \__beerydoc_meta_replace_underscore: |
| 284 |
{ |
| 285 |
\tl_map_inline:nn |
| 286 |
{ |
| 287 |
\c__beerydoc_math_subscript_underscore_tl |
| 288 |
_ |
| 289 |
\c_underscore_str |
| 290 |
\c__beerydoc_active_underscore_tl |
| 291 |
} |
| 292 |
{ |
| 293 |
\tl_replace_all:Non \l__beerydoc_meta_tl {##1} |
| 294 |
{ \__beerydoc_meta_subscript:n } |
| 295 |
} |
| 296 |
} |
| 297 |
\cs_new_protected:Npn \__beerydoc_meta_subscript:n #1 |
| 298 |
{ \ensuremath { \sb {#1} } } |
| 299 |
|
| 300 |
\NewDocumentCommand \marg { s m } |
| 301 |
{ |
| 302 |
\mode_if_math:TF |
| 303 |
{ \msg_error:nnn { beerydoc } { math-mode-invalid } { marg } } |
| 304 |
{ |
| 305 |
\IfBooleanTF #1 |
| 306 |
{ \__beerydoc_m_arg:n {#2} } |
| 307 |
{ \__beerydoc_m_arg_meta:n {#2} } |
| 308 |
} |
| 309 |
} |
| 310 |
\cs_set_protected:Npn \__beerydoc_tmp:Nn #1#2 |
| 311 |
{ |
| 312 |
\cs_new_protected:Npn #1 ##1 |
| 313 |
{ |
| 314 |
\group_begin: |
| 315 |
\ttfamily |
| 316 |
\c_left_brace_str #2 \c_right_brace_str |
| 317 |
\group_end: |
| 318 |
} |
| 319 |
} |
| 320 |
\__beerydoc_tmp:Nn \__beerydoc_m_arg:n {#1} |
| 321 |
\__beerydoc_tmp:Nn \__beerydoc_m_arg_meta:n { \meta {#1} } |
| 322 |
|
| 323 |
\NewDocumentCommand \oarg { s m } |
| 324 |
{ |
| 325 |
\mode_if_math:TF |
| 326 |
{ \msg_error:nnn { beerydoc } { math-mode-invalid } { oarg } } |
| 327 |
{ |
| 328 |
\IfBooleanTF #1 |
| 329 |
{ \__beerydoc_o_arg:n {#2} } |
| 330 |
{ \__beerydoc_o_arg_meta:n {#2} } |
| 331 |
} |
| 332 |
} |
| 333 |
\cs_set_protected:Npn \__beerydoc_tmp:Nn #1#2 |
| 334 |
{ |
| 335 |
\cs_new_protected:Npn #1 ##1 |
| 336 |
{ |
| 337 |
\group_begin: |
| 338 |
\ttfamily |
| 339 |
[ #2 ] |
| 340 |
\group_end: |
| 341 |
} |
| 342 |
} |
| 343 |
\__beerydoc_tmp:Nn \__beerydoc_o_arg:n {#1} |
| 344 |
\__beerydoc_tmp:Nn \__beerydoc_o_arg_meta:n { \meta {#1} } |
| 345 |
|
| 346 |
\NewDocumentCommand \sarg { } |
| 347 |
{ |
| 348 |
\mode_if_math:TF |
| 349 |
{ \msg_error:nnn { beerydoc } { math-mode-invalid } { sarg } } |
| 350 |
{ \__beerydoc_s_arg: } |
| 351 |
} |
| 352 |
\cs_new_protected:Npn \__beerydoc_s_arg: |
| 353 |
{ \__beerydoc_langle: \texttt {*} \__beerydoc_rangle: } |
| 354 |
|
| 355 |
\cs_set_protected:Npn \__beerydoc_tmp:nN #1#2 |
| 356 |
{ |
| 357 |
\quark_if_recursion_tail_stop:n {#1} |
| 358 |
\use:e |
| 359 |
{ |
| 360 |
\NewDocumentCommand \exp_not:c {#1} { m } |
| 361 |
{ |
| 362 |
\exp_not:N \mode_if_math:TF |
| 363 |
{ \msg_error:nnn { beerydoc } { math-mode-invalid } {#1} } |
| 364 |
{ \exp_not:c { __beerydoc_#1:n } {##1} } |
| 365 |
} |
| 366 |
} |
| 367 |
\cs_new_protected:cpn { __beerydoc_#1:n } ##1 |
| 368 |
{ \group_begin: #2 ##1 \@ \group_end: } |
| 369 |
\__beerydoc_tmp:nN |
| 370 |
} |
| 371 |
\__beerydoc_tmp:nN |
| 372 |
{cls} \sffamily |
| 373 |
{pkg} \sffamily |
| 374 |
{env} \ttfamily |
| 375 |
{plug} \ttfamily |
| 376 |
{ \q_recursion_tail } \scan_stop: |
| 377 |
\q_recursion_stop |
| 378 |
|
| 379 |
\NewDocumentCommand \hook { m } |
| 380 |
{ |
| 381 |
\mode_if_math:TF |
| 382 |
{ \msg_error:nnn { beerydoc } { math-mode-invalid } { hook } } |
| 383 |
{ \__beerydoc_hook:n {#1} } |
| 384 |
} |
| 385 |
\cs_new_protected:Npn \__beerydoc_hook:n #1 |
| 386 |
{ |
| 387 |
\group_begin: |
| 388 |
\tl_set:Nn \l__beerydoc_hook_tl {#1} |
| 389 |
\tl_replace_all:Nnn \l__beerydoc_hook_tl { / } { \slash } |
| 390 |
\ttfamily |
| 391 |
\l__beerydoc_hook_tl \@ |
| 392 |
\group_end: |
| 393 |
} |
| 394 |
|
| 395 |
\NewDocumentCommand \socket { m } |
| 396 |
{ |
| 397 |
\mode_if_math:TF |
| 398 |
{ \msg_error:nnn { beerydoc } { math-mode-invalid } { socket } } |
| 399 |
{ \__beerydoc_socket:n {#1} } |
| 400 |
} |
| 401 |
\cs_new_protected:Npn \__beerydoc_socket:n #1 |
| 402 |
{ |
| 403 |
\group_begin: |
| 404 |
\tl_set:Nn \l__beerydoc_socket_tl {#1} |
| 405 |
\tl_replace_all:Nnn \l__beerydoc_socket_tl { / } { \slash } |
| 406 |
\ttfamily |
| 407 |
\l__beerydoc_socket_tl \@ |
| 408 |
\group_end: |
| 409 |
} |
| 410 |
|
| 411 |
\NewDocumentCommand \latin { m } |
| 412 |
{ |
| 413 |
\mode_if_math:TF |
| 414 |
{ \msg_error:nnn { beerydoc } { math-mode-invalid } { latin } } |
| 415 |
{ \__beerydoc_latin:n {#1} } |
| 416 |
} |
| 417 |
\cs_new_protected:Npn \__beerydoc_latin:n #1 |
| 418 |
{ \group_begin: \ttfamily #1 \group_end: } |
| 419 |
|
| 420 |
\NewDocumentCommand \honorific { m } |
| 421 |
{ |
| 422 |
\mode_if_math:TF |
| 423 |
{ \msg_error:nnn { beerydoc } { math-mode-invalid } { honorific } } |
| 424 |
{ \__beerydoc_honorific:n {#1} } |
| 425 |
} |
| 426 |
\cs_new_protected:Npn \__beerydoc_honorific:n #1 |
| 427 |
{ \group_begin: #1 \@ \group_end: } |
| 428 |
|
| 429 |
\NewDocumentCommand \allcaps { O { 50 } m } |
| 430 |
{ |
| 431 |
\mode_if_math:TF |
| 432 |
{ \msg_error:nnn { beerydoc } { math-mode-invalid } { allcaps } } |
| 433 |
{ \__beerydoc_text_all_caps:nn {#1} {#2} } |
| 434 |
} |
| 435 |
\cs_new_protected:Npn \__beerydoc_text_all_caps:nn #1#2 |
| 436 |
{ \textls [ \int_eval:n {#1} ] { \text_uppercase:n {#2} } } |
| 437 |
|
| 438 |
\NewDocumentCommand \allsmallcaps { s O { 50 } m } |
| 439 |
{ |
| 440 |
\mode_if_math:TF |
| 441 |
{ \msg_error:nnn { beerydoc } { math-mode-invalid } { allsmallcaps } } |
| 442 |
{ |
| 443 |
\IfBooleanTF #1 |
| 444 |
{ \__beerydoc_text_lowercase_small_caps:nn {#2} {#3} } |
| 445 |
{ \__beerydoc_text_small_caps:nn {#2} {#3} } |
| 446 |
} |
| 447 |
} |
| 448 |
\cs_new_protected:Npn \__beerydoc_text_small_caps:nn #1#2 |
| 449 |
{ \textls [ \int_eval:n {#1} ] { \scshape #2 } } |
| 450 |
\cs_new_protected:Npn \__beerydoc_text_lowercase_small_caps:nn #1#2 |
| 451 |
{ \textls [ \int_eval:n {#1} ] { \scshape \text_lowercase:n {#2} } } |
| 452 |
|
| 453 |
\RenewDocumentCommand \slash { } { / \penalty \exhyphenpenalty } |
| 454 |
|
| 455 |
% Code and syntax environments |
| 456 |
|
| 457 |
% For the code and syntax environments, I have used ideas from l3doc. |
| 458 |
\NewDocumentEnvironment { code } { +v } { \__beerydoc_code_start:nw {#1} } |
| 459 |
{ \__beerydoc_code_end: } |
| 460 |
\cs_new_protected:Npn \__beerydoc_code_start:nw #1 |
| 461 |
{ |
| 462 |
\__beerydoc_code_typeset_start: |
| 463 |
\__beerydoc_code_init: |
| 464 |
\__beerydoc_code_names:n {#1} |
| 465 |
\__beerydoc_code_descr_start:w |
| 466 |
} |
| 467 |
\cs_new_protected:Npn \__beerydoc_code_end: |
| 468 |
{ |
| 469 |
\__beerydoc_code_descr_stop: |
| 470 |
\__beerydoc_code_assemble: |
| 471 |
\__beerydoc_code_typeset_stop: |
| 472 |
} |
| 473 |
\cs_new_protected:Npn \__beerydoc_code_typeset_start: |
| 474 |
{ |
| 475 |
\par |
| 476 |
\vspace { \skip_eval:n { \c_beerydoc_med_skip - \parskip } } |
| 477 |
\noindent |
| 478 |
} |
| 479 |
\cs_new_protected:Npn \__beerydoc_code_typeset_stop: |
| 480 |
{ |
| 481 |
\par |
| 482 |
\dim_set:Nn \prevdepth { \coffin_dp:N \l__beerydoc_code_coffin } |
| 483 |
\vspace { \skip_eval:n { \c_beerydoc_med_skip - \parskip } } |
| 484 |
} |
| 485 |
\cs_new_protected:Npn \__beerydoc_code_init: |
| 486 |
{ |
| 487 |
\bool_if:NT \l__beerydoc_code_bool |
| 488 |
{ \msg_error:nn { beerydoc } { code-env-not-nestable } } |
| 489 |
\bool_set_true:N \l__beerydoc_code_bool |
| 490 |
\box_gclear:N \g__beerydoc_syntax_box |
| 491 |
\cs_set_eq:NN \footnote \__beerydoc_code_footnote:n |
| 492 |
} |
| 493 |
\cs_new_protected:Npn \__beerydoc_code_footnote:n #1 |
| 494 |
{ |
| 495 |
\footnotemark |
| 496 |
\hook_gput_next_code:nn { env/code/after } { \footnotetext {#1} } |
| 497 |
} |
| 498 |
\cs_new_protected:Npn \__beerydoc_code_names:n #1 |
| 499 |
{ |
| 500 |
\tl_set:Nn \l__beerydoc_code_names_tl {#1} |
| 501 |
\tl_remove_all:Nn \l__beerydoc_code_names_tl { \obeyedline } |
| 502 |
\tl_replace_all:NVn \l__beerydoc_code_names_tl \c__beerydoc_active_tab_tl |
| 503 |
{ ~ } |
| 504 |
\tl_replace_all:NVn \l__beerydoc_code_names_tl \c_catcode_active_space_tl |
| 505 |
{ ~ } |
| 506 |
\clist_set:NV \l__beerydoc_code_names_clist \l__beerydoc_code_names_tl |
| 507 |
\clist_if_empty:NT \l__beerydoc_code_names_clist |
| 508 |
{ \msg_error:nn { beerydoc } { code-env-no-items } } |
| 509 |
\hcoffin_set:Nn \l__beerydoc_code_names_coffin |
| 510 |
{ |
| 511 |
\small |
| 512 |
\ttfamily |
| 513 |
\begin{tblr}[expand=\expanded] |
| 514 |
{ |
| 515 |
colspec = { l } |
| 516 |
, abovesep = 0pt |
| 517 |
, belowsep = 0pt |
| 518 |
, leftsep = 0pt |
| 519 |
, rightsep = 0pt |
| 520 |
} |
| 521 |
\toprule |
| 522 |
\addlinespace[2pt] |
| 523 |
\expanded { \clist_use:Nn \l__beerydoc_code_names_clist { \\ } } |
| 524 |
\\ |
| 525 |
\addlinespace[2pt] |
| 526 |
\bottomrule |
| 527 |
\end{tblr} |
| 528 |
} |
| 529 |
\dim_set:Nn \l__beerydoc_code_names_dim |
| 530 |
{ \coffin_wd:N \l__beerydoc_code_names_coffin } |
| 531 |
\bool_set:Nn \l__beerydoc_code_names_long_bool |
| 532 |
{ \dim_compare_p:nNn \l__beerydoc_code_names_dim > \marginparwidth } |
| 533 |
} |
| 534 |
\cs_new_protected:Npn \__beerydoc_code_descr_start:w |
| 535 |
{ |
| 536 |
\vcoffin_set:Nnw \l__beerydoc_code_descr_coffin { \textwidth } |
| 537 |
\noindent \ignorespaces |
| 538 |
} |
| 539 |
\cs_new_protected:Npn \__beerydoc_code_descr_stop: { \vcoffin_set_end: } |
| 540 |
\cs_new_protected:Npn \__beerydoc_code_assemble: |
| 541 |
{ |
| 542 |
\dim_set:Nn \l__beerydoc_code_descr_yoffset_dim |
| 543 |
{ |
| 544 |
\l_fontscale_normalsize_baselineskip_skip - |
| 545 |
0.7 \l_fontscale_normalsize_size_dim |
| 546 |
} |
| 547 |
\dim_set:Nn \l__beerydoc_syntax_yoffset_dim { \heavyrulewidth + 2pt } |
| 548 |
\bool_if:NTF \l__beerydoc_code_names_long_bool |
| 549 |
{ |
| 550 |
\box_if_empty:NTF \g__beerydoc_syntax_box |
| 551 |
{ |
| 552 |
\coffin_set_eq:NN \l__beerydoc_code_coffin |
| 553 |
\l__beerydoc_code_descr_coffin |
| 554 |
\coffin_join:NnnNnnnn \l__beerydoc_code_coffin { l } { t } |
| 555 |
\l__beerydoc_code_names_coffin { l } { b } |
| 556 |
{ - \marginparwidth - \marginparsep } |
| 557 |
{ \l__beerydoc_code_descr_yoffset_dim } |
| 558 |
} |
| 559 |
{ |
| 560 |
\hcoffin_set:Nn \l__beerydoc_syntax_coffin |
| 561 |
{ \box_use:N \g__beerydoc_syntax_box } |
| 562 |
\coffin_set_eq:NN \l__beerydoc_code_coffin |
| 563 |
\l__beerydoc_code_names_coffin |
| 564 |
\coffin_join:NnnNnnnn \l__beerydoc_code_coffin { r } { t } |
| 565 |
\l__beerydoc_syntax_coffin { l } { t } |
| 566 |
{ \marginparsep } { - \l__beerydoc_syntax_yoffset_dim } |
| 567 |
\coffin_join:NnnNnnnn \l__beerydoc_code_coffin { r } { b } |
| 568 |
\l__beerydoc_code_descr_coffin { r } { t } |
| 569 |
{ 0pt } { - \l__beerydoc_code_descr_yoffset_dim } |
| 570 |
} |
| 571 |
\coffin_typeset:Nnnnn \l__beerydoc_code_coffin { l } { T } |
| 572 |
{ - \marginparwidth - \marginparsep } { 0pt } |
| 573 |
} |
| 574 |
{ |
| 575 |
\box_if_empty:NTF \g__beerydoc_syntax_box |
| 576 |
{ |
| 577 |
\coffin_set_eq:NN \l__beerydoc_code_coffin |
| 578 |
\l__beerydoc_code_descr_coffin |
| 579 |
\coffin_join:NnnNnnnn \l__beerydoc_code_coffin { l } { t } |
| 580 |
\l__beerydoc_code_names_coffin { l } { t } |
| 581 |
{ - \l__beerydoc_code_names_dim - \marginparsep } |
| 582 |
{ \l__beerydoc_syntax_yoffset_dim } |
| 583 |
} |
| 584 |
{ |
| 585 |
\hcoffin_set:Nn \l__beerydoc_syntax_coffin |
| 586 |
{ \box_use:N \g__beerydoc_syntax_box } |
| 587 |
\coffin_set_eq:NN \l__beerydoc_code_coffin |
| 588 |
\l__beerydoc_syntax_coffin |
| 589 |
\coffin_join:NnnNnnnn \l__beerydoc_code_coffin { l } { b } |
| 590 |
\l__beerydoc_code_descr_coffin { l } { t } |
| 591 |
{ 0pt } |
| 592 |
{ |
| 593 |
- \l__beerydoc_code_descr_yoffset_dim |
| 594 |
- \l__beerydoc_syntax_yoffset_dim |
| 595 |
} |
| 596 |
\coffin_join:NnnNnnnn \l__beerydoc_code_coffin { l } { t } |
| 597 |
\l__beerydoc_code_names_coffin { r } { t } |
| 598 |
{ - \marginparsep } { \l__beerydoc_syntax_yoffset_dim } |
| 599 |
} |
| 600 |
\coffin_typeset:Nnnnn \l__beerydoc_code_coffin { l } { T } |
| 601 |
{ - \l__beerydoc_code_names_dim - \marginparsep } { 0pt } |
| 602 |
} |
| 603 |
} |
| 604 |
\NewDocumentEnvironment { syntax } { } { \__beerydoc_syntax:w } |
| 605 |
{ \__beerydoc_syntax_end: } |
| 606 |
\cs_new_protected:Npn \__beerydoc_syntax:w |
| 607 |
{ |
| 608 |
\bool_if:NF \l__beerydoc_code_bool |
| 609 |
{ \msg_error:nn { beerydoc } { syntax-env-misused } } |
| 610 |
\bool_if:NT \l__beerydoc_syntax_bool |
| 611 |
{ \msg_error:nn { beerydoc } { syntax-env-not-nestable } } |
| 612 |
\bool_set_true:N \l__beerydoc_syntax_bool |
| 613 |
\vbox_gset:Nw \g__beerydoc_syntax_box |
| 614 |
\dim_set:Nn \hsize |
| 615 |
{ |
| 616 |
\textwidth |
| 617 |
\bool_if:NT \l__beerydoc_code_names_long_bool |
| 618 |
{ - \l__beerydoc_code_names_dim + \marginparwidth } |
| 619 |
} |
| 620 |
\setlength \parskip { 0pt } |
| 621 |
\ttfamily |
| 622 |
\small |
| 623 |
\raggedright |
| 624 |
\obeyspaces |
| 625 |
\obeylines |
| 626 |
} |
| 627 |
\cs_new_protected:Npn \__beerydoc_syntax_end: |
| 628 |
{ |
| 629 |
\vbox_gset_end: |
| 630 |
\ignorespacesafterend |
| 631 |
} |
| 632 |
|
| 633 |
% Floats |
| 634 |
|
| 635 |
\renewcommand\bottomfraction{0.5} % default = 0.3 |
| 636 |
\setcounter{bottomnumber}{2} % default = 1 |
| 637 |
\setcounter{topnumber}{3} % default = 2 |
| 638 |
\setcounter{totalnumber}{4} % default = 3 |
| 639 |
|
| 640 |
% Environments |
| 641 |
|
| 642 |
\RequirePackage { multicol } |
| 643 |
|
| 644 |
% Page style |
| 645 |
|
| 646 |
% \flushbottom |
| 647 |
\raggedbottom |
| 648 |
\vbadness = 100 |
| 649 |
% \maxdepth = 0pt |
| 650 |
|
| 651 |
\setlength \topskip { \dim_use:N \l_fontscale_normalsize_size_dim } |
| 652 |
\setlength \splittopskip { \topskip } |
| 653 |
|
| 654 |
\RequirePackage { geometry } |
| 655 |
\exp_args:Ne \geometry |
| 656 |
{ |
| 657 |
a4paper |
| 658 |
, textwidth = 5in |
| 659 |
, textheight = |
| 660 |
\fp_to_dim:n { \c_beerydoc_golden_ratio_fp * \dim_to_fp:n { 5in } } |
| 661 |
, heightrounded |
| 662 |
, hmarginratio = 2 \c_colon_str 1 |
| 663 |
, headheight = \skip_use:N \l_fontscale_footnotesize_baselineskip_skip |
| 664 |
, headsep = \dim_use:N \c_beerydoc_big_dim |
| 665 |
, footskip = |
| 666 |
\dim_eval:n |
| 667 |
{ \c_beerydoc_big_dim + \l_fontscale_footnotesize_baselineskip_skip } |
| 668 |
} |
| 669 |
\dim_set:Nn \marginparsep { 1em } |
| 670 |
\dim_log:N \marginparsep |
| 671 |
\dim_set:Nn \marginparwidth { 2in - \marginparsep } |
| 672 |
\dim_log:N \marginparwidth |
| 673 |
|
| 674 |
\RequirePackage { fancyhdr } |
| 675 |
\pagestyle { fancy } |
| 676 |
\fancyhf { } |
| 677 |
\renewcommand \headrulewidth { 0pt } |
| 678 |
\fancyfoot [ C ] { \thepage \c_space_tl of~ \pageref { LastPage } } |
| 679 |
|
| 680 |
% Paragraph style |
| 681 |
|
| 682 |
\frenchspacing |
| 683 |
% \nonfrenchspacing |
| 684 |
% \linespread { 1 } |
| 685 |
\RequirePackage [ skip = \skip_use:N \c_beerydoc_med_skip ] { parskip } |
| 686 |
% default = 0.5 \baselineskip plus 2pt |
| 687 |
\RequirePackage [ raggedrightboxes ] { ragged2e } |
| 688 |
\setlength \RaggedRightRightskip |
| 689 |
{ 0pt plus \dim_use:N \c_beerydoc_alphabet_dim } % default = 0pt plus 2em |
| 690 |
\setlength \JustifyingParindent { 2em } % default = \parindent |
| 691 |
\RaggedRight |
| 692 |
% \justifying |
| 693 |
\RequirePackage { letterspace } |
| 694 |
\pretolerance = -1 % default = 100 |
| 695 |
\tolerance = 200 % default = 200 |
| 696 |
\setlength \emergencystretch { 0pt } % default = 0 |
| 697 |
\widowpenalty = 10000 |
| 698 |
\clubpenalty = \widowpenalty |
| 699 |
\displaywidowpenalty = \widowpenalty |
| 700 |
% hyphenation |
| 701 |
\hyphenpenalty = 50 % default = 50 |
| 702 |
\exhyphenpenalty = \hyphenpenalty % default = 100 |
| 703 |
\finalhyphendemerits = 0 % default = 5000 |
| 704 |
|
| 705 |
% Headings, Table of contents |
| 706 |
|
| 707 |
\RequirePackage { titlesec , titletoc } |
| 708 |
\setcounter { secnumdepth } { 3 } |
| 709 |
\setcounter { tocdepth } { 3 } |
| 710 |
|
| 711 |
\titlespacing* \section { 0pt } % section , indent |
| 712 |
{ |
| 713 |
\skip_eval:n |
| 714 |
{ |
| 715 |
\c_beerydoc_big_dim |
| 716 |
plus \dim_eval:n { \c_beerydoc_big_dim / 2 * 4 } |
| 717 |
minus \dim_eval:n { \c_beerydoc_big_dim / 3 / 4 } |
| 718 |
} |
| 719 |
} % before |
| 720 |
{ \skip_use:N \c_beerydoc_med_skip } % after |
| 721 |
\titlespacing* \subsection { 0pt } |
| 722 |
{ |
| 723 |
\skip_eval:n |
| 724 |
{ |
| 725 |
\dim_eval:n { \c_beerydoc_med_dim * 4 / 3 } |
| 726 |
plus \dim_eval:n { \c_beerydoc_med_dim / 2 * 4 } |
| 727 |
minus \dim_eval:n { \c_beerydoc_med_dim / 3 / 4 } |
| 728 |
} |
| 729 |
} |
| 730 |
{ \skip_use:N \c_beerydoc_med_skip } |
| 731 |
\titlespacing* \subsubsection { 0pt } |
| 732 |
{ |
| 733 |
\skip_eval:n |
| 734 |
{ |
| 735 |
\dim_eval:n { \c_beerydoc_med_dim * 4 / 3 } |
| 736 |
plus \dim_eval:n { \c_beerydoc_med_dim / 2 * 4 } |
| 737 |
minus \dim_eval:n { \c_beerydoc_med_dim / 3 / 4 } |
| 738 |
} |
| 739 |
} |
| 740 |
{ \skip_use:N \c_beerydoc_med_skip } |
| 741 |
|
| 742 |
\titleformat \section [ block ] % section , shape |
| 743 |
{ \raggedright \large \bfseries } % format |
| 744 |
{ \thesection } { 1em } % label , length between label and title body |
| 745 |
{ } { } % before code , after code |
| 746 |
\titleformat \subsection [ block ] |
| 747 |
{ \raggedright \normalsize \bfseries } |
| 748 |
{ \thesubsection } { 1em } |
| 749 |
{ } { } |
| 750 |
\titleformat \subsubsection [ block ] |
| 751 |
{ \raggedright \normalsize \bfseries } |
| 752 |
{ \thesubsubsection } { 1em } |
| 753 |
{ } { } |
| 754 |
|
| 755 |
% Lists, List headings |
| 756 |
|
| 757 |
\RequirePackage { enumitem } |
| 758 |
\setlist |
| 759 |
{ |
| 760 |
% horizontal spacing |
| 761 |
leftmargin = 2em |
| 762 |
, labelsep = 0.5em |
| 763 |
% vertical spacing |
| 764 |
, topsep = 0pt |
| 765 |
, partopsep = 0pt |
| 766 |
, parsep = 0pt |
| 767 |
, itemsep = 0pt |
| 768 |
} |
| 769 |
\setlist[2]{leftmargin=*} |
| 770 |
\setlist[3]{leftmargin=*} |
| 771 |
\setlist[4]{leftmargin=*} |
| 772 |
\setlist [ itemize , 1 ] { label = \textbullet } |
| 773 |
\setlist [ itemize , 2 ] { label = \scaletextbullets {2} } |
| 774 |
\setlist [ itemize , 3 ] { label = \scaletextbullets {3} } |
| 775 |
\setlist [ itemize , 4 ] { label = \scaletextbullets {4} } |
| 776 |
\setlist [ enumerate , 1 ] { label = \arabic* . } |
| 777 |
\setlist [ enumerate , 2 ] { label = \theenumi \arabic* . } |
| 778 |
\setlist [ enumerate , 3 ] { label = \theenumii \arabic* . } |
| 779 |
\setlist [ enumerate , 4 ] { label = \theenumiii \arabic* . } |
| 780 |
|
| 781 |
% list headings |
| 782 |
% https://tex.stackexchange.com/questions/2644 |
| 783 |
\NewDocumentCommand \keepnextpar { s } |
| 784 |
{ |
| 785 |
\mode_if_math:TF |
| 786 |
{ \msg_error:nnn { beerydoc } { math-mode-invalid } { keepnextpar } } |
| 787 |
{ |
| 788 |
\IfBooleanTF #1 |
| 789 |
{ \__beerydoc_keep_next_par_if_single_line: } |
| 790 |
{ \__beerydoc_keep_next_par: } |
| 791 |
} |
| 792 |
} |
| 793 |
\cs_new_protected:Npn \__beerydoc_keep_next_par: { \nobreak \@afterheading } |
| 794 |
\cs_new_protected:Npn \__beerydoc_keep_next_par_if_single_line: |
| 795 |
{ \int_compare:nNnT \prevgraf = 1 { \__beerydoc_keep_next_par: } } |
| 796 |
|
| 797 |
\NewDocumentCommand \listheading { m } |
| 798 |
{ |
| 799 |
\mode_if_math:TF |
| 800 |
{ \msg_error:nnn { beerydoc } { math-mode-invalid } { listheading } } |
| 801 |
{ \__beerydoc_list_heading:n {#1} } |
| 802 |
} |
| 803 |
\cs_new_protected:Npn \__beerydoc_list_heading:n #1 |
| 804 |
{ |
| 805 |
#1 |
| 806 |
\par |
| 807 |
\__beerydoc_keep_next_par_if_single_line: |
| 808 |
} |
| 809 |
|
| 810 |
% Tables |
| 811 |
|
| 812 |
\RequirePackage { tabularray } |
| 813 |
\UseTblrLibrary { booktabs , siunitx } |
| 814 |
|
| 815 |
% Verbatim |
| 816 |
|
| 817 |
\RequirePackage { fancyvrb } |
| 818 |
\hook_gput_code:nnn { begindocument } { beerydoc } { \DefineShortVerb { \| } } |
| 819 |
|
| 820 |
% Quotes |
| 821 |
|
| 822 |
\RequirePackage { csquotes } |
| 823 |
\RenewDocumentEnvironment { quote } { } |
| 824 |
{ |
| 825 |
\list { } |
| 826 |
{ |
| 827 |
\setlength \leftmargin { 1.5em } |
| 828 |
\setlength \rightmargin { \leftmargin } |
| 829 |
} |
| 830 |
\item \scan_stop: |
| 831 |
} |
| 832 |
{ \endlist } |
| 833 |
|
| 834 |
% Footnotes |
| 835 |
|
| 836 |
\RequirePackage [ bottomfloats , ragged ] { footmisc } |
| 837 |
% \setlength { \skip \footins } { \c_beerydoc_big_skip } |
| 838 |
\setlength \footnotesep { \f@linespread \footnotesep } |
| 839 |
\cs_set_protected:Npn \@makefntext #1 |
| 840 |
{ |
| 841 |
\hbox_set:Nn \l__beerydoc_footnote_box { \@thefnmark . } |
| 842 |
\vcoffin_set:Nnn \l__beerydoc_footnote_coffin { \textwidth } |
| 843 |
{ |
| 844 |
\list { \@thefnmark . } |
| 845 |
{ |
| 846 |
\setlength \leftmargin |
| 847 |
{ \dim_eval:n { \box_wd:N \l__beerydoc_footnote_box + 0.5em } } |
| 848 |
% \setlength \rightmargin { \leftmargin } |
| 849 |
\setlength \labelsep { 0.5em } |
| 850 |
\setlength \topsep { 0pt } |
| 851 |
\setlength \partopsep { 0pt } |
| 852 |
} |
| 853 |
\item \scan_stop: #1 \endlist |
| 854 |
} |
| 855 |
\coffin_typeset:Nnnnn \l__beerydoc_footnote_coffin { l } { b } |
| 856 |
{ 0pt } { 0pt } |
| 857 |
} |
| 858 |
|
| 859 |
% References |
| 860 |
|
| 861 |
\hook_gput_code:nnn { shipout / lastpage } { beerydoc } { \label { LastPage } } |
| 862 |
\RequirePackage { xurl } |
| 863 |
\RequirePackage { hyperref } |
| 864 |
\hypersetup { bookmarksnumbered , hidelinks , linktoc = page } |
| 865 |
|
| 866 |
% The argument to \tl_to_str:n must be braced. |
| 867 |
\cs_new:Npn \__beerydoc_pdfstring_tl_to_str:n #1 { \tl_to_str:n {#1} } |
| 868 |
\cs_new:Npn \__beerydoc_pdfstring_meta:n #1 { < \tl_to_str:n {#1} > } |
| 869 |
\cs_new:Npn \__beerydoc_pdfstring_cs:n |
| 870 |
{ \textbackslash \__beerydoc_pdfstring_cs_aux:n } |
| 871 |
% Replaces \meta with \__beerydoc_pdfstring_meta:n. |
| 872 |
\cs_new:Npn \__beerydoc_pdfstring_cs_aux:n #1 |
| 873 |
{ \__beerydoc_pdfstring_cs:wn #1 \meta \q_recursion_tail \q_recursion_stop } |
| 874 |
\cs_new:Npn \__beerydoc_pdfstring_cs:wn #1 \meta #2 |
| 875 |
{ |
| 876 |
\tl_to_str:n {#1} |
| 877 |
\quark_if_recursion_tail_stop:n {#2} |
| 878 |
\__beerydoc_pdfstring_meta:n {#2} |
| 879 |
\__beerydoc_pdfstring_cs:wn |
| 880 |
} |
| 881 |
\cs_new:Npn \__beerydoc_pdfstring_key_value:n #1 |
| 882 |
{ |
| 883 |
\str_if_eq:eeTF { \str_head:n {#1} } { = } |
| 884 |
{ \__beerydoc_pdfstring_value:n {#1} } |
| 885 |
{ \__beerydoc_pdfstring_key:n {#1} } |
| 886 |
} |
| 887 |
\cs_new:Npn \__beerydoc_pdfstring_value:n #1 |
| 888 |
{ \str_range:nnn {#1} { 2 } { -1 } } |
| 889 |
\cs_new_eq:NN \__beerydoc_pdfstring_key:n \__beerydoc_pdfstring_cs_aux:n |
| 890 |
|
| 891 |
\pdfstringdefDisableCommands |
| 892 |
{ |
| 893 |
\tl_map_inline:nn { \cls \pkg \env \hook \socket \plug } |
| 894 |
{ \cs_set_eq:NN #1 \__beerydoc_pdfstring_tl_to_str:n } |
| 895 |
\cs_set_eq:NN \meta \__beerydoc_pdfstring_meta:n |
| 896 |
\cs_set_eq:NN \cs \__beerydoc_pdfstring_cs:n |
| 897 |
\cs_set_eq:NN \key \__beerydoc_pdfstring_key_value:n |
| 898 |
} |
| 899 |
|
| 900 |
% Messages |
| 901 |
|
| 902 |
\msg_new:nnn { beerydoc } { math-mode-invalid } |
| 903 |
{ '\iow_char:N \\ #1'~ invalid~ in~ math~ mode~ \msg_line_context:. } |
| 904 |
\msg_new:nnn { beerydoc } { code-env-no-items } |
| 905 |
{ |
| 906 |
The~ argument~ to~ the~ 'code'~ environment~ must~ contain~ at~ least~ |
| 907 |
one~ code~ element~ \msg_line_context:. |
| 908 |
} |
| 909 |
\msg_new:nnn { beerydoc } { code-env-not-nestable } |
| 910 |
{ |
| 911 |
The~ 'code'~ environment~ cannot~ be~ used~ within~ another~ |
| 912 |
'code'~ environment~ \msg_line_context:. |
| 913 |
} |
| 914 |
\msg_new:nnn { beerydoc } { syntax-env-misused } |
| 915 |
{ |
| 916 |
The~ 'syntax' environment~ must~ be~ used~ within~ a~ |
| 917 |
'code'~ environment~ \msg_line_context:. |
| 918 |
} |
| 919 |
\msg_new:nnn { beerydoc } { syntax-env-not-nestable } |
| 920 |
{ |
| 921 |
The~ 'syntax' environment~ cannot~ be~ used~ within~ another~ |
| 922 |
'syntax'~ environment~ \msg_line_context:. |
| 923 |
} |