Wednesday, December 23, 2020

Re: Substitute pattern over multiple lines

On 2020-12-23 22:34, John Cordes wrote:
> :g/^2 TYPE tngnote//2 NOTE /s/^2 NOTE \zs\(.*\n\(\%(\D\|3 CONC
> \).*\n\)\+\)/\='<div
> class="xxx">'.substitute(substitute(submatch(1), '\n3 CONC ', '',
> 'g'), '\n', '', 'g')."<\/div>\n"
>
> which as far as I can tell at the moment is working perfectly,
> handling all situations the way I wanted.

The only glaring edge-case is a situation in which a "2 TYPE tngnote"
section is followed by *no* NOTE, followed by a section that *isn't*
a "2 TYPE tngnote" that *does* have a NOTE that shouldn't be touched
such as

2 TYPE tngnote
9 TIM FAKE ANNOTATION this tngnote has no NOTE
2 TYPE granola
2 NOTE Don't touch granola-type notes or
3 CONC rewrap their content or add <div>s!

In such a case, it will wrap the NOTE even though it's in a different
TYPE that shouldn't be touched because it's the first NOTE after a "2
TYPE tngnote", even though it's in a different section.

So that's where I'd focus my checking :-)

-tim



--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201223225243.40882090%40bigbox.attlocal.net.

No comments: