-
Notifications
You must be signed in to change notification settings - Fork 84
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
Windows line breaks on Linux prevent removal of white space from end of line #256
Comments
In addition, I see different amounts of white space in empty lines when using or not using |
Here we go:
Output:
Expected:
|
I'm sorry for the delay. To be honest, I'm confused by this and don't understand what it's about. I'll try and ask some questions at some point. |
No problem, this is not an urgent issue at all. I fixed it by converting all my files using What is this about? This is about getting a I use Feel free to ask for further clarification at any point in time ;) |
OK, that's helpful, thanks very much. I'll follow up with you once I've understood this more. |
I do not know if this is a stupid idea: |
@bersbersbers any ideas on this? The body is read in using Latexindent /FileExtention.pm, https://github.com/cmhughes/latexindent.pl/blob/main/LatexIndent/FileExtension.pm |
@cmhughes do you mean in terms of the what or the how? As to the what, I would have no problem if As to the how and the code snippet: I have no perl experience at all, so I don't know what these two lines do on different platforms: latexindent.pl/LatexIndent/FileExtension.pm Lines 143 to 144 in a65f1fb
Do they strip the line endings or not? Completely or just what is expected on the platform? Etc. |
Thanks, these are helpful questions. I'll look into them and report back. |
How about if there is a switch, something like
And it would do something like you describe : |
Yeah, why not - sounds good on Linux. Would it do the same on Windows, or would it "normalise" to |
These are good questions. Instead of a new setting, for your use case, could you use the replacement switch and the following settings : replacements:
-
substitution: s/\r\n/\n/sg |
I'm sure I could. Then again, most people only need to do this once, so My motivation to open this issue was rather to have you think about |
Would this feature need an option to operate on Linux-based line breaks and turn them into Windows-based line breaks? |
I think that depends on what happens without this option.
There may be more |
As of 74ee20c I've updated Can you grab copy
Does this do as you would like? |
I'll gladly try (in three weeks, though). |
Hmm - may I am doing something wrong, but I replaced
Same with
Deleting that Is the above working for you? It should output I am using TeX Live, if that matters. |
If I start with
|
Yes, I do. But I don't see any difference between the two outputs that you show, so I wonder how this example helps to verify the issue.
I think so, but they have little to do with the issue ("Windows line breaks on Linux prevent removal of white space from end of line").
Add spaces to the ends of lines: sed -i "s/\s*$/ /" issue-256.tex
unix2dos issue-256.tex
cat issue-256.tex | tr " " "_"
latexindent -s issue-256.tex -o +-mod1
latexindent -s -y="dos2unixlinebreaks:1" issue-256.tex -o +-mod2
file issue-256-mod1.tex
cat issue-256-mod1.tex | tr " " "_"
file issue-256-mod2.tex
cat issue-256-mod2.tex | tr " " "_" I receive this as an output (twice) - the \begin{thebibliography}{00}
\bibitem{b1}_B1___
\bibitem{b2}_B2___
\end{thebibliography} (The output files do have different line endings as shown by you, so the |
Have you tried the removeTrailingWhiteSpace option :
https://latexindentpl.readthedocs.io/en/latest/sec-default-user-local.html#lst-removetrailingwhitespace
…On Thu, 17 Jun 2021, 07:49 bersbersbers, ***@***.***> wrote:
Can you verify you receive the same outputs?
Yes, I do. But I don't see any difference between the two outputs that you
show, so I wonder how this example helps to verify the issue.
Are these as expected/desired?
I think so, but they have little to do with the issue ("Windows line
breaks on Linux prevent removal of white space from end of line").
Could you let me know how to test your example using the template above?
Add spaces to the ends of lines:
sed -i "s/\s*$/ /" issue-256.tex
unix2dos issue-256.tex
cat issue-256.tex | tr " " "_"
latexindent -s issue-256.tex -o +-mod1
latexindent -s -y="dos2unixlinebreaks:1" issue-256.tex -o +-mod2
file issue-256-mod1.tex
cat issue-256-mod1.tex | tr " " "_"
file issue-256-mod2.tex
cat issue-256-mod2.tex | tr " " "_"
I receive this as an output (twice) - the ___ (triple underscores)
indicate spaces at the ends of lines which are not removed:
\begin{thebibliography}{00}
\bibitem{b1}_B1___
\bibitem{b2}_B2___
\end{thebibliography}
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#256 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAQ7CYAYSQQAWZ25XLSEVATTTGLJDANCNFSM4ZICUZNA>
.
|
I had not, in fact, because my original code in #256 (comment) did not use that, either - but same thing: sed -i "s/\s*$/ /" issue-256.tex
unix2dos issue-256.tex
cat issue-256.tex | tr " " "_"
latexindent -s -y="removeTrailingWhitespace:beforeProcessing:1;afterProcessing:1" issue-256.tex -o +-mod1
latexindent -s -y="removeTrailingWhitespace:beforeProcessing:1;afterProcessing:1,dos2unixlinebreaks:1" issue-256.tex -o +-mod2
file issue-256-mod1.tex
cat issue-256-mod1.tex | tr " " "_"
file issue-256-mod2.tex
cat issue-256-mod2.tex | tr " " "_" gives (twice)
|
To stay with my original example: This works ( printf "1 \n" | latexindent | tr " " "_" This does not ( printf "1 \n" | unix2dos | latexindent -y="dos2unixlinebreaks:1" | tr " " "_" Tell me if this should be working, then I'll investigate further if my installation is correctly patched. If this is not working for you, either, the issue is not fixed. |
Ok, as of 954d88c I think this works as you would like. If you grab Document.pm from the
produces Is this as you would like? |
Yes! I cannot test the current |
OK. Feel free to grab Switches.pm, or to clone develop. For the moment, I'll label this as resolved. It'll be part of the next release, coming soon hopefully. |
Resolved as of #278, upload to ctan to follow. |
Using
latexindent
3.9 from TeX Live on Linux.original .tex code
actual/given output
desired or expected output
The text was updated successfully, but these errors were encountered: