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
891 stars 84 forks source link

Environment text continues to wrap with textwrapoptions:environments:0 #211

Closed lsfinn closed 4 years ago

lsfinn commented 4 years ago

latexindent v3.8.2

My goal is to wrap text (one sentence per line), but not the body of environments. My understanding of the docs is that I accomplish this by enabling text wrapping while setting the appropriate environment options to 0, as in

modifyLineBreaks:
    oneSentencePerLine:
        manipulateSentences: 1
    textWrapOptions:
        columns: 75
        environments:
            quotation: 0
            align: 0
    environments:
        BeginStartsOnOwnLine: 1
        BodyStartsOnOwnLine: 1
        EndStartsOnOwnLine: 1
        EndFinishesWithLineBreak: 1

(store instructions in file my.yaml)

Applied to the file lorem.tex,

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer tempus viverra est sed tempor. Suspendisse sapien tellus, suscipit ut enim eu,
\begin{itemize}
    \item tempus iaculis mauris.
    \item Nulla facilisi.
\end{itemize}
Integer ut ornare ex.

Pellentesque tempor porttitor
\begin{align}
     nunc vitae lacinia.& Cras dapibus risus\\
     congue nibh ultricies&, sit amet ultricies\\
     sem tempor. Sed sed&
\end{align}
laoreet magna. Phasellus iaculis ante scelerisque urna scelerisque lobortis.

\begin{quotation}
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer tempus viverra est sed tempor. Suspendisse sapien tellus, suscipit ut enim eu,
\end{quotation}

via

latexindent -l=my.yaml -m -w -s lorem.tex

I find that text is continues to wrap in both the quotation and the align environments:

Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Integer tempus viverra est sed tempor.
Suspendisse sapien tellus, suscipit ut enim eu,
\begin{itemize}
  \item tempus iaculis mauris.
  \item Nulla facilisi.
\end{itemize}
Integer ut ornare ex.

Pellentesque tempor porttitor
\begin{align}
  nunc vitae lacinia.
                        & Cras dapibus risus   \\
  congue nibh ultricies & , sit amet ultricies \\
  sem tempor.
  Sed sed               &
\end{align}
laoreet magna.
Phasellus iaculis ante scelerisque urna scelerisque lobortis.

\begin{quotation}
  Lorem ipsum dolor sit amet, consectetur adipiscing elit.
  Integer tempus viverra est sed tempor.
  Suspendisse sapien tellus, suscipit ut enim eu,
\end{quotation}

Perhaps mistakenly I expect that the body of the quotation and align environments to be passed unmodified by the wrapping routines.

cmhughes commented 4 years ago

Thanks for this, I'll do my best to try to explain what's going on.

oneSentencePerLine

The oneSentencePerLine https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch.html#features-of-the-onesentenceperline-routine

The sentence manipulation routine takes place after verbatim environments, preamble and trailing comments have been accounted for; this means that any characters within these types of code blocks will not be part of the sentence manipulation routine.

Importantly, and perhaps the documentation should say this if it doesn't already, the oneSentencePerLine does not operate on a per-code-block basis. The oneSentencePerLine does not know about any other code blocks.

In relation to your example, Sed sed& \end{align} laoreet magna. is considered a sentence, and so Sed sed ... will start on its own line. Again, the oneSentencePerLine does not know about any other code blocks.

Perhaps this could/should change and perhaps it should be able to operate on a per-code-block basis...?

textWrapOptions

The text wrap routine can operate on a per-code-block basis. If we use the following YAML file:

modifyLineBreaks:
    textWrapOptions:
        columns: 75
        perCodeBlockBasis: 1
        all:
          except:
            - quotation
            - align

then we receive the following ouput:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer tempus
viverra est sed tempor. Suspendisse sapien tellus, suscipit ut enim eu,
\begin{itemize}
    \item tempus iaculis mauris.
    \item Nulla facilisi.
\end{itemize}
Integer ut ornare ex.

Pellentesque tempor porttitor
\begin{align}
    nunc vitae lacinia.   & Cras dapibus risus   \\
    congue nibh ultricies & , sit amet ultricies \\
    sem tempor. Sed sed   &
\end{align}
laoreet magna. Phasellus iaculis ante scelerisque urna scelerisque
lobortis.

\begin{quotation}
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer tempus viverra est sed tempor. Suspendisse sapien tellus, suscipit ut enim eu,
\end{quotation}

I hope this helps. Let me know.

lsfinn commented 4 years ago

Hi Chris -

Thanks much for such a rapid response.

Please check my new understanding here: textWrapOptions and oneSentencePerLine are entirely independent functions under the broader rubric of modifyLineBreaks. This was something I didn’t fully appreciate.

I seem, however, to have another problem. When I use the YAML file in your example with the input file provided I’m getting a different result than you are:

Lorem ipsum dolor
sit amet,
consectetur adipiscing
elit. Integer tempus
viverra est sed tempor. Suspendisse
sapien tellus, suscipit ut enim eu,
\begin{itemize}
        \item tempus iaculis mauris.
        \item Nulla facilisi.
\end{itemize}
Integer ut ornare ex.

Pellentesque tempor porttitor
\begin{align}
        nunc vitae lacinia.   & Cras dapibus risus   \\
        congue nibh ultricies & , sit amet ultricies \\
        sem tempor. Sed sed   &
