10 Replies Latest reply on Sep 20, 2013 2:47 AM by FieryPantone

    problems importing tagged text

    FieryPantone Level 3

      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!

        • 1. Re: problems importing tagged text
          JoaoCP Level 2

          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.

          • 2. Re: problems importing tagged text
            FieryPantone Level 3

            Thanks, Joao – I've changed the first two lines as you suggest, but the only difference is that now everything arrives in my IDD file as [BasicParagraph]. All the paragraph styles are present in the tagged source <dps> section and show up as entries in the Paragraph Styles panel: they just aren't being applied :-{ Any more tips?

            • 3. Re: problems importing tagged text
              JoaoCP Level 2

              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_taggedtext.pdf

              • 4. Re: problems importing tagged text
                FieryPantone Level 3

                Here's the start of my tagged text file, which the editor assures me uses DOS/Windows line ends and ANSI encoding. The style definitions all exist in the target, which is used as a template.

                <ANSI-WIN>
                <vsn:7>
                <dps:Heading1>
                <dps:Heading2>
                <dps:UnorderedList>
                <dps:Body>
                <dps:ListHeader>
                <pstyle:Heading1>AARDVARK 
                <pstyle:Body>is our innovative system for our entire range of ships. AARDVARK allows you to manage, update and configure your ships remotely via a web browser. It helps you reduce man-hours in the field and respond faster to market and customer needs.
                <pstyle:Body>AARDVARK was specifically developed to remotely manage large ship pools – for integrators, processors, banks, ship operators and retail or petrol chains. It can handle a pool of up to 500,000 ships and process up to 400 connections simultaneously via a single communication server. Therefore, AARDVARK is perfectly suitable for international business environments.
                <pstyle:Heading2>Key features
                <pstyle:UnorderedList>Modular and customizable system
                <pstyle:UnorderedList>Easy control of access rights and user profiles (micro-role system)
                <pstyle:UnorderedList>Intuitive web-based user interface
                <pstyle:UnorderedList>Smart search tools for quick access to data
                <pstyle:UnorderedList>Single-click mechanism for bulk updates
                <pstyle:UnorderedList>Training and support
                <pstyle:Heading2>Integrated and scalable
                <pstyle:Body>AARDVARK is powerful and flexible! Its capacity ranges from one ship up to an entire fleet. It supports various ship generations and several protocols.

                Result this morning – page of page using the <Heading1> definition :-{ I'm encouraged to hear you've been getting better results, just wish I could too! The reference manual spends most of its time going into arcane detail, as a reference manual should, but it's also where I learnt everything I've tried to apply so far.

                • 5. Re: problems importing tagged text
                  JoaoCP Level 2

                  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

                  1 person found this helpful
                  • 6. Re: problems importing tagged text
                    FieryPantone Level 3

                    That was it! thank-you very much.

                    btw – when might I really want to use "Remove text formatting"?

                    • 7. Re: problems importing tagged text
                      JoaoCP Level 2

                      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.

                      • 8. Re: problems importing tagged text
                        FieryPantone Level 3

                        Yes, I agree – it's very satisfying to know "aha! there's exactly the command I need, once every leap year …" Now you've explained it, I could just about imagine using it to pull content from an MML file [see sample] into IDD: but only "just about", because I'd more likely want to use the MML tags with grep to reproduce the structure/styles. Still, perhaps one of these days – cleaning up HTML source, perhaps?

                        <MML>

                        <!DefineTag Heading1>

                        <!DefineTag Heading2>

                        <!DefineTag UnorderedList>

                        <!DefineTag Body>

                        <!DefineTag ListHeader>

                        <Heading1>AARDVARK

                        <Body>is our innovative system for our entire range of ships. AARDVARK allows you to manage, update and configure your ships remotely via a web browser. It helps you reduce man-hours in the field and respond faster to market and customer needs.

                        <Body>AARDVARK was specifically developed to remotely manage large ship pools – for integrators, processors, banks, ship operators and retail or petrol chains. It can handle a pool of up to 500,000 ships and process up to 400 connections simultaneously via a single communication server. Therefore, AARDVARK is perfectly suitable for international business environments.

                        <Heading2>Key features

                        <UnorderedList>Modular and customizable system

                        <UnorderedList>Easy control of access rights and user profiles (micro-role system)

                        <UnorderedList>Intuitive web-based user interface

                        <UnorderedList>Smart search tools for quick access to data

                        <UnorderedList>Single-click mechanism for bulk updates

                        <UnorderedList>Training and support

                        <Heading2>Integrated and scalable

                        <Body>AARDVARK is powerful and flexible! Its capacity ranges from one ship up to an entire fleet. It supports various ship generations and several protocols.

                        • 9. Re: problems importing tagged text
                          JoaoCP Level 2

                          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.

                          • 10. Re: problems importing tagged text
                            FieryPantone Level 3

                            That's extremeley generous! thank-you, Joao. I'll report back, and just hope I'll be allowed to write in my Scripts Panel folder … corporate installation :-{

                             

                            N