Page MenuHomePhabricator

Search and replace removes partial annotations
Closed, DeclinedPublic


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.

Change only quotes type and not wikicode inside it.

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

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:


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.

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

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