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

Don't ignore non-trivial lines with no indentation #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jberger
Copy link

@jberger jberger commented Jun 20, 2020

When using the removeIndentation setting globally and including whole
files, I notice that an odd thing happens. All code that is indented is
outdented by one level! On investigation, this is caused by ignoring
lines that begin without whitespace when computing the indentation level
to consider the base.

With this modified regex you still get the same result, ie a string of
leading whitespace, however a line without leading whitespace still
matches and the length of that result is 0. The trivial case of an
entirely blank line is also handled by including a zero-width forward
lookahead assertion that some non-whitespace character must occur after
the leading optional indentation in order for that line to be included
in the match.

When using the removeIndentation setting globally and including whole
files, I notice that an odd thing happens. All code that is indented is
outdented by one level! On investigation, this is caused by ignoring
lines that begin without whitespace when computing the indentation level
to consider the base.

With this modified regex you still get the same result, ie a string of
leading whitespace, however a line without leading whitespace still
matches and the length of that result is 0. The trivial case of an
entirely blank line is also handled by including a zero-width forward
lookahead assertion that some non-whitespace character must occur after
the leading optional indentation in order for that line to be included
in the match.
jberger added a commit to jberger/Mojolicious-Plugin-RevealJS that referenced this pull request Jun 20, 2020
this has been proposed as a PR upstream,
ldionne/reveal-sampler#14
@jberger
Copy link
Author

jberger commented Jun 20, 2020

If this is confusing, let me demonstrate:

one
  two
    three

currently becomes

one
two
  three

but with my patch it does the right thing, even if the full text is indented but contains an empty line

  two

    three

becomes

two

  three

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant