Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erroneous Indentation at Paragraph Start and Failure to Wrap First Sentence after \item #521

Open
aaronpmishkin opened this issue Feb 21, 2024 · 3 comments
Labels
bug unexpected behaviour; should be a priority for fixing one-sentence-per-line one sentence per line; documented at https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch text-wrap text wrapping; documented at https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch.html

Comments

@aaronpmishkin
Copy link

I am trying to combine oneSentencePerLine with text wrapping using when: after, but have encountered two strange issues.

  1. When using when: after, five tabs are inserted before the first sentence following a blank line.

  2. The first sentence after an \item in an itemize or enumerate environment is not wrapped. This is true regardless of the value for when.

original .tex code

This is the first paragraph. We don't expect it to be indented, but we do expect each sentence to be placed on its own line and for long sentences to be wrapped at 79 characters. Hopefully it works properly.

This is the second paragraph. We don't expect it to be indented either, but for some reason five tabs are inserted at the very start of the paragraph. This unexpected behavior disappears if text wrapping is performed before code blocks are identified, but then indented blocks will not be properly wrapped at 79 characters.
Hopefully we can fix this by doing the following.
\begin{itemize}
    \item Oddly, while sentences are placed on new lines, the first sentence after the ``item'' command is not wrapped even if it is longer than 79 characters. The second sentence is properly wrapped, so many this has something to do with sentence identification after ``item'' commands. 
\end{itemize}

yaml settings

defaultIndent: '    '
preserveBlankLines: 1
condenseMultipleBlankLinesInto: 0
maxNumberOfBackUps: 9
modifyLineBreaks:
  environments:
    BeginStartsOnOwnLine: 1
    BodyStartsOnOwnLine: 1
    EndStartsOnOwnLine: 1
    EndFinishesWithLineBreak: 1
  oneSentencePerLine:
    manipulateSentences: 1
    removeSentenceLineBreaks: 1
    textWrapSentences: 1 
    sentencesFollow:
      par: 1
      blankLine: 1
      fullStop: 1
      exclamationMark: 1
      questionMark: 1
      rightBrace: 1
      commentOnPreviousLine: 1
    sentencesBeginWith:
      A-Z: 1
    sentencesEndWith:
      basicFullStop: 0
      betterFullStop: 1
      exclamationMark: 1
      questionMark: 1
  textWrapOptions:
    columns: 79
    when: after
    blocksFollow:
               other: |-
                 (?x)
                    \\\]
                    |
                    \\item(?:\h|\[)
                    |
                    \\caption\h*(?:\[\])?\h*\{ 

actual/given output

This is the first paragraph.
We don't expect it to be indented, but we do expect each sentence to be placed
on its own line and for long sentences to be wrapped at 79 characters.
Hopefully it works properly.

                   This is the second paragraph.
We don't expect it to be indented either, but for some reason five tabs are
inserted at the very start of the paragraph.
This unexpected behavior disappears if text wrapping is performed before code
blocks are identified, but then indented blocks will not be properly wrapped
at 79 characters.
Hopefully we can fix this by doing the following.
\begin{itemize}
    \item Oddly, while sentences are placed on new lines, the first sentence after the ``item'' command is not wrapped even if it is longer than 79 characters.
          The second sentence is properly wrapped, so many this has something
          to do with sentence identification after ``item'' commands.
\end{itemize}

desired or expected output

This is the first paragraph.
We don't expect it to be indented, but we do expect each sentence to be placed
on its own line and for long sentences to be wrapped at 79 characters.
Hopefully it works properly.

This is the second paragraph.
We don't expect it to be indented either, but for some reason five tabs are
inserted at the very start of the paragraph.
This unexpected behavior disappears if text wrapping is performed before code
blocks are identified, but then indented blocks will not be properly wrapped
at 79 characters.
Hopefully we can fix this.
\begin{itemize}
    \item Oddly, while sentences are placed on new lines , the first sentence
          after the ``item'' command is not wrapped even if it is longer than
          79 characters.
          The second sentence is properly wrapped, so maybe this has something
          to do with sentence identification after ``item'' commands.
\end{itemize}

anything else

Perhaps the first problem is an issue with my configuration. However, the default value

textWrapOptions:
  blocksFollow:
    other: \\\]|\\item(?:\h|\[)

makes me think that sentences after \item should automatically be identified as blocks to be wrapped. Is this correct?

As for the second problem, I expected the indentation to be the same regardless of the timing of text wrapping. My understanding is that when: after should change text wrapping to occur after indentation is handled, but leave indentation the same.

@aaronpmishkin aaronpmishkin changed the title Erroneous Indentation at Paragraph Start and Failure to Wrap First Sentence after \Item Erroneous Indentation at Paragraph Start and Failure to Wrap First Sentence after \item Feb 21, 2024
@cmhughes cmhughes added text-wrap text wrapping; documented at https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch.html one-sentence-per-line one sentence per line; documented at https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch labels Feb 24, 2024
@cmhughes
Copy link
Owner

Thanks for using the template. This looks like a bug... I'll investigate, not sure of the time line...

@aaronpmishkin
Copy link
Author

Many thanks! Let me know if I can provide any further information.

Cheers!

@cmhughes
Copy link
Owner

For my reference, the following YAML is minimal to reproduce the behaviour

defaultIndent: '    '
modifyLineBreaks:
  oneSentencePerLine:
    manipulateSentences: 1
    textWrapSentences: 1 
  textWrapOptions:
    columns: 79
    when: after

@cmhughes cmhughes added the bug unexpected behaviour; should be a priority for fixing label May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected behaviour; should be a priority for fixing one-sentence-per-line one sentence per line; documented at https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch text-wrap text wrapping; documented at https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch.html
Projects
None yet
Development

No branches or pull requests

2 participants