Back

If your email is not recognized and you believe it should be, please contact us.

Forum Replies Created

Viewing 15 posts - 166 through 180 (of 1,338 total)
  • Author
    Posts
  • in reply to: XML Attributes problem #34226

    An interesting challenge — a mix of Proper User Interface, Ease of Use, Adjustability, and a side dish of How Does This Xml Stuff Actually Works.

    Try this script. You must fill in the tag name of your figures in the first variable, and fill the list ‘labels’ with the attribute names you want to add/change.
    The forum converts straight single and double quotes to curly ones, and you’ll have to change them back to straight before it can work. If you use the ESTK Editor to edit your scripts, you will see properly quoted text strings marked with a color, that might help.

    — 8< —- script follows below

    // xmlElementName contains your base XML tag
    xmlElementName = “Figure”;

    // attribute labels; add at will
    var labels = [
    “href”,
    “width”,
    “height”,
    “label3”,
    “etcetera”
    ];

    var values = new Array(labels.length);

    if (app.documents.length == 0)
    alert (“uh you didn’t open any document”);
    else if (!app.activeDocument.xmlTags.item(xmlElementName).isValid)
    alert (‘oh there seems to be no tag named “‘+xmlElementName+'”‘);
    else if (app.selection.length == 0)
    alert (“ah you forgot to select anything”);
    else if (app.selection.length > 1)
    alert (“please one at a time only!”);
    else if (app.selection[0].associatedXMLElement == null)
    alert (“yeah this object has no tag to begin with”);
    else if (app.selection[0].associatedXMLElement.markupTag.name != xmlElementName)
    alert (‘this object is tagged but with “‘+app.selection[0].associatedXMLElement.markupTag.name+'”, not with “‘+xmlElementName+'”‘);
    else
    {
    var obj = app.selection[0];
    var w = new Window(“dialog”, “Result”);
    for (i=0; i<labels.length; i++)
    {
    with (w.add(“group”))
    {
    add (“statictext”, undefined, labels[i]);
    values[i] = add (“edittext”, undefined, “”); values[i].characters = 30;

    prevVal = obj.associatedXMLElement.xmlAttributes.item(labels[i]);
    if (prevVal.isValid)
    values[i].text = obj.associatedXMLElement.xmlAttributes.item(labels[i]).value;
    }
    }
    with (w.add(“group”))
    {
    orientation = “row”;
    add (“button”, undefined, “OK”);
    add (“button”, undefined, “Cancel”);
    }
    if (w.show()==1)
    {
    for (i=0; i<labels.length; i++)
    {
    prevVal = obj.associatedXMLElement.xmlAttributes.item(labels[i]);
    if (prevVal.isValid)
    obj.associatedXMLElement.xmlAttributes.item(labels[i]).value = values[i].text;
    else
    obj.associatedXMLElement.xmlAttributes.add(labels[i], values[i].text);
    }
    }
    }

    in reply to: Grep-string for specific text between parentheses #34214

    You don’t say what GREP you are using now, but I guess it’s something like this:

    \(.+?\)

    — very simple, “pick up everything inside parentheses”. Let’s go through your specifications:

    1. “start with capitalized names”:

    \(\u.+?\)

    already works a treat. The only extra it picks up is your remark “(I doubt it, hierarchy)”.

    2. “end with one or more digits”:

    \(\u.+?\d\)

    Hmm. For some reason this picks up too much text — it crosses over a closing parenthesis! (Which is not an “error” per se, but rather an unexpected interpretation of the Rules. Careful examination shows it still does EXACTLY what you ask for!)
    An alternative notation works as expected:

    \(\u[^)]+\d\)

    3. “most of the time, a 4 digit date”:

    GREP cannot handle ‘most of the time’ … But if you find the last expression skips occurrences that for some reason do not end with a digit but DO contain a year, you can add this as a second GREP style:

    \(\u[^)]+\D(19|20)\d\d(?!\d).*?\)

    .. it matches capitalized name, then Not-A-Digit, followed by either “19” or “20” and two digits, and then just about anything up to a closing paren.

    4. “override GREP with none”:

    No– but you CAN override a GREP style with a character style that applies the original font again, not ‘removing’ the font but rather overriding it a second time. But I would only do so in case of an acute emergency — it’s better to make your GREP styles work for you instead of fighting them.

    in reply to: Slang & Apostrophe Usage #34175

    Is ’em the only single ‘uns, or are you mixing them with ‘actual’ single quotes as well?

    But ‘twould be too easy, I guess, if your “actual” quoting quotes were all double — then all one’d need is look for “space apostrophe” (to avoid “can’t”, “shan’t”, and “wan’t” (yes: the latter I actually encountered)).

    in reply to: Number List in Tables #34174

    Merge the cells in each row vertically.

    If you don’t want to do this, for one reason or another, then you can’t use automatic numbered lists to do what yo want.

    in reply to: change Footnote style #34173

    The only choice of applying prefixes and suffixes is to either one, or both, reference and note number. Nothing in there to specify one format for one and another for the other.

    An ugly way could be to mess around with the Note paragraph style and try to get rid of the leading space. However, a quick try shows that this is a regular space — it grows and shrinks with the others on the same line. You could make it a non-breaking fixed width space …

    (After some fruitless tinkering) Best is not to rely on ID’s automated systems, then. Set the right prefix and suffix for *one* of the two, and add it for the other as regular text.
    If you use Prefix/Suffix for the Footnote References and your footnote text always has the same style, you can easily use Find/Change to add the parentheses around the number:

    * add parentheses around the footnote marker
    * copy
    * in Find/Change, search for ^F in your footnote text style
    * replace with ^C

    One way to get rid of spell check problems is marking these names with [No Language]. However, as a side effect ID will stop hyphenating them. (Which is usually not a problem. But it is a side effect nevertheless.)

    You could also mark the names with the *same* language — that way you only have to add them to a single language dictionary.

    If you are using paragraph styles, and the styles for all different languages are derived from a single parent style, you could check if it’s worth adding a GREP style that applies this One Language To Rule Them All.

    in reply to: Shortcut for "No break" ? #34117

    There is no default shortcut for No Break. But, as Bob said, it’s easy to add one. (I second Tim’s obsvn. that Peter was not looking for the character “Non-Breaking Space.)

    Go to Edit > Keyboard Shortcuts > Panel Menu’s. Scroll down the list for “Character: No Break”. Set it to whatever you want — I use “Ctrl+Alt+B” (I think it originally did something else that wasn’t as useful). You don’t need to memorize or write down the combo; as soon as InDesign allows you to use it, you will also see the combo appear in the Character Panel menu next to the No Break item, just like any other shortcut.

    In general, to locate a command quickly, it’s easier to just click the “Show Set” button. This loads the complete set of shortcuttable items into your default text editor, and then you can use its Find Text option to locate what you need.

    in reply to: Indyfont #34115

    > .. an indesign file was opened with many many pages (why?)

    Probably because you asked for it? Please see the manual on how to enter character ranges. If you entered something like ‘A..Z’, IF will create 26 pages. If you entered something else, such as ‘!..~’, you will get something like 90 pages.

    If you are using the demo, it will only export the very first character, so it’s no use to create an entire font.

    > .. it started up a new font again (it didnt save me), why?

    Since I cannot look over your shoulder and see what you are doing wrong, can you please

    1. Make sure you are trying with the latest version.
    2. Download the manual.
    3. Follow the instructions starting on p. 4, “7. Create your first font” EXACTLY.

    When done properly, you end up with a one-character font.

    in reply to: Indyfont #34106

    Wait a minute. The latest demo version doesn’t have an “OK” button, it’s called “Create” instead (but you still can’t press it until you enter some characters to create).

    Make sure you download the latest version, also from that same site.

    in reply to: Indyfont #34105

    You need to give it some characters to create first. That’s probably the issue here.

    On Marc Autret’s site you can download the manual (https://www.indiscripts.com/post/2013/05/indyfont-1-1-public-pro-release-and-users-guide).

    in reply to: Only select tables in current story #34090

    Glad you like the article! This is, by the way, exactly how I learned to write scripts: start with an original working script, customize some details to fit, and then try to change it to do *exactly* what you need.

    The line that’s responsible for processing tables document-wide is this one, in the function checkUserSelection:

    allTables = app.activeDocument.stories.everyItem().tables.everyItem().getElements();

    To process only tables in the ‘current’ story, change it to this:

    allTables = app.selection[0].parentStory.tables.everyItem().getElements();

    .. and to process only tables inside a text selection, try this:

    allTables = app.selection[0].tables.everyItem().getElements();

    in reply to: How to change 'space' to 'tab' with GREP #34075

    It does exactly what you ask: if you press the Find button, you will see it highlights the digit(s), period, and space. That is what gets replaced with just the single tab in your Replace field.

    There are two straightforward solutions. You already bracketed the not-to-be-removed part of the expression, so you can “recall” that in the Replace field using “$1”:

    $1

    A slightly better way is not to highlight the digit at all and only change the actual space to a tab. Search for this:

    (?<=\d\.)

    and replace with just a single tab. This looks for a space which *must be preceded* by a single digit and a period (so these are *not* included in the found expression). Then only the space gets changed. This is ‘better’ in the sense that it’s best to replace only what needs to be changed; in this case, the space itself.

    A note: is not really just a space, it’s all kinds of spaces. That sounds ideal, except that this also considers both the hard return and the soft line break as “space”. So in this case, you might be changing hard returns to tabs as well.

    Then again, maybe that’s exactly what you want :)

    If not, you can build a list of space types you *do* want to change. Use this: [ ~S] instead of the single code . This is “tab, space, unbreakable space”; you can add all other space codes you think you may need.

    in reply to: GREP to cut text and paste in separate text box? #34069

    Ah, so this was the “other” question. Redbook is correct, it seems all that’s needed here is a different GREP search. Use this to locate your curly bracketed remarks:

    app.findGrepPreferences.findWhat = “{.+?}”;

    (don’t forget to straighten the quotes out)

    In this case, for GREP you need to ‘escape’ the curly brackets because they are special command codes. In addition, you do not want “all that you can get” between an opening and closing curly bracket — if there is more than one set in a single paragraph, GREP will happily grab all between the very *first* opening bracket and the very *last* closing one. To prevent this, you add a ‘?’ after the ‘grab-anything’ command ‘.+’; it will now match the shortest possible match instead of the longest possible.

    in reply to: Marginal line numbers extracted from text #34049

    Cool! Glad you could get it to work, Debugging By Proxy is hard.

    Also thanks for the heads up on the quotes. I’ll try and remember that next time I post a script — I don’t think David can make this issue go away on the forum.

    in reply to: Marginal line numbers extracted from text #34044

    Try something like this. Please check if the new forum didn’t interfere with the code!

    app.findGrepPreferences = null;
    app.findGrepPreferences.findWhat = “[d+]”;
    numberList = app.activeDocument.findGrep(true);

    for (i=0; i<numberList.length; i++)
    {
    tf = numberList[i].textFrames.add({anchoredObjectSettings:{anchoredPosition:AnchorPosition.ANCHORED, anchorXoffset:”1mm”}});
    tf.geometricBounds = [“0mm”,”0mm”,”10mm”, “50mm” ];
    numberList[i].move(LocationOptions.AT_BEGINNING, tf.texts[0]);
    tf.fit (FitOptions.FRAME_TO_CONTENT);
    }

Viewing 15 posts - 166 through 180 (of 1,338 total)