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

[packages/autoflow] Handles wrapping text around LaTeX tags #18168

Merged
merged 1 commit into from Jan 15, 2019

Conversation

Projects
None yet
3 participants
@isundaylee
Copy link
Contributor

isundaylee commented Oct 2, 2018

(This PR is a resubmission of atom/autoflow#68 now that autoflow is merged into the main atom repo.)

Issue or RFC Endorsed by Atom's Maintainers

atom/autoflow#68

Description of the Change

Currently, LaTeX tags that are placed next to the text would be wrapped together with the text. For example, the following text:

\begin{enumerate}[label=(\alph*)]
    \item{
        Lorem ipsum dolor sit amet, nisl odio amet, et tempor netus neque at at blandit, vel vestibulum libero dolor, semper lobortis ligula praesent. Eget condimentum integer, porta sagittis nam, fusce vitae a vitae augue. Nec semper quis sed ut, est porttitor praesent. Nisl velit quam dolore velit quam, elementum neque pellentesque pulvinar et vestibulum.
    }
\end{enumerate}

would be wrapped to

\begin{enumerate}[label=(\alph*)] \item{ Lorem ipsum dolor sit amet, nisl odio
amet, et tempor netus neque at at blandit, vel vestibulum libero dolor, semper
lobortis ligula praesent. Eget condimentum integer, porta sagittis nam, fusce
vitae a vitae augue. Nec semper quis sed ut, est porttitor praesent. Nisl velit
quam dolore velit quam, elementum neque pellentesque pulvinar et vestibulum. }
\end{enumerate}

whereas the expected result is

\begin{enumerate}[label=(\alph*)]
    \item{
        Lorem ipsum dolor sit amet, nisl odio amet, et tempor netus neque at at
        blandit, vel vestibulum libero dolor, semper lobortis ligula praesent.
        Eget condimentum integer, porta sagittis nam, fusce vitae a vitae augue.
        Nec semper quis sed ut, est porttitor praesent. Nisl velit quam dolore
        velit quam, elementum neque pellentesque pulvinar et vestibulum.
    }
\end{enumerate}

This PR changes the wrapping algorithm such that lines at the beginning and end of each paragraph that resemble LaTeX tags would be ignored for the purpose of wrapping. At the end of the wrapping process, they would be reproduced verbatim. This results in the expected result shown above.

This PR adds 3 test cases in spec/autoflow-spec.coffee that demonstrate and test the expected behavior.

Alternate Designs

N/A

Possible Drawbacks

The main drawback is the potential of non-LaTeX-tags being mis-detected as LaTeX tags, and therefore ignored from the wrapping process. To minimize this risk, the matching regular expressions are written to match the whole line using /^...$/g instead of any part of the line.

Verification Process

  • Added unit tests.
  • Ran the entire autoflow test suite.
  • Quick manual test on a LaTeX file and verified the expected behavior.
@lee-dohm

This comment has been minimized.

Copy link
Member

lee-dohm commented Oct 15, 2018

Thanks! We're going to take a look at this as soon as we can.

@smashwilson

This comment has been minimized.

Copy link
Member

smashwilson commented Jan 15, 2019

👍 LGTM. A Little LaTeX-specific but we already have a bunch of different language-specific commenting styles and such in autoflow so I think this fits.

@smashwilson smashwilson merged commit c3b8966 into atom:master Jan 15, 2019

3 checks passed

Atom Pull Requests #20181002.1 succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@isundaylee

This comment has been minimized.

Copy link
Contributor Author

isundaylee commented Jan 16, 2019

@lee-dohm @smashwilson Thanks for the review and merge! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.