Skip to main content
13-Aquamarine
December 20, 2019
Solved

Arbortext Editor - How to search and replace text except some tags

  • December 20, 2019
  • 1 reply
  • 3257 views

Hi guys,

sometimes we must search and replace text with the arbortext editor. This works fine, but in some xml-files/productions it is important that these replacements are not made in some special tags. 

We cannot find any option in the search & replace window. Unfortunately also with ACL we could not find a solution, as the "gsub" method would replace in the whole document.


Do you have an idea to find a way to search and replace in the arbortext editor except some tags?

Thank you in advance.

Greetings from Germany

Best answer by hbestler

Hi Clay,

thank you for your answer. Meanwhile we found a solution via using the DCF-File, in which we restrict editing in some elements via using the ElementOption and "protected" attribute.


Your idea with ACL seems to be also an elegant way which we would also try. 

Thank you for that. 

 

Greetings from Germany

1 reply

18-Opal
February 6, 2020

You can do this with ACL, with a combination of the find() function and the inside_tag() function. A solution might look something like this:

function replaceSome() {
 set deletespaces=off;
 # for find command 0x20 = quiet, 0x40 = no wrap prompt, 0x100 = no wrap, 0x200 = select str
 local flags = 0x20 + 0x40 + 0x100 + 0x200;
 local hits = 0;
 local skips = 0;
 # define list of tags to skip below, separated by semicolons
 local ignorelist = "title;listitem";
 # define term to search below
 local searchterm = "the";
 local ignoretags[];
 split(ignorelist, ignoretags, ";");
 while (find(searchterm, flags)) {
 local oid, pos;
 oid = selection_end(pos);
 goto_oid(oid, pos);
 hits++;
 local ignore = 0;
 for (t in ignoretags) {
 if (inside_tag(ignoretags[t])) {
 	ignore = 1;
 	skips++;
 	break;
 }
 }
 if (!ignore) {
 delete_mark;
 insert("Das");
 }
 }
 response("Found " . hits . " instances, skipped " . skips . " instances due to container element");
}
hbestler13-AquamarineAuthorAnswer
13-Aquamarine
March 3, 2020

Hi Clay,

thank you for your answer. Meanwhile we found a solution via using the DCF-File, in which we restrict editing in some elements via using the ElementOption and "protected" attribute.


Your idea with ACL seems to be also an elegant way which we would also try. 

Thank you for that. 

 

Greetings from Germany