jed-users mailing list

[2005 Date Index] [2005 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: Esc-q and new line / line feed chars


On  4.05.05, Romano Giannetti wrote:
 
> What I usually do is what Guenter suggest. If you keep your "JED paragraph"
> separated by at least a  blank line, when you need to pass the file to, say,
> Word, you can do the following:
> 
> - replace every new line (M-x replace is esc-% in emacs mode, then to enter
> the new line use ctrl-q ctrl-j) with a char you never use, say "¿". You have
> now all the text in one long line. 
> 
> - replace every "¿¿" with a new-line.

Why not use "^L"? (Ok, I assume you used a character that is easy to 
type for you but unlikely to be used by others...)
  
> - replace every "¿" with a space.
>
> Or use the attached "para_to_line.py" script to do the same. 

or 
  
define paragraphs_to_lines()
{
   push_spot_bob();
   replace("\n\n", "");
   replace("\n", " ");
   replace("", "\n");
   pop_spot();
}

(untested).


Günter

#!/usr/bin/python
#
# Transform tex-like paragraph into line
#
import sys
#
if len(sys.argv)!=2 :
    sys.stderr.write("Usage: %s <filename>\n" % sys.argv[0])
    sys.exit(1)
try: 
    f = file(sys.argv[1], "r")
except IOError:
    sys.stderr.write("Could not open %s for read\n" % sys.argv[1])
    sys.stderr.write("Usage: %s <filename>\n" % sys.argv[0])
    sys.exit(1)

parsep = "\n\n") # replace this with a single "\n" if the lines should join

new_paragraph = False

for line in f:
    if line.strip() == "": # empty line == paragraph separator
        if new_paragraph:
            sys.stdout.write("\n")
        new_paragraph = True
    else:
        if new_paragraph:
            sys.stdout.write(parsep)
            new_paragraph = False
        sys.stdout.write(line.rstrip("\n")+" ")

sys.stdout.write("\n")


-- 
G.Milde web.de

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2005 date index] [2005 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]