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

[Bug] indentation when using \href with a url containing % #55

Open
marcfranquesa opened this issue Nov 25, 2024 · 3 comments
Open

[Bug] indentation when using \href with a url containing % #55

marcfranquesa opened this issue Nov 25, 2024 · 3 comments

Comments

@marcfranquesa
Copy link
Contributor

marcfranquesa commented Nov 25, 2024

Links to files containing spaces contain %, and \href allows you to insert the link as is. tex-fmt seems to understand it as a comment and considers the { from \href to not be closed, therefore indenting the rest of the document.

Example:

\documentclass[12pt]{article}

\usepackage{hyperref}

\begin{document}

\href{https://github.com/WGUNDERWOOD/tex-fmt/example%20file.pdf}{URL with \%}.

\end{document}

After formatting with tex-fmt:

\documentclass[12pt]{article}

\usepackage{hyperref}

\begin{document}

\href{https://github.com/WGUNDERWOOD/tex-fmt/example%20file.pdf}{URL with \%}.

  \end{document}

Thanks!

@WGUNDERWOOD
Copy link
Owner

WGUNDERWOOD commented Nov 25, 2024

Thanks for catching this! I'll think about how best to address it. For now, you can always skip formatting for this line by appending % tex-fmt: skip.

@matu3ba
Copy link

matu3ba commented Jan 15, 2025

Likely same bug, but broken .tex document as result.
Before working with lualatex --file-line-error --synctex=1 --output-directory=build repro_href_bug.tex

\documentclass{article} % Use the custom resume.cls style
\usepackage{hyperref}
\begin{document}
  \begin{itemize}
  \item Contributed to Zig \href{https://github.com/ziglang/zig/pulls?q=is%3Apr+author%3Amatu3ba+is%3Aclosed+compiler_rt}{compiler runtime integer routines} including tests for all edge cases.
  \end{itemize}
\end{document}

After tex-fmt repro_href_bug.tex output

WARN: tex-fmt repro_href_bug.tex: Line 6 (5). Line cannot be wrapped. \href{https://github.com/ziglang/zig/pulls?
q=is%3Apr+author%3Amatu3ba+is%3Aclosed+compiler_rt}{compiler runtime integer routines} including tests for all ed
ge cases.
WARN: tex-fmt repro_href_bug.tex: Line 6 (5). Line cannot be wrapped. \href{https://github.com/ziglang/zig/pulls?
q=is%3Apr+author%3Amatu3ba+is%3Aclosed+compiler_rt}{compiler
WARN: tex-fmt repro_href_bug.tex: Indent does not return to zero. Last non-indented line is line 4 

and document is now

\documentclass{article} % Use the custom resume.cls style
\usepackage{hyperref}
\begin{document}
\begin{itemize}
  \item Contributed to Zig
    \href{https://github.com/ziglang/zig/pulls?q=is%3Apr+author%3Amatu3ba+is%3Aclosed+compiler_rt}{compiler
      % runtime integer routines} including tests for all edge cases.
  \end{itemize}
  \end{document}

failing on running lualatex --file-line-error --synctex=1 --output-directory=build repro_href_bug.tex
with

This is LuaHBTeX, Version 1.18.0 (TeX Live 2024/Arch Linux) 
 restricted system commands enabled.
(./repro_href_bug.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-02-20>
 (/usr/share/texmf-dist/tex/latex/base/article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(/usr/share/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texmf-dist/tex/latex/hyperref/hyperref.sty
(/usr/share/texmf-dist/tex/generic/iftex/iftex.sty)
(/usr/share/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texmf-dist/tex/latex/kvsetkeys/kvsetkeys.sty)
(/usr/share/texmf-dist/tex/generic/kvdefinekeys/kvdefinekeys.sty)
(/usr/share/texmf-dist/tex/generic/pdfescape/pdfescape.sty
(/usr/share/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty)
(/usr/share/texmf-dist/tex/generic/pdftexcmds/pdftexcmds.sty
(/usr/share/texmf-dist/tex/generic/infwarerr/infwarerr.sty)))
(/usr/share/texmf-dist/tex/latex/hycolor/hycolor.sty)
(/usr/share/texmf-dist/tex/latex/auxhook/auxhook.sty)
(/usr/share/texmf-dist/tex/latex/hyperref/nameref.sty
(/usr/share/texmf-dist/tex/latex/refcount/refcount.sty)
(/usr/share/texmf-dist/tex/generic/gettitlestring/gettitlestring.sty
(/usr/share/texmf-dist/tex/latex/kvoptions/kvoptions.sty)))
(/usr/share/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(/usr/share/texmf-dist/tex/latex/hyperref/pd1enc.def)
(/usr/share/texmf-dist/tex/generic/intcalc/intcalc.sty)
(/usr/share/texmf-dist/tex/latex/hyperref/puenc.def)
(/usr/share/texmf-dist/tex/latex/url/url.sty)
(/usr/share/texmf-dist/tex/generic/bitset/bitset.sty
(/usr/share/texmf-dist/tex/generic/bigintcalc/bigintcalc.sty))
(/usr/share/texmf-dist/tex/latex/base/atbegshi-ltx.sty))
(/usr/share/texmf-dist/tex/latex/hyperref/hluatex.def
(/usr/share/texmf-dist/tex/generic/stringenc/stringenc.sty)
(/usr/share/texmf-dist/tex/latex/base/atveryend-ltx.sty)
(/usr/share/texmf-dist/tex/latex/rerunfilecheck/rerunfilecheck.sty
(/usr/share/texmf-dist/tex/generic/uniquecounter/uniquecounter.sty)))
(/usr/share/texmf-dist/tex/latex/l3backend/l3backend-luatex.def)
(./build/repro_href_bug.aux) (/usr/share/texmf-dist/tex/latex/base/ts1cmr.fd)
(./build/repro_href_bug.out) (./build/repro_href_bug.out))
Runaway argument?
{compiler \end {itemize} \end {document} 
! File ended while scanning use of \href@split.
<inserted text> 
\par 
<*> repro_href_bug.tex
                   
? 

@matu3ba
Copy link

matu3ba commented Jan 15, 2025

Observation is also texlab shows incorrect lsp infos for highlighting:
lsp_selection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants