Forum Replies Created
-
AuthorPosts
-
Peter KahrelParticipantDo you apply a character style to the footnote numbers (using a nested style)? If yes, check that character style and make sure that it doesn’t set a leading bigger than the paragraph’s leading.
Peter
Peter KahrelParticipantFinding names by Grep has been discussed in this forum and elswhere many times. Do a google on ‘indesign grep names’ and you get many references that you can use.
Peter
Peter KahrelParticipantIn what way does that code not work? Works fine for me.
Explain in some more detail what you want to do, because clearly I don’t understand it. You have a character style and a paragraph style. And you want to set up a Grep style in the paragraph style using that character style. Correct?
Peter KahrelParticipantSomething like this:
pstyle = app.activeDocument.paragraphStyles.add({name:"Paragraph – No Break"}); pstyle.nestedGrepStyles.add ({ appliedCharacterStyle: app.activeDocument.characterStyles.item('Character – No Break'), grepExpression: '. . .' });Peter
Peter KahrelParticipantWhat you want to avoid has no name as far as I’m aware because nobody objects to it. Some publishers want to avoid single-letter words (A, a, I) at the end of a line, but it still has no name.
That the expressio doesn’t work for you is probably caused by the double spaces that Ari mentioned, and his suggested solutions should handle that.
Peter KahrelParticipantYou want to keep together the first two words in a sentence. So you should exclude the period from the capture:
(?<=\. )\w+? \wThe so-called lookbehind
(?<=\. )reads “if preceded by a period and a space”. This means that the period and the space are included in the search, so they’re matched but not captured. Therefore the ‘no break’ will be applied only to the two words after the period+space.Note that the way you matched the first two words in a sentence —
\w+ \w+— doesn’t allow either of them to be hyphenated. The formulation above —\w+? \w— allows the second word to be hyphenated because only its first character is applied no-break. The first word is still applied no-break, so it won’t hyphenate. If you want to allow both words at the beginning of the sentence to kept together and to be hyphenated, use this GREP:Find what:
\. \w+\K
Change to: ~Sand blank the Find format and Change format panes. The above query paraphrases as “replace the space between the first two words in a sentence with a non-fixed-width space”. The \K designates a so-called variable-width lookbehind.
Peter
Peter KahrelParticipantThat report is not suitable directly to select a paragraph from. But something in-between that fancy approach (which is possible but requires more scripting) and nothing at all is the script below. Open the document, run the script, and enter the story id (in the report) and the paragraph index separated by a space, slash, whatever non-numeric, and press Enter or click OK.
(function () { var parId = prompt ('Enter a story id followed by the paragraph index:', ''); if (parId !== null) { // var parts = parId.split(/\D/); var par = app.documents[0].stories.itemByID(Number(parts[0])).paragraphs[parts[1]]; app.windows[0].activePage = par.parentTextFrames[0].parentPage; par.select(); } }());
Peter KahrelParticipantMade a mess of the codes. Sorry. But it’s still readable and correct.
Peter KahrelParticipantJim,
.+means 'one or more characters'.
.*stands for 'zero or more characters', so that would find</i><i>as well. But.doesn't match the end-of-paragraph marker, and in this case that seems good because </i> at the end of a paragraph and <i> at the beginning of the next one seem legitimate. Or not?P.
Peter KahrelParticipantThanks for your kind words, Ari.
P.
Peter KahrelParticipantJim,
This is a good candidate for changing italics formatting to text tags like <i>. . .</i>. That way you can look for a single non-italic character in an italic environment. After the italic conversion, such a character would look like this: </i>è<i> (italic off, è, italic on). Replace that with è and finally change the italic text tags to italic formatting.
To change italic formatting to tags:
Find what:
.+
Find format: +ItalicChange to:
<i>$0</i>
Change format: Regular (or Roman, Medium, Book — the non-italic stylen name of your font)Now replace
</i>è<i>withè. Or place all accented characters in your document in a class:</i>[éëê]<i>. Or target all single characters:</i>.<i>.Finally, rstore italic formatting:
Find what:
<i>(.+?)</i>
Find format: <nothing>Change to:
$1
Change format: ItalicPeter
March 31, 2016 at 7:11 am in reply to: Convert smart (curly) quotes to dumb (straight) quotes in InDesign using JS #83536
Peter KahrelParticipantWell, actually, no need to play with the document’s Typeographic quotes setting. (Grep) Find
", replace with~".
Peter KahrelParticipantHere’s a scriptlet to change the language in all paragraph styles:
styles = app.activeDocument.allParagraphStyles; for (i = 1; i < styles.length; i++) { styles[i].appliedLanguage = 'English: UK'; }To do character styles as well, change allParagraphStyles to allCharacterStyles.
Peter
March 26, 2016 at 4:21 am in reply to: Use GREP to apply Paragraph Style X when text is between Paragraph Style Y and Z #83416
Peter KahrelParticipantA GREP expression can match things in one style only: you can’t specify different styles for a search. But if your ingredients lists are always preceded by the word ‘Ingredients’ and followed by the word ‘Directions’, then you can use this GREP to apply your ingredients style:
Find what:
(?s)(?<=Ingredients\r).+?(?=\rDirections)
Change to: <Leave empty>
Change format: <ingredients style>(?s)// Consider the text as a single line so that . matches \r
(?<=Ingredients\r)// Match Ingredients and the following return
.+?// Math up to . . .
(?=\rDirections)// a return followed by DirectionsThis expression matches any paragraphs between Ingredients and Directions. The \r characters (paragraph breaks) must be part of the lookaround to avoid applying the ingredients paragraph style to the Ingredients and Directions headings.
Peter
Peter KahrelParticipantNo need for a table. Use a GREP to place the last names before the first names, sort the list, then use another GREP to place the last names after the first names:
Find what:
^(.+?) (.+)
Change to:$2@$1Sort the list
Find what:
^(.+)@(.+)
Change to:$2 $1Breakdown:
^Start of paragraph
(.+?)Match and capture up to (the first space)
Match the first space
(.+)Match and capture the rest of the paragraphPeter
-
AuthorPosts
