Hi all,

Several months ago I submitted an awk script to convert from VimOutliner to 
LyX. Now I'm starting to do more of my authoring in VimOutliner before 
converting to LyX, and within VimOutliner I represent emphasis by 
either !emphasize one word or !{emphasize all these words}.

In order to turn those into character styles, I've created this shellscript:

================================================
#!/bin/bash

#cat junk.jnk |  sed -e 's/[[:space:]]!../___&&&&/g; h; i\shunk'
tmpfile=mktemp
cat > $tmpfile
ex $tmpfile \
        -c"%s/!{\([^}]\+\)}/\r\r\\\\begin_inset CharStyle MyEmph\rshow_label 
false\rstatus inlined\r\r\\\\begin_layout 
Standard\r\1\r\\\\end_layout\r\r\\\\end_inset\r\r/g" \
        -c"%s/!{/bangsign_brace/" \
        -c"%s/\(\s\)!\(\S\+\)/\1\r\r\\\\begin_inset CharStyle 
MyEmph\rshow_label 
false\rstatus inlined\r\r\\\\begin_layout 
Standard\r\2\r\\\\end_layout\r\r\\\\end_inset\r\r/g" \
        -c"%s/bangsign_brace/!{/" \
        -c"wq!"

#       -c"%s/\(\s\)!\(\S\+\)/\1>>>\2<<</g" \
cat $tmpfile
rm -f $tmpfile

================================================

I'm not good enough at sed to do the parsing in sed, so I used ex (the back 
end engine editor for Vim). My script has two failings:

1) On single word emphasis, it emphasizes any trailing punctuation. I had 
trouble with structures like [^;,.] so couldn't do that.

2) On multiword emphasis, it works only if the opening and closing braces are 
on the same line. Otherwise it leaves them as is so that they can be manually 
fixed within LyX.

So the conversion looks like this:

otl2lyx.awk level_environment.table rjust_book.otl | ./emph.sh > body.lyx
Vim body.lyx shell.lyx

I hope this helps someone :-)

SteveT


SteveT
 
Steve Litt
Books written in LyX:
        Troubleshooting Techniques of the Successful Technologist
        Twenty Eight Tales of Troubleshooting
        Troubleshooting: Just the Facts

Reply via email to