Page MenuHomePhabricator

Search and replace removes partial annotations
Closed, DeclinedPublic

Description

I guess this might be hard to implement, but here goes the steps:

  1. Open example page.
  2. Replace "(.+)" with „$1” (regexp search enabled).
  3. Replace all.

Expected:
Change only quotes type and not wikicode inside it.

Results:
Wikicode is removed effectively changing "[[blah]]" to „blah”.

Note that when match is inside a link it works fine (e.g. something -> otherthing is OK; (\w),(\w) -> $1, $2 is OK).

Event Timeline

Nux created this task.Feb 18 2017, 5:43 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptFeb 18 2017, 5:43 PM
Esanders renamed this task from Search and replace removes wikicode inside matches to Regex search and replace removes link annotation.Feb 19 2017, 8:40 PM

The replace part of search and replace is plain text only. It will match annotations (e.g. links) that are already in the document, but in this case you search pattern matches the whole line.

Why it may seem intuitive what the correct result is in this case, consider replacing "hello" with "everyone" in the following document:

<b>he</b>llo

Should the word 'everyone' be bold? Regular? Partially bold? This is the same problem as you have where your search match contains partially linked text.

Esanders renamed this task from Regex search and replace removes link annotation to Search and replace removes partial annotations.Feb 19 2017, 8:45 PM
Esanders closed this task as Declined.
Nux added a comment.Feb 21 2017, 10:15 PM

I see this differently. Note that I'm using regexp. So when I match "(.+)" I get a selection on a link with quotes around it so parentheses should match HTML/wikicode that contains the link. In other words - $1 should contain markup equivalent of [[blah]]. If that would be possible to do you would get following cases:

code search replace resulting code
"[[blah]]""(.+)"„$1”„[[blah]]”
<b>he</b>llohellohihi
s<b>he</b>lls(.+)llw$1elw<b>he</b>el

I think that would work intuitively. Effectively something$1else would insert something before whatever matched $1 and else after.