Posted: 2008-03-31 18:43:10
For non-Perl macros this should not make a difference. Straight and curly quotes are equivalent. However, you must take care to save the macro as a "Nisus Macro", not a "Nisus Perl Macro".Anne Cuneo wrote:Hamid: Wow! You are right, the straight quotes went curly, I hadn't noticed.
The following macro should do the trick:Dirk_Barends wrote:Now if I could make this macro to work on selected text only, it would be a good replacement for the old Number Renumber Lines (Perl) macro.
Perhaps Martin knows how to do that?
Code: Select all
# calculate the selection endpoint so we can stop there
$bound = Selection Location
$selLen = Selection Length
$bound += $selLen
# keep searching for the start of a paragraph
$count = 0
$isContinue = 1
While $isContinue
$isContinue = Find ‘^(?:\d+\.?\s*)?’, ‘E-W’
If $isContinue
$foundLoc = Selection Location
$foundLen = Selection Length
If $foundLoc >= $bound
# we’ve left the original selection
$isContinue = 0
Else
# number the paragraph
$count += 1
Insert Text “$count. ”
# adjust boundary to account for replacement
$delta = Selection Length
$delta -= $foundLen
$bound += $delta
Select End
End
End
End