JS:CS3 Newbie needs help! find/change character styles

I'm new to scripting and JavaScript is giving me a headache, but I'll keep trying. What I'm trying to do is automate a few things so that the production time of our school newspaper is reduced while insuring accuracy.
I've played around a little with the text find change sample and the changing or adding paragraph styles in the InDesignCS3_ScriptingGuide_JS.pdf and I barely understand what I'm doing.
When us page designers receive text to place in the document, our editors mark the text with tags like: < b >text< / b >, where the word "text" is to be bolded. (there wouldn't any spaces between < and b and > etc. I just did that so It'll show up here). We have basic character styles and paragraph styles set up, and we just started working with nested styles.
Is there a way we can search for the < b > tag and bold everything after it up until the < / b > tag? Sort of the way it does for html (the way it would do for this message if I took out the spaces). It'll be great if it could remove the tags as well, but if not, I know I could create a find/change script to do the removal afterwards.
I appreciate any input.
Thanks!

You've not found yourself the easiest of tasks! You need GREP find/replace, not text. Do you have any experience with GREP? It's worth investigating, it's a powerful feature. The script below handles bold. For clarity, it doesn't do any error checking: it assumes that there's a document with text in it and that the document contains a character style called 'bold'.
// talk to Indesign, nobody else
#target indesign
// reset the Find/Change dialog
app.findGrepPreferences = app.changeGrepPreferences = null;
// find everything between <b> and  (including these codes)
app.findGrepPreferences.findWhat = '<b>.+?</b>';
// add 'bold' style
app.changeGrepPreferences.appliedCharacterStyle = 'bold';
// make the changes
app.activeDocument.changeGrep();
// now delete the <b> and </b> codes
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = '</?b>';
app.changeGrep();
You can adapt it easily to handle other codes, and at a later stage you could generalise it so that you needn't repeat whole bunches of code.
Good luck with your first forays. Again, it's not the easiest of tasks, but it's worth getting to grips with.
Peter

