cmhughes / latexindent.pl

Perl script to add indentation (leading horizontal space) to LaTeX files. It can modify line breaks before, during and after code blocks; it can perform text wrapping and paragraph line break removal. It can also perform string-based and regex-based substitutions/replacements. The script is customisable through its YAML interface.
GNU General Public License v3.0
864 stars 84 forks source link

Can't find string terminator '"' error - bug? #542

Closed peske closed 3 months ago

peske commented 3 months ago

Please sorry for not following the issue template, but it looks unrelated. First, the tex file(s) are way too long. Second, the error I'm getting does not refer to tex at all, but it looks more like some internal bug.

In short, when running the latest (v3.24) version as part of Gitlab CI/CD pipeline on a Gitlab runner (Ubuntu 24.04 server), I'm getting the following error:

Can't find string terminator '"' anywhere before EOF at /tmp/par-6769746c61622d72756e6e6572/cache-67f49a1963ebec69758cc8b180fc4bc1290fc8fa/inc/lib/LatexIndent/FileExtension.pm line 190. Compilation failed in require at /tmp/par-6769746c61622d72756e6e6572/cache-67f49a1963ebec69758cc8b180fc4bc1290fc8fa/inc/lib/LatexIndent/Document.pm line 36. BEGIN failed--compilation aborted at /tmp/par-6769746c61622d72756e6e6572/cache-67f49a1963ebec69758cc8b180fc4bc1290fc8fa/inc/lib/LatexIndent/Document.pm line 36. Compilation failed in require at script/latexindent.pl line 28. BEGIN failed--compilation aborted at script/latexindent.pl line 28.

However, when I roll back to latexindent v3.23.6, 2024-01-17 on the same machine (that comes by default with sudo apt-get install texlive-full), everything is OK, and the pipeline succeeds.

cmhughes commented 3 months ago

How do I test this? I need specific instructions, please.

On Wed, 8 May 2024, 13:49 Aleksandar Pesic, @.***> wrote:

Please sorry for not following the issue template, but it looks unrelated. First, the tex file(s) are way too long. Second, the error I'm getting does not refer to tex at all, but it looks more like some internal bug.

In short, when running the latest (v3.24) version as part of Gitlab CI/CD pipeline on a Gitlab runner (Ubuntu 24.04 server), I'm getting the following error:

Can't find string terminator '"' anywhere before EOF at /tmp/par-6769746c61622d72756e6e6572/cache-67f49a1963ebec69758cc8b180fc4bc1290fc8fa/inc/lib/LatexIndent/FileExtension.pm line 190. Compilation failed in require at /tmp/par-6769746c61622d72756e6e6572/cache-67f49a1963ebec69758cc8b180fc4bc1290fc8fa/inc/lib/LatexIndent/Document.pm line 36. BEGIN failed--compilation aborted at /tmp/par-6769746c61622d72756e6e6572/cache-67f49a1963ebec69758cc8b180fc4bc1290fc8fa/inc/lib/LatexIndent/Document.pm line 36. Compilation failed in require at script/latexindent.pl line 28. BEGIN failed--compilation aborted at script/latexindent.pl line 28.

— Reply to this email directly, view it on GitHub https://github.com/cmhughes/latexindent.pl/issues/542, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ7CYA5BPSIKA2W244TOUDZBINM7AVCNFSM6AAAAABHM5BUAKVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI4DKNJSGAZTKMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

cmhughes commented 3 months ago

@fengzyf looks like this may be another issue

cmhughes commented 3 months ago

Please provide a minimal file and instructions so that I can experiment

peske commented 3 months ago

I would really like to help, but sharing the tex file is not possible for two reasons:

However, I can share with you configs, if it may help. So defaultSettings.json files are identical for both mentioned versions, and unchanged after the installation. There is a local .latexindent.yaml file in the workspace directory, with the following content:

defaultIndent: "    "

noAdditionalIndent:
  textbf: 1
  emph: 1

modifyLineBreaks:
  textWrapOptions:
    columns: 81
    when: after

replacements:
  -
    when: before
    substitution: |-
      s/%\h*chktex\h*35//sg
  -
    when: after
    substitution: |-
      s/(_\{(min|max)(_|\}).*$)/$1 % chktex 35/mg

The command is executed with the following flags:

latexindent -kv --local=.latexindent.yaml,../.latexindent.yaml --modifylinebreaks --replacement --silent

I hope it helps.

fengzyf commented 3 months ago

I would really like to help, but sharing the tex file is not possible for two reasons:

  • First it's a huge file (in fact it's a main.tex file that includes dozens of huge tex files), resulting in ~100 pages long PDF, with several hundreds equations. And based on the error output I'm unable to know which part of which file is causing the problem.
  • Also, the content of the file is a secret that I'm not allowed to share.

I can't reproduce your problem without a minimum file, you can construct a minimum file by referring to the URL: https://tex.meta.stackexchange.com/questions/228/ive-just-been-asked-to-write-a-minimal-working-example-mwe-what-is-that

For the first reason, try the following to locate the code causing the problem.

In the more likely scenario that you've just encountered a new problem, the best approach I've found is to start commenting out the newest pieces you've added one at a time and seeing when the problem goes away. At that point, you can try to make a new minimal document containing only the part you had to remove to make the problem go away -- if all goes well, you'll be able to make the new (much smaller) document reproduce the same problem.

Binary search is usually the fastest solution. Remove roughly 1/2 of your thesis. If the problem persists, repeat. If not, undo and remove the other 1/2 of your thesis. Of course it isn't quite that straightforward always, but even if you have hundreds of pages of text, you can fairly quickly reduce the problem to a short fragment of code.

For the second reason, replace some text with non-sensitive content and utilize dummy text.

Need a few paragraphs of text to demonstrate your problem? Use a package that produces dummy text. Popular choices are lipsum (plain paragraphs) and blindtext (can produce entire documents with section titles, lists, and formulae).

Need just a tiny amount of text? Then keep it maximally simple; avoid formulae, italics, tables – anything that’s not essential to the problem. Popular choices for dummy words are foo, bar, and baz.

peske commented 3 months ago

I will try to detect the part that causes the problem and share it.

cmhughes commented 3 months ago

If you can provide a minimal example, feel free to post it here, but for the moment I'm closing this.