Latexindent.pl Versions Save

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.

V3.17

2 years ago

new features

  • batches of files now supported, issue 332
  • -wd switch which means 'overwrite if different'; similar to the -w switch, but will only activate the overwrite and back-up file procedure if the indented text is different from the original
  • multipleSpacesToSingle feature for oneSentencePerLine
  • --GCString switch available to optionally load the Unicode::GCString module, issue 303

V3.16

2 years ago

text wrap overhaul

This release implements a complete overhaul of the textWrap routine. The interface is now

    textWrapOptions:
        columns: 0
        multipleSpacesToSingle: 1            
        blocksFollow:
           headings: 1
           commentOnPreviousLine: 1
           par: 1
           blankLine: 1
           verbatim: 1
           filecontents: 1
           other: '\\\]|\\item(?:\h|\[)'      # regex
        blocksBeginWith:
           A-Z: 1
           a-z: 1
           0-9: 0
           other: 0                           # regex
        blocksEndBefore:
           commentOnOwnLine: 1
           verbatim: 1
           filecontents: 1
           other: '\\begin\{|\\\[|\\end\{'    # regex
        huge: overflow                        # forbid mid-word line breaks
        separator: ""

Full details are documented at https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch.html#text-wrapping and some details within https://github.com/cmhughes/latexindent.pl/issues/346

minor updates to defaultSettings.yaml

tabulararray is now supported by default, https://github.com/cmhughes/latexindent.pl/issues/343

V3.15

2 years ago

new feature: pre-commit now supported with latexindent.pl!

A massive thank you to @tdegeus for contributing this feature.

The feature is documented fully at https://latexindentpl.readthedocs.io/en/latest/sec-appendices.html#pre-commit; for reference see also https://github.com/cmhughes/latexindent.pl/pull/322 and https://github.com/cmhughes/latexindent.pl/issues/316

In brief, variations of the file .pre-commit-config.yaml in your .git repository as follows

- repo: https://github.com/cmhughes/latexindent.pl
  rev: V3.15
  hooks:
  - id: latexindent
    args: [-s]

and then running

pre-commit run --all-files

will run latexindent.pl on all .tex files in your repository. There's a supported option for conda users also. Full details at https://latexindentpl.readthedocs.io/en/latest/sec-appendices.html#pre-commit

V3.14

2 years ago

V3.13.5

2 years ago

latexindent-yaml-schema.json created and documented, discussion at issue 206.

V3.13.3

2 years ago

Minor updates:

  • fineTuning update following issue 307
  • lookForChildCodeBlocks in align at ampersand routine issue 308

V3.13.2

2 years ago

defaultSettings.yaml can (optionally) now be located in LatexIndent/ folder.

This was proposed in https://github.com/conda-forge/staged-recipes/pull/16914

V3.13.1

2 years ago

Upgrade to -y switch https://github.com/cmhughes/latexindent.pl/issues/296, and minor updates to documentation https://github.com/cmhughes/latexindent.pl/issues/299 and https://github.com/cmhughes/latexindent.pl/issues/300

Thank you to @XuehaiPan for their contribution.

V3.13

2 years ago

This release implements an upgrade to the verbatim blocks, and friends. Thank you to @XuehaiPan for this contribution. See https://github.com/cmhughes/latexindent.pl/issues/288 for discussion and history.

Summary

  1. Anything specified within noIndentBlock, verbatimEnvironments and verbatimCommands can now be specified in the form
verbatimEnvironments:
       nameAsRegex:
         name: '\w+code\*?' 
         lookForThis: 1

  1. the lookForThis field is optional, and if not present, will assumed to be 1 (this is consistent with other settings in the script)
  2. we have used nameAsRegex but it could be named as anything, for example, it could be named mintedalias
verbatimEnvironments:
       mintedalias:
         name: '\w+code\*?' 
         lookForThis: 1

  1. if the users code only contains \begin{pythoncode}...\end{pythoncode} then the above YAML settings is equivalent to
verbatimEnvironments:
       pythoncode: 1
  1. For noIndentBlock users can specify begin and end (both) or only name:

noIndentBlock:
  beginend:
    begin: regex_begin
    end: regex_end
    body: regex_body  # optional

  nameonly:
    name: regex_name
    body: regex_body  # optional

  # the above is equivalent to the follows when `regex_name` does not contain `'*'` and body is omitted
  regex_name: 1
  1. The following settings are examples of incomplete/conflicted settings, which will be ignored:
  # the followings are ignored
  none:  # incomplete settings, ignored
    lookForThis: 1

  beginonly:  # incomplete settings, ignored
    begin: regex_begin

  endonly:  # incomplete settings, ignored
    end: regex_end

  namebeginend:  # conflict settings, ignored
    begin: regex_begin
    end: regex_end
    name: regex_name

  namebegin:  # conflict settings, ignored
    begin: regex_begin
    name: regex_name

  nameend:  # conflict settings, ignored
    end: regex_end
    name: regex_name