Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty hook raises error with label-specific message #1423

Open
muzimuzhi opened this issue Aug 2, 2024 · 3 comments
Open

Empty hook raises error with label-specific message #1423

muzimuzhi opened this issue Aug 2, 2024 · 3 comments
Labels
category base (latex) fixed in dev Fixed in development branch, not in stable release

Comments

@muzimuzhi
Copy link
Contributor

Brief outline of the bug

Empty hook label is not supported so it raises an expandable error with label-specific message:

! LaTeX hooks Error: Empty code label on line 41. Using 'top-level' instead.

Empty hook is not supported too, but the raised error is the same as that for empty label, thus misleading. (At least the suggestion to using top-level hook name is wrong.)

Minimal example showing the bug

\RequirePackage{latexbug}       % <--should be always the first line (see CONTRIBUTING)!
\AddToHook{myhook}[]{code} % empty label
\AddToHook{}{code}         % empty hook
\UseName{@@end}

Log file (required) and possibly PDF file

latex2e-empty-hook-misleading-message.log

@muzimuzhi
Copy link
Contributor Author

The parsing of dot-syntax in hooks and labels shares the same function \__hook_parse_label_default:n.

One possibility is to make that function absorb a new boolean argument (as a marker) and pass it to the function \__hook_parse_dot_label:n which would raise different errors (empty-label or empty-hook) depending on the value of that boolean.

latex2e/base/lthooks.dtx

Lines 3425 to 3442 in 11f2110

\cs_new_protected:Npn \@@_normalize_hook_args:Nnn #1 #2 #3
{
\@@_normalize_hook_args_aux:Nn #1
{
{ \@@_parse_label_default:n {#2} }
{ \@@_parse_label_default:n {#3} }
}
}
\cs_new_protected:Npn \@@_normalize_hook_rule_args:Nnnnn #1 #2 #3 #4 #5
{
\@@_normalize_hook_args_aux:Nn #1
{
{ \@@_parse_label_default:n {#2} }
{ \@@_parse_label_default:n {#3} }
{ \tl_trim_spaces:n {#4} }
{ \@@_parse_label_default:n {#5} }
}
}

Copy link

github-actions bot commented Oct 1, 2024

This issue has been automatically marked as stale because it has not had recent activity.

@github-actions github-actions bot added the stale label Oct 1, 2024
@muzimuzhi
Copy link
Contributor Author

This issue is already fixed in dev ( fixed in dev Fixed in development branch, not in stable release ).

@u-fischer u-fischer added fixed in dev Fixed in development branch, not in stable release and removed stale labels Oct 1, 2024
@FrankMittelbach FrankMittelbach added this to the Release 2024 Fall milestone Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category base (latex) fixed in dev Fixed in development branch, not in stable release
Projects
Status: Done in dev
Development

No branches or pull requests

3 participants