cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

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

hbestler
11-Garnet

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

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

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

2 REPLIES 2

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");
}

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

View solution in original post

Announcements