Similar Messages

  • Need help finding Sound and Vibration Toolkit Example Files

    I need help finding some Sound and Vibration Toolkit Example Files?
    http://www.ni.com/white-paper/3779/en
    From this link you get:  getting_started_otb.llb
    The missing files are:
    OAT Truncate Time Indices.vi
    Speed profile.ctl
    oa_Config Time or RPM Segment.vi
    svl-Complex Datatype Default.vi
    Running Windows 7, LabVIEW 2011, 32bit
    Sound and Vibration Measurement Suite
    Sound and Vibration Toolkit
    Thanks,
    -SS
    Solved!
    Go to Solution.
    Attachments:
    License S and V.png ‏4 KB

    SS,
    You can find these files here:
    C:\Program Files (x86)\National Instruments\LabVIEW 2011\vi.lib\addons\Sound and Vibration\Order Analysis\Resample Order Tracking\SubVIs
    C:\Program Files (x86)\National Instruments\LabVIEW 2011\vi.lib\addons\Sound and Vibration\Order Analysis\Tach Process\SubVIs
    C:\Program Files (x86)\National Instruments\LabVIEW 2011\vi.lib\addons\Sound and Vibration\Order Analysis\Resample Order Tracking\SubVIs
    svl-Complex Datatype Default.vi changes to svc-Complex Datatype Default.vi
    C:\Program Files (x86)\National Instruments\LabVIEW 2011\vi.lib\addons\_NISVFA\_Shared subVIs\Common
    Make sure you are license activated, and you will have to dig through the *vi and relink a subvi.
    Then you should get a white arrow.
    -SS 

  • HT4061 i need help finding my iphone 4

    i need help finding my iphone4.  i didnt have the app find my iphone i bought the phone from my friend ... so i dont know the serial number but i do have his name and phone number also it carrier plan .... i need to freeze the phone they are able to make call to my family member that have iphone

    If you did not set up the find my iphone feature on the iphone itself then you cannot track it.
    Change your passwords and alert your carrier

  • I lost my iPod I need help finding it.

    I lost my iPod and need help finding it. It took me a long time to save my money for someone to come and still it please help me

    - If you previously turned on the FIndMyiPod feature and location service is on, and wifi is on and connected go to iCloud, sign in, and go to FindMyiPhone. It the iPod has been restored it will never show up.
    - Report to police and change the passwords fro all accounts used on the iPod.
    - Apple will not help
    Reporting a lost or stolen Apple product

  • MacBook - Newbie: Need help on printing wirelessly to XP shared printer

    MacBook - Newbie: Need help on printing to XP shared printer
    Bear with me please. I read tons of articles on this but somehow as a newbie to MAC (girlfriends sick daughter), I am missing something. 10.5.2
    Currently, she can print directly if we plug in the HP Deskjet printer directly via USB to the MACBook. No problem.
    When we first got the MACBOOK I tried setting up the MACBOOK wirelessly to recognize the workgroup where the printer was attached via USB to the Windows XP PC. However it printed out garbage since I did not know there was a difference between XP printing and MAC (Gutenberg/gimp printing/drivers).
    Now I know there is a difference.
    But in reading various instructions, I no longer can find how to connect the MAC to the Windows workgroup. Note we do have a printer set up currently as USB-HP Deskjet on the Macbook (not sure I need to delete it yet).
    I went to System Preferences on MACBOOK and clicked on printers, more printers. In the drop down box was CANON, APPLETALK, IP HP printing and Firewire. There was no WINDOWS selection as I saw in other online web instructions.
    So not sure how to proceed to find a way to:
    1. Connect to Windows workgroup (click on what exactly), step by step please!!
    2. Add correct HP Deskjet 5490 printer (perhaps there is one with Gutenberg or perhaps I need Gutenprint-really not sure what I am talking about)
    Thanks so much in advance. Fiancé's kid has had her cancer recur in a different place and someone was nice enough to buy her a MACBOOK as a gift.
    Sincerely
    Peter

    ccarbery wrote:
    OK...I figured it out...no need to reply.  I noticed that there was another Protocol to use to set up the printer on the Mac, I was using LPD, so I switched it to HP Jet Direct-socket, and it prints fine...thanks.  I am curious as to why LPD wouldn't work; if anyone has that answer I would like to know...thanks
    Any chance of posting the Protocol you used to connect to your printer with your laptop?  I'm have the exact same problem printing from my MB.  Same error message "..is busy".

  • I need help with changing my verizon vm to the system voicemail

    I need help with changing my verizon vm to the system voicemail

    Deleting the iTunes account is not the solution as you will very likely lose any and all purchases ever made with the account.
    If you cannot find the option on the site, contact iTunes support.

  • Need help in changing the langauge on the Nokia570...

    Anybody can help please. I was given a brand new Nokia 5700 by my nephew from Taiwan and the langauge set is Chinese. I do not read or write chinese. Need help to change thelangauge on the phone. Any body can help.
    Thanks in advance

    Friend, I am based in China and my secretary is chinese - but nobody can figure out how to do it. I have another engineer who has the same phone has been playing around with it for 2 days and cannot get it done also. That is the reason I am getting on this site for help.
    Thanks anyways

  • Need help finding my iphone serial number but my phone is dead

    Need help finding my iphone serial number but my phone is dead

    no one here can help you find it.

  • I need help finding this hp hard drive for dv6521eo

    I need help finding this hp hard drive and memory  for dv6521eo

    Hi:
    You can purchase any SATA II 2.5" notebook hard drive up to 500 GB in size.
    Memory is PC2-6400.
    Paul

  • HT1349 I need help finding an old library that itunes states my ipod is already linked to

    I need help finding an old library that it states my ipod is already linked to.  My computer recently had a terrible virus and needed to be wiped clean.  I had to redownload itunes and I bought several songs.  I want to add them to my old library because I had several cd's that I had uploaded.  Is there a way to find that old library and combine them without having to erase all the songs that are currently on my ipod???  Thanks

    Umm.  If you wiped the hard drive, then all old libraries are gone unless you have them on backup.

  • Need help finding a driver for my hp webcam . My computer say I dont have a camera but I do.

    Need help finding my camera[webcam] on my computor.

    Can you provide us with your computer model number?  Take a look in Device Manager to see if there is an Imaging Devices group that includes the webcam.  If not, is there an Unknown Device listed?  This would indicate that your webcam is detected, but there is no driver installed.  We can help you find the correct driver if that is the case.  Let's start with the computer model number.  Thanks.
    I am an HP employee. The opinions expressed are my own and not those of HP.

  • HT5622 I need help finding a movie that I downloaded, can anyone help me with this?

    Hello, I need help finding a movie that I downloaded, can anyone help me with this?

    If you downloaded it to your iTunes library it will be in the Movies folder.  If you downloaded it to an iOS device you will find it in the Videos app.  This explains how to redownload previously purchased videos (available in some locations as long as the studio permits it): http://support.apple.com/kb/PH12283.

  • Need help finding the best Mac for gf

    hi I need help finding the best desktop. I am looking to buy MAC for gf.
    she uses final cut program question is does the GB/RAM/STORAGE matter on performance?
    She has a 2009 Apple computer I want to upgrade her to a new one
    I Dont know much when it comes to specs. She edits tons of videos and pictures.
    what's recommended for a video/photo editor that's good in performance ?

    Pro consumer might go with iMac even.
    Final Cut Pro latest benefits from dual AMD graphics.
    Video is one animal, graphics a much different.
    Great site full of performance, buying and configuration ideas:
    MacPerformance Go to the main topics
    I think you need to get clear on budgets. start with mid range and add all the options and can spend $4,000 or $7,000.
    Go to the Mac Store and do some looking and Google for reviews of software, hardware of course.
    Barefeats
    Rumors Pro
    Visit the forum for FCP-X would be a place to start.
    Final Cut Pro X

  • Need help finding errors.

    I need help finding the error(s) in my code. I am writing a program to convert decimal to binary. It is not an application. It is more of a blue print for an object.
    The Program is:
    public class DecimalToBinary
         private long decimal;
         private long binary;
    //Constructor setes the variable decimal and coverts and sets the variable binary
    public DecimalToBinary(int decValue)
         decimal = (long)decValue;
         binary = convert(decValue);
    //This method does the actual conversion from decimal to binary
    public long convert(long dec)
              long remainder = 0; //Start with initial value
         String bin = ""; //Start with a blank string
              while (dec > 0)
              remainder = dec%2; //get remainder
                   dec /=2; //get the number divided by 2
                   bin = remainder + bin; //concatenate the remainder to string
         return Long.parseLong(bin);
         //Accesor methods to get the value of decimal
    public long getDecimal()
         return decimal;
    // Accessor Method to return binary Value
    public long getBinary()
         return binary;
    // To string to represent Object.
    public String toString()
         String result = "";
    result = decimal +"\t\t\t" +binary;
         name1.getDecimal()     
         return result;
    The error I am getting is:
    DecimalToBinary.java:56: ';' expected
         name1.getDecimal()     
         ^
    1 error
    ----jGRASP wedge2: exit code for process is 1.
    ----jGRASP: operation complete.
    I've tried putting the ; in there but it doesn't help and only throws another error.

    Did you read the error message?
    DecimalToBinary.java:56: ';' expected
    name1.getDecimal() What is missing? Can you see where on the line of code it has identified that the missing thing is?

  • HT2204 I need help to change my security questions I have forgot them

    I need help to change my security questions I have forgot them

    If you have a rescue email address (which is not the same thing as an alternate email address) set up on your account then you can try going to https://appleid.apple.com/ and click 'Manage your Apple ID' on the right-hand side of that page and log into your account. Then click on 'Password and Security' on the left-hand side of that page and on the right-hand side you might see an option to send security question reset info to your rescue email address.
    If you don't have a rescue email address (you won't be able to add one until you can answer 2 of your questions) then see if this user tip helps : https://discussions.apple.com/docs/DOC-4551
    e.g. you can try contacting iTunes Support : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Account Management , and then try Apple ID Account Security
    or try ringing Apple in your country and ask to talk to the Accounts Security Team : http://support.apple.com/kb/HE57

Maybe you are looking for