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:
Nobumi Iyanaga <[log in to unmask]>
Reply To:
Date:
Fri, 21 Apr 2017 23:44:11 +0900
Content-Type:
text/plain
Parts/Attachments:
text/plain (40 lines)
Hello,

I have a macro that "transliterate" the newer forms of kanjis to their traditional forms, working either on a selected text, or on the whole text when there is no selection. Here it is (I omit the main part of the macro, the "transliteration map", because it is too long):

$doc = Document.active
if $doc == undefined  # if there is no open document...
	exit
end
$text = $doc.text
$sels = $doc.textSelections

$map = Hash.new
$map{'悪'} = '惡'
$map{'芦'} = '蘆'
$map{'圧'} = '壓'
...

if $sels.firstValue.length  # if there is a visible selection (not just a caret)...
	foreach $sel in $sels
		$text.transliterateInRange($sel.range, $map)
	end
else
	$newDoc = $doc.copy
	$text = $newDoc.text
	$sels = $doc.text.findAll '\p{Han}+', 'E', '-am'
	foreach $sel in $sels
		$text.transliterateInRange($sel.range, $map)
	end
end

-- This works well for the main text part of a file, but not for notes. I would like to make it to work for notes included. I cannot figure out how to do this. Could anyone of you please give me such a macro?

Thank you very much in advance.

Best regard,

Nobumi Iyanaga
Tokyo,
Japan

ATOM RSS1 RSS2