|
CHAPTER 3: Maps Between Spaces
Help for Authors , WikiSandbox, edit SideBar |
This site is based on PmWiki. PmWiki is a wiki-based system for collaborative creation and maintenance of websites. PmWiki pages look and act like normal web pages, except they have an “Edit” link that makes it easy to modify existing pages and add new pages into the website, using basic editing rules. You do not need to know or use any HTML or CSS. Page editing can be left open to the public or restricted to small groups of authors. For more information look at DocumentationIndex. This site does LATEXwfy: Perl script to help wikify Linearalgebra
#!/usr/bin/perl
# section and base number
$S = 1;
$X = 4;
while (<>)
{
# $..$ ==> {$..$}
s/\$([^\$]+)\$/{\$$1\$}/g;
# \begin{eq..} ==> \n=|[$ $$\n\begin{equation*}
s/(\\begin\{eq.+\})/\n=|[\$ \$\$\n$1/;
# \end{eq..} ==> \n=|[$ $$\n\end{equation*}
s/(\\end\{eq.+\})/$1\n\$\$ \$]\n/;
# \( ==> {$
s/\\\(/{\$/g;
# \) ==> $}
s/\\\)/\$}/g;
# \begin{definition} ===> "\n>>bgcolor=lightblue<<\n!!!! X.X Definition"
if (/\\begin{def.+}/) {
s/(\\begin{def.+})/\n>>bgcolor=lightblue<<\n!!!! $S.$X Definition/;
$X = $X + 1;
}
# \end{definition} ==> >><<
s/\\end{definition}/>><<\n/;
# \begin{example} ===> !!!! X.X Example
if (/\\begin{example}/) {
s/(\\begin{example})/\n!!!! $S.$X Example/;
++$X;
}
# \end{example} ==> \n
s/\\end{example}/\n/;
# \begin{theorem} ==> "\n>>bgcolor=lightblue<<\n!!!! X.X Theorem"
if (/\\begin{theorem}/) {
s/(\\begin{theorem})/\n>>bgcolor=lightblue<<\n!!!! $S.$X Theorem/;
++$X;
}
# \end{theorem} ==> >><<
s/\\end{theorem}/>><<\n/;
# \begin{lemma} ==> !!!! x.x Lemma
if (/\\begin{lemma}/) {
s/\\begin{lemma}/\n!!!! $S.$X Lemma/;
++$X;
}
# \end{lemma} ==> \n
s/\\end{lemma}/\n/;
# \begin{proof} ==> !!!!! PROOF:
s/\\begin{proof}/\n!!!!! PROOF:\n/;
# \end{proof} ==> '''''QED'''''
s/\\end{proof}/'''''QED'''''/;
# \vec{u} ==> \vec{ $u$ }
s/\\vec{u}/\\vec{ \$u\$ }/g;
# \vec{a} ==> \vec{ $a$ }
s/\\vec{a}/\\vec{ \$a\$ }/g;
# \Dash ==> --
s/\\Dash/--/g;
# \begin{align*} ==> \n=|[$ $$\n\begin{align*}
s/(\\begin{ali.+})/\n=|[\$ \$\$\n$1/;
# \end{ali.} ==> \end{ali.}\n$ $$]\n
s/(\\end{ali.+})/$1\n\$\$ \$]\n/;
# \begin{multl.} ==> \n=|[$ $$\n\begin{multl.}
s/(\\begin{multl.+})/\n=|[\$ \$\$\n$1/;
# \end{multl.} ==> \end{multl.}\n$ $$]\n
s/(\\end{multl.+})/$1\n\$\$ \$]\n/;
# \index{...} ==>
s/\\index{.+}/ /;
# \definend{...} ==> ''...''
s/\\definend{(.+)}/''$1''/;
# \noindent ==>
s/\\noindent//;
# \begin{corollary} ==> !!!! x.x Corollary
if (/\\begin{corollary}/) {
s/\\begin{corollary}/\n!!!! $S.$X Corollary/;
++$X;
}
# \end{corollary} ==> \n
s/\\end{corollary}/\n/;
print;
}
wex: Perl Script to wikify Exercises
#!/usr/bin/perl
# Chapter, Section, Subsection, Number
$C = "One";
$S = "IV";
$B = 4;
$N = 1;
$M = "TOPICS--Analyzing Networks";
$CSB = "$C.$S.$B";
$abc = "a";
while (<>)
{
# \begin{answer}...\end{answer} ==> delete
if (/\\begin{answer}/) {
while(!/\\end{answer}/) {
$_ = <>;
}
$_ = <>;
}
# \begin{exercises} ==> !Exercises: C.S.B M
s/\\begin{exercises}/(:title Exercises $CSB --- $M:)\nColor codes: %red%recommended%%, %blue%basic%%, %purple%puzzle%%\n/;
# \end{exercises} ==>
s/\\end{exercises}//;
# \recommended \item ==> red
if (/\\recommended\s?\\item/) {
s/^.*\\recommended\s?\\item/* %red%$CSB%%.$N /;
++$N;
}
# \puzzle \item ==> purple
if (/\\puzzle\s?\\item/) {
s/^.*\\puzzle\s?\\item/*.%purple%$CSB%%.$N /;
++$N;
}
# \item ==> blue
if (/\\item/) {
s/^.*\\item/* %blue%$CSB%%.$N /;
++$N;
}
# $..$ ==> {$..$}
s/\$([^\$]+)\$/{\$$1\$}/g;
# \begin{exparts*} ==> re-start $abc
if (/\\begin{ex.+}/) {
$abc = "a";
s/(\\begin\{exp.+\})//;
}
# \end{exparts*} ==>
s/\\end{exp.+}/ /;
# \partsitem ==> **(a)
if (/\\partsitem/) {
s/^.*\\partsitem(.*)/**($abc)$1/;
++$abc;
}
# \begin{linsys} ==> \n=|[$ $$\n\begin{linsys}...
s/[\$]?(\\begin{linsy.+)/\n=|[\$ \$\$\n$1/;
# \end{linsys} ==> \n$$ $]\n
s/(\\end\{linsys\}).*/$1\n\$\$ \$]\n/;
# \end{exp..} ==> \n=|[$ $$\n\end{exp..}
s/(\\end\{exp.+\})/$1\n\$\$ \$]\n/;
# \begin{eq..} ==> \n=|[$ $$\n\begin{equation*}
s/(\\begin\{eq.+\})/\n=|[\$ \$\$\n$1/;
# \end{eq..} ==> \n=|[$ $$\n\end{equation*}
s/(\\end\{eq.+\})/$1\n\$\$ \$]\n/;
# \( ==> {$
s/\\\(/{\$/g;
# \) ==> $}
s/\\\)/\$}/g;
# \vec{u} ==> \vec{ $u$ }
s/\\vec{u}/\\vec{ \$u\$ }/g;
# \vec{a} ==> \vec{ $a$ }
s/\\vec{a}/\\vec{ \$a\$ }/g;
# \Dash ==> --
s/\\Dash/--/g;
# \begin{align*} ==> \n=|[$ $$\n\begin{align*}
s/(\\begin{ali.+})/\n=|[\$ \$\$\n$1/;
# \end{ali.} ==> \end{ali.}\n$ $$]\n
s/(\\end{ali.+})/$1\n\$\$ \$]\n/;
# \begin{multl.} ==> \n=|[$ $$\n\begin{multl.}
s/(\\begin{multl.+})/\n=|[\$ \$\$\n$1/;
# \end{multl.} ==> \end{multl.}\n$ $$]\n
s/(\\end{multl.+})/$1\n\$\$ \$]\n/;
# \index{...} ==>
s/\\index{.+}/ /;
# \definend{...} ==> ''...''
s/\\definend{(.+)}/''$1''/;
# \noindent ==>
s/\\noindent//;
print;
}
inline like this
|