The solution using xparse with the following redefinition (see redefine path with trailing backslash)
\RenewDocumentCommand\path{v}{hidden for privacy}
does not seem to work in all contexts.
For example, the following MWE using path without a trailing backslash within a footnote does not work.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{xparse}
\usepackage{url}
\RenewDocumentCommand\path{v}{Path hidden for privacy}
\begin{document}
\footnote{\path{C:\User\John Doe}}
\end{document}
Here, I get the following error:
! LaTeX3 Error: The verbatim command '\path' cannot be used inside an
(LaTeX3) argument.
And when using a path argument with a trailing backslash within a footnote, it doesn't work due to another error (runaway argument?):
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{xparse}
\usepackage{url}
\RenewDocumentCommand\path{v}{Path hidden for privacy}
\begin{document}
\footnote{\path{C:\User\John Doe\}}
\end{document}
The error message for this MWE is as follows:
Runaway argument?
{\path {C:\User \John Doe\}} \end {document}
! File ended while scanning use of \@footnotetext.
Is there a way to redefine path to replace its content with a placeholder that also works within other contexts like footnote?
\in path names in the first place. – daleif Nov 16 '20 at 12:33C:\User\John Doetex will acceptC:/User/John Doethen you do not need any verbatim handling – David Carlisle Nov 16 '20 at 12:51