#!/bin/sh #cut at given keyword keyword() { # I changed "0" to "\$" because my sed # doesn't want to understand "0". # -- Zoltan sed "1,/^%$1/ d;/^%/,\$ d" } menus() { # I changed "0" to "\$" because my sed # doesn't want to understand "0". # -- Zoltan sed "1,/^%menus/ d;/^%endmenus/,\$ d" } #convert xshl tags into texinfo totexinfo1() { sed 's/@/@@/g s/^[ ]*//g s/[ ]*$//g s/[ ][ ]*/ /g s/{/@{/g s/}/@}/g s/^%%%*//g s/^\%[a-z_0-9 ]*$//g ' } totexinfo() { sed ' s///g s//@ifinfo/g s/<\/noprint>/@end ifinfo/g //, /<\/menuitems>/ s/

]*\)>\([^<]*\)<\/a>/* \1:: \2/g s//@menu /g s/<\/menuitems>/@end menu /g s/]*>//g s/<\/tutor>//g //,/<\/notex>/ d s/--/---/g s/^

$/\ \ @example/g s/^<\/tt>

$/@end example\ \ /g s//@math{/g s/<\/math>/}/g s//@code{/g s/<\/tt>/}/g s//@emph{/g s/<\/emph>/}/g s/^

$// s/

/\ \ /g s/

/@table @strong/g s/<\/dl>/@end table/g s/
/@item /g s/
//g s/^
//g s/
/\ /g s/]*\)>/@node \1, \3, \2, \4/g s/]*\)>\(.*\)<\/a>\./\2. @xref{\1}./g s/]*\)>\(.*\)<\/a>/\2/g ' } #convert headers to make new chapter chapter() { sed '1,/<\/head>/ s//@chapter /g s/<\/head>//g s//@section /g ' } menu() { sed ' s/

Syntax<\/emph>:(\([^)]*\))/@defun \1 \ @end defun/g s/

/@appendix /g s//@appendixsec /g s//@appendixsubsec /g s/
//g s/<\/center>//g s/<\/head>//g s/<\/main>//g s/<\/menuhead>//g ' #s/
/@chapter /g #s//@section /g #s//@subsection /g #s//@unnumberedsubsec /g } section() { sed '1,/<\/head>/ s//@section /g s/<\/head>//g s//@subsection /g ' } appendix() { sed '1,/<\/head>/ s//@appendix /g s/<\/head>//g s//@subsection /g ' } case "$1" in chapter) keyword $2 | totexinfo1 | totexinfo | chapter ;; section) keyword $2 | totexinfo1 | totexinfo | section ;; appendix) keyword $2 | totexinfo1 | totexinfo | appendix ;; menus) menus | totexinfo1 | menu | totexinfo ;; esac