# Author: Chris Karakas
# http://www.karakas-online.de
#
# Part of the LyX-to-X project.
# See http://www.karakas-online.de/mySGML/ for a detailed
# description.
#
# Copyright (c) 2004, Chris Karakas
# http://www.karakas-online.de
# chris at mydomain dot de (see above for my domain)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
# Valid only for LyX v. 1.6.x
# Substitute with
# s/]*\)><\/link>//g
# Valid only for LyX v. 1.2.x
#
# Substitute with
# Not a really good idea, so leave it commented.
# If you decide to use it, you will be able to
# cross-reference to an arbitrary point in your
# document, not just sections and chapters!
# BUT: The link will not be of the form
# "Section something" - it will be just the
# word "here" in hyperlink form...
# That's why I say it is not a really good idea.
# But perhaps you could elaborate on this...
#
# s/]*\)>/here<\/link>/g
# Valid only for LyX v. 1.2.0
# Substitute
#
# some title
#
# with
#
# some title
#
# also substitute
#
# some title
#
# with
#
# some title
s/<\(sect[^>]*\)>\([^<]*\)]*\)>/<\1 \3>\2/g
s/<\(chapter\)>\([^<]*\)]*\)>/<\1 \3>\2/g
# Valid only for LyX v. 1.6.x
# Substitute
#
#
#
# some title
#
# with
#
#
#
# some title
#
# /^[^<]*]*\)>\([ \t\n\r]*[ \n]*[^<]*\)]*\)><\/anchor>/<\1 \3>\2/
# P
# D
# }
# Valid only for LyX v. 1.6.x
# Substitute with the more elaborate
#
#
#
#
# ]]>
#
#
#
# ]]>
#
#
#
# ]]>
#
# Figure
#
#
#
# where \1 is the matched image filename without the extension.
###########################################################################################
# s/<\/graphic>/ \
# <\!\[ \%output\.print\.png; \[\
# \
# \
# <\/imageobject>\
# \]\]>\
# <\!\[ \%output\.print\.pdf; \[\
# \
# \
# <\/imageobject>\
# \]\]>\
# <\!\[ \%output\.print\.eps; \[\
# \
# \
# <\/imageobject>\
# \]\]>\
# \
# Figure<\/phrase>\
# <\/textobject>\
# <\/mediaobject>/g
# }
# Valid only for LyX v. 1.2.0
# Substitute with the more elaborate
#
#
#
#
# ]]>
#
#
#
# ]]>
#
#
#
# ]]>
#
# Figure
#
#
#
# where \1 is the matched image filename without the extension.
###########################################################################################
/^.*
\
\3<\/para>\
<\/caption>\
<\/mediaobject>\
<\/figure>\
/g
}
/^.*[^<]*/\
\
<\!\[ \%output\.print\.png; \[\
\
\
<\/imageobject>\
\]\]>\
<\!\[ \%output\.print\.pdf; \[\
\
\
<\/imageobject>\
\]\]>\
<\!\[ \%output\.print\.eps; \[\
\
\
<\/imageobject>\
\]\]>\
<\!\[ \%output\.print\.bmp; \[\
\
\
<\/imageobject>\
\]\]>\
\
Figure<\/phrase>\
<\/textobject>\
<\/mediaobject>/g
}
# This will not work, if you have both program code and images
# that you want to include from LyX!
#
# /^.*[^<]*]*>/\
# \
# <\!\[ \%output\.print\.png; \[\
# \
# \
# <\/imageobject>\
# \]\]>\
# <\!\[ \%output\.print\.pdf; \[\
# \
# \
# <\/imageobject>\
# \]\]>\
# <\!\[ \%output\.print\.eps; \[\
# \
# \
# <\/imageobject>\
# \]\]>\
# <\!\[ \%output\.print\.bmp; \[\
# \
# \
# <\/imageobject>\
# \]\]>\
# \
# Inline graphic<\/phrase>\
# <\/textobject>\
# <\/inlinemediaobject>/g
# }
# Valid only for both LyX v. 1.6.x and LyX v. 1.2.0
# Substitute with
/^.*[^<]*]*\)>//g
/^.*[^<]*<\/programlisting>/s/<\/programlisting\([^>]*\)>/<\/screen\1>/g
# Enclose pairs in
#
pairs
# /^[^<]* \1/
# /^[^<]*<\/tgroup>/s/\(<\/tgroup>\)/\1\
# <\/table>/
# Delete the tag before the tag
# and prepend
.
# /^[^<]*/{
# N
# s/\([ \t\n\r]*]*\)>/
\
# Sample Table<\/title>\
# \1>/
# P
# D
# }
# Delete the before the tag.
s/ after the tag.
s/<\/tgroup><\/para>/<\/tgroup>/g
# For table captions and titles to be output correctly,
# you have to eliminate the from any sequence
#
# AND you have to write a table float, in the inside of
# which you will have to set the title and the caption
# environment on one line, then press , set the
# environment to "Standard" (this will produce the
# element we eliminate here) and continue with
# the table normally. A warning about an
# "end tag for element "TABLE" which is not open"
# is the less evil we can get and is harmless
# (a LyX bug in 1.2.0, not openjade's)
/<\/title>
#
# with
#
#
s/
[ ]*[ ]*]*\)>/
/g
# Delete one in .
s/<\/para><\/listitem><\/listitem>/<\/para><\/listitem>/g
# Substitute 'ldquo' with 'quot' and 'rdquo' with 'quot' too.
# s/“/\"/g
# s/”/\"/g
#
# Substitute quotes with tags.
# Depending on the language attribute (lang="...")
# of the elements (, for example), they are
# rendered differently (e.g. with guillemets in french).
# The spaces in the regexps avoid markup like
#
# where such substitution would be detrimental.
s/[ ,]+“/ /g
s/”[ ,]+/<\/quote> /g
# But we are not done with the quots yet :-(
# In we have to substitute
#
# "
#
# with
#
# "
# / <----- at the END of a line!
#
#
# to
#
#
#
#
# We do this only to MARK the start of a *displayed*
# (as opposed to *inline*) equation.
# Don't bother that we named it "informalequation".
# We could have neamed it "whatever".
# In the AWK script awkscr_math, we will convert it
# back, but only after we have transformed the rest
# from to .
# Because, that's the trick, everything that is
# still called "equation" *after* the change below,
# it is actually an *inlineequation*!!
/<\/para>$/{
N
s/[ \t\n\r]*/\
/
p
d
}
# /^$/{
# N
# s/[ \t\n\r]*/\
# /
# p
# d
# }
# Insert a newline after the $ that follows the
# element of an equation. Thus, $ will stay
# on one line - and this makes processing with
# awkscr_math easier: we can then check if $0 (which
# is the current line in awk) contains "$" - and skip it.
s/\$/\$\
/g
# For Citations:
# Substitute
#
#
#
# with
#
# someID
#
# Important: we use the *short* notation,
# because we cannot distinguish between the first and
# the subsequent occurences of a citation.
s//\
\1<\/citation>\
/g
# Insert bibliography and index creation command.
# Comment if you don't want!
#
# Substitute
#
#
#
# with
#
# &index;
#
#
#/<\/book>/s/<\/book>/\&bibliography;\
#\&index;\
#<\/book>/
# Insert bibliography and index creation command.
# Comment if you don't want!
#
# Substitute
#
#
#
# with
#
# &index;
#
#
#/<\/article>/s/<\/article>/\&bibliography;\
#\&index;\
#<\/article>/
# Key combinations
#
# CTRL-X-Y
s/\([^-]\)CTRL-\([^-. &<]*\)-\([^-. &,)<]*\)/\1\
\
CTRL<\/keycap>\
\2<\/keycap>\
\3<\/keycap>\
<\/keycombo>\
\
CTRL_\2_\3<\/primary>\
<\/indexterm>\
/g
# CTRL-X
s/\([^-]\)CTRL-\([^-. &,)<]*\)/\1\
\
CTRL<\/keycap>\
\2<\/keycap>\
<\/keycombo>\
\
CTRL_\2<\/primary>\
<\/indexterm>\
/g
# CTRL
s/\([^-]\)CTRL\([ .,\t\r\n)]\)/\1\
\
CTRL<\/keycap>\2\
<\/keycombo>\
\
CTRL<\/primary>\
<\/indexterm>\
/g
s/CTRL_\([^-. &<]*\)_\([^-. &,)<]*\)/CTRL-\1-\2/g
s/CTRL_\([^-. &<]*\)/CTRL-\1/g
# ESC-X-Y
s/\([^-]\)ESC-\([^-. &<]*\)-\([^-. &,)<]*\)/\1\
\
ESC<\/keycap>\
\2<\/keycap>\
\3<\/keycap>\
<\/keycombo>\
\
ESC_\2_\3<\/primary>\
<\/indexterm>\
/g
# ESC-X
s/\([^-]\)ESC-\([^-. &,)<]*\)/\1\
\
ESC<\/keycap>\
\2<\/keycap>\
<\/keycombo>\
\
ESC_\2<\/primary>\
<\/indexterm>\
/g
# ESC
s/\([^-]\)ESC\([ .,\t\r\n)]\)/\1\
\
ESC<\/keycap>\2\
<\/keycombo>\
\
ESC<\/primary>\
<\/indexterm>\
/g
s/ESC_\([^-. &<]*\)_\([^-. &,)<]*\)/ESC-\1-\2/g
s/ESC_\([^-. &<]*\)/ESC-\1/g
# ALT-X-Y
s/\([^-]\)ALT-\([^-. &<]*\)-\([^-. &,)<]*\)/\1\
\
ALT<\/keycap>\
\2<\/keycap>\
\3<\/keycap>\
<\/keycombo>\
\
ALT_\2_\3<\/primary>\
<\/indexterm>\
/g
# ALT-X
s/\([^-]\)ALT-\([^-. &,)<]*\)/\1\
\
ALT<\/keycap>\
\2<\/keycap>\
<\/keycombo>\
\
ALT_\2<\/primary>\
<\/indexterm>\
/g
# ALT
s/\([^-]\)ALT\([ .,\t\r\n)]\)/\1\
\
ALT<\/keycap>\2\
<\/keycombo>\
\
ALT<\/primary>\
<\/indexterm>\
/g
s/ALT_\([^-. &<]*\)_\([^-. &,)<]*\)/ALT-\1-\2/g
s/ALT_\([^-. &<]*\)/ALT-\1/g
# Acronyms
# PHP, GNU, EOF, Python, POSIX, GUI, LDP...
s/\([ .\t\r\n]\)PHP\([ .\t\r\n]\)/\1PHP<\/acronym>\2/g
s/\([ .\t\r\n]\)GNU\([ .\t\r\n]\)/\1GNU<\/acronym>\2/g
s/\([ .\t\r\n]\)EOF\([ .\t\r\n]\)/\1EOF<\/acronym>\2/g
s/\([ .\t\r\n]\)Python\([ .\t\r\n]\)/\1Python<\/acronym>\2/g
s/\([ .\t\r\n]\)POSIX\([ .\t\r\n]\)/\1POSIX<\/acronym>\2/g
s/\([ .\t\r\n]\)GUI\([ .\t\r\n]\)/\1GUI<\/acronym>\2/g
s/\([ .\t\r\n]\)LDP\([ .\t\r\n]\)/\1LDP<\/acronym>\2/g
s/\([ .\t\r\n]\)IDE\([ .\t\r\n]\)/\1IDE<\/acronym>\2/g
s/\([ .\t\r\n]\)RPM\([ .\t\r\n]\)/\1RPM<\/acronym>\2/g
s/\([ .\t\r\n]\)PGP\([ .\t\r\n]\)/\1PGP<\/acronym>\2/g
s/\([ .\t\r\n]\)GPG\([ .\t\r\n]\)/\1GPG<\/acronym>\2/g
s/\([ .\t\r\n]\)ID\([ .\t\r\n]\)/\1ID<\/acronym>\2/g
s/\([ .\t\r\n]\)BW\([ .\t\r\n]\)/\1BW<\/acronym>\2/g
s/\([ .\t\r\n]\)ASCII\([ .\t\r\n]\)/\1ASCII<\/acronym>\2/g
s/\([ .\t\r\n]\)CPU\([ .\t\r\n]\)/\1CPU<\/acronym>\2/g
# Product names
# UNIX, Linux, Acrobat, Windows...
s/\([ .\t\r\n]\)UNIX\([ .\t\r\n]\)/\1UNIX<\/productname>\2/g
s/\([ .\t\r\n]\)Linux\([ .\t\r\n]\)/\1Linux<\/productname>\2/g
s/\([ .\t\r\n]\)Acrobat\([ .\t\r\n]\)/\1Acrobat<\/productname>\2/g
s/\([ .\t\r\n]\)Windows\([ .\t\r\n]\)/\1Windows<\/productname>\2/g
s/\([ .\t\r\n]\)Mandrake\([ .\t\r\n]\)/\1Mandrake<\/productname>\2/g
s/\([ .\t\r\n]\)SuSE\([ .\t\r\n]\)/\1SuSE<\/productname>\2/g
# Applications
# TeX, LaTeX, Acrobat Reader, PHP-Nuke
s/\([ .\t\r\n]\)TeX\([ .\t\r\n]\)/\1TeX<\/application>\2/g
s/\([ .\t\r\n]\)LaTeX\([ .\t\r\n]\)/\1LaTeX<\/application>\2/g
s/\([ .\t\r\n]\)Reader\([ .\t\r\n]\)/\1Reader<\/application>\2/g
s/\([ .\t\r\n]\)PHP-Nuke\([ .\t\r\n]\)/\1PHP-Nuke<\/application>\2/g
s/\([ .\t\r\n]\)Perl\([ .\t\r\n]\)/\1Perl<\/application>\2/g
s/\([ .\t\r\n]\)Java\([ .\t\r\n]\)/\1Java<\/application>\2/g