Can dynamic list numbers be transformed into ordinary text?
Can dynamic list numbers be transformed into ordinary text?
Can dynamic list numbers be transformed into ordinary text? Or had one better use a macro to put running numbers in front of each paragraphs? In fact I seem to remember that earlier versions of Nisus did come with such a macro.
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Can dynamic list numbers be transformed into ordinary text?
There's no built-in command for this, but the following macro transforms all list items/bullets in your document to fixed/ordinary text:js wrote:Can dynamic list numbers be transformed into ordinary text?
Code: Select all
Select Document End
While Select Previous List Item
$selection = TextSelection.active
$bullet = $selection.substring
Write Selection $bullet
EndBut perhaps your first idea is more convenient?Or had one better use a macro to put running numbers in front of each paragraphs?
Re: Can dynamic list numbers be transformed into ordinary text?
I find that by putting "Lists:Number list" (so that the macro works directly from a Selection of paragraphs), this is extremely fast and convenient. Thank you.
- greenmorpher
- Posts: 767
- Joined: 2007-04-12 04:01:46
- Location: Melbourne, Australia
- Contact:
Re: Can dynamic list numbers be transformed into ordinary text?
Can we clarify this? I tried the macro and got page full of numbers both when I ran it on unsdelected text and when I ran it on selected text! It was duplicating the second level -- numbers, not the text of the head.
Cheers, Geoff
Geoffrey Heard
Publisher, Editor, Business Writer
The Worsley Press
FREE Bonus book offer. Get "How to make great ads for (sm)all business" FREE when you buy "Type & Layout: Are you communicating or just making pretty shapes?" or "How to Start and Produce a Magazine or Newsletter". Amazon or www.worsleypress.com
Cheers, Geoff
Geoffrey Heard
Publisher, Editor, Business Writer
The Worsley Press
FREE Bonus book offer. Get "How to make great ads for (sm)all business" FREE when you buy "Type & Layout: Are you communicating or just making pretty shapes?" or "How to Start and Produce a Magazine or Newsletter". Amazon or www.worsleypress.com
Re: Can dynamic list numbers be transformed into ordinary text?
Geoff, I reproduced the problem by running the macro on your Outline.dot.
http://nisus.com/forum/viewtopic.php?p=16788#p16788
What magic did you use? -;) I don’t understand why your template makes misbehave Martin’s macro. Anyway, if you need such a macro right now, try this one.
This one relies on tabs following numbers/bullets for there seems to be no other way to get List Items, regardless of the activeness of the document. I’d like to have something equivalent to Note object commands for Lists.
Edit: I forgot to write this: When I was writing the macro above, I was believing that you had touched the document while Martin’s macro was running. So, I wrote it so that it works properly even if the target document has become inactive. But the problem seems to be elsewhere.
Edit: This one may be faster. Select Previous List Item does not seem to be the culprit. Perhaps is Write Selection too slow or does it make misbehave Select Previous List Item?
Edit: This another one seems to work properly on Outline.dot too.
Edit: Perhaps does Write Selection fail to replace an existent attribute with a new one in some situations?
http://nisus.com/forum/viewtopic.php?p=16788#p16788
What magic did you use? -;) I don’t understand why your template makes misbehave Martin’s macro. Anyway, if you need such a macro right now, try this one.
Code: Select all
$doc = Document.active
if $doc == undefined
exit
end
$sels = $refs = Array.new
foreach $text in $doc.allTexts
$i = 0
while $i < $text.length
$attr = $text.displayAttributesAtIndex $i
$range = $text.rangeOfDisplayAttributesAtIndex $i
if Defined $attr.listStyle
$sel = TextSelection.new $text, $range
$sels.appendValue $sel
end
$i = $range.bound
end
end
if ! $sels.count
exit 'No list found, exiting...'
end
foreach $sel in $sels
$founds = $sel.subtext.findAll '^[^\t]+(?=\t)', 'E'
foreach $found in $founds
$range = $found.range
$range.location += $sel.location
$ref = TextSelection.new $sel.text, $range
$refs.appendValue $ref
end
end
foreach $ref in reversed $refs
$ref.text.replaceInRange $ref.range, $ref.substring
endEdit: I forgot to write this: When I was writing the macro above, I was believing that you had touched the document while Martin’s macro was running. So, I wrote it so that it works properly even if the target document has become inactive. But the problem seems to be elsewhere.
Edit: This one may be faster. Select Previous List Item does not seem to be the culprit. Perhaps is Write Selection too slow or does it make misbehave Select Previous List Item?
Code: Select all
$doc = Document.active
$sels = Array.new
Select Document End
while Select Previous List Item
$sel = TextSelection.active
$sels.appendValue $sel
end
foreach $sel in $sels
$sel.text.replaceInRange $sel.range, $sel.substring
endCode: Select all
Select Document End
while Select Previous List Item
$sel = TextSelection.active
$sel.text.replaceInRange $sel.range, $sel.substring
end- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Can dynamic list numbers be transformed into ordinary text?
The problem with using the macro on Geoff's template is that his list items are enforced via a paragraph style. When the macro replaces those list items with plain string list numbers, it does not clear NWP's desire to enforce the paragraph style, and thus the list style as well.
The solution is for the macro to tell NWP that the list style should be explicitly turned off for the paragraph (ie, override the paragraph style):
The solution is for the macro to tell NWP that the list style should be explicitly turned off for the paragraph (ie, override the paragraph style):
Code: Select all
Select Document End
While Select Previous List Item
$selection = TextSelection.active
$bullet = $selection.substring
Menu 'Lists:Use None'
Write Selection $bullet
End- greenmorpher
- Posts: 767
- Joined: 2007-04-12 04:01:46
- Location: Melbourne, Australia
- Contact:
Re: Can dynamic list numbers be transformed into ordinary text?
thanx Kino & Martin
Cheers, Geoff
Cheers, Geoff
Alternative script using Copy & Paste
The following script also seems to work. Like Geoff, I have a list style associated with the paragraph style. However, for some reason, pasting plain text seems to change the list style to None without the "Menu 'Lists:Use None' command in Martin's script. Is Martin's last script a more reliable approach than my Copy/Paste?
Code: Select all
# Move to end of document
Select Document End
# Convert all list numbers (list bullets) to plain text.
# Go backwards so numbering doesn't change as we progress.
While Select Previous List Item
Copy Text Only
Paste Text Only
End