NISUS Archives

April 2017

NISUS@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Reply To:
Date:
Sat, 15 Apr 2017 04:24:57 +0900
Content-Type:
text/plain
Parts/Attachments:
text/plain (96 lines)
Dear Vika,

Sorry for being very late in reply.

> On 2016/09/14, at 02:40, Vika Gardner <[log in to unmask]> wrote:
> 
> I feel silly for needing to ask this, but I am attempting to embed some Arabic text (from YouTube) into a citation that needs to be in English.

Not silly at all. That is an annoying phenomenon related to mirrored characters (parentheses in this case), very difficult to treat. 

> Although I expect I will transliterate it later, for now I just want to stick with the Arabic as it appears in YouTube.
> 
> The citation format is:
> name (2015) title.  Available at: https://youtu.be/Fwg1koXr-V4 (accessed 13 Sep 2016).
> 
> The Arabic to be inserted is (name line 1, title line 2)
> دكتور ذاكر نايك مترجم
> 
> حوار د.ذاكر نايك مع ملحد اسئلة وإجابات مذهلة

I wrote three macros to deal with that kind of problems and uploaded them as
<http://www2.odn.ne.jp/alt-quinon/files/NWPro/arabic/DirectionalMarkMacros.zip>

Before inserting Arabic "name", please select "(2015)" in your document and run "Protect L2R Text" macro.


### Protect L2R Text ###

# This macro enclose selected left to right text(s) between U+202A and U+202C so that the insertion of right to left text(s) will not affect the directionality of the former.

$doc = Document.active
if ! $doc
	exit 'No open document, exiting...'
end

$sels = $doc.textSelections
if ! $sels[0].length
	exit 'There is no selection, exiting...'
end

$LRE = Text.newWithCodepoint(0x202A) # LEFT-TO-RIGHT EMBEDDING
$PDF = Text.newWithCodepoint(0x202C) # POP DIRECTIONAL FORMATTING

foreach $sel in reversed $sels
	$sel.text.insertAtIndex($sel.bound, $PDF)
	$sel.text.insertAtIndex($sel.location, $LRE)
end

### end of macro


The zip file above mentioned contains "Protect R2L Text" (not tested) too. I just replaced 0x202A with 0x202B and modified a variable name and the macro description accordingly.

As directional marks inserted by the two "Protect" macros are invisible and may cause problems when you will replace Arabic text with its transliteration or if you delete or move them accidentally. So the third macro which removes them.


### Remove Directional Marks ###

# This macro removes directional marks from selection(s). If there is no selection, it will work against the whole document.

$doc = Document.active
if ! $doc
	exit 'No open document, exiting...'
end

$sels = $doc.textSelections
if ! $sels.firstValue.length
	$doc.text.replaceAll '[\x{200E}\x{200F}\x{202A}-\x{202E}]+', '', 'E'
else
	foreach $sel in reversed $sels
		$subtext = $sel.subtext
		$subtext.replaceAll '[\x{200E}\x{200F}\x{202A}-\x{202E}]+', '', 'E'
		$sel.text.replaceInRange($sel.range, $subtext)
	end
end

### end of macro


BTW you can insert those invisible characters using NWP's menu commands under Insert:Directionality Markers. You *can* but it is not very easy to do so. I did fail very often. That is why I wrote those macros.

I think menu commands corresponding those macros should be added to a future version of NWP.


> Although I used to do this regularly in the opposite direction (putting English into Persian), it was a very long time ago, and many OS's back.  So things might well have changed.

Well, perhaps this kind of problem did not occur with the legacy Mac OS but I don't remember anymore.


Kino


P.-S.

Don't apply Arabic (language attribute) on دكتور ذاكر نايك مترجم. That will mess up everything.

ATOM RSS1 RSS2