|
LinuxTex /
PureLatexSummary: Make latex available in wiki edits without additional wrapping markup (This project is connected to the Cookbook.LinuxTex recipe.) This page is dedicated to making latex syntax available to the wiki editor without extra (or only minimal) wrapping markup. The main motivation for this is to simplify the import and export of once-created latex code, as well as to ease the way for the general scientific user who is accustomed with latex but most often not with wiki particularities. In the end it should be possible to prepare a document collaboratively over the web (with minimal wiki knowledge), and take the result to print media (without any conversion barrier etc.). This project has just taken off to the phase of "work in progress". Below I have listed the issues that I liked to be implemented most:
As the main syntax elements of both latex and the wiki language do not (seem to) overlap, I have started implementing the above features by just adding appropriate custom markup to the linuxtex.php, for example: Markup('$$','directives','/\\$\\$(.*?)\\$\\$/e',"blockformula('$1')"); // for block latex
If this should not suffice in future, some parser switch of the form similar to
CHANGELOG
Markup rules implemented until nowThis is what I have currently in use in my linuxtex.php:
// pattern to match
#$DoubleBrackets['/\\{\\$(.*?)\\$\\}/e'] = "inline('$1')";
#$DoubleBrackets['/\\{\\%(.*?),(.*?)\\%\\}/e'] = "tex('$1', '$2')";
#$DoubleBrackets['/EQ\((.*?)\)/e'] = "ref('$1')";
#Markup('{$','directives','/\\{\\$(.*?)\\$\\}/e',"inline('$1')"); // for inline latex
###Markup('{$ ','directives','/\\{\\$\\ (.*?)\\ \\$\\}/e',"inline('$1')"); // for inline latex
Markup('{$$','directives','/\\{\\$\\$(.*?)\\$\\$\\}/e',"blockformula('$1')"); // for block latex (without reference)
// removal of the rule above strangely results in the '$$' rule being left uninterpreted :(
// The following rules recognize $x$, $\theta$, $$\int_\omega f(x) = 1$$ and $$ \int_\omega f(x) = 1 $$, but
// avoid $ x $ or $x $. (This would be too easily mixed up with variables in code snippets.)
Markup('$2','directives','/\\$([^\ ])\\$/e',"inline('$1')"); // for one-character inline latex
Markup('$$','directives','/\\$\\$(.*?)\\$\\$/e',"blockformula('$1')"); // for block latex (without reference)
Markup('$','directives','/\\$([^\ ].*?[^\ ])\\$/e',"inline('$1')"); // for inline latex
Markup('{%','directives','/\\{\\%(.*?),(.*?)\\%\\}/e',"tex('$1','$2')"); // for formula with reference
Markup('\begin{align*}','fulltext','/\\\\begin\\{align\\*\\}(.*?)\\\\end\\{align\\*\\}/sei',"blockformula('$1')");
// for formulas inside align environment, still unfinished
Markup('/EQ','directives','/EQ\((.*?)\)/e',"ref('$1')"); //for references to formulas
// interpret \section{} etc.:
Markup('\section', 'block', '/\\\\section\\{(.*?)\\}/e', "'<:block,1><h2'.PSS('>$1</h').'2>'");
Markup('\subsection', 'block', '/\\\\subsection\\{(.*?)\\}/e', "'<:block,1><h3'.PSS('>$1</h').'3>'");
Markup('\subsubsection', 'block', '/\\\\subsubsection\\{(.*?)\\}/e', "'<:block,1><h4'.PSS('>$1</h').'4>'");
// interpret \emph{}:
Markup('\emph', 'inline', "/\\\\emph\\{(.*?)\\}/", '<em>$1</em>');
ThomasP June 24, 2007, at 08:11 AM |