From 5df79c53745fde5d6c3340a2979b1429cd5892c1 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Sat, 8 Oct 2011 20:30:28 +0200 Subject: Initial import of htcd system 1.0 Signed-off-by: Henrik Rydberg --- src/lang/latex.cc | 152 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 src/lang/latex.cc (limited to 'src/lang/latex.cc') diff --git a/src/lang/latex.cc b/src/lang/latex.cc new file mode 100644 index 0000000..d423230 --- /dev/null +++ b/src/lang/latex.cc @@ -0,0 +1,152 @@ +/************************************************************************* + * + * HTCd - Copyright (C) 1998-2006 Henrik Rydberg + * + * 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 of the License, 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; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +using namespace std; + +static opmap op_latex; + +latex_env::latex_env(Env& p) : Env(p) { ops=&op_latex; } + +////////////////////////////////////////////////////// + +TOK_IMPL(it) { + mstring s; env.parg(s,-1); + if(s.nempty()) { out<<""; out<"; } + else { out<<""; env.epilog=sref("")+env.epilog; } +} + +TOK_IMPL(em) { + mstring s; env.parg(s,-1); + if(s.nempty()) { out<<""; out<"; } + else { out<<""; env.epilog=sref("")+env.epilog; } +} + +TOK_IMPL(bf) { + mstring s; env.parg(s,-1); + if(s.nempty()) { out<<""; out<"; } + else { out<<""; env.epilog=sref("")+env.epilog; } +} + +TOK_IMPL(mathbf) { + mstring s; env.parg(s,-1); + if(s.nempty()) { out<<""; out<"; } + else { out<<""; env.epilog=sref("")+env.epilog; } +} + +TOK_IMPL(rm) { + mstring s; env.parg(s,-1); + if(s.nempty()) { out<expr); + out<\n" + "%\n" + "%Note that the body is optional, just like in latex.\n" + ); + TOK_ADD(em,"?",tok_t::PUBLIC, + "%Set emph mode\n" + "%Syntax: \\em\n" + "%\n" + "%Note that the body is optional, just like in latex.\n" + ); + TOK_ADD(bf,"?",tok_t::PUBLIC, + "%Set Boldface mode\n" + "%Syntax: \\bf\n" + "%\n" + "%Note that the body is optional, just like in latex.\n" + ); + TOK_ADD(mathbf,"?",tok_t::PUBLIC, + "%Set Math boldface mode\n" + "%Syntax: \\mathbf\n" + "%\n" + "%Note that the body is optional, just like in latex.\n" + ); + TOK_ADD(rm,"?",tok_t::PUBLIC, + "%Set rm face mode\n" + "%Syntax: \\rm\n" + "%\n" + "%Note that the body is optional, just like in latex.\n" + ); + + ////////////////////////////////////////////////////////// + + TOK_ADD(setpara,"x",tok_t::PUBLIC, + "%Set paragraph string\n" + "%Syntax: \\setpara{string}\n" + "%\n" + "%Whenever a series of newlines is encountered, it is\n" + "%replaced by this string. The default is a newline.\n" + "%\n" + "%Operates on stack level (may be nested)\n" + ); + TOK_ADD(epilog,"x",tok_t::PUBLIC, + "%Add string to the epilog\n" + "%Syntax: \\epilog{string}\n" + "%\n" + "%The epilog string is output when the current stack frame\n" + "%goes out of scope. For functions like \\bf, which needs\n" + "%an end tag to be inserted at the right place.\n" + "%\n" + "%Operates on stack level (may be nested)\n" + ); + + ////////////////////////////////////////////////////////// + + TOK_ADD(equation,"r",tok_t::PUBLIC, + "%Evaluate equation (LaTeX)\n" + "%Syntax: \\equation{body}\n" + ); + + ////////////////////////////////////////////////////////// + + Const(T,sref("t"),sref("\t"),tok_t::PUBLIC); + Const(T,sref("n"),sref("\n"),tok_t::PUBLIC); + Const(T,sref("f"),sref("\f"),tok_t::PUBLIC); + + ////////////////////////////////////////////////////////// +} + -- cgit v1.2.3