Get Marker text of type

Community Beginner ,
Jul 20, 2021 Jul 20, 2021

Copy link to clipboard

Copied

Hi community,

I try to get external links of doc using markers. I filter markers with type 'Hypertext' and search in them 'www', 'http'. 

Problem is that when working with big file, that contains more than 30000 markers FrameMaker crashes.

Here is the code that I use:

function getLinksFromDoc(oDoc) {
  
  var marker = oDoc.FirstMarkerInDoc
  var dLinks = {};
  var lTemp;
   while (marker.id) {
    if (marker.MarkerTypeId.Name = 'Hypertext' && (marker.MarkerText.match('URL') || marker.MarkerText.match('http') || marker.MarkerText.match('www') )  ) {
      markerText = marker.MarkerText;
      lTemp = markerText.split(' ');
      for (var i = 0; i < lTemp.length; i++) {
        if (lTemp[i].match('http') || lTemp[i].match('www')) {
          dLinks[lTemp[i]] = 1;
        }
      }
    } 
    marker = marker.NextMarkerInDoc;
  }

  return dLinks;
}

 

Does anybody know how to get only markers with specific type? 

What can I do to optimize the code?

Views

38

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation