Page MenuHomePhabricator

In remarkup, strip one leading space from each line in a quoted block if possible
ClosedPublic

Authored by epriestley on Mar 26 2019, 8:40 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Dec 2, 10:37 AM
Unknown Object (File)
Thu, Nov 28, 3:25 PM
Unknown Object (File)
Thu, Nov 28, 4:20 AM
Unknown Object (File)
Tue, Nov 26, 6:15 AM
Unknown Object (File)
Tue, Nov 26, 6:15 AM
Unknown Object (File)
Tue, Nov 26, 6:15 AM
Unknown Object (File)
Tue, Nov 26, 6:15 AM
Unknown Object (File)
Tue, Nov 26, 6:14 AM
Subscribers
None
Tokens
"Orange Medal" token, awarded by Krinkle.

Details

Summary

Fixes T13268. Currently, when we quote text, we add > (with a space) but don't try to strip it when un-quoting text.

Instead, try to strip it.

We can still end up with some occasional weird cases (users manually typing ">") that we may have to refine eventually, but this should make the common case ("Quote" button in the UI) work more consistently.

Test Plan

Added a test, made it pass.

Screen Shot 2019-03-26 at 1.37.43 PM.png (595×378 px, 22 KB)

Diff Detail

Repository
rPHU libphutil
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

src/markup/engine/__tests__/remarkup/del.txt
1–2

This is quite a test case.

amckinley added inline comments.
src/markup/engine/remarkup/blockrule/PhutilRemarkupQuotesBlockRule.php
27–31

We don't want to just keep doing this whole process in a loop until it's no longer true?

This revision is now accepted and ready to land.Mar 26 2019, 9:02 PM

We would, except that a two space indent creates a code block. So if you type this:

__abcd

...you get this:

abcd

That quotes as:

>   abcd

With 3 spaces.

This change strips it to 2 spaces so it still works, but if we strip all spaces it'll un-code-block it.

I thought there was a test case for that already (quoted-code-block.txt) but that actually just tests a triple-backtick version. I'll add a space-to-indent version.

  • Add an explicit test case for >, three spaces, then text (which should be a code block).
This revision was automatically updated to reflect the committed changes.