Re: [Tb] Search __AT__ Replace .... any ideas?

From: Mark Anderson <mac__AT__yeardley.demon.co.uk>
Date: Thu May 25 2006 - 11:56:51 EDT

On 25/5/06 15:23, "Oliver Wrede" <wrede__AT__fh-aachen.de> wrote:

> Hello!
>
> Tinderbox does not seem offer any feature for finding AND replacing
> text.
>
> So my simple question is if anyone here has an idea of how to do such
> search & replace operations?

I guess some 'nix based scripting - not my area - is the way to go. As the
links are stored as a block I guess the logic to be followed is that if the
search value match is inside a <text></text> element then:

- if find & replace values are the same length no action is needed.
- store as a variable the start/stop positions of the substring and the
difference between the search and replace value lengths.
- find the first match inside a <text> element.
- find the <item> or <agent> element immediately enclosing the <text>
element and note its ID attribute's value.
- search for <link> elements (they're in a block towards the end of the TBX)
and search for any whose ID matches the ID from the last step. Ignore if
link's "sstart" value is "-1" (if so it's a note level link, thus not a
text-anchored link)
- resolve the start/stop position maths post replacement, any links
overlapping or after the replaced section need to be processed
- repeat for each affected link in that <text> element
- process next <text> element find match.

There's one issue that you'd need to test and that is whether characters
that are stored as entities (i.e. accented letters, etc.) are counted as 1
character or the length of the entity.

So that's what needs doing. Sorry I've no idea how to do that!

---
Regards

Mark Anderson
Tinderbox wiki gardener

Tinderbox Wiki: http://www.eastgate.com/wiki2/wiki.cgi?TinderboxWiki
aTbRef: http://www.acrobatfaq.com/tbx/index.html
Received on Thu May 25 11:57:02 2006

This archive was generated by hypermail 2.1.8 : Mon Jun 19 2006 - 13:29:14 EDT