Need script to place line break based on character style

I'm a designer and know very little about scripting or XML, but here goes. I have some XML files I'm formatting for print, and they don't have paragraph returns where they need to be. The returns always need to be before a specific XML tag (that I can change to a specific character style to make it easier to find...). But I don't see a way to do this using the usual InDesign Find/Replace tools, so I assume scripting is going to be the answer. Anyone know how to accomplish this?
Here's an example of the content I'm working with. The breaks need to happen BEFORE each <City> element. I'm using InDesign CS6 on a Mac.
<?xml version="1.0" encoding="UTF-8"?>
<Regions><Region>
BIG BEND COUNTRY<City>
<City_Name>ALPINE                       
</City_Name><Event_Name>
Big Bend Ranch Rodeo                                                                                </Event_Name>
<Date>August 8-9                                                                                                                                                                                                                                                         
</Date><Venue_Name>
Sul Ross State University S.A.L.E. Arena</Venue_Name>
<Website1>www.bigbendranchrodeo.com                                            
</Website1><Phone1>
4323642696</Phone1>
<Phone2></Phone2>
</City><City>
<City_Name>ALPINE                       
</City_Name><Event_Name>
Big Bend Balloon Bash                                                                               </Event_Name>
<Date>August 30-September 1                                                                                                                                                                                                                                                     
</Date><Venue_Name>
Alpine-Casparis Municipal Airport</Venue_Name>
<Website1>bigbendballoonbash.com                                        
</Website1><Phone1>
4328377486</Phone1>
<Phone2></Phone2>
</City><City>
<City_Name>EL PASO                      
</City_Name><Event_Name>
Alfresco! Fridays                                                                                   </Event_Name>
<Date>August 1, 8, 15, 22, 29                                                                                                                                                           
</Date><Venue_Name>
Convention Center Plaza</Venue_Name>
<Website1>www.alfrescofridays.com                                              
</Website1><Phone1>
915/534-0600</Phone1>
<Phone2/></City>
Thanks in advance!

karol wrote:
You can use [ code ] tags when pasting code https://bbs.archlinux.org/help.php#bbcode
For it to really auto-update the mirrorlist it has to be put in a cronjob :-)
If I run it twice, will the original mirrorlist (moved to mirrorlist.bak after the first run) be irrevocably lost?
Just nitpicking: you don't have to use 'g' for global changes in the sed substitutions as there is only one occurrence per line.
Thanks Karol - I made the adjustments above to address both comments. The 'g' for sed I think is OK to leave in :-)
Last edited by Archieman (2011-05-31 04:00:55)

