Skip to content

Latest commit

 

History

History
436 lines (264 loc) · 14.3 KB

sec-fine-tuning.rst

File metadata and controls

436 lines (264 loc) · 14.3 KB

Fine tuning

latexindent.pl operates by looking for the code blocks detailed in tab:code-blocks. The fine tuning of the details of such code blocks is controlled by the fineTuning field, detailed in lst:fineTuning.

This field is for those that would like to peek under the bonnet/hood and make some fine tuning to latexindent.pl’s operating.

warning;fine tuning

regular expressions;fine tuning

regular expressions;environments

regular expressions;ifElseFi

regular expressions;commands

regular expressions;keyEqualsValuesBracesBrackets

regular expressions;NamedGroupingBracesBrackets

regular expressions;UnNamedGroupingBracesBrackets

regular expressions;arguments

regular expressions;modifyLineBreaks

regular expressions;lowercase alph a-z

regular expressions;uppercase alph A-Z

regular expressions;numeric 0-9

regular expressions;at least one +

Warning

Making changes to the fine tuning may have significant consequences for your indentation scheme, proceed with caution!

../defaultSettings.yaml

The fields given in lst:fineTuning are all regular expressions. This manual is not intended to be a tutorial on regular expressions; you might like to read, for example, (Friedl, n.d.) for a detailed covering of the topic.

We make the following comments with reference to lst:fineTuning:

  1. the environments:name field details that the name of an environment can contain:

    1. a-z lower case letters
    2. A-Z upper case letters
    3. @ the @ ’letter’
    4. \* stars
    5. 0-9 numbers
    6. _ underscores
    7. \ backslashes

    regular expressions;at least one +

    The + at the end means at least one of the above characters.

  2. the ifElseFi:name field:
    1. @? means that it can possibly begin with @
    2. followed by if
    3. followed by 0 or more characters from a-z, A-Z and @
    4. the ? the end means non-greedy, which means ‘stop the match as soon as possible’
  3. the keyEqualsValuesBracesBrackets contains some interesting syntax:
    1. | means ‘or’
    2. (?:(?<!\\)\{) the (?:...) uses a non-capturing group – you don’t necessarily need to worry about what this means, but just know that for the fineTuning feature you should only ever use non-capturing groups, and not capturing groups, which are simply (...)
    3. (?<!\\)\{) means a { but it can not be immediately preceded by a \
  4. in the arguments:before field
    1. \d\h* means a digit (i.e. a number), followed by 0 or more horizontal spaces
    2. ;?,? means possibly a semi-colon, and possibly a comma
    3. \<.*?\> is designed for ’beamer’-type commands; the .*? means anything in between <...>
  5. the modifyLineBreaks field refers to fine tuning settings detailed in sec:modifylinebreaks. In particular:
    1. betterFullStop is in relation to the one sentence per line routine, detailed in sec:onesentenceperline
    2. doubleBackSlash is in relation to the DBSStartsOnOwnLine and DBSFinishesWithLineBreak polyswitches surrounding double back slashes, see subsec:dbs
    3. comma is in relation to the CommaStartsOnOwnLine and CommaFinishesWithLineBreak polyswitches surrounding commas in optional and mandatory arguments; see tab:poly-switch-mapping

It is not obvious from lst:fineTuning, but each of the follow, before and between fields allow trailing comments, line breaks, and horizontal spaces between each character.

warning;capture groups

Warning

For the fineTuning feature you should only ever use non-capturing groups, such as (?:...) and not capturing groups, which are (...)

Friedl, Jeffrey E. F. n.d. Mastering Regular Expressions.