\end{align}
laoreet magna. Phasellus iaculis ante scelerisque urna scelerisque
lobortis.

\begin{quotation}
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer tempus viverra est sed tempor. Suspendisse sapien tellus, suscipit ut enim eu,
\end{quotation}

In your results the text before the \begin{align} is wrapped; in my result, it is not.

I’ve checked that the YAML file you provided are the only modifications to the defaults.

Have you any thoughts on what might be going on here?

Thanks much,

Sam

cmhughes commented 4 years ago

Hi Sam, Thanks for the follow-up.

Please check my new understanding here: textWrapOptions and oneSentencePerLine are entirely independent functions under the broader rubric of modifyLineBreaks. This was something I didn’t fully appreciate.

Yes, that's correct. Perhaps I need to make the documentation clearer on this.

I confirm that the output I posted is still the same output that I receive. Explicitly, starting with:

lorem.tex

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer tempus viverra est sed tempor. Suspendisse sapien tellus, suscipit ut enim eu,
\begin{itemize}
    \item tempus iaculis mauris.
    \item Nulla facilisi.
\end{itemize}
Integer ut ornare ex.

Pellentesque tempor porttitor
\begin{align}
     nunc vitae lacinia.& Cras dapibus risus\\
     congue nibh ultricies&, sit amet ultricies\\
     sem tempor. Sed sed&
\end{align}
laoreet magna. Phasellus iaculis ante scelerisque urna scelerisque lobortis.

\begin{quotation}
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer tempus viverra est sed tempor. Suspendisse sapien tellus, suscipit ut enim eu,
\end{quotation}

and

cmh.yaml

modifyLineBreaks:
    textWrapOptions:
        columns: 75
        perCodeBlockBasis: 1
        all:
          except:
            - quotation
            - align

and running the command

latexindent.pl -m lorem.tex  -l cmh.yaml -o lorem-out

then I receive the output

lorem-out.tex

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer tempus
viverra est sed tempor. Suspendisse sapien tellus, suscipit ut enim eu,
\begin{itemize}
    \item tempus iaculis mauris.
    \item Nulla facilisi.
\end{itemize}
Integer ut ornare ex.

Pellentesque tempor porttitor
\begin{align}
    nunc vitae lacinia.   & Cras dapibus risus   \\
    congue nibh ultricies & , sit amet ultricies \\
    sem tempor. Sed sed   &
\end{align}
laoreet magna. Phasellus iaculis ante scelerisque urna scelerisque
lobortis.

\begin{quotation}
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer tempus viverra est sed tempor. Suspendisse sapien tellus, suscipit ut enim eu,
\end{quotation}

If your output is not as above, then do be sure to check your log file, indent.log.

Has this helped? Best Chris

lsfinn commented 4 years ago

Hmmm . . .

Still not reproducing your results:

cmh.yaml: modifyLineBreaks: textWrapOptions: columns: 75 perCodeBlockBasis: 1 all: except:

Running the command

latexindent.pl -m lorem.tex -l cmh.yaml -o lorem-out I receive the output

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer tempus viverra est sed tempor. Suspendisse sapien tellus, suscipit ut enim eu, \begin{itemize} \item tempus iaculis mauris. \item Nulla facilisi. \end{itemize} Integer ut ornare ex.

Pellentesque tempor porttitor \begin{align} nunc vitae lacinia. & Cras dapibus risus \ congue nibh ultricies & , sit amet ultricies \ sem tempor. Sed sed & \end{align} laoreet magna. Phasellus iaculis ante scelerisque urna scelerisque lobortis.

\begin{quotation} Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer tempus viverra est sed tempor. Suspendisse sapien tellus, suscipit ut enim eu, \end{quotation}

The indent.log file does not show anything amiss:

