Review of the text of the paragraph is bold or italic [JS] CS3

Hello

I'm trying to write a script to check a document in section my paragraph and change the text leading 8 and size of points if it is not bold or italic. The problem that I'm trying retrun value I can used to search the text of paragraph is "BOLD" and or italic.

Does anyone know how to do this?

Here's what I have so far;

var the_document = app.documents.item (0);
var the_story = app.selection [0] .parentStory;

counter = 0;

{}
var current_paragraph = the_story.paragraphs.item (counter)


{with (the_document.textDefaults)}

var mytextobject = current_paragraph.texts.firstItem ();
mytextobject. Leading = 8;
mytextobject.pointSize = 7;
}

counter ++;
} While (counter < the_story.paragraphs.length);

The font style is held in a text property called "fontStyle", a string of simple text holding something as "Ordinary", "Italic", "Bold" and "Bold Italic" (or, depending on your policy, something like 'Condensed Light', ' "Extended BOLD" #2 "or"76 Black Italic"").

ATTENTION: you seem to be checking the entire paragraphs. If the fontstyle is mixed, the property will be indefinite. It will be "Bold" or "Italic" If the entire paragraph, including his final statement is bolded or italicized .

Tags: InDesign

Similar Questions

  • detect if the selection is in bold or italic.

    Hello, I am building a very simple with only one button, bold and italic text editor.
    I have more options, but I was wondering how can you detect when you select
    a text if this selection is bold or italic, or bold and italic?

    Anyone has any idea on this?

    Use getTextFormat with selectionBeginIndex and selectionEndIndex.

    var format: TextFormat =
    textField.getTextFormat)
    textField.selectionBeginIndex
    textField.selectionEndIndex);

    trace (format.bold, format.italic)

  • Find/replace, searching for specific text to replace it with the paragraph tag

    I tried to replace a string of text that I have at the beginning of a paragraph indicating a certain style of paragraph with this style of ID while eliminating the text string. For example, I put @IN1 at the beginning of a paragraph I want formatted with the paragraph of my ID IN1 style. However, when I have 'Search' @IN1 with no. find format and 'to' do not change (i.e. empty) with the paragraph style selected 1 selected under format change, it applies the paragraph style, but does not delete the text string @IN1. When you do a search/replace without the portion of paragraph desired syle, he removes the @IN1 correctly. It is a bug, or is there something I have to put in the change of area indicate no text? Thank you

    Using the GREP tab, find ^ (@IN1) (.) and replace with $2 and set the paragraph style in the change of format.

    The ^ beginning of paragraph says and the $2 is the second subexpression matching.

  • How get the text of each paragraph when a textStyleRange is made of texts to multiple paragraphs

    Hello

    Always on my account findText. The result is sometimes as a textStyleRange which contains the texts of multiple paragraphs. What is the best (and easy) way to get the text of each paragraph individually?

    Example: The result of an italic findText with the following extract gives me "saectur quatur? " " Ipsapidunte our" as a unique textStyleRange (correct) but I want to get the text of each paragraph.

    Is there a way to force the findText in the paragraphs and not those of them and if not, how to cut the textStyleRange in 2 texts?

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

    Our Ipsapidunte and eumquosame derepre id ulparch iliquae offic tem faccusd aecaborrum, sequi aut doloreperi quaectem eatem faces very quam, con nullaccus repratur molorio enis modi sumquibus nostemquam and volorum facidunti nonseditati re a dolut dolorest ab idipitem saectur quatur?

    Our Ipsapidunte and eumquosame derepre id ulparch iliquae offic tem faccusd aecaborrum, sequi aut doloreperi quaectem eatem faces very quam, con nullaccus nostemquam repratur molorio enis modi sumquibus and re volorum facidunti nonseditati a saectur dolut dolorest ab idipitem quatur?

    There are two solutions:

    (1) you could be formatted every paragraph with formatting marks that you know doesn't exist anywhere else. In this way, each textStyleRange is guaranteed to end at the end of the paragraph.

    (2) you can access the entire first paragraph: myTextStyleRange.paragraphs [0]. I have not tested, but no doubt it works. You could also do a loop: paraLength = myTextStyleRange.paragraphs.length; for (i = 0; i< paralength;="" i++);="" mypara="myTextStyleRange.paragraphs[i];}">

  • How to create link for reference to the paragraphs or text anchor to another indesign file?

    Hello

    I'm new in indesign scripting.

    I want to create the reference, which is the link to the paragraphs (or text anchor) another indesign file (new.indd).

    My first problem is how to get all the paragraphs or anchor text of the file new.indd

    I have a TextFrame whose content is Adobe Indesign.

    I want to apply an Adobe Indesign link reference to the paragraphs with the Destination Documents: new.indd.

    How it's done by script?

    I have try to use this:

    indesign #target

    myDocument var = app.documents.add ();

    var myTextFrame = myDocument.pages.item (0).textFrames.add ();

    myTextFrame.geometricBounds is ['10', 15 ' p', '30', '35p'];.

    myTextFrame.contents = "Adobe Indesign";

    var text = myTextFrame.texts.firstItem ();

    var hyperlinkURLDestination = myDocument.hyperlinkURLDestinations.add ("C/Documents and Settings/Administrator/Desktop/new.indd");

    var DestinationDoc = hyperlinkURLDestination.parent ();

    var xRefForm = myDocument.crossReferenceFormats.item ("Page number");

    source var = myDocument.crossReferenceSources.add (text, xRefForm);

    var myLink = myDocument.hyperlinks.add (source, hyperlinkURLDestination);

    When I run this script it gives error "the destination is not valid. You can create Cross - reference to anchor text or destination of the paragraph.

    How to get all the Paragrapgs or text the file new.indd anchor and create cross-references using the this.

    Thank you.

    You can create cross-references to anchor points and paragraphs. If you need create an anchor text in new.indd, then use as the target of the cross reference:

    var anchor = app.documents.item ('new.indd').hyperlinkTextDestinations.item ('myAnchor');

    source var = app.activeDocument.crossReferenceSources.add (text, xRefForm);

    app.activeDocument.hyperlinks.add (source, anchor);

    Peter

  • get the text of the paragraph?

    Hi all

    How to extract text perticular single paragraph object.  I've searched the forums and get the paragraph.texts.itemByRange () methods, but I don't know how to use this method to get the text of perticular and I want to delete the text of the paragraph.

    I would appreciate for any help to...

    Kind regards

    Imagine

    Sorry, that makes it clearer.

    1 itemByRange is useful only when you have the beginning and the end of the range in the form of numbers. What, where you plan to do? Ask in a dialog box from where to where to remove them? The lines "the user has selected" text are just a choice, and you can manipulate that immediately. There is no reason to convert it to a format usable for itemByRange first.

    2. at this stage in your stage of learning, should not focus on Getting the * thing at work, rather than focusing on writing elegant, easy to manage, short but not darkened code? All of you who have no meaning if your script does not run.

  • Script to determine the number of lines of text in a paragraph?

    I'm revisiting a problem I posted here last summer, thanks to all those who have offered help, but I could not sort it out.

    http://forums.Adobe.com/thread/455526?TSTART=0

    What I'm after is a 'search' function to insert in a FindChangeByList.

    Jongware suggested the following - but when inserted in my list, I can't seem to do anything - it does not take a Javascript error.

    app.findTextPreferences = NothingEnum.nothing;
    app.findTextPreferences.appliedParagraphStyle = "Callout_3";
    foundItems = app.activeDocument.findText();
    for (var i=foundItems.length-1; i>=0; i--)
    {
      if (foundItems[i].paragraphs[0].lines == 2)
        foundItems[i].paragraphs[0].appliedParagraphStyle = "Callout_2";
      if (foundItems[i].paragraphs[0].lines == 1)
        foundItems[i].paragraphs[0].appliedParagraphStyle = "Callout_1";
    }

    I regularly get a 'word' document on which I run a "FindChangeByList" that cleans and formats the text with a number of GREP/text searches.

    One of the lines of research converts a particluar to the text string to a paragraph style "Callout_3" (the most common legends).

    This style applies to paragraph NET, above and below the line, to create a block/strip of color that says text is reveresed.

    The problem I have, is that the style (due to the rules of paragraph), works well if the paragraph has x 3 lines of text.

    I have updated styles in place for any eventuality - Callout_1 (for the single line of text), Callout_2 (for x 2 lines of text) etc.

    I'm looking for is a script that can count the number of lines in the paragraph (once the "Callout_3" style has been applied) and then change the style accordingly the number of lines in each paragraph/legend.

    Any other thoughts?

    Steve

    -your script can be incorporated into a FindChangeByList .txt file?

    No, he needs to access real paragraph finds it to count the number of line of this paragraph. FindChangeByList Find/change regular strings together, and you can not search for a certain number of lines.

    -what it takes to go to the 'findStyle ('Callout_1');"reference within a"group of paragraph style"called"legends "?

    ... Nothing. Because the style can be within a group, I wrote this little function. The findStyle performs a loop on * all * paragraph styles in the document, the root and in each group and returns the first style with the name that you provide in the function call (tested!).

    So if there is a 'Callout_1' style anywhere, it should find it... Are you sure you put the name at the top of the script? I've seen in a post later that it is actually called "Callout_1line".

  • (AS) Select the text of the paragraph without bringing out the carriage return

    (AS) Select the text of the paragraph without bringing out the carriage return character.

    I need help to select a paragraph in a story.
    The selection does not contain a 'return' (ASCII number 13 ")

    My current sample is as follows:
    -example assumes that the insertion point is already placed in a specific paragraph.

    Tell application "Adobe InDesign CS3"
    activate
    theDoc Set to the active document
    say theDoc
    Select the paragraph 1 of the selection
    end tell--theDoc
    end tell--app

    Sounds simple... The example above to select my paragraph selected.

    but he also chose the carriage return also. How would I go to do this?

    Any advice would be helpful!

    Thank you!

    Try:

    Select text in character-2 of paragraph 1 of the selection of character 1

  • Display of the paragraphs of the text from MySQL database

    Hi all

    I have a small database used to store news articles and post them on a website.  However what is happening, is that the press articles are not displayed with the information in the paragraph which came it.


    When the page is displayed it just displays the text in a block even if I see the carriage returns if I discover the database in phpMyAdmin.

    Can someone help please?

    You have two options:

    • Save your items with embedded HTML (use something like FCKEditor or TinyMCE to add HTML features to your text box on the entry form)
    • Place two new lines between each paragraph in the text entry and use the PHP function nl2br() displaying the output

    Dreamweaver CS4 (and CS3) go insert nl2br() around dynamic text if you double-click the dynamic text object in the server behaviors panel and select Convert - new lines to BRS licences in the menu format. This encapsulates the object dynamic text as follows:

    
    

    nl2br() converts line-break characters in
    .

  • Why wrap text too early before the paragraph width is reached?

    I was highlighting the elements on one of my pages (you will see the blue outline) and noticed that my paragraphs is enveloping way too quickly before it reaches the full width of the paragraph. In the image below, I even copied a screenshot in Photoshop and saw that I could move one of the words ("these") upwards with plent of spare part. What is going on?

    http://www.keithpurtell.com/kthings/para.gif

    And here is a link to the page, then you can check the HTML/CSS integration...

    http://www.keithpurtell.com/kthings/Claude-Debussy.htm

    (And Yes, I know that CSS validation choke on my gradients.)

    The browser is obedient padding-right: 10% and max-width: 38em rules on the p tag in the main style sheet

    p {make: 1em/1.4 normal;}
    letter-spacing: .03em;
    margin: 0 0 1em 0;
    Max-width: 38em;
    {padding-right: 10%;
    }

    Tip: use F12 (Developer Tools) in IE or Firefox extension Firebug and you can quickly isolate the CSS rules that cause these issues by simply clicking on the defective elements in page with your mouse.

  • Change the paragraphs found in the standard paragraph style?

    I have look here for about an hour and could not find a discussion for this.  I see where it clears the substitutions but not change Style all together.  Here's what I need help do.  If I left saying text 4 selected boxes, I want the power to change the standard paragraph to paragraph and character set to None style style. If there is already can a discussion that I missed in this regard you point me in that direction.  If this is not the case, can I please help with this.

    You can usetpk1982of script to change all the paragraphs of the standard paragraph. But if you only want the block of selected text, then you will need to adjust thescript to change paragraph styles in the selected text frames.

    basically replace line 2 by var allTFrames = app.selection;
    Also, if you need to clear character styles need to do before you change the paragraph style or character styles will be removed and the formatting will be left as a local override.  Your final script after that these changes would be:

    myDoc var = app.activeDocument;

    var myTFrames = app.selection;

    for (var i = 0; i)< mytframes.length;="" i++)="">

    var tFrame = myTFrames [i];

    pStory var = tFrame.parentStory;

    var allParas = pStory.paragraphs.everyItem ();

    pStory.characters.everyItem () .appliedCharacterStyle = app.activeDocument.characterStyles [0];

    allParas.appliedParagraphStyle = app.activeDocument.paragraphStyles [1];

    }

    Note: instead of simply replacing the 2 wire I also changed the name of the variable to reflect rather than leave it in the form allTFrames; and add line 7... Other than these two changes everything was the script of tpk1982

  • Balls, created in the paragraph style options in Indesign

    Hi all

    In the paragraph style, how to create bullets before the text and after the text also.

    Please someone help me solve this problem.

    I have attached the screenshot of the sample. Like that, I must create in indesign paragraph style options.

    Capture.JPG

    Thank you...

  • Cannot delete the paragraph format

    I created a template with titre3 instead of Head3 - same name just different properties. I deleted all the paragraph formats, imported the new model, updated headers. Head3 remains persistent in the document. I don't then uncheck the box for NextParagraph so that there is no required following paragraph. It just removes himself from the period of document. I tried to remove it from the catalog and it does not remove the format. But this is still in the document. Any thoughts?

    I noticed something like this in the past as well. I don't know what caused it.

    My problem was:

    • Save as MIF.
    • Open the MIF with a text editor.
    • Search the text in the paragraph of the problem.
    • Check if it has the attribute set to Yes flocked. If Yes, change the No.
    • Save the MIF file.
    • Open it in FrameMaker. Check, if you can change the format of your problem paragraph subsection.
  • [JS] Copy or move the paragraph and character style style

    Hello
    I try to transfer paragraphs a the document to a block a second document but I have hugs the style of paragraph et style character applied.
    I use this command line:


    o.leBlocLegendes.contents = o.leBlocLegendes.contents + leDocument.stories.firstItem().paragraphs[leConteurPara].contents;
    
    


    How do I do not lose anything?

    Thank you


    Original message

    Hello

    I am trying to transfer of the paragraphs in a document to a block of a second document but I loses all the style of paragraph and style of applied character.

    Plug-in this command line:

    o.leBlocLegendes.contents = o.leBlocLegendes.contents + leDocument.stories.firstItem().paragraphs[leConteurPara].contents;
    

    Comment do pay nothing lose?

    Thank you

    Hi Liphou,

    .silence is indeed a property of type string only disregardingly of styles, anchor frames and other animals.

    You prefer the use of object methods and duplicate stories. However styles can be substituted with the target document. If you can load styles before the duplication of the text.

    var main = function() {
        var doc, st, tempDoc, f, tf;
        if (!app.documents.length
            || app.selection.length!=1
            || !app.selection[0].properties.parentStory) {
            alert("You need to select text or text frame");
            return;
        }
    
        doc = app.activeDocument;
    
        if ( !doc.properties.fullName ) {
            alert("Please save file first !");
            return;
        }
    
        st = app.selection[0].parentStory;
        f = File ( doc.fullName );
        tempDoc = app.documents.add();
        tempDoc. importStyles ( ImportFormat.TEXT_STYLES_FORMAT, f, GlobalClashResolutionStrategy.LOAD_ALL_WITH_OVERWRITE );
    
        tf = tempDoc.textFrames.add();
        st.duplicate(LocationOptions.AT_BEGINNING, tf.insertionPoints[0]);
        tf.fit(FitOptions.FRAME_TO_CONTENT);
    
    }
    
    main();
    

    HTH,

    Loïc

    www.ozalto.com

  • Entries of table of contents in the first word of the paragraphs

    Hi all. I would appreciate your help in this matter.

    Currently my page format will-

    Section

    1 subtitle. Lorem ipsem asjdlffojsdlf asldfjlsjfklsf.

    These two have a point each, with the other having automatically number each paragraph style (where the 1. + the dash).

    The Question- How can I get my OCD to show that the word 'subtitle' and is not the number, and the rest of the paragraph is?

    Also - think There are a few paragraphs that have the same style (so that each paragraph numbered), but I don't want to show them on the table of contents, as they do not have a subtitle.

    Your help is very appreciated. Thank you all.

    Ah, you're right. You cannot apply the condition directly as part of a style of characters, but you can always do it in several steps.

    First define the style of character, and in this case everything there need for attributes is a unique name. Once defined, apply it to the text a nested style or GREP style in your paragraph style from the list after the text that you want to keep the separator character before the page number. Once the generated table of contents you can use find/replace to find this style of character and to apply the condition, and then finally to hide the State in the Panel (State must be visible for search/replace to apply it).

Maybe you are looking for