1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 16:27:26 +08:00
Commit Graph

9 Commits

Author SHA1 Message Date
Bartłomiej Dach
08350a1aca Add parenthesis handling to old link format
Allow users to put both balanced round parentheses, as well as
unbalanced escaped ones, in old style link text. The implementation
is the same as for Markdown and new style links, except for swapping
all instances of

    \[\]

to

    \(\)

for obvious reasons (different type of parenthesis requiring escaping).
Tests also included.
2019-09-04 00:21:27 +02:00
Bartłomiej Dach
f04add6d9e Add bracket handling to Markdown link format
Allow users to put both balanced brackets, as well as unbalanced
escaped ones, in Markdown link text. The implementation is the exact
same as in the case of new format links.

For completion's sake, tests also included.
2019-09-04 00:07:00 +02:00
Bartłomiej Dach
a8f16503e2 Add backslash escaping to new link format
For users to be able to add square brackets inside of links using
the new format, the regular expression used for parsing those links
contained a balancing group, which can be used for matching pairs
of tokens (in this case, opening and closing brackets, in that order).
However, this means that users could not post links with unmatched
brackets inside of them (ie. ones that contain single brackets, or
a closing bracket and then an opening one). Allow for escaping opening
and closing brackets using the backslash character.

The change substitutes this old fragment of the regex in the display
text group:

    [^\[\]]*        // any character other than closing/opening bracket

for this one:

    (((?<=\\)[\[\]])|[^\[\]])*

The second pattern in the alternative remains the same; the first one
performs the escaping, as follows:

    (
        (?<=\\)     // positive lookbehind expression:
                    // this match will succeed, if the next expression
                    // is preceded by a single backslash
        [\[\]]      // either an opening or closing brace
    )

Since the entire display group is matched, unfortunately the lookbehind
expression does not actually strip the backslashes, so they are
manually stripped in handleMatches.

As demonstrated in the unit tests attached, this also allows balanced
brackets to be mixed with escaped ones.
2019-09-03 23:18:39 +02:00
Dean Herbert
1ccef61f7b Fix some missed instances of TestCase 2019-05-15 18:32:29 +09:00
Dean Herbert
8617aaa2a7 Update licence header (and remove year) 2019-01-24 17:43:03 +09:00
Dean Herbert
32a74f95a5 Normalize all the line endings 2018-04-13 18:26:38 +09:00
Dean Herbert
2ffe16d3d2 Improve clarity and coverage of unit tests 2018-01-30 18:57:42 +09:00
Dean Herbert
1dbaf9b7a7 Add many more tests 2018-01-30 16:38:18 +09:00
Dean Herbert
f996acd7e6 Add back old non-visual tests 2018-01-29 18:37:11 +09:00