Re: Match <div and </div>
Benno Schulenberg <[email protected]> Tue, 24 Jan 2023 12:55:54 +0100
| Newsgroups | gmane.editors.nano.general |
|---|---|
| Message-ID | <[email protected]> |
Op 24-01-2023 om 06:52 schreef Seb:
> One detail for other readers of the list: I didn't see any "tortoise bracket" in
> your email. But there were question marks.
Then your mailer seems not to support UTF-8. Apparently you are one of
the few people that still stick to ISO-8859-*. The tortoise brackets
appear fine for me in the archive:
https://lists.gnu.org/archive/html/help-nano/2023-01/msg00013.html
> The way you solved the problem indicates that the same technique would work for
> other pairs, such as <form or <p. But I don't want to assign a keystroke to each.
> I tried to modify the line by replacing the first "div" with "(\w+)" and the
> following ones with "\1", as I would in a Perl regexp. It's not working.
The correspondence between "(...)" in a search string and "\x" in the
replacement string is valid only within a single replace command: a \x
does not carry over into subsequent replace commands. In other words:
each replace command stands on its own.
(Also: even if the \x would have carried over, the keystroke would have
failed to work wherever a HTML document contains an non-paired tag, like
<br>.)
If you want to be able to jump not just between <div> and </div> but
also between other pairs of tags, then you have to add the relevant
replace commands for each tag to the key binding, and use a different
replacement for each tag. For example:
bind M-B "{replace}<div{enter}^Q{enter}A
{replace}</div{enter}^R{enter}A
{replace}<form{enter}^S{enter}A
{replace}</form{enter}^T{enter}A
{findbracket}
{replace}^T{enter}</form{enter}A
{replace}^S{enter}<form{enter}A
{replace}^R{enter}</div{enter}A
{replace}^Q{enter}<div{enter}A
{left}{right}" main
In this case, instead of rare code points, I have used control codes
that are very unlikely to occur in any document. Enter each one by
preceding the keystroke with M-V.
Benno
OpenPGP_signature
(application/pgp-signature, 840 B) - not displayed