Numbering paragraphs: possible?
-
- Posts: 164
- Joined: 2004-09-23 02:15:46
- Location: Switzerland
- Contact:
Numbering paragraphs: possible?
I am sure someone asked this before, but I can't find it and I need it; is there a way of numbering paragraphs? I am doing the translation of film dialogues, and it sure would help me, because it would alert me if I missed a paragraph, which, I notice, is so easy to do.
Thanks to the helpful friends…
Thanks to the helpful friends…
Anne
Number List
It seems the only way now is to use 'Number List' style from Lists from the Format menu or the Formatting palette group.
-
- Posts: 164
- Joined: 2004-09-23 02:15:46
- Location: Switzerland
- Contact:
Thanks for the suggestion, Hamid. Unfortunately, it does not really work, as the source (the original script) is a given, and the paragraph number is fixed, it's quicker to number them by hand…
I looked through the macros and realized then the isn't one for line numbering - in fact I cannot find line numbering anywhere. Didn't someone create one? I seem to remember vaguely something of the kind in the Nisus list. Please remember, if you answer this, that I am strictly a macro USER, I have never written one. Thanks again!
I looked through the macros and realized then the isn't one for line numbering - in fact I cannot find line numbering anywhere. Didn't someone create one? I seem to remember vaguely something of the kind in the Nisus list. Please remember, if you answer this, that I am strictly a macro USER, I have never written one. Thanks again!
Anne
Line numbering
Line numbering is a built-in feature which you can access from the View menu. If you want to number paragraphs only, you can use the following macro. Copy the macro below and save it with .pl extension, and run it on a copy of your file.
#Nisus Macro Block
#source front
#destination new
#End Nisus Macro Block
my $count = 1;
while (my $line = <STDIN>) {
print "$count\t$line";
$count++;
}
#Nisus Macro Block
#source front
#destination new
#End Nisus Macro Block
my $count = 1;
while (my $line = <STDIN>) {
print "$count\t$line";
$count++;
}
-
- Posts: 164
- Joined: 2004-09-23 02:15:46
- Location: Switzerland
- Contact:
It worked, thanks. I'm grateful.
Unfortunately, it creates a new document in which all styles are lost. It does not matter for the original, but it does matter for the translation I'm working on!
I suppose I'll give up for this time. I should have thought of this earlier. But I keep the macro for a next time. I'll number the original then (it does not matter if styles are lost there…), and number my version as I go.
In Nisus Classic there was a trick to have the numbering in the margin rather than in the text. I don't remember what we did, I just remember using it. Is there a possibility here?
Unfortunately, it creates a new document in which all styles are lost. It does not matter for the original, but it does matter for the translation I'm working on!
I suppose I'll give up for this time. I should have thought of this earlier. But I keep the macro for a next time. I'll number the original then (it does not matter if styles are lost there…), and number my version as I go.
In Nisus Classic there was a trick to have the numbering in the margin rather than in the text. I don't remember what we did, I just remember using it. Is there a possibility here?
Anne
-
- Posts: 42
- Joined: 2006-12-14 09:09:51
Number Renumber Lines
I happen to have this Number Renumber Lines macro:
Thought it was standard with Nisus, but perhaps I got it somewhere else.
Dirk Barends
Code: Select all
#Nisus Macro Block
#source front selection
#destination front selection
#End Nisus Macro Block
use strict;
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");
my $count = 1;
my $start = 1;
while (my $line = <STDIN>) {
$line =~ s/[\r\n]+//g;
if ($line !~ /^(\d+)/) {
print "$count$line\n";
} else {
if ($start) {
$count = $1;
$start = 0;
print "$line\n";
} else {
$line =~ s/^(\d+)/$count/;
print "$line\n";
}
}
$count++;
}
Dirk Barends
-
- Posts: 164
- Joined: 2004-09-23 02:15:46
- Location: Switzerland
- Contact:
- martin
- Official Nisus Person
- Posts: 5228
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
The macro Dirk quoted will also remove the formatting in your document. This macro should however do the trick:
Code: Select all
Set Selection 1, 0 # move to start of document
$count = 0
While Find ‘^(?:\d+\.?\s*)?’, ‘E-W’
Type Text “$count. ”
$count += 1
End
Last edited by martin on 2008-03-28 00:34:02, edited 1 time in total.
-
- Posts: 42
- Joined: 2006-12-14 09:09:51
line numbering
This macro renumbers line too, if they are already numbered.Anne Cuneo wrote:[...]
Before I use it: what is this “number renumber” section?
Should be saved as a Nisus Perl macro, and yes it can affect formatting of the text.
But it works, for me (the other one from Martin doesn't work well.)
Dirk Barends
-
- Posts: 164
- Joined: 2004-09-23 02:15:46
- Location: Switzerland
- Contact:
Thanks Martin, but I think there still is a problem, when I want to apply the Macro, il tells me there is an error in the first line. Am I missing something here?
I am using what I found in your message, I just did a copy-paste. Like this:
Set Selection 1, 0 # move to start of document
$count = 0
While Find ‘^(?:\d+\.?\s*)?’, ‘E-W’
Type Text “$count. ”
$count += 1
End
Cheers.
I am using what I found in your message, I just did a copy-paste. Like this:
Set Selection 1, 0 # move to start of document
$count = 0
While Find ‘^(?:\d+\.?\s*)?’, ‘E-W’
Type Text “$count. ”
$count += 1
End
Cheers.
Anne
-
- Posts: 42
- Joined: 2006-12-14 09:09:51
Did you save it as a Nisus Macro? As for example:Anne Cuneo wrote:Thanks Martin, but I think there still is a problem, when I want to apply the Macro, il tells me there is an error in the first line. Am I missing something here?
Number Lines.nwm
Saved as a Perl Macro it gave that error with me too.
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?
Dirk Barends
Bug
Nisus Macros are supposed to treat straight quotes the same as curly quotes, but it seems not to be the case when you run this macro. This must be filed as a bug.Anne Cuneo wrote:Thanks Martin, but I think there still is a problem, when I want to apply the Macro, il tells me there is an error in the first line. Am I missing something here?
If you change all the curly quotes in the macro to straight quotes, the macro will work. However, there will be a problem if any paragraph already starts with a number.
-
- Posts: 164
- Joined: 2004-09-23 02:15:46
- Location: Switzerland
- Contact:
Dirk: Brilliant! I'm going to try. Of course, I saved it as Pearl Macro… I'll keep you posted.Did you save it as a Nisus Macro? As for example:
Number Lines.nwm
Saved as a Perl Macro it gave that error with me too.
Nisus Macros are supposed to treat straight quotes the same as curly quotes, but it seems not to be the case when you run this macro. This must be filed as a bug.
Hamid: Wow! You are right, the straight quotes went curly, I hadn't noticed.
I am just leaving, I'll be in the train for several hours (offline) and try things out. I'll let you know tonight.
Anne
Quotes
It is the QuickFix settings of your language which does that in the macro file. To prevent this happening, use a Tech language setting for all NWP (.nwm) and perl (.pl) macro files; this is particularly important for perl macros, or perl code included in NWP macros, which require straight quotes.the straight quotes went curly