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

text wrapping comment text to 3 #552

Closed Mikachu2333 closed 1 month ago

Mikachu2333 commented 1 month ago

Please provide the following when posting an issue:

original .tex code

%校级社团
% 测试

yaml settings

modifyLineBreaks:
  condenseMultipleBlankLinesInto: 2
  optionalArguments:
    tblr:
      OptArgBodyStartsOnOwnLine: 1 # -1,0,1,2,3,4
  textWrapOptions:
    comments:
      wrap: 1

lookForAlignDelims:
  tblr:
    alignFinalDoubleBackSlash: 1
    #dontMeasure: largest
    multiColumnGrouping: 1

fineTuning:
  keyEqualsValuesBracesBrackets:
    name: |-
      (?x)
      [a-zA-Z@\*0-9_\/.:\#-]+
      (?:
        [a-zA-Z@\*0-9_\/.\h:\#-]
        \{
          [a-zA-Z@\*0-9_\/.\h:\#-,]+?
        \}
      )*?
defaultIndent: "    "

actual/given output

No errors.

[11:55:40.296][Format][TeX] Start formatting with latexindent.
[11:55:40.297][Format][TeX] Formatting LaTeX. The command is latexindent:["-c=d:/Temp/sdsmu_welcome_tex/","d:/Temp/sdsmu_welcome_tex/in_school/summary/__latexindent_temp_community_summary.tex","-m","--GCString","-l=d:/Temp/sdsmu_welcome_tex/latexindent.yaml"].
[11:55:40.883][Format][TeX] Formatted %WS1%\in_school\summary\community_summary.tex
% 3
% 3

desired or expected output

% 校级社团
% 测试

anything else

Latex Workshop Settings

"latex-workshop.latexindent.args": [
        "-c=%DIR%/",
        "%TMPFILE%",
        "-m",
        "--GCString",
        "-l=%DIR%/latexindent.yaml"
    ],
Mikachu2333 commented 1 month ago

Useful yaml setting contribute to this bug

textWrapOptions:
    comments:
      wrap: 1
cmhughes commented 1 month ago

This doesn't seem to be related to Chinese characters.

Using

% 1
%  2

and the minimal settings

modifyLineBreaks:
  textWrapOptions:
    comments:
      wrap: 1

gives the error:

Unescaped left brace in regex is passed through in regex; marked by <-- HERE in m/\G((?>(?!\n)\PM\pM*|(?<![^\n])\pM+){ <-- HERE 0,-2})((?>\n|\r\n|[^\x{a0}\x{202f}\S]\pM*)|\n+|\z)/ at /home/cmhughes/perl5/perlbrew/perls/perl-5.40.0/lib/5.40.0/Text/Wrap.pm line 56.
Unescaped left brace in regex is passed through in regex; marked by <-- HERE in m/\G((?>(?!\n)\PM\pM*|(?<![^\n])\pM+){ <-- HERE -2})/ at /home/cmhughes/perl5/perlbrew/perls/perl-5.40.0/lib/5.40.0/Text/Wrap.pm line 61.
Increasing $Text::Wrap::columns from -1 to 2 at /home/cmhughes/projects/latexindent/LatexIndent/Wrap.pm line 721.
Unescaped left brace in regex is passed through in regex; marked by <-- HERE in m/\G((?>(?!\n)\PM\pM*|(?<![^\n])\pM+){ <-- HERE 0,-2})((?>\n|\r\n|[^\x{a0}\x{202f}\S]\pM*)|\n+|\z)/ at /home/cmhughes/perl5/perlbrew/perls/perl-5.40.0/lib/5.40.0/Text/Wrap.pm line 56.
Unescaped left brace in regex is passed through in regex; marked by <-- HERE in m/\G((?>(?!\n)\PM\pM*|(?<![^\n])\pM+){ <-- HERE -2})/ at /home/cmhughes/perl5/perlbrew/perls/perl-5.40.0/lib/5.40.0/Text/Wrap.pm line 61.
Increasing $Text::Wrap::columns from -1 to 2 at /home/cmhughes/projects/latexindent/LatexIndent/Wrap.pm line 784.
Mikachu2333 commented 1 month ago

Sorry but I got no error... and latexindent.pl just exchange my comments to the number "3"

RE-update

Yes, it is not related to CJK characters.

Mikachu2333 commented 1 month ago

Here is a video for this issue

https://github.com/user-attachments/assets/c5e58f07-be12-4dcf-9a46-78adb0a4d451

cmhughes commented 1 month ago

The problem is that columns hasn't been specified.

However, latexindent should fail gracefully. I'll get to this soon, hopefully.

cmhughes commented 1 month ago

Implemented at https://github.com/cmhughes/latexindent.pl/releases/tag/V3.24.4, uploaded to ctan, thanks for reporting.