Adding hyperlinks and text ankles using Grep

Hi all

I tried to add both a hyperlink text source and destination within my document using Grep, but I can't seem to do things. I'm looking to find the source text that has the style of paragraph "1HD" and begins with the word 'History', and then turn that into the source text for the hyperlink. Secondly, that the text "References" later to become the anchor of the text to the destination of the link. As a reference, here is what is defined:

var myHeader = app.findGrepPreferences.appliedParagraphStyle = "1HD";
var myHeader = app.findGrepPreferences.findWhat = "Historical \w*";

as well as

var myAnchor = app.findGrepPreferences.appliedParagraphStyle = "";
var myAnchor = app.findGrepPreferences.findWhat = "References";

I did experiment with information I could get my hands on in line, but I always feel to get an error or another. Any guidance would be greatly appreciated!

Regards and thanks in advance.

Julian

Hi Julian,.

Can useful code, below

1 change the line 5 according to the guidelines of your paragraph Style request

var myDoc = app.activeDocument;
app.findGrepPreferences = app.changeGrepPreferences = null;

app.findGrepPreferences.findWhat = ".+";
app.findGrepPreferences.appliedParagraphStyle = "MN_first";
var myFound1 = myDoc.findGrep();

count = 0
for(k=0; k

To anchor text, use the code below:

var myDoc = app.activeDocument;
app.findGrepPreferences = app.changeGrepPreferences = null;

app.findGrepPreferences.findWhat = ".+";
app.findGrepPreferences.appliedParagraphStyle = "MN_first";
var myFound1 = myDoc.findGrep();

count = 0
for(k=0; k

Concerning

Siraj

Tags: InDesign

Similar Questions

  • Why would I not mix RGB and text colors using Gamma 1.00?

    Forms and text are slicked visibly better with the parameters of fusion in the section controls advanced settings color defined as follows:

    ColorSettingsGammaQuestion.png

    For example, consider the appearance of the edges of this text and the circular shape layer in a clear with these settings vs sRGB document:

    Defined as above:

    AAGamma1.0.png

    Authorized:

    AAGamma2.2.png

    The difference is subtle, but important in my opinion, marking the difference between good quality and good quality.  You can see the difference in the partial shading pixels at the edges curved in this enlargement of a part of the foregoing:

    BlendComparison.png

    So my question is this:

    Is there a reason that I would not only set the values above and use them all the time?

    I fully understand the concepts of gamma and post-pixel (and I think it's awesome that Photoshop has this feature), but I ask this question here because there may be of the subtleties of how Photoshop uses these settings, I'm not aware of and in particular that they are NOT defined in this way by default with Photoshop CS6.

    -Christmas

    Mix with gamma 1.0 will be slower and may lose precision (quantification).

    Mix with gamma 1.0 will make existing documents, or documents from other users look different.

    Most users should not change the settings.

    Some users who work with third party software which only works in gamma 1.0 may need change settings, and some researchers may need to change the settings for their work.

    Mixture of text using gamma 1.0 will not look correct.

    Text anti-aliasing is still more an art than a science. (and this is why there is always a setting for her)

    The gamma setting for text in CS6 mixture will result in glyphs appearing on weight even when light on dark and dark on light and different positions compared to the pixel grid.  Gamma 2.2 made dark light too fat and light on dark too thin. Gamma 1.0 makes dark on clear too thin and light on the darkness too fat.  The two extremes are glyphs seems to change shape when it is positioned in different phases compared to the pixel grid.

  • Is it possible to apply several styles of an entire text paragraph using GREP?

    Hello.

    I have a very complicated text, with a lot of formatting. It's a book liturgical altar, (Missal). He has a particular text for each day, it is in Latin and every paragraph, every day, as it's own particular formatting, including color in words, special characters, etc.. Very interesting work of InDesign. (Maybe I'll give more details later.)

    GREP will make things much easier. But I was wondering if there is there any tool which allows to have a group of GREP querys and apply a different paragraph style to all matches in the text, ALL IN ONE tool. (I know the search/replace tool, but I was looking for something even better.)

    It would be a great idea (I think) for future versions of InDesign, don't you think?

    I have many more questions on this project, but I will try to research as much as possible without having to open new positions. More details to come later.

    The can request handler that string together you a list of the various operations of fin/change GREP in a single operation, so you can set a query for each style, that you need, and then perform a single operation.

  • Adding default and hidden metadata using the SDK user interface values

    Hello

    Is it possible to add a default value to a xmp_property, but using the SDK UI?

    Also is it possible using the SDK of the interface user of adding option to a document without him appearing on the opinion of the Committee?

    For example, I want to add a file, XMP "animal" with the value "cat" label by using the SDK of the user interface, but without the information displayed on the Panel.

    Thank you

    Trevor

    All the metadata in a file will be shown in the Raw, but this area will be added to the other point of view and change signs for anyone to be able to see or modify.

  • Text added to the text field using the variable does not appear

    Hello

    I have a test field I created dynamically.  If I add some text to it by writing: myField.text = 'text', the text if poster, but if I add text using a variable is nothing.  If I trace trace text in the text field ("text =" myField.text) get good value.

    Someone at - it ideas?

    Best regards

    Chris McLaughlin

    Try to comment out the two lines below and see if it helps...

    ["textField" + guestCueCnt 'c'] .defaultTextFormat plus myFormat;
    ["textField" + guestCueCnt + 'c'] .embedFonts = true;

  • How to use GREP expression to group the last two words of a paragraph?

    Hi guys, I'm dealing with a document that is riddled with the orphan and want to use GREP to get rid of them all.

    I found this thread talking about how to group all the last 10 characters. But in my language, you can have up to 4 words together (almost a third of the sentence!) and still not break the limit of 10 characters. So if I use this expression, a sentence cut in half way, which make the whole paragraph looks horrible. I also tried the (\s\w+)? $ expression, but he left a few intact orphans (No. very random, model at all).

    So is there any other expression that can make the last 2 words of any paragraph together like glue stick?

    (\H+?\h ?) {2} $

    (^/)

  • Use GREP text style - help!

    I'm trying to learn the GREP style text... and hitting my head on a brick wall!

    The text is:

    Topic | Institution | Date

    Lorem ipsum dolor...

    I want to format the text before the line of the first vertical (|) as "BOLD", the text between the first and second vertical lines in italics and a third style to the text between the second vertical line and carriage return. The rest of the text (Lorem...) will be the normal paragraph style. Seems simple enough...

    I'm uncomfortable with the creation of character styles relevant for formatting I need, I can't just not work how to select the corresponding text. I can't figure out yet how to express 'select the text before' character as ' |'.

    Can someone help me write the GREP expression, or point me in the direction of some examples that contain similar phrases? I found that a few cheatsheets online (below), but none contain the phrase "select text before".

    http://www.night-Ray.com/regex.PDF

    http://www.ericagamet.com/wp-content/uploads/2011/11/Erica-Gamets-grep-cheat-sheet.PDF

    Joel Cherney wrote:

    Everything is build on grep, everything I have to do - just click on style of para.

    AHA! It is not a GREP query, but a collection of GREP styles. And you do not write em! Busted!

    No, I wrote them... but yes, it's a collection of styles. A bit like this:

    really not a big piece of art, but it works and can be used as a start point.its to everyone to decide what to use. What and when. Frankly, I almost forgot the nested styles even exist...

  • Toshiba value added logical and device for general use - what is it?

    Hello

    I completely put in place a new system on the Tecra S2, Win XP and everything. All the drivers from the site Web of Toshiba helped but now only a single 'questionmark' remains in the hardware Manager:

    Toshiba added value to general use and logical device

    I cannot find a driver anywhere or so for that. What is it indeed?
    The laptop works fine, no problem.

    Greetings,
    Ben

    I think it is (among other things) an ACPI driver...
    and you can download it-I remember...
    don't forget the 'value added package' and 'common modules' to install

  • I added my e-mail account current and most often used, but has any of my files from this account and any unwanted file.

    * Original title: e-mail files

    I just got my new computer with win10. I added my e-mail account current and most often used, but has any of my files from this account and any unwanted file. These files can be added?

    You cannot add folders to the Mail App. I suggest you to install an e-mail client. I use Thunderbird myself.

    Top 11 programs free email for Windows
    http://email.about.com/od/windowsemailclients/TP/free_email_prog.htm

  • A loop through hyperlinks and add * at the end of the hyperlink source text?

    Hello

    I'm sure it's very simple, but my javascript is a little rusty and a little short of time, so I was wondering if someone could point me in the right direction?

    I need a script that loops through all the hyperlinks in a document (no matter what styles are or are not applied). Please check the source text to see if it starts with "www" or "http".

    If the source text starts with "www" or "http" then do nothing. OTHERWISE add an * at the end of the text. In other words if there is text in the document as "Click on this link" (and there had a hyperlink applied) it would be changed to "click on this link." If there is text in the document as "www.google.com" (and there had a hyperlink applied), it would remain unchanged. The hyperlinks themselves remain unchanged.

    So I'm not sure what my If/else statement must be?

    Links = app.activeDocument.hyperlinks;

    for (i = 0; i < links.length; i ++)

    {if

    ???

    }

    Thank you very much in advance for your help!

    Angèle

    How stupid. You are absolutely right. The names of hyperlink above, test script must test the hyperlink source texts. In the small sample, I have tested the script on, names of hyperlink and source texts were the same, that's why I had not spotted the questionable logic of the script. This scripts properly tests:

    hlinks = app.documents[0].hyperlinks.everyItem().getElements();
    re = /^(?:http|www)/;
    for (i = hlinks.length-1; i >= 0; i--) {
      if (hlinks[i].source.hasOwnProperty ('sourceText') && !re.test (hlinks[i].source.sourceText.contents)) {
        hlinks[i].source.sourceText.contents += '*';
      }
    }
    

    This would also explain the unexpected behavior of your / ^ j / test. (/ ^ j / tests whether a string starts with 'j' - no need to the * or the parentheses.)

    Peter

  • Script to search for text and remove the hyperlink and characterstyle link which applies (back to normal)

    I need help with my script to search for text and remove the hyperlink and characterstyle link which applies (returns the normal text).

    I can't do either as I want.  I want the user to be able to type in a dialog text they want to search for, do search this text IGNORING case (case insensitive) and then for all instances that he find it, remove character styles that are applied to the (set to [none]) and delete the hyperlinks.

    My code seems to define the character style [None], when I click on the text and look at the window of character Styles, BUT all old styles (font color, underline) are always applied and removed not as I want.

    Also, I can't understand how to remove all of the old links.

    Here is my code:

    myDocument var = app.activeDocument;

    var noneStyle = myDocument.characterStyles.item ("[None]");

    var myFindVal = "";

    var myErrorText = "";

    var myErrorCount = 0;

    myDialog = app.dialogs.add var ({name: "search user submitted text and delete hyperlinks from objects found.", canCancel: true});

    {with (MyDialog)}

    {with (dialogColumns.Add ())}

    {with (borderPanels.Add ())}

    staticTexts.add ({staticLabel: "search and delete hyperlinks for :"}); "})

    myTextBox var = textEditboxes.add({minWidth:100});)

    }

    }

    }

    If (myDialog.show () == true) {}

    myFindVal = myTextBox.editContents;

    doSearchAndReplace();

    app.findTextPreferences = NothingEnum.nothing;

    app.changeTextPreferences = NothingEnum.nothing;

    If (myErrorCount == 0) {}

    Alert ("done! ("Part of the links have been removed for: '" + myFindVal + ""! "");

    }

    else {}

    Alert ("last error: '" + myErrorText + "' & number of errors:" + myErrorCount);

    }

    }

    myDialog.destroy ();

    function doSearchAndReplace() {}

    app.findTextPreferences.findWhat = myFindVal;

    app.findChangeTextOptions.caseSensitive = false;

    app.findChangeTextOptions.includeFootnotes = false;

    app.findChangeTextOptions.includeHiddenLayers = false;

    app.findChangeTextOptions.includeLockedLayersForFind = false;

    app.findChangeTextOptions.includeLockedStoriesForFind = false;

    app.findChangeTextOptions.includeMasterPages = false;

    app.findChangeTextOptions.wholeWord = false;

    var myFoundItems = myDocument.findText ();

    for (i = 0; i < myFoundItems.length; i ++) {}

    myRemoveHyperlinkAndStyle (myFoundItems [i]);

    }

    }

    function myRemoveHyperlinkAndStyle (myFoundItem) {}

    try {}

    myDocument.hyperlinkTextDestinations.item (myFoundItem) .remove ();

    myDocument.hyperlinkTextSources.item (myFoundItem) .remove ();

    myDocument.hyperlinkURLDestinations.item (myFoundItem) .remove ();

    myFoundItem.applyCharacterStyle (noneStyle);

    }

    {catch (MyError)}

    myErrorCount ++;

    myErrorText = MonErreur;

    }

    }

    Hello

    Right, some hyperlink might be a pageItem...

    expand the 'if' condition with:

    If (myHyp [len].source.hasOwnProperty ("sourceText") &... content ==...)

    Jarek

  • How to change the highlight color, click the button image and text and sound.  are there packages of buttons for use in my project?

    How to change the highlight color, click the button image and text and sound. are there packages of buttons for use in my project?

    Hello

    Even if the point of things based Web links buttons created using them is of simple images. Captivate uses simple images. If you need to put your creative hat and not to let the fact that you see the word 'web' scared you somehow. An image is an image. Use on the web, use Captivate. Same case!

    If you change the properties of the button, you can activate the legend of success. Fix any sound that you like with the legend of success and it will play when you click the button. If you do not want to see the legend of success, delete the text and configure it as transparent.

    See you soon... Rick

    Useful and practical links

  • rules of the clues in the text and oracle query using matches

    Dear all,

    I would like to ask questions about the function of rules and matches the oracle text.
    I followed a lead in the oracle text application developer guide.
    I have a table of rules like this:

    1 oracle
    2 larry or ellison
    3 oracle and text
    market share 4

    Then I create an index in this table. This is necessary for the matches function call. Here's the syntax:

    create index queryx on queries (query_string)
    indexType is ctxsys.ctxrule;

    Then, I noticed that the result on DR$ QUERYX$ I table as follows:

    0 2 2 1 LARRY (BLOB)
    MARKET 0 4 4 1 (BLOB) {MARKET} {ACTION}
    0 1 1 1 ORACLE (BLOB)
    0 3 3 1 ORACLE (BLOB) {TEXT}
    0 2 2 1 ELLISON (BLOB)

    What I want to ask is why do the words 'share' and 'text' appear in the DR table $ QUERYX$?

    When we use the function of the matches, it can search on the result of the index and therefore he walls can't find the word 'action '. Thus, when for example I ask like this:

    Select query_id queries where matches (query_string, "it only to share ten percent of all products sold") > 0

    It will give 0 results since no words in "it only to share ten percent of all products sold ' was in the index table. But in fact it could possibly be classified as category 4 rules which is "market share".

    I tried this in a large data set and get the same result.
    Here are my rules generated from my collection of document:

    1 {REQUIREMENTS of} & {ELICITATION}
    1 {REQUIREMENTS of} ~ {ELICITATION} & {ACTOR}
    1 {REQUIREMENTS of} ~ {ELICITATION} ~ {ACTOR} & {FURPS}
    1 {REQUIREMENTS OF} ~ {ELICITATION} ~ {ACTOR} ~ {FURPS} ~ {OUTLINE}
    1 {REQUIREMENTS of} ~ {ELICITATION} ~ {ACTOR} ~ {FURPS} ~ {OUTLINE} & {PROC}
    1 {REQUIREMENTS of} ~ {ELICITATION} ~ {ACTOR} ~ {FURPS} ~ {OUTLINE} ~ {PROC} & {SPEED}
    1 {REQUIREMENTS of} ~ {ELICITATION} ~ {ACTOR} ~ {FURPS} ~ {OUTLINE} ~ {PROC} ~ {SPEED} & {PDF}
    1 {REQUIREMENTS of} ~ {ELICITATION} ~ {ACTOR} ~ {FURPS} ~ {OUTLINE} ~ {PROC} ~ {SPEED} ~ {PDF} & {SET}
    1 {REQUIREMENTS of} ~ {ELICITATION} ~ {ACTOR} ~ {FURPS} ~ {OUTLINE} ~ {PROC} ~ {SPEED} ~ {PDF} ~ {SET} & {UNNECESSARY}
    1 {REQUIREMENTS of} ~ {ELICITATION} ~ {ACTOR} ~ {FURPS} ~ {OUTLINE} ~ {PROC} ~ {SPEED} ~ {PDF} ~ {SET} ~ {UNNECESSARY} & {MISUSE}
    1 {INTERPRETATION} ~ {REQUIREMENTS}
    2 {DESIGN of} & {PERFORMANCE}
    2 {DESIGN of} ~ {REPRESENTATION} & {MAY} & {FOUNDATIO} & {OCTOBER}
    2 {DESIGN of} ~ {REPRESENTATION} & {MAY} & {FOUNDATIO} ~ {OCTOBER} & {PROCEDURAL}
    2 {DESIGN of} ~ {REPRESENTATION} & {MAY} & {FOUNDATIO} ~ {OCTOBER} ~ {PROCEDURAL} & {STRICT}
    2 {DESIGN of} ~ {REPRESENTATION} & {MAY} & {FOUNDATIO} ~ {OCTOBER} ~ {PROCEDURAL} ~ {STRICT} & {ENTER}
    2 {DESIGN of} ~ {REPRESENTATION} & {MAY} & {FOUNDATIO} ~ {OCTOBER} ~ {PROCEDURAL} ~ {STRICT} ~ {ENTER} & {NUMBER} & {LAYER}
    2 {DESIGN OF} ~ {REPRESENTATION} ~ {CAN}
    3 {PM} & {TEST} & {ATTRIBUTION}

    And this is the result of table with a ctxrule index:

    (only the column token_text shown)
    PM
    DESIGN
    DESIGN
    DESIGN
    DESIGN
    DESIGN
    DESIGN
    DESIGN
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    INTERPRETATION

    so when I try to file a document with the word in there way, it should produce category 1 (based on rules), but since there is no word 'plan' in the tabel index, matches will return 0 means that the document is classifiedto not any category. I don't understand why this is happening. Everyone knows about it? I'd appreciate any help.
    Thank you very much.

    Share market means that the market immediately followed word on the part of the word, so if you don't have the word share then is not a match. If she had walked or hand, then he would be looking for just one part.

  • How to monitor the database and listener using grep

    Hi all

    This may sound simple, but I need to know.

    How do you analyze 2 processes and database listener using ps - ef | grep pid.

    I tried now
    [oradb04@dbserver ~]$ ps -ef|grep lsnr
    oradb03   7044     1  0  2009 ?        00:03:53 /oracle/fdqmdb/10.2.0/bin/tnslsnr FDQM -inherit
    oradb05  13504     1  0  2009 ?        00:00:15 /oracle/fdqmsitdb/10.2.0/bin/tnslsnr FDQMSIT -inherit
    oradb01  21066     1  0 Jan07 ?        00:11:27 /oracle/hypdevdb/10.2.0/bin/tnslsnr HYPDEV -inherit
    oradb04  23116     1  0  2009 ?        00:06:56 /oracle/hypsitdb/10.2.0/bin/tnslsnr HYPSIT -inherit
    oradb04  25605 24208  0 23:04 pts/0    00:00:00 grep lsnr
    [oradb04@dbserver ~]$ ps -ef|grep pmon
    oradb01   3589     1  0 03:21 ?        00:00:02 ora_pmon_HYP11DEV
    oradb03   4097     1  0  2009 ?        00:00:01 ora_pmon_FDQM
    oradb05  12831     1  0  2009 ?        00:00:04 ora_pmon_FDQMSIT
    oradb04  22671     1  0  2009 ?        00:00:37 ora_pmon_HYP11SIT
    oradb04  27517 24208  0 23:05 pts/0    00:00:00 grep pmon
    [oradb04@dbserver ~]$ ps -ef|grep lsnr
    oradb03   7044     1  0  2009 ?        00:03:53 /oracle/fdqmdb/10.2.0/bin/tnslsnr FDQM -inherit
    oradb05  13504     1  0  2009 ?        00:00:15 /oracle/fdqmsitdb/10.2.0/bin/tnslsnr FDQMSIT -inherit
    oradb01  21066     1  0 Jan07 ?        00:11:27 /oracle/hypdevdb/10.2.0/bin/tnslsnr HYPDEV -inherit
    oradb04  23116     1  0  2009 ?        00:06:56 /oracle/hypsitdb/10.2.0/bin/tnslsnr HYPSIT -inherit
    oradb04  27520 24208  0 23:05 pts/0    00:00:00 grep lsnr
    [oradb04@dbserver ~]$ ps -ef|grep 23116
    oradb04  23116     1  0  2009 ?        00:06:56 /oracle/hypsitdb/10.2.0/bin/tnslsnr HYPSIT -inherit
    oradb04  27661 24208  0 23:06 pts/0    00:00:00 grep 23116
    [oradb04@dbserver ~]$ ps -ef|grep 22671
    oradb04  22671     1  0  2009 ?        00:00:37 ora_pmon_HYP11SIT
    oradb04  28774 24208  0 23:06 pts/0    00:00:00 grep 22671
    [oradb04@dbserver ~]$ ps aux|grep 22671
    oradb04  22671  0.0  0.0 3295640 23896 ?       Ss    2009   0:37 ora_pmon_HYP11SIT
    oradb04  32317  0.0  0.0  61088   700 pts/0    S+   23:09   0:00 grep 22671
    [oradb04@dbserver ~]$ ps aux|grep 22671|grep 23116
    [oradb04@dbserver ~]$ ps aux|grep HYP|grep 22671|grep 23116
    My need is a single command to show the status of pid 22671 and 23116

    Kind regards
    Sam

    If you use Linux, you can try ps - fp :

    $ ps -fp 4738 18890
    UID        PID  PPID  C STIME TTY      STAT   TIME CMD
    oracle    4738     1  0  2009 ?        Ss     0:06 ora_pmon_DB102
    oracle   18890     1  0 Jan04 ?        Ssl    0:01 /oracle/app/oracle/product/10.2.0/dbhome_1/bin/tnslsnr LIS
    
  • Using "States" on the image and text together

    I'm having a problem with 'States' of an image with text above. I would like for the image to 100% opacity and text to be hidden in the States 'normal' and 'active '. In the States of "mouse down" and the 'reversal', I would like the image to have an opacity of 20% as well as the text to be visible.  Basically, I'm trying to achieve a similar effect to this Web page: http://www.shedbuilt.com/#mi=11 & pt = 0 & pi = 39 & p = -1 & a = -1 & at = -1. I can define States for text and image separately, but I would like that they work as a single object when it is tilted. Thanks for your help!

    Try the widget status button

    Abhishek

Maybe you are looking for