Similar Messages

  • Table of Contents based on Character Style?

    Trying to do an annotated table of contents containing captions of all photos in a book, followed by verbose descriptions. Purpose is to avoid cluttering pages bearing the photos, which will have only a brief caption is followed by the name of the owner of the object in the caption, in the same paragraph.
    Book will include a listing of the captions in page order (i.e., table of contents) without the owner names, followed by verbose descriptions. Can I get around this by making character styles for each (caption, owner, respectively), and create a TOC based one character style? If not, can I configure the para. style of the caption to omit the line-feed, and base the TOC on that?
    Plan is then manually to add descriptions to each TOC entry, immediately following captions. Will that stay intact, if any subsequent photo locations are changed?

    Jack wrote:
    OK, have done that, and all required content is now showing up in the TOC.
    I'm glad you managed to sort that out.
    Is it possible to omit the line breaks between elements referring to the same page?
    Hmmm...the thing is...a paragraph is a paragraph is a paragraph. By nature, it breaks to the next line. There are ways to fake it but none (that I can think of) which will hold up to an automated TOC update. Maybe someone else will come along with a trick I don't know about.
    So then, for the moment let's assume the only way to get the caption and the description into the same TOC paragraph is to put them in the same paragraph on the document page. Also still assuming I truly understand the end-result you want; here's how I would do it:
    If you set the separate-but-threaded caption and description frames as I first proposed, you'll need to go back and take out the paragraph break between the caption and the description. It will have to be replaced by a simple "frame break" which will push the description (now the same paragraph and paragraph style as the caption), into its own hidden frame as before.If, in the TOC, you want the caption and the description to have differing formatting, it would also be useful to insert (between the caption and the description on the document page) an End Nested Style Here character before that frame break. (If the caption and the description can be formatted identically, you won't need this step, and they can simply be formatted by your simple TOC Entry Style paragraph style.)
    All above can be done using Find/Change. Find: End of Paragraph (^p). Change to: End Nested Style Here (^h) Frame Break (^R). So here's what it looks like in the dialog.
    If the captions and descriptions are the only text in your document, you probably get away with Change All, otherwise it may be best to step through finding and changing one instance at a time.
    Now if you update your TOC, the descriptions should be pulled up into the same paragraph as the captions.
    Take advantage of the Nested Style possibility to vary the formatting of the caption and description by adding a nested style to your TOC Entry Style. Set it to style the description portion of the entry. Then add a Nested Style and set a Character Style to format the caption portion of the entry... "through 1 End Nested Style Character".

  • Need script to place multiple single page pdfs in ID pages

    Does anyone know of a script that would place a whole folder full of single page pdf files into an indesign document one per page, alphabetically by pdf file name, and ideally add new pages as needed. The last part is optional, as the ID document could already have the required number of pages, all using the same master page with the the picture frame already in place.
    In my current project, the pdfs are all the same size as the ID document page size.
    This would be along the lines of the scripts that place multipage pdfs, but for single page ones. I have tried first creating a multipage pdf by inserting a folder full of single page pdfs at the end of an initial pdf. Acrobat 8 pro does this very well indeed, but selects the pages from the source folder in random order. I need them in alphabetical order.
    Thanks for any insight,
    Al

    For this project I could equally well use a script that would place or re link to a new pdf in a single page ID document, print device independent postscript with some sort of unique or sequential filename, and repeat the process for a whole folder of source pdf files. No new pages need to be added, and the new pdf could replace the prior one.
    What I am after is a device independent ps file for these pdf files. The ones produced by batch processing from Acrobat 8 Pro do not offer enough control, as in that method I would need *only* the black separation.
    Thanks,
    Al

  • Beginner needs help with adding line breaks...

    Hello,
    I would like to add line breaks after each of my form fields I tried adding
    but it does not work. Can anyone help please?
    Thanks in advance,
    Julien.
    <h:form id="calendarForm">
               <h:messages/>
                <h:outputLabel value="login"/><h:inputText id ="login" value="#{AccountJSFManagedBean.login}" required="true"/><h:message showDetail="true" for="login"/>
                <h:outputLabel value="firstName"/><h:inputText id ="fn" value="#{AccountJSFManagedBean.firstName}" required="true"/><h:message showDetail="true" for="fn"/>
                <h:outputLabel value="lastName"/><h:inputText id ="ln" value="#{AccountJSFManagedBean.lastName}" required="true"/><h:message showDetail="true" for="ln"/>
                <h:outputLabel value="email"/><h:inputText id ="email" value="#{AccountJSFManagedBean.email}" required="true"/><h:message showDetail="true" for="email"/>
                <h:outputLabel value="date of birth"/>
                <t:inputCalendar id="secondOne" monthYearRowClass="yearMonthHeader" weekRowClass="weekHeader"
                    currentDayCellClass="currentDayCell" value="#{AccountJSFManagedBean.dateOfBirth}" renderAsPopup="true"
                    popupTodayString="#{example_messages['popup_today_string']}" popupWeekString="#{example_messages['popup_week_string']}" required="true"/>
                 <h:commandButton value="sign up" action="#{AccountJSFManagedBean.signUp}" />
            </h:form>

    Which form fields? In the code posted, I don't see where you have tried putting linebreaks.
    You can try putting the <BR> tags in f:verbatim tags. Like this:
    <f:verbatim><br /></f:verbatim>CowKing

  • Script needed to generate a list of paragraph and character styles from the Book Level

    Hello,
    I am using FrameMaker 11 in the Adobe Technical Communication Suite 4 and I need to find a script that will generate a list
    of paragraph and character styles from the book level.
    I am working with unstructured FrameMaker books, but will soon be looking at getting a conversion table developed
    that will allow me to migrate all my data over to Dita (1.1 for now).
    Any thoughts, ideas on this is very much appreciated.
    Regards,
    Jim

    Hi Jim,
    I think the problem you are having with getting a response is that you are asking someone to write a script for you. Normally, you would have to pay someone for this, as it is something that folks do for a living.
    Nonetheless, I had a few minutes to spare, so I worked up the following script that I believe does the job. It is very slow, clunky, and totally non-elegant, but I think it works. It leverages the book error log mechanism which is built in and accessible by scripts, but is spendidly unattractive. I hope this gives you a starting point. It could be made much more beautiful, of course, but such would take lots more time.
    Russ
    ListAllFormatsInBook()
    function ListAllFormatsInBook()
        var doc, path, fmt;
        var book = app.ActiveBook;
        if(!book.ObjectValid()) book = app.FirstOpenBook;
        if(!book.ObjectValid())
            alert("No book window is active. Cannot continue.");
            return;
        CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
        CallErrorLog(book, 0, 0, "** Book format report for:");
        CallErrorLog(book, 0, 0, book.Name);
        var comp = book.FirstComponentInBook;
        while(comp.ObjectValid())
            path = comp.Name;
            doc = SimpleOpen (path, false);
            if(doc.ObjectValid())
                CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
                CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
                CallErrorLog(book, doc, 0, "");
                CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
                CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
                CallErrorLog(book, 0, 0, "Paragraph formats:");
                fmt = doc.FirstPgfFmtInDoc;
                while(fmt.ObjectValid())
                    CallErrorLog(book, 0, 0, "  - " + fmt.Name);
                    fmt = fmt.NextPgfFmtInDoc;
                CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
                CallErrorLog(book, 0, 0, "Character formats:");
                fmt = doc.FirstCharFmtInDoc;
                while(fmt.ObjectValid())
                    CallErrorLog(book, 0, 0, "  - " + fmt.Name);
                    fmt = fmt.NextCharFmtInDoc;
            else
                CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
                CallErrorLog(book, 0, 0, "!!!  Could not open: " + comp.Name + " !!!");
                CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
            comp = comp.NextComponentInBook;
    function CallErrorLog(book, doc, object, text)
        var arg;
        arg = "log ";
        if(book == null || book == 0 || !book.ObjectValid())
            arg += "-b=0 ";
        else arg += "-b=" + book.id + " ";
        if(doc == null || doc == 0 || !doc.ObjectValid())
            arg += "-d=0 ";
        else arg += "-d=" + doc.id + " ";
        if(object == null || object == 0 || !object.ObjectValid())
            arg += "-O=0 ";
        else arg += "-O=" + object.id + " ";
        arg += "--" + text;
        CallClient("BookErrorLog", arg);

  • Is there a way to allow for two lines in "running header (character style)" text variable?

    In my "running header (character style)" text variables, some of the items are quite long and take up more space in my header than I have room for - because I have another "running header (character style)" text variable beside it - and I am trying to figure out if there is a way to force that text variable to go into two lines when it runs out of space.
    Does anyone know if this is possible?

    Sadly, only by adding a forced line break in the variable. Adobe’s engineers are unable to allow long variables to break at the end of a line. Sad, since this is a feature I remember from a Macintosh word processor I used in 1988.

  • Break link to Character Style with JS (CS4ME)

    Hi,
    I'm wondering how to break a link to a character style in JS. By break
    link I mean removing the character style but preserving the formatting.
    Given a selected textStyleRange, say, in the UI there are two ways of
    doing this. One is to click "Break link to Style" in the flyout meny of
    the character style palette.
    The other is to right-click and select "Apply character style."
    It's a little unintuitive, because CLICKING on removes overrides,
    but right-clicking and selecting the menu option doesn't.
    So when I saw that, I said to myself aha! Probably:
    myText.appliedCharacterStyle = myCharStyle
    is equivalent to clicking on , while
    myText.applyCharacterStyle(myCharStyle)
    is equivalent to right-clicking on and choosing "Apply character
    style."
    But it isn't.
    They both apply None and remove all formatting.
    So, anyone know how to break a link to character style without removing
    formatting in JS?
    Thanks,
    Ariel

    Thanks Peter. That's interesting. After Shabbos I'll have to try figure
    out how to apply a character style without removing overrides as well.
    It may be a two-step procedure.
    Thanks,
    Ariel

  • Niceties of apply the [None] character style and its relation to Break link to Character Style (CS4 upwards)

    Hi,
    Am I the last to realise that, with text selected, clicking on is
    different from right-clicking on and selecting "Apply " in
    the character palette?
    Let me explain: Say you have some text selected. The text has a
    character style applied called "Superscript", whose only attribute is to
    apply superscript.
    Now, with that text selected, if you click on the result is that
    is applied and all formatting is lost.
    But, if you right-click on and choose "Apply " from the
    context menu, is applied but formatting is NOT list. Effectively
    this is the equivalent of choosing "Break link to style" in the flyout
    menu of the character palette.
    Curious to know if you've come across that that distinction before?
    Thanks,
    Ariel

    Sorry Peter. On behalf of the stupid Jive forums, I do apologize. Everywhere in my post where I wrote [None], it was jived up a little and changed to a link. (I've only got Internet access during breaks -- a self-imposed firewall that allows me to actually get some work done.)
    The post shoudl have read:
    Hi,
    Am I the last to realise that, with text selected, clicking on [None] is different from right-clicking on [None] and selecting "Apply [None]" in the character palette?
    Let me explain: Say you have some text selected. The text has a character style applied called "Superscript", whose only attribute is to apply superscript.
    Now, with that text selected, if you click on [None] the result is that [None] is applied and all formatting is lost.
    But, if you right-click on [None] and choose "Apply [None]" from the context menu, [None] is applied but formatting is NOT list. Effectively this is the equivalent of choosing "Break link to style" in the flyout menu of the character palette.
    Curious to know if you've come across that that distinction before?
    Thanks,
    Ariel

  • Insert line break into .txt file

    Alright, so I am writing out to a simple .txt file, and I
    need to force a line break in it. My immediate thought is to use
    "\n" as that is a line break. So, I write it out to the text file,
    and instead of a line break, I see the "complex character" symbol
    (you know, that square that shows up with unknown characters). I
    have tried the various ASCII values to no avail, tried \r, even
    tried copy-pasting a line break in from notepad. Nothing seems to
    be working for me. How do I do this?
    _logFile = "\n";
    stream = new FileStream();
    stream.open(file,FileMode.WRITE);
    stream.writeUTFBytes(_logFile);
    stream.close();

    in windows use "\r\n"
    i.e. _logFile = "\r\n";

  • Print a line break every 9 characters

    this is a relatively simple problem but for some reason i cant figure it out.
    i have a 2 dimensional array of 9x9 ints.
    i am saving this array to a file, and want to print all 81 ints, separated by spaces, and after every 9 ints printed i want the line to break.
    this is what i have:
              for(int i = 0; i < 9; ++i)
                   for(int j = 0; j < 9; ++j)
                        outStream.print(intBoard[i][j] + " ");however, with this method it prints them without line breaks after every 9. anyone know an easy way to do this? i was thinking something along the lines of keeping a count, e.g. count++ after every time it goes through the loop, but still cant figure out how it would work.
    thanks very much in advance

    for(int i = 0; i < 9; ++i) { // <-- Added Brace
         for(int j = 0; j < 9; ++j)
              outStream.print(intBoard[i][j] + " ");
            // <-- Create break here
    } // <-- Added BraceSo, after every time the inner loop completes, you'll need to create a line break, then the loop starts over and repeats.

  • Find Grep And Ignore the line break

    Hi Guys!,
    In my document having the text of "application \nfor you"
    Then, I need to ignore the line break in entire text indesign document.
    please help me!
    Thanks by
    John Peter.

    hi,
    I am find only words
    the line break wherever it is used in the document. so i am ignore the \n
    Document text : \napplication \nfor \nyou      ----this sentence contain many line breaks
    I will find the text of above document text.
    Find what of grep preferences: (application for you)(--here what to do for ignore \n)
    Please help me.
    thanks,
    John peter.

  • Thai script line breaking in CS6

    Hello,
    I am having serious difficulty finding a way to implement acceptable line breaking in a long document I am working in Thai script. I am working with InDesign CS6, using the World-Ready Composer. I have tried a variety of differnet Thai fonts. The text I am flowing into the document has already been marked (by the author) with a large number of additional acceptable break locations (which I have converted to different types of spaces). The text still breaks randomly in the middle of strings (and also at the space locations -- but not seemingly with any priority).
    I have tried using the standard Paragraph Composer as well. Some line spacing changes, and cursor behaviour over some strings is different, but the bad line breaks still happen.
    I have also tried the same text in CS5 and CS4. Same problem.
    The Language setting for styles is set to 'No Language'. I was certainly hopeful that the extra breaks marked in the text with thin or zero width spaces would provide enough line break flexibility. Does not seem so.
    Would anyone here have any advice, or other (better) experience working with Thai?
    Thanks
    Jeff

    Joel,
    Thanks very much for your reply. This was quite helpful. I was able to wrap all runs of Thai script letter characters with no break. I am actually importing InDesign Tagged Text into InDesign. I used the following regular expression to search and replace in the tagged text files.
    Search: ([\u0E01-\u0E5B]+)
    Replace: <cNoBreak:1>\1<cNoBreak:>
    Using a GREP style in InDesign is an easier solution. Unfortunately there is a chance in the text I am working with that the resulting style will become nested within a piece of text already wrapped with a character style, so the local noBreak instruction is the only reliable way.
    The World Ready Composer has added so much needed support for the OpenType font features required for complex script rendering. Much appreciated! I do hope in future versions of InDesign that support for these South Asian languages will continue to improve by adding the necessary text (morphology) analysis needed to implement real support for line breaking. (The characters in Thai belong to the Unicode line breaking class "SA", which indicates that software needs to provide this added support -- such as a dictionary lookup, or other analysis, to indicate which characters should be allowed to break after)
    It feels like InDesign (at this point) is just treating all characters in these Thai text runs as an acceptable breaking location, and doing its best to stick close to the prefered justification word and letter spacing values.
    Thanks, again for the helpful idea.
    Jeff

  • I need to find all XML elements and add a line break to the text of each of them

    I need to find all XML elements and add a line break to the text of each of them.
    Is this possible with a script?

    I need to go from this ...
    to this...
    but looking for the XML elements (not paragraphs) and then adding text ...
    Thanks for your attention !!!

  • Reg Exp help needed (trouble with line breaks)

    Hello,
    I am attempting to parse a line of text with regular expressions. I am having difficulty with the line breaks.
    I want to divide the following line by the first '\n' char.
    For instance, I wan the output to be as follows:
    found 1: one
    found 2: ddd
    dddHowever, I get the following with my attached code:
    found 1: one
    found 2: dddHowever, the second line break seems to be the end of the second group.
    How do I get the any character '.' to read past any subsequent line breaks?
    import java.util.regex.*;
    public class Test
         String rawSequenceArg = ">one\nddd\nddd";     
           Pattern p = Pattern.compile(">([^\n]+)\n(.+)");
           Matcher m = p.matcher(rawSequenceArg);
           if(m.find())
                System.out.println("found 1: " + m.group(1));
                System.out.println("found 2: " + m.group(2));
    }

    In this case, the DOTALL flag is the one you need; it allows the dot (period, full stop) to match line separator characters. MULTILINE makes the '^' and '$' anchors match the beginning and end of logical lines, instead of just the beginning and end of the input.

  • Read Only TextAreas with Carriage Return, Line Breaks and Word Wrapping

    Hi all,
    I know there are a few posts around this subject but I cannot find the answer to the exact problem I have.
    I have a page that has a 'TextArea with Character Counter' (4000 Chars) that is conditionally read only based on the users credentials (using the 'Read Only' attributes of the TextArea item).
    When the field is editable (not Read Only) everything works fine but when I make the field Read Only I start to have problems:
    The first problem is that the Carriage Return and Line Breaks are ignored and the text becomes one continuos block. I have managed to fix this by adding pre and post element text of pre and /pre tags. This has made the Carriage Return and Line Breaks word nicely and dispaly correctly.
    However, it has introduced a second problem. Long lines, with no Carriage Returns or Line Breaks, now extend to the far right of the page with no word wrapping, making my page potentially 4000+ characters wide.
    How can I get the field to be display only, with recognised Carriage Returns and Line Breaks, and Word Wrapping inside a fixed width of, say, 150 characters?
    Many thanks,
    Martin

    Hi,
    Just a cut and paste of yours with the field name changed:
    htp.p('<script>');
    htp.p('$x("P3_COMMENTS").readonly=true;');
    htp.p('</script>');I also have the following in the page HTML Header, could they be conflicting?
    <script type="text/javascript" language="JavaScript">
    function setReleaseToProd(wpTypeCode){
       //setReleaseToProd($v(this))
      var get = new htmldb_Get(null,$v('pFlowId'),'APPLICATION_PROCESS=set_release_to_prod',0);
      get.addParam('x01',wpTypeCode);
      gReturn = get.get();
      if(gReturn) {
         $s('P3_RELEASE_TO_PROD',gReturn);
      get = null;
    </script>I am a long way from knowing much about Javascript (this page code was written by someone else) so all help is much appreciated.
    Martin

Maybe you are looking for

  • How to update "Encrypt with UserKey" after Windows User Profile replacement?

    A problem with my User Profile required that the files be backed up, the profile deleted, a new profile created and my files restored. I have several SSIS projects built in Visual Studio 2012 that use "EncryptSensitiveWithUserKey". I assume the "User

  • Is there a way to create photo books on the ipad2?

    One of the main reasons I purchased the ipad2 was to edit and organize photos with the touch screen. I love the ability to make photo books and order the books through Apple on iphoto for Mac, but can't seem to find anything comparable on my ipad.

  • Default user settings in cProjects

    Hi all! Does anyone know if it's possible to change the default user settings in cProjects at user creation? Basically, we would like to have the processing mode set by default as "display" instead of "change". After user creation in the backend/port

  • How can I load external file .txt in After Effects CC 2014.0 Release / Mavericks OS X 10.9.4 (13E28)?

    ello everybody. Someone can help me to load a external file .txt in After Effects CC 2014.0 Release / Mavericks OS X 10.9.4 (13E28)? I tried the code bellow, but doesn't work. try{ myPath = "~/Desktop/source.txt"; $.evalFile(myPath); eval(thisComp.na

  • Select dates

    Hello, I need to select all dates between two dates. This select is subquery of larger query, returning data rows by day (month or year) between two dates. I use all_objects and trunc(sysdate + rownum) to select the dates. Is it posible to optimize t