Copy link to clipboard
Copied
Any GREP code for the below would be really helpful. Either to use as a GREP style or to use in find/change.
I want "character style A" applied to the brackets which have arabic characters in between them.
And i want "character style B" applied to the brackets which have English characters in between them.
[My purpose is
If the brackets have arabic text in between them, they will have character direction right to left applied. And if there is English text in between them then they will have character direction left to right applied to them]
Copy link to clipboard
Copied
I am only a journeyman with GREP, but the place to start is how you are handling the language transitions. It seems to me, and you state that you're using Character Styles to map either the Arabic passages in English text, and vice versa. So starting any GREP search by looking for that, or those, Character Styles would be the key to selecting one or the other. Where are you having trouble making the selections?
Copy link to clipboard
Copied
I can think of a few ways to approach this, but are you sure you want to use the ornate Quranic parentheses for both languages? I think we might want to get someone in this thread who actually knows how to do Quranic layout. I'm not sure, but I do suspect that those brackets are more than just Cool Looking Brackets. I think that they go along with glyphs like End of Ayah to do specific Quranic layout techniques - like marking verse numbers? I don't know, perhaps you do?
But in terms of actually answering your question: It's easy to use GREP to apply a particular character style to "any glyph inside of a given unicode range":
[\x{0100}-\x{FFFF}]+
This one captures "everything north of plain vanilla ASCII" and I'm showing it to you to show you the syntax, not because I think you should mark Everything That's Not ASCII as Arabic. It'd catch all of your ornate parentheses, as well, not just the ones surrounding Arabic. You can groom it to catch only the ranges you want to mark with your Arabic paragraph style. But it wouldn't catch the spaces between Arabic words. Nor would it catch your English.
Another strategy would be to try to catch anything between two ornate parentheses - easy with a lookahead and a lookbehind. But then you're working manually, Find-ing a given chunk of text between two ornate parentheses, and then manually applying your EN charstyle or your AR charstyle. Like James, I would assume that you wouldn't need an EN charstyle, as that should be styled according to your default EN paragraph style. But maybe you have some reason to want both forms of parenthetical language styled with separate character styles?
But if I look at your italicized rationale - that you want RTL character direction applied to Arabic text, and LTR applied to English - then I wonder why you don't just mark your Arabic text as Arabic in the language dropdown, and then mark all text with Default character direction? Seems easier than making RTL specific character styles, to me. Then it's as easy as
Find: [\x{0100}-\x{FFFF}]+
Change to: $0
Change format: Arabic (dropdown is in the "Advanced Character Formats" section of the Find Formats dialog)
That way, absolutely anything at all in your doc that isn't ASCII is marked as Arabic. This can be dangerous... for example, this will mark all en-spaces and em-spaces as RTL, which might be detrimental to your layout. So you'd need to groom your Unicode ranges in your query, to include only Arabic text? Wikipedia tells me that these are all of the Arabic Unicode ranges:
So then your query would look something like, um, this?
Find: [\x{0600}-\x{06FF}|\x{0750}-\x{07FF}|\x{0870}-\x{089F}|\x{080A}-\x{08FF}|\x{FB50}-\x{FDFF}]+
You'd need to find your ornate brackets and exclude them from this query, but that should catch All the Arabic.
Copy link to clipboard
Copied
My client wants the Qur'anic text in arabic and its translation in these ornate brackets. These brackets come in the KFGQPC Uthman Taha Naskh font and have unicode FD3E and FD3F.
Arabic text that is not Qur'anic is surrounded by square brackets.
It makes sense to mark Arabic text as Arabic in the language dropdown with Default character direction.