Skip navigation
Currently Being Moderated

problems importing tagged text

Sep 11, 2013 4:33 AM

Tags: #tagged_text

IDD CS5.5, 7.5.2

what I do

  1. prepare IDD tagged text file, using DOS/Windows line ends and ANSII encoding
  2. open IDD CS5.5 file with formatted content
  3. select all content
  4. File > Place InDesign tagged text file, using "show list of problem tags" option

what I get

  • no angle brackets imported, no errors in the list of problem tags …
  • 74 paragraphs, all using the first paragraph style specified in the tagged text

I wish IDD tagged text were as easy to get on with as FrameMaker's MML … that would also make it easier for me to start with one tagged source file and use the content in different applications with a minimum of effort. Any tips on _exactly_ what has to be done to placate the IDD Import goblins welcome!

 
Replies
  • Currently Being Moderated
    Sep 11, 2013 7:17 AM   in reply to Niels Grundtvig Nielsen

    Check whether your file is correctly prefixed. Mine begins with:

     

    <ANSI-MAC>

    <vsn:9>

     

    because I'm using CC (ie, InDesign version 9) on a Mac.

     

    Yours should begin with:

     

    <ANSI-WIN>

    <vsn:7>

     

    I've just made a test, converting one of my tagged files to ISO Latin 1 encoding, with DOS/Windows linebreaks (CRLF), using the header above, and they were imported without problems in my Mac.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 12, 2013 4:29 AM   in reply to Niels Grundtvig Nielsen

    Are your paragraph and characters properly tagged? Paragraphs should be prefixed with:

     

    <pstyle:TheParagraphStyle>

     

    And you apply character styles using this syntax:

     

    <cstyle:TheCharacterStyle>stylized characters<cstyle:>

     

     

    Here's an adapted sample of one of my tagged files, just to show you how a tagged file may be build (the body of the sample contains some tips):

     

    <ANSI-MAC>

    <vsn:9>

    <pstyle:title>The title of the story

    <pstyle:body text with drop cap>This is the first paragraph. It has an opening paragraph style tag, like the previous one. But, as you can see, I didn't "close" the previous paragraph style; unlike HTML or XML, InDesign tagged text has no closing tags for paragraph styles.

    <pstyle:body text>This is the second paragraph, which has another style. Here you can see a <cstyle:bold>character style<cstyle:> applied. For obvious reasons,

    character styles require a closing tag.

    This is the third paragraph. Notice that this one doesn't have a paragraph style tag. As long as I don't use any other paragraph style, this and the following paragraphs will be formatted with the last style applied (in this case, "body text").

    This fourth paragraph has another important hint. A tagged file can describe the attributes of all (or part) of its styles and swatches. This definition goes in the beginning of the file, after the header and right before the first paragraph. The styles and swatches defined in the tagged file will be inserted and/or will replace the ones in the ID file. This can be a good thing if you want to place your tagged file in a new document that has no styles or swatches. It's also useful when you want to be sure that the tagged file styles will prevail even if there are identically named styles in the ID file. On the other hand, if your InDesign file already has all the properly defined styles and swatches, and you  want your tagged text to be imported with the ID styles/swatches definitions, than the structure of this sample is the best bet. Because I didn't define the attributes of any paragraph or character style, this sample will be formatted according with the style definitions of my destination ID document. The only caveat of this approach is that, if there's no correspondent style in the InDesign file, the paragraph will be formatted with "[No paragraph style]" and the "orphan" character styles will be formatted with "[None]". But these errors show up in the import message dialog, which makes them easy to fix (or ignore).

     

     

    That's it. InDesign tagged texts are simple, easy to create and very reliable (and that's why I only use this workflow since 1992, in the PageMaker days). But they are also very powerful. If you want to dive deeply in this subject, I recommend the Adobe's official reference manual, which is located at:

     

    http://help.adobe.com/en_us/indesign/cs/taggedtext/indesign_cs5_tagged text.pdf

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 17, 2013 4:43 AM   in reply to Niels Grundtvig Nielsen

    Your sample worked here.

     

    Look again at the import options dialog box.

     

    I guess you inadvertently checked the "Remove Text Formatting" option.

     

    tagged_text_import_options.png

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 18, 2013 4:04 AM   in reply to Niels Grundtvig Nielsen

    You're welcome!

     

    Regarding that option, it doesn't really do much sense. After all, if you took the time to build a tagged text file, why would you want to strip its formatting? Nevertheless, there is a few situations when it may come in handy (like, say, someone exported an ID story to tagged text and you want to re-use that text without any of the original formats). Besides, InDesign loves to  provide several options, even if they may be rarely used. I, for one, enjoy that.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 19, 2013 3:53 PM   in reply to Niels Grundtvig Nielsen

    Give this script a try:

     

    -------------------------------------

     

    // DESCRIPTION: This InDesign script reads the tags of an imported MML file and applies their corresponding paragraph styles.

    // USAGE: Place the MML file in InDesign. Using the Text tool, select all or part of the imported text. Run this script.

     

    var myDocument = app.activeDocument;

     

    if (app.documents.length != 0){

    //If the selection contains more than one item, the selection

    //is not text selected with the Type tool.

    if (app.selection.length == 1){

    //Evaluate the selection based on its type.

      switch (app.selection[0].constructor.name){

       case "Character":

       case "Word":

       case "TextStyleRange":

       case "Line":

       case "Paragraph":

       case "TextColumn":

       case "Text":

        convertMML(app.selection[0]);

       break;

       default:

        alert("Please select all or part of the text using the Text Tool.");

       break;

      }

    } else {

      alert("No valid selection.");

    }

    }

     

     

    function convertMML(theSelection) {

     

    // this sequence collects the names of the paragraph styles in the MML file

    var theContent = theSelection.contents;

      var theParagraphs = theContent.split("\r");

      var theParagraphStyles = [];

      for (var i = 0; i < theParagraphs.length; i++) {

        if (theTag = theSelection.paragraphs[i].contents.match(/<!DefineTag (.+?)>/)) {

          theParagraphStyles.push(theTag[1]);

        }

      }

    // ********* this sequence adds dummy paragraph styles in the document, if necessary

    for (var i = 0; i < theParagraphStyles.length; i++) {

      var currentStyle = theParagraphStyles[i];

            try { myDocument.paragraphStyles.add({ name: currentStyle }) } catch(err){};

    }

     

    // ********* This sequence set the preferences of the Grep queries

    app.findChangeGrepOptions.includeFootnotes = true;

    app.findChangeGrepOptions.includeHiddenLayers = false;

    app.findChangeGrepOptions.includeLockedLayersForFind = false;

    app.findChangeGrepOptions.includeLockedStoriesForFind = true;

    app.findChangeGrepOptions.includeMasterPages = true;

    app.findGrepPreferences = NothingEnum.nothing;

    app.changeGrepPreferences = NothingEnum.nothing;

     

     

    // ********* The action begins here

     

    // ********* This sequence removes spaces and/or TABs in the beginning of the lines

    app.findGrepPreferences.findWhat = '^\\s+';

    app.changeGrepPreferences.changeTo = '';

    myDocument.changeGrep();

     

    // ********* This sequence consolidates multiple paragraph returns into one

    app.findGrepPreferences.findWhat = '\\r\\r+';

    app.changeGrepPreferences.changeTo = '\\r';

    myDocument.changeGrep();

     

     

    // ********* This sequence removes the header and the paragraph declarations

    app.findGrepPreferences.findWhat = '((^<MML>\\r)|(^<!DefineTag .+?>\\r))';

    app.changeGrepPreferences.changeTo = '';

    myDocument.changeGrep();

     

     

    // ********* Now that everything is cleared up and in place, we can make the required changes

    for (var i = 0; i < theParagraphStyles.length; i++) {

      app.findGrepPreferences = NothingEnum.nothing;

      app.changeGrepPreferences = NothingEnum.nothing;

      var currentStyle = theParagraphStyles[i];

      var theGrepString = '^<' + currentStyle + '>';

      app.findGrepPreferences.findWhat = theGrepString;

      app.changeGrepPreferences.appliedParagraphStyle = myDocument.paragraphStyles.itemByName(currentStyle);

      myDocument.changeGrep();

      app.findGrepPreferences = NothingEnum.nothing;

      app.changeGrepPreferences = NothingEnum.nothing;

      app.findGrepPreferences.findWhat = theGrepString;

      app.changeGrepPreferences.changeTo = '';

      myDocument.changeGrep();

    }

    }

     

    --------------------------------------------

     

    It worked in your sample. To install it, select the text between the multi-hyphens lines, copy it to a text editor, save it with the ".js" or ".jsx" extension and put it on your Scripts Panel folder.

     

    To run it, place the MML in InDesign as unformatted text, select everything with the Text tool and double click the script in the Scripts panel. All the tags will be eliminated and the paragraphs will be formatted according with the MML tags. Be aware that this script doesn't contemplate character styles and any other formatting; only paragraph tags, like your sample.

     

    Hope it helps.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points