0 Replies Latest reply on May 19, 2014 9:53 AM by DavidFdezGlez

    Import Html text and convert to InDesign tags

    DavidFdezGlez Level 1

      Hello everybody,

      The script receives a JSON with text (html markup: headers <h1>, <b></b>, new line characters, ...).

      I have to save the converted text into a temp text file and then do .place() into a text frame. That's the only way it can recognise new tags.

       

       

      //text and contentArea are defined previously.
      var convertedText = convertTags(text);
      
      
      var convertedTextFile = new File (FILE_PATH + "/Temp/convertedTextFile.txt");
      convertedTextFile.open('wr');
      convertedTextFile.write(convertedText);
      convertedTextFile.close();
      
      contentArea.place(convertedTextFile);
      
      function convertTags(htmlTaggedText){               
           var inDesignTaggedText = "<ASCII-MAC>\n" + htmlTaggedText.replace("<h1>", "<ParaStyle:Heading 1>").replace("</h1>", "");
           return inDesignTaggedText;
      }
      
      

       

       

      General question is, whether there is any more elegant solution to this?

       

      Thanks in advance