INFO: latexindent.pl version 3.8.2, 2020-06-10, a script to indent .tex files latexindent.pl lives here: /Users/lsfinn/Documents/Repositories/git/Vendor/latexindent/ Sun Jul 26 14:26:56 2020 Filename: lorem.def INFO: Processing switches: -l|--localSettings: Read localSettings YAML file -o|--outputfile: output to file -m|--modifylinebreaks: modify line breaks INFO: Directory for backup files and indent.log: . INFO: Perl modules are being loaded from the following directories: /opt/local/lib/perl5/5.28/FindBin.pm /opt/local/lib/perl5/site_perl/5.28/YAML/Tiny.pm /opt/local/lib/perl5/5.28/File/Copy.pm /opt/local/lib/perl5/5.28/File/Basename.pm /opt/local/lib/perl5/5.28/Getopt/Long.pm /opt/local/lib/perl5/site_perl/5.28/File/HomeDir.pm /opt/local/lib/perl5/site_perl/5.28/darwin-thread-multi-2level/Unicode/GCString.pm /opt/local/lib/perl5/site_perl/5.28/Log/Log4perl.pm INFO: Latex Indent perl modules are being loaded from, for example: /Users/lsfinn/Documents/Repositories/git/Vendor/latexindent/LatexIndent/Document.pm INFO: YAML settings read: defaultSettings.yaml Reading defaultSettings.yaml from /Users/lsfinn/Documents/Repositories/git/Vendor/latexindent/defaultSettings.yaml INFO: YAML settings read: indentconfig.yaml or .indentconfig.yaml Home directory is /Users/lsfinn (didn't find either indentconfig.yaml or .indentconfig.yaml) To specify user settings you would put indentconfig.yaml here: /Users/lsfinn/indentconfig.yaml Alternatively, you can use the hidden file .indentconfig.yaml as: /Users/lsfinn/.indentconfig.yaml INFO: YAML settings read: -l switch Adding cmh.yaml to YAML read paths INFO: YAML settings, reading from the following files: Reading USER settings from cmh.yaml

  modifyLineBreaks:
    textWrapOptions:
      all:
        except:
          - quotation
          - align
      columns: '75'
      perCodeBlockBasis: '1'

INFO: -o switch active: output file check -o switch called with file name without extension: lorem.out Updated to lorem.out.def as the file extension of the input file is def INFO: Phase 1: searching for objects INFO: Phase 2: finding surrounding indentation INFO: Phase 3: indenting objects INFO: Phase 4: final indentation check INFO: Output routine: Outputting to file lorem.out.def

INFO: Please direct all communication/issues to: https://github.com/cmhughes/latexindent.pl

I do recover the same results you quote if I add

modifyLineBreaks: removeParagraphLineBreaks: all: 1

Is there perhaps a difference in other default files?

Thanks,

Sam

— Sam Finn lsfinn@gmail.com

On Jul 26, 2020, at 1:29 PM, Chris Hughes notifications@github.com wrote:

Hi Sam, Thanks for the follow-up.

Please check my new understanding here: textWrapOptions and oneSentencePerLine are entirely independent functions under the broader rubric of modifyLineBreaks. This was something I didn’t fully appreciate.

Yes, that's correct. Perhaps I need to make the documentation clearer on this.

I confirm that the output I posted is still the same output that I receive. Explicitly, starting with:

lorem.tex

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer tempus viverra est sed tempor. Suspendisse sapien tellus, suscipit ut enim eu, \begin{itemize} \item tempus iaculis mauris. \item Nulla facilisi. \end{itemize} Integer ut ornare ex.

Pellentesque tempor porttitor \begin{align} nunc vitae lacinia.& Cras dapibus risus\ congue nibh ultricies&, sit amet ultricies\ sem tempor. Sed sed& \end{align} laoreet magna. Phasellus iaculis ante scelerisque urna scelerisque lobortis.

\begin{quotation} Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer tempus viverra est sed tempor. Suspendisse sapien tellus, suscipit ut enim eu, \end{quotation} and

cmh.yaml

modifyLineBreaks: textWrapOptions: columns: 75 perCodeBlockBasis: 1 all: except:

  • quotation
  • align and running the command

latexindent.pl -m lorem.tex -l cmh.yaml -o lorem-out then I receive the output

lorem-out.tex

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer tempus viverra est sed tempor. Suspendisse sapien tellus, suscipit ut enim eu, \begin{itemize} \item tempus iaculis mauris. \item Nulla facilisi. \end{itemize} Integer ut ornare ex.

Pellentesque tempor porttitor \begin{align} nunc vitae lacinia. & Cras dapibus risus \ congue nibh ultricies & , sit amet ultricies \ sem tempor. Sed sed & \end{align} laoreet magna. Phasellus iaculis ante scelerisque urna scelerisque lobortis.

\begin{quotation} Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer tempus viverra est sed tempor. Suspendisse sapien tellus, suscipit ut enim eu, \end{quotation} If your output is not as above, then do be sure to check your log file, indent.log.

Has this helped? Best Chris

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cmhughes/latexindent.pl/issues/211#issuecomment-664030315, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHAVLL4A5VHT66GLSRKBRLR5R73BANCNFSM4PHIJBYA.

cmhughes commented 4 years ago

Can you add showAmalgamatedSettings: 1 as shown in the following

https://latexindentpl.readthedocs.io/en/latest/sec-default-user-local.html#lst-logfilepreferences

And then repost your log file?

lsfinn commented 4 years ago

Following your instructions here’s the new log file:

INFO: latexindent version 3.8.2, 2020-06-10, a script to indent .tex files latexindent lives here: /usr/local/texlive/2020/texmf-dist/scripts/latexindent/ Tue Jul 28 11:56:53 2020 Filename: lorem.tex INFO: Processing switches: -l|--localSettings: Read localSettings YAML file -o|--outputfile: output to file -m|--modifylinebreaks: modify line breaks INFO: Directory for backup files and indent.log: . INFO: YAML settings read: defaultSettings.yaml Reading defaultSettings.yaml from /usr/local/texlive/2020/texmf-dist/scripts/latexindent/defaultSettings.yaml INFO: YAML settings read: indentconfig.yaml or .indentconfig.yaml Home directory is /Users/lsfinn (didn't find either indentconfig.yaml or .indentconfig.yaml) To specify user settings you would put indentconfig.yaml here: /Users/lsfinn/indentconfig.yaml Alternatively, you can use the hidden file .indentconfig.yaml as: /Users/lsfinn/.indentconfig.yaml INFO: YAML settings read: -l switch Adding cmh.yaml to YAML read paths INFO: YAML settings, reading from the following files: Reading USER settings from cmh.yaml

  logFilePreferences:
    showAmalgamatedSettings: '1'
  modifyLineBreaks:
    textWrapOptions:
      all:
        except:
          - quotation
          - align
      columns: '75'
      perCodeBlockBasis: '1'

  Amalgamated/overall settings to be used:
  ---
  backupExtension: .bak
  commandCodeBlocks:
    commandNameSpecial:
      -
        amalgamate: '1'
      - '@ifnextchar\['
    roundParenthesesAllowed: '1'
    stringsAllowedBetweenArguments:
      -
        amalgamate: '1'
      - node
      - at
      - to
      - decoration
      - \+\+
      - \-\-
  cycleThroughBackUps: '0'
  defaultIndent: "\t"
  fileContentsEnvironments:
    filecontents: '1'
    filecontents*: '1'
  fileExtensionPreference:
    .bib: '4'
    .cls: '3'
    .sty: '2'
    .tex: '1'
  fineTuning:
    NamedGroupingBracesBrackets:
      follow: \h|\R|\{|\[|\$|\)|\(
      name: '[0-9\.a-zA-Z@\*><]+?'
    UnNamedGroupingBracesBrackets:
      follow: \{|\[|,|&|\)|\(|\$
    arguments:
      before: (?:#\d\h*;?,?\/?)+|\<.*?\>
      between: _|\^|\*
    commands:
      name: '[+a-zA-Z@\*0-9_\:]+?'
    environments:
      name: '[a-zA-Z@\*0-9_\\]+'
    ifElseFi:
      name: '@?if[a-zA-Z@]*?'
    keyEqualsValuesBracesBrackets:
      follow: (?:(?<!\\)\{)|,|(?:(?<!\\)\[)
      name: '[a-zA-Z@\*0-9_\/.\h\{\}:\#-]+?'
    modifyLineBreaks:
      betterFullStop: (?:\.\)(?!\h*[a-z]))|(?:(?<!(?:(?:e\.g)|(?:i\.e)|(?:etc))))\.(?!(?:[a-z]|[A-Z]|\-|~|\,|[0-9]))
      comma: ','
      doubleBackSlash: \\\\(?:\h*\[\h*\d+\h*[a-zA-Z]+\h*\])?
  indentAfterHeadings:
    chapter:
      indentAfterThisHeading: '0'
      level: '2'
    paragraph:
      indentAfterThisHeading: '0'
      level: '6'
    part:
      indentAfterThisHeading: '0'
      level: '1'
    section:
      indentAfterThisHeading: '0'
      level: '3'
    subparagraph:
      indentAfterThisHeading: '0'
      level: '7'
    subsection:
      indentAfterThisHeading: '0'
      level: '4'
    subsection*:
      indentAfterThisHeading: '0'
      level: '4'
    subsubsection:
      indentAfterThisHeading: '0'
      level: '5'
  indentAfterItems:
    description: '1'
    enumerate: '1'
    itemize: '1'
    list: '1'
  indentPreamble: '0'
  indentRules:
    anotherenvironment: "\t\t\t\t"
    chapter: ' '
    item: '      '
    myenvironment: "\t\t"
    myitem: '        '
    section: ' '
  indentRulesGlobal:
    UnNamedGroupingBracesBrackets: '0'
    afterHeading: '0'
    commands: '0'
    environments: '0'
    filecontents: '0'
    ifElseFi: '0'
    items: '0'
    keyEqualsValuesBracesBrackets: '0'
    mandatoryArguments: '0'
    namedGroupingBracesBrackets: '0'
    optionalArguments: '0'
    specialBeginEnd: '0'
  itemNames:
    item: '1'
    myitem: '1'
  logFilePreferences:
    PatternLayout:
      default: '%A%n'
      trace: '%A%n'
      ttrace: '%A%n'
    endLogFileWith: '--------------'
    showAmalgamatedSettings: '1'
    showDecorationFinishCodeBlockTrace: '0'
    showDecorationStartCodeBlockTrace: '0'
    showEveryYamlRead: '1'
    showGitHubInfoFooter: '1'
  lookForAlignDelims:
    Bmatrix: '1'
    Vmatrix: '1'
    align: '1'
    align*: '1'
    alignat: '1'
    alignat*: '1'
    aligned: '1'
    array: '1'
    bmatrix: '1'
    cases: '1'
    dcases: '1'
    listabla: '1'
    longtable: '1'
    matrix: '1'
    pmatrix: '1'
    tabu: '1'
    tabular:
      alignDoubleBackSlash: '1'
      alignFinalDoubleBackSlash: '0'
      alignRowsWithoutMaxDelims: '1'
      delimiterJustification: left
      delimiterRegEx: (?<!\\)(&)
      delims: '1'
      dontMeasure: '0'
      justification: left
      multiColumnGrouping: '0'
      spacesAfterAmpersand: '1'
      spacesBeforeAmpersand: '1'
      spacesBeforeDoubleBackSlash: '1'
    tabularx:
      delims: '1'
    vmatrix: '1'
  lookForPreamble:
    .bib: '0'
    .cls: '0'
    .sty: '0'
    .tex: '1'
  maxNumberOfBackUps: '0'
  maximumIndentation: '-1'
  modifyLineBreaks:
    commands:
      CommandNameFinishesWithLineBreak: '0'
      CommandStartsOnOwnLine: '0'
    condenseMultipleBlankLinesInto: '1'
    environments:
      BeginStartsOnOwnLine: '0'
      BodyStartsOnOwnLine: '0'
      EndFinishesWithLineBreak: '0'
      EndStartsOnOwnLine: '0'
      equation*:
        BeginStartsOnOwnLine: '0'
        BodyStartsOnOwnLine: '0'
        EndFinishesWithLineBreak: '0'
        EndStartsOnOwnLine: '0'
    ifElseFi:
      BodyStartsOnOwnLine: '0'
      ElseFinishesWithLineBreak: '0'
      ElseStartsOnOwnLine: '0'
      FiFinishesWithLineBreak: '0'
      FiStartsOnOwnLine: '0'
      IfStartsOnOwnLine: '0'
      OrFinishesWithLineBreak: '0'
      OrStartsOnOwnLine: '0'
      ifnum:
        BodyStartsOnOwnLine: '0'
        ElseFinishesWithLineBreak: '0'
        ElseStartsOnOwnLine: '0'
        FiFinishesWithLineBreak: '0'
        FiStartsOnOwnLine: '0'
        IfStartsOnOwnLine: '0'
        OrFinishesWithLineBreak: '0'
        OrStartsOnOwnLine: '0'
    items:
      ItemFinishesWithLineBreak: '0'
      ItemStartsOnOwnLine: '0'
    keyEqualsValuesBracesBrackets:
      EqualsFinishesWithLineBreak: '0'
      EqualsStartsOnOwnLine: '0'
      KeyStartsOnOwnLine: '0'
    mandatoryArguments:
      LCuBStartsOnOwnLine: '0'
      MandArgBodyStartsOnOwnLine: '0'
      RCuBFinishesWithLineBreak: '0'
      RCuBStartsOnOwnLine: '0'
    namedGroupingBracesBrackets:
      NameFinishesWithLineBreak: '0'
      NameStartsOnOwnLine: '0'
    oneSentencePerLine:
      manipulateSentences: '0'
      removeSentenceLineBreaks: '1'
      sentenceIndent: ''
      sentencesBeginWith:
        A-Z: '1'
        a-z: '0'
        other: '0'
      sentencesEndWith:
        basicFullStop: '0'
        betterFullStop: '1'
        exclamationMark: '1'
        other: '0'
        questionMark: '1'
      sentencesFollow:
        blankLine: '1'
        commentOnPreviousLine: '1'
        exclamationMark: '1'
        fullStop: '1'
        other: '0'
        par: '1'
        questionMark: '1'
        rightBrace: '1'
      textWrapSentences: '0'
    optionalArguments:
      LSqBStartsOnOwnLine: '0'
      OptArgBodyStartsOnOwnLine: '0'
      RSqBFinishesWithLineBreak: '0'
      RSqBStartsOnOwnLine: '0'
    preserveBlankLines: '1'
    removeParagraphLineBreaks:
      afterHeading: '0'
      alignAtAmpersandTakesPriority: '1'
      all: '0'
      beforeTextWrap: '0'
      environments:

— Sam Finn lsfinn@gmail.com

cmhughes commented 4 years ago

Thanks for that, Sam. I don't see any differences between yours and mine.

Let's continue to strip this down. Starting with

lorem-mwe.tex

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer tempus viverra est sed tempor. Suspendisse sapien tellus, suscipit ut enim eu,

and

sam.yaml

modifyLineBreaks:
    textWrapOptions:
        columns: 75
        perCodeBlockBasis: 1
        all:
          except:
            - quotation
            - align

logFilePreferences:
    showEveryYamlRead: 1
    showAmalgamatedSettings: 1

and running

latexindent.pl -m lorem.tex -l sam.yaml -o lorem-out

then I receive

lorem-out.tex

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer tempus
viverra est sed tempor. Suspendisse sapien tellus, suscipit ut enim eu,

Would you like to try the above and report back?

lsfinn commented 4 years ago

Hi Chris -

On this we agree:

Lorem-out.tex: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer tempus viverra est sed tempor. Suspendisse sapien tellus, suscipit ut enim eu,

and indent.log:

INFO: latexindent version 3.8.2, 2020-06-10, a script to indent .tex files latexindent lives here: /usr/local/texlive/2020/texmf-dist/scripts/latexindent/ Sat Aug 1 11:05:07 2020 Filename: lorem-mwe.tex INFO: Processing switches: -l|--localSettings: Read localSettings YAML file -o|--outputfile: output to file -m|--modifylinebreaks: modify line breaks INFO: Directory for backup files and indent.log: . INFO: YAML settings read: defaultSettings.yaml Reading defaultSettings.yaml from /usr/local/texlive/2020/texmf-dist/scripts/latexindent/defaultSettings.yaml INFO: YAML settings read: indentconfig.yaml or .indentconfig.yaml Home directory is /Users/lsfinn (didn't find either indentconfig.yaml or .indentconfig.yaml) To specify user settings you would put indentconfig.yaml here: /Users/lsfinn/indentconfig.yaml Alternatively, you can use the hidden file .indentconfig.yaml as: /Users/lsfinn/.indentconfig.yaml INFO: YAML settings read: -l switch Adding sam.yaml to YAML read paths INFO: YAML settings, reading from the following files: Reading USER settings from sam.yaml

  logFilePreferences:
    showAmalgamatedSettings: '1'
    showEveryYamlRead: '1'
  modifyLineBreaks:
    textWrapOptions:
      all:
        except:
          - quotation
          - align
      columns: '75'
      perCodeBlockBasis: '1'

  Amalgamated/overall settings to be used:
  ---
  backupExtension: .bak
  commandCodeBlocks:
    commandNameSpecial:
      -
        amalgamate: '1'
      - '@ifnextchar\['
    roundParenthesesAllowed: '1'
    stringsAllowedBetweenArguments:
      -
        amalgamate: '1'
      - node
      - at
      - to
      - decoration
      - \+\+
      - \-\-
  cycleThroughBackUps: '0'
  defaultIndent: "\t"
  fileContentsEnvironments:
    filecontents: '1'
    filecontents*: '1'
  fileExtensionPreference:
    .bib: '4'
    .cls: '3'
    .sty: '2'
    .tex: '1'
  fineTuning:
    NamedGroupingBracesBrackets:
      follow: \h|\R|\{|\[|\$|\)|\(
      name: '[0-9\.a-zA-Z@\*><]+?'
    UnNamedGroupingBracesBrackets:
      follow: \{|\[|,|&|\)|\(|\$
    arguments:
      before: (?:#\d\h*;?,?\/?)+|\<.*?\>
      between: _|\^|\*
    commands:
      name: '[+a-zA-Z@\*0-9_\:]+?'
    environments:
      name: '[a-zA-Z@\*0-9_\\]+'
    ifElseFi:
      name: '@?if[a-zA-Z@]*?'
    keyEqualsValuesBracesBrackets:
      follow: (?:(?<!\\)\{)|,|(?:(?<!\\)\[)
      name: '[a-zA-Z@\*0-9_\/.\h\{\}:\#-]+?'
    modifyLineBreaks:
      betterFullStop: (?:\.\)(?!\h*[a-z]))|(?:(?<!(?:(?:e\.g)|(?:i\.e)|(?:etc))))\.(?!(?:[a-z]|[A-Z]|\-|~|\,|[0-9]))
      comma: ','
      doubleBackSlash: \\\\(?:\h*\[\h*\d+\h*[a-zA-Z]+\h*\])?
  indentAfterHeadings:
    chapter:
      indentAfterThisHeading: '0'
      level: '2'
    paragraph:
      indentAfterThisHeading: '0'
      level: '6'
    part:
      indentAfterThisHeading: '0'
      level: '1'
    section:
      indentAfterThisHeading: '0'
      level: '3'
    subparagraph:
      indentAfterThisHeading: '0'
      level: '7'
    subsection:
      indentAfterThisHeading: '0'
      level: '4'
    subsection*:
      indentAfterThisHeading: '0'
      level: '4'
    subsubsection:
      indentAfterThisHeading: '0'
      level: '5'
  indentAfterItems:
    description: '1'
    enumerate: '1'
    itemize: '1'
    list: '1'
  indentPreamble: '0'
  indentRules:
    anotherenvironment: "\t\t\t\t"
    chapter: ' '
    item: '      '
    myenvironment: "\t\t"
    myitem: '        '
    section: ' '
  indentRulesGlobal:
    UnNamedGroupingBracesBrackets: '0'
    afterHeading: '0'
    commands: '0'
    environments: '0'
    filecontents: '0'
    ifElseFi: '0'
    items: '0'
    keyEqualsValuesBracesBrackets: '0'
    mandatoryArguments: '0'
    namedGroupingBracesBrackets: '0'
    optionalArguments: '0'
    specialBeginEnd: '0'
  itemNames:
    item: '1'
    myitem: '1'
  logFilePreferences:
    PatternLayout:
      default: '%A%n'
      trace: '%A%n'
      ttrace: '%A%n'
    endLogFileWith: '--------------'
    showAmalgamatedSettings: '1'
    showDecorationFinishCodeBlockTrace: '0'
    showDecorationStartCodeBlockTrace: '0'
    showEveryYamlRead: '1'
    showGitHubInfoFooter: '1'
  lookForAlignDelims:
    Bmatrix: '1'
    Vmatrix: '1'
    align: '1'
    align*: '1'
    alignat: '1'
    alignat*: '1'
    aligned: '1'
    array: '1'
    bmatrix: '1'
    cases: '1'
    dcases: '1'
    listabla: '1'
    longtable: '1'
    matrix: '1'
    pmatrix: '1'
    tabu: '1'
    tabular:
      alignDoubleBackSlash: '1'
      alignFinalDoubleBackSlash: '0'
      alignRowsWithoutMaxDelims: '1'
      delimiterJustification: left
      delimiterRegEx: (?<!\\)(&)
      delims: '1'
      dontMeasure: '0'
      justification: left
      multiColumnGrouping: '0'
      spacesAfterAmpersand: '1'
      spacesBeforeAmpersand: '1'
      spacesBeforeDoubleBackSlash: '1'
    tabularx:
      delims: '1'
    vmatrix: '1'
  lookForPreamble:
    .bib: '0'
    .cls: '0'
    .sty: '0'
    .tex: '1'
  maxNumberOfBackUps: '0'
  maximumIndentation: '-1'
  modifyLineBreaks:
    commands:
      CommandNameFinishesWithLineBreak: '0'
      CommandStartsOnOwnLine: '0'
    condenseMultipleBlankLinesInto: '1'
    environments:
      BeginStartsOnOwnLine: '0'
      BodyStartsOnOwnLine: '0'
      EndFinishesWithLineBreak: '0'
      EndStartsOnOwnLine: '0'
      equation*:
        BeginStartsOnOwnLine: '0'
        BodyStartsOnOwnLine: '0'
        EndFinishesWithLineBreak: '0'
        EndStartsOnOwnLine: '0'
    ifElseFi:
      BodyStartsOnOwnLine: '0'
      ElseFinishesWithLineBreak: '0'
      ElseStartsOnOwnLine: '0'
      FiFinishesWithLineBreak: '0'
      FiStartsOnOwnLine: '0'
      IfStartsOnOwnLine: '0'
      OrFinishesWithLineBreak: '0'
      OrStartsOnOwnLine: '0'
      ifnum:
        BodyStartsOnOwnLine: '0'
        ElseFinishesWithLineBreak: '0'
        ElseStartsOnOwnLine: '0'
        FiFinishesWithLineBreak: '0'
        FiStartsOnOwnLine: '0'
        IfStartsOnOwnLine: '0'
        OrFinishesWithLineBreak: '0'
        OrStartsOnOwnLine: '0'
    items:
      ItemFinishesWithLineBreak: '0'
      ItemStartsOnOwnLine: '0'
    keyEqualsValuesBracesBrackets:
      EqualsFinishesWithLineBreak: '0'
      EqualsStartsOnOwnLine: '0'
      KeyStartsOnOwnLine: '0'
    mandatoryArguments:
      LCuBStartsOnOwnLine: '0'
      MandArgBodyStartsOnOwnLine: '0'
      RCuBFinishesWithLineBreak: '0'
      RCuBStartsOnOwnLine: '0'
    namedGroupingBracesBrackets:
      NameFinishesWithLineBreak: '0'
      NameStartsOnOwnLine: '0'
    oneSentencePerLine:
      manipulateSentences: '0'
      removeSentenceLineBreaks: '1'
      sentenceIndent: ''
      sentencesBeginWith:
        A-Z: '1'
        a-z: '0'
        other: '0'
      sentencesEndWith:
        basicFullStop: '0'
        betterFullStop: '1'
        exclamationMark: '1'
        other: '0'
        questionMark: '1'
      sentencesFollow:
        blankLine: '1'
        commentOnPreviousLine: '1'
        exclamationMark: '1'
        fullStop: '1'
        other: '0'
        par: '1'
        questionMark: '1'
        rightBrace: '1'
      textWrapSentences: '0'
    optionalArguments:
      LSqBStartsOnOwnLine: '0'
      OptArgBodyStartsOnOwnLine: '0'
      RSqBFinishesWithLineBreak: '0'
      RSqBStartsOnOwnLine: '0'
    preserveBlankLines: '1'
    removeParagraphLineBreaks:
      afterHeading: '0'
      alignAtAmpersandTakesPriority: '1'
      all: '0'
      beforeTextWrap: '0'
      environments:
        quotation: '0'
      filecontents: '0'
      ifElseFi: '0'
      items: '0'
      mandatoryArguments: '0'
      masterDocument: '0'
      optionalArguments: '0'
      paragraphsStopAt:
        commands: '0'
        comments: '0'
        environments: '1'
        filecontents: '0'
        heading: '0'
        ifElseFi: '0'
        items: '0'
        specialBeginEnd: '0'
        verbatim: '1'
      preamble: '0'
      specialBeginEnd: '0'
    specialBeginEnd:
      SpecialBeginStartsOnOwnLine: '0'
      SpecialBodyStartsOnOwnLine: '0'
      SpecialEndFinishesWithLineBreak: '0'
      SpecialEndStartsOnOwnLine: '0'
    textWrapOptions:
      afterHeading: '0'
      alignAtAmpersandTakesPriority: '1'
      all:
        except:
          - quotation
          - align
      columns: '75'
      environments:
        quotation: '0'
      filecontents: '0'
      ifElseFi: '0'
      items: '0'
      mandatoryArguments: '0'
      masterDocument: '0'
      optionalArguments: '0'
      perCodeBlockBasis: '1'
      preamble: '0'
      separator: ''
      specialBeginEnd: '0'
    verbatim:
      VerbatimBeginStartsOnOwnLine: '0'
      VerbatimEndFinishesWithLineBreak: '0'
  noAdditionalIndent:
    comment: '1'
    document: '1'
    exercises: '1'
    foreach: '0'
    frame: '0'
    mydefinition: '1'
    myexample: '1'
    mysolution: '1'
    problem: '1'
    widepage: '1'
  noAdditionalIndentGlobal:
    UnNamedGroupingBracesBrackets: '0'
    afterHeading: '0'
    commands: '1'
    environments: '0'
    filecontents: '0'
    ifElseFi: '0'
    items: '0'
    keyEqualsValuesBracesBrackets: '0'
    mandatoryArguments: '0'
    namedGroupingBracesBrackets: '0'
    optionalArguments: '0'
    specialBeginEnd: '0'
  noIndentBlock:
    cmhtest: '1'
    noindent: '1'
  onlyOneBackUp: '0'
  preambleCommandsBeforeEnvironments: '0'
  removeTrailingWhitespace:
    afterProcessing: '1'
    beforeProcessing: '0'
  replacements:
    -
      amalgamate: '1'
    -
      lookForThis: '1'
      that: pl.latexindent
      this: latexindent.pl
      when: before
  specialBeginEnd:
    displayMath:
      begin: \\\[
      end: \\\]
      lookForThis: '1'
    displayMathTeX:
      begin: \$\$
      end: \$\$
      lookForThis: '1'
    inlineMath:
      begin: (?<!\$)(?<!\\)\$(?!\$)
      end: (?<!\\)\$(?!\$)
      lookForThis: '1'
    specialBeforeCommand: '0'
  verbatimCommands:
    lstinline: '1'
    verb: '1'
  verbatimEnvironments:
    lstlisting: '1'
    minted: '1'
    verbatim: '1'

INFO: -o switch active: output file check -o switch called with file name without extension: lorem-out Updated to lorem-out.tex as the file extension of the input file is tex INFO: Phase 1: searching for objects INFO: Phase 2: finding surrounding indentation INFO: Phase 3: indenting objects INFO: Phase 4: final indentation check INFO: Output routine: Outputting to file lorem-out.tex

INFO: Please direct all communication/issues to: https://github.com/cmhughes/latexindent.pl — Sam Finn lsfinn@gmail.com

On Aug 1, 2020, at 12:54 AM, Chris Hughes notifications@github.com wrote:

Thanks for that, Sam. I don't see any differences between yours and mine.

Let's continue to strip this down. Starting with

lorem-mwe.tex

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer tempus viverra est sed tempor. Suspendisse sapien tellus, suscipit ut enim eu,

and

sam.yaml

modifyLineBreaks: textWrapOptions: columns: 75 perCodeBlockBasis: 1 all: except:

  • quotation
  • align

logFilePreferences: showEveryYamlRead: 1 showAmalgamatedSettings: 1 and running

latexindent.pl -m lorem.tex -l sam.yaml -o lorem-out then I receive

lorem-out.tex

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer tempus viverra est sed tempor. Suspendisse sapien tellus, suscipit ut enim eu, Would you like to try the above and report back?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cmhughes/latexindent.pl/issues/211#issuecomment-667484425, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHAVLJ3IRVW2PMJU6EMNLLR6O33JANCNFSM4PHIJBYA.

cmhughes commented 4 years ago

Hi Sam, Ok, that's good news.

Can you add little bits at a time, building up to your original example to see at which point your output diverges from mine?

Best Chris

lsfinn commented 4 years ago

Hi Chris,

My original example had the first para broken into a series of short lines, which I expected to be wrapped to the designated column length. Your revision removed the line breaks to form a single long line, which was wrapped. That is the distinction.

Based on this it seems I was wrong in my presumption that text wrapping worked both ways: i.e., always moving line breaks so that successive lines as close to, but less than, columns as possible.

If my new understanding - that text wrapping only addresses lines longer than columns - is correct, then I think we can close this out. If, however, text wrapping should address lines that are both longer and shorter than columns, then we’ll need to continue to track this down.

Let me know - and, thanks!

Sam

— Sam Finn lsfinn@gmail.com

On Aug 1, 2020, at 3:31 PM, Chris Hughes notifications@github.com wrote:

Hi Sam, Ok, that's good news.

Can you add little bits at a time, building up to your original example to see at which point your output diverges from mine?

Best Chris

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cmhughes/latexindent.pl/issues/211#issuecomment-667589581, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHAVLPKSI6T6EKJNOIJSE3R6SCRVANCNFSM4PHIJBYA.

cmhughes commented 4 years ago

Hi Sam, Many thanks for this, it's helpful. I'm sorry it has taken so long to get to the bottom of it.

Yes, I think your description is accurate, and is part of the reason why the remove paragraph line break feature exists.

I think a relevant part of the documentation is:

https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch.html#combining-removeparagraphlinebreaks-and-textwrapoptions

See what you think, and let me know,

All the best Chris

On Mon, 3 Aug 2020, 18:29 Sam Finn, notifications@github.com wrote:

Hi Chris,

My original example had the first para broken into a series of short lines, which I expected to be wrapped to the designated column length. Your revision removed the line breaks to form a single long line, which was wrapped. That is the distinction.

Based on this it seems I was wrong in my presumption that text wrapping worked both ways: i.e., always moving line breaks so that successive lines as close to, but less than, columns as possible.

If my new understanding - that text wrapping only addresses lines longer than columns - is correct, then I think we can close this out. If, however, text wrapping should address lines that are both longer and shorter than columns, then we’ll need to continue to track this down.

Let me know - and, thanks!

Sam

— Sam Finn lsfinn@gmail.com

On Aug 1, 2020, at 3:31 PM, Chris Hughes notifications@github.com wrote:

Hi Sam, Ok, that's good news.

Can you add little bits at a time, building up to your original example to see at which point your output diverges from mine?

Best Chris

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/cmhughes/latexindent.pl/issues/211#issuecomment-667589581>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AAHAVLPKSI6T6EKJNOIJSE3R6SCRVANCNFSM4PHIJBYA .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cmhughes/latexindent.pl/issues/211#issuecomment-668146285, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ7CYBNBZSXFUAHSVFTK6DR63XXDANCNFSM4PHIJBYA .