diff --git a/PythonLatex/__init__.py b/PythonLatex/__init__.py index 6a2c389..1df286b 100644 --- a/PythonLatex/__init__.py +++ b/PythonLatex/__init__.py @@ -1,3 +1,3 @@ __all__ = ["latex_structure", "generate_latex"] -import latex_structure +from . import latex_structure diff --git a/PythonLatex/generate_latex.py b/PythonLatex/generate_latex.py index 44ca38b..daad604 100644 --- a/PythonLatex/generate_latex.py +++ b/PythonLatex/generate_latex.py @@ -1,364 +1,369 @@ #! /usr/bin/python ################################################################ from __future__ import print_function ################################################################ import re as myre import PythonLatex.latex_structure as tex import types import sympy as sym import hashlib import dill ################################################################ from sympy.printing.latex import LatexPrinter from sympy import latex from sympy.core.function import Derivative ################################################################ class CustomStrPrinter(LatexPrinter): def nbIdenticalDx(self, expr): first_dx = expr.args[1:][0] count = 0 for dx in expr.args[1:]: if dx == first_dx: count += 1 if count == len(expr.args[1:]): return count, first_dx return 0, None def _print_Derivative(self, expr): # print expr # print LatexPrinter._print_Derivative(self,expr) count, dx = self.nbIdenticalDx(expr) f = expr.args[0] if len(f.args) == 0: return LatexPrinter._print_Derivative(self, expr) dxf = f.args[0] f_nargs = len(f.args) # case where ' applies if f_nargs == 1 and dx == dxf: return (latex(expr.args[0].func) + - "'"*len(expr.args[1:]) + + "'" * len(expr.args[1:]) + "(" + latex(dxf) + ")") return LatexPrinter._print_Derivative(self, expr) def _print_Subs(self, expr): if not isinstance(expr.args[0], Derivative): return LatexPrinter._print_Subs(self, expr) # print expr deriv = expr.args[0] _dxs = deriv.args[1:] # print _dxs p1 = expr.args[1] p2 = expr.args[2] # print len(_dxs) _subst = {} _subst2 = {} for i in range(0, len(p1)): _subst[p1[i]] = p2[i] if hasattr(p2[i], 'args'): _p2 = type(p2[i]) _subst2[p1[i]] = _p2 _dxs = [e.subs(_subst2) for e in _dxs] new_f = deriv.args[0].subs(_subst) # print 'CCCCCCCCC' # print new_f # print _dxs # print _subst tmp = Derivative(new_f, *_dxs) # print tmp return latex(tmp) # return LatexPrinter._print_Subs(self,expr) ################################################################ -class PyCode(tex.LatexBlock): +class PyCode(object): """ """ def checkLine(self, line): m = myre.match(r"\\end{python}", line) if m: return Block() return Block.checkLine(self, line) def checkValidity(self): for c in self.content: if isinstance(c, types.InstanceType): raise Exception("python block cannot have subblocks") def __str__(self): return "" def generateHashSource(self): - txt_content = self.content[0] + txt_content = self.content.encode() self.hash_source = hashlib.sha1(txt_content).hexdigest() gl = globals() self.global_keys_before = gl.keys() self.local_keys_before = self.__dict__.keys() def needReexecute(self): if self.alias == 'header': return True if 'loaded_hash_source' in self.__dict__: return not self.loaded_hash_source == self.hash_source return True def saveBlockOutputInfo(self): if self.alias == 'header': return global_keys = globals().keys() global_keys_to_save = set(global_keys) - set(self.global_keys_before) global_keys_to_save = list(global_keys_to_save) global_entries_to_save = dict( [(e, globals()[e]) for e in global_keys_to_save]) local_keys = self.__dict__.keys() local_keys_to_save = set(local_keys) - set(self.local_keys_before) local_keys_to_save = list(local_keys_to_save) local_entries_to_save = dict( [(e, self.__dict__[e]) for e in local_keys_to_save]) try: for k in global_entries_to_save: try: - print ('try to save ', k, - ' ', latex(global_entries_to_save[k])) + print('try to save ', k, + ' ', latex(global_entries_to_save[k])) global_entries_to_save[k] = dill.dumps( global_entries_to_save[k]) print('saved ', k) except Exception as e: print(e) self.global_block_result = dill.dumps( global_entries_to_save) self.local_block_result = dill.dumps(local_entries_to_save) self.global_hash_result = hashlib.sha1( self.global_block_result).hexdigest() self.local_hash_result = hashlib.sha1( self.local_block_result).hexdigest() except Exception as e: print("cannot save block: {0}\n{1}".format(self.alias, e)) self.global_block_result = None self.global_hash_result = None self.local_block_result = None self.local_hash_result = None self.hash_source = None filename = self.alias + '.pytex.out' f = open(filename, 'w') # print "save symbols {0}: hash_source {1}".format( # self.alias,self.hash_source) raw_save = [self.hash_source, self.global_hash_result, self.global_block_result, self.local_hash_result, self.local_block_result] dill.dump(raw_save, f) f.close() def loadBlockOutputInfo(self): return if self.alias == 'header': return filename = self.alias + '.pytex.out' try: f = open(filename, 'r') self.loaded_hash_source, self.global_hash_result, self.global_block_result, self.local_hash_result, self.local_block_result = dill.load(f) # print "loaded symbols" # print "AAAAAAAAAAA " + str(self.loaded_hash_source) globals().update(dill.loads(self.global_block_result)) self.__dict__.update(dill.loads(self.local_block_result)) # print pickle.loads(self.global_block_result).keys() # print self.__dict__.keys() f.close() print('loaded {0}'.format(filename)) except Exception: # print "Could not load block " + self.alias # print e pass def evalBlock(self): - txt_content = self.content[0] + txt_content = self.content self.generateHashSource() self.loadBlockOutputInfo() need_reexecute = self.needReexecute() if need_reexecute or reexec: print("execute block: {0}".format(self.alias)) gl = globals() gl.update({'self': self}) try: exec(txt_content, gl) except Exception as e: mesg = """For block '{0}' there was an execution problem {1} Block was: ************ {2} """.format(self.alias, e, txt_content) if (not continue_flag): raise Exception(mesg) else: - print (mesg) + print(mesg) del gl['self'] self.saveBlockOutputInfo() def getContent(self, varname): try: c = self.__dict__[varname] except Exception as ex: print(ex) raise Exception("cannot retreive variable " + varname + " from block " + self.alias) if (myre.search('sympy', str(type(c)))): c = sym.latex(c) return c - def __init__(self, name, parent, options): + def __init__(self, name, alias, content): - tex.LatexBlock.__init__(self, name, parent, options) + self.name = name + self.alias = alias + self.content = content if not self.name == 'python': raise Exception( 'cannot create a PyCode block from block type ' + self.name) - if self.options is None: + if self.alias is None: raise Exception("not valid python block") - m = myre.match(r"{(.*?)}", self.options) - if not m: - raise Exception("not valid options " + self.options) - self.alias = m.group(1) + self.block_eval = None ################################################################ def evaluatePythonBlock(b): - if b.name == 'python': + if isinstance(b, tex.LatexEnvironment) and b.name == 'python': + b.hide = True + b = PyCode(b.name, b.option, str(b.toks[1])) + globals()[b.alias] = b b.evalBlock() def replaceAliases(b, text): - if b.name == 'python': + if isinstance(b, tex.LatexEnvironment) and b.name == 'python': return text if type(text) == str: # print text regex = r'\\py{(.*?)}' m = myre.findall(regex, text) if not m: return text # print text for expression in m: - # print expression + # print('replaceAliasses: ', expression) try: - exec("ans = " + expression) + d = dict() + exec("ans = " + expression, globals(), d) except Exception as e: print("Block " + str(b.name) + " Cannot parse expression '" + str(expression) + "'\n" + str(e)) + ans = d['ans'] rep = '\\py{' + expression + '}' try: ans_str = str(latex(ans)) except Exception as e: print("AAAAAAAA " + str(e)) return text # print "ans is now " + str(ans) - globals().update({'ans':ans}) + globals().update({'ans': ans}) # print "replace " + rep + " with " + cont text = text.replace(rep, ans_str, 1) - # print text return text ################################################################ def collectScript(b, text): - if b.name == 'python': - globals()['total_python_script'] += "{0} = CodeEval()".format( - b.alias) + if isinstance(b, tex.LatexEnvironment) and b.name == 'python': + # print('AAAA ', b) + globals()['total_python_script'] += "{0} = CodeEval()\n".format( + b.option) globals()['total_python_script'] += text.replace( - 'self', b.alias) + 'self', b.option) return text if type(text) == str: # print text regex = r'\\py{(.*?)}' m = myre.findall(regex, text) if not m: return text # print m for expression in m: globals()['total_python_script'] += ( - "print 'printing expression: {0}'\n".format( + "print('printing expression: {0}')\n".format( str(expression).replace("'", "\\'"))) globals()['total_python_script'] += ( "ans = " + expression + "\n") globals()['total_python_script'] += ( - "print str(latex(ans)) + '\\n\\n'\n") + "print(str(latex(ans)) + '\\n\\n'\n)") return text ################################################################ continue_flag = False reexec = True def interpretPython(filename, c_flag, reexec_flag): continue_flag = c_flag reexec = reexec_flag tex_struct = tex.LatexStructure() - tex_struct.buildLatexBlocks(filename) + # tex_struct.buildLatexBlocks(filename) + tex_struct.parseLatexFile(filename) total_python_script = """ from PythonLatex.generate_latex import * class CodeEval: pass """ globals().update({'total_python_script': total_python_script}) globals().update({'reexec': reexec}) globals().update({'continue_flag': continue_flag}) - tex_struct.pathInBlock(ftext=collectScript) - tex_struct.pathInBlock(fbegin=evaluatePythonBlock, - ftext=replaceAliases) + tex_struct.pathInBlock(text_functor=collectScript) + tex_struct.pathInBlock(begin_functor=evaluatePythonBlock, + text_functor=replaceAliases) total_python_script = globals()['total_python_script'] # pyblocks = tex_struct.getBlocksFromType("python") # # for b in pyblocks: # total_python_script += b.content[0] tmp_file = open('python_script.py', 'w') tmp_file.write(total_python_script) tmp_file.close() return str(tex_struct) diff --git a/PythonLatex/latex_structure.py b/PythonLatex/latex_structure.py index 54edb15..cdef886 100644 --- a/PythonLatex/latex_structure.py +++ b/PythonLatex/latex_structure.py @@ -1,322 +1,364 @@ -#!/usr/bin/python +#!/ usr / bin / python ################################################################ from __future__ import print_function ################################################################ import re import types import pyparsing as pp ################################################################ class LatexEnvironment(object): def __init__(self, toks): self.toks = toks self.content = self.toks[1:-1] - print('env:', self) + self.head = self.toks[0] + self.tail = self.toks[-1] + self.name = self.head.toks[2] + self.option = self.head.toks[5] + # print('env:', self.name) + self.hide = False def __str__(self): - return ''.join([str(t) for t in self.toks]) + if self.hide: + return '' + return ''.join([str(self.head), '\n'] + + [str(i) for i in self.content] + + [str(self.tail)]) def __getitem__(self, index): return self.toks[index] class LatexCommand(object): def __init__(self, toks): self.toks = toks - # print('command:', toks) def __str__(self): return ''.join(self.toks) def __getitem__(self, index): return self.toks[index] class LatexBlock(object): - def __init__(self, toks): + def __init__(self, toks, name=None): self.toks = toks - # print('block:', self) + self.name = name def __str__(self): return ''.join([str(t) for t in self.toks]) class LatexMain(object): def __init__(self, toks): self.toks = toks + self.content = self.toks def __str__(self): - return ''.join([str(t) for t in self.toks]) + # for i in self.toks: + # print('LatexMain:\n', type(i), str(i)) + res = ''.join([str(t) for t in self.toks]) + # print(res) + return res def __getitem__(self, index): return self.toks[index] ################################################################ class LatexStructure: def getBlocksFromType(self, typ): mylist = [] def foo(b): if b.name == typ: mylist.append(b) self.pathInBlock(fbegin=foo) return mylist @staticmethod def ppValidCharacters(): valid_characters = pp.printables valid_characters = valid_characters.replace('%', '') valid_characters = valid_characters.replace('{', '') valid_characters = valid_characters.replace('}', '') valid_characters = valid_characters.replace('\\', '') valid_characters += ' \t\r\n' return valid_characters @property def text(self): if '_text' not in self.__dict__: self._text = pp.Word(self.ppValidCharacters()) self._text.skipWhitespace = False self._text = (self._text | pp.Literal('\\\\') | pp.Literal(r'\&') | pp.Literal(r'\%')) return self._text @property def comment(self): if '_comment' not in self.__dict__: self._comment = pp.Literal('%') self._comment += pp.SkipTo(pp.LineEnd()) self._comment.skipWhitespace = False return self._comment @property def block(self): if '_block' not in self.__dict__: _start = pp.Literal('{') _end = pp.Literal('}') _content = pp.Forward() _block = _start + _content + _end self._block = _block _content << pp.ZeroOrMore(self.environment | self.ppCommand() | self.block | self.text | self.comment) _content.skipWhitespace = False self._block.skipWhitespace = False def createBlock(toks): b = LatexBlock(toks) - # print('block:', b) +#print('block:', b) return b _block.addParseAction(createBlock) return self._block @staticmethod def ppCommand(name=None, n_options=None): if name is None: _command = pp.Literal('\\') + pp.Word(pp.alphanums + '@') else: _command = pp.Literal('\\' + name) option = ( pp.Literal('[') + pp.delimitedList(pp.Word(pp.alphanums), combine=True) + pp.Literal(']')) valid_param_character = pp.printables + ' \t\r\n\\' valid_param_character = valid_param_character.replace('{', '') valid_param_character = valid_param_character.replace('}', '') parameters = ( pp.Literal('{') + pp.delimitedList(pp.Word(valid_param_character), combine=True) + pp.Literal('}')) _command += pp.ZeroOrMore(option | parameters) _command.skipWhitespace = False def createCommand(toks): c = LatexCommand(toks) - # print('command:', c) +#print('command:', c) return c _command.addParseAction(createCommand) return _command @property def environment(self): if '_environment' in self.__dict__: return self._environment _env_start = self.ppCommand('begin', n_options=1) _env_end = self.ppCommand('end') _env_content = pp.Forward() _env = _env_start + _env_content + _env_end self._environment = _env self._environment.skipWhitespace = False def set_excluding_command(toks): env_name = toks[0][2] _command_excluding = self.ppCommand() - # print('command_excluding:', env_name) +#print('command_excluding:', env_name) if env_name == 'python': python_block = pp.SkipTo(pp.Literal(r'\end{python}')) python_block.skipWhitespace = False _env_content << python_block else: _env_content << pp.ZeroOrMore( _env | _command_excluding | self.block | self.text | self.comment) def check(toks, env_name): if toks[0][1] != 'end': return toks - # print('check:', toks, env_name) - # print('check2:', toks[0], env_name) - # print('check2:', type(toks[0]), env_name) - # print('check3:', toks[0][3], env_name) +#print('check:', toks, env_name) +#print('check2:', toks[0], env_name) +#print('check2:', type(toks[0]), env_name) +#print('check3:', toks[0][3], env_name) if toks[0][3] == env_name: return toks[652336456] return toks _command_excluding.addParseAction( lambda toks: check(toks, env_name)) _env_start.addParseAction(set_excluding_command) def createEnvironment(toks): e = LatexEnvironment(toks) - print('env:', e) return e _env.addParseAction(createEnvironment) return self._environment def parseLatexFile(self, filename): - # self.main_block = LatexBlock() - # self.current_block = self.main_block + #self.main_block = LatexBlock() + #self.current_block = self.main_block fin = open(filename, 'r') inp = fin.read() - # inp = r' \begin{toto}tatie \begin{re}tututoto \end{re} aa\end{toto}' - # inp = r'\begin{toto}tatie\end{toto}' - # inp = r'tatie' - # inp = r'\documentclass[10pt]{article}' - # inp = r'{ yala {toto} \begin{align} tutu \begin{equation} toto \end{equation} \end{align} {\titi { tutu} } }' - # print (inp) + # inp = r ' \begin{toto}tatie \begin{re}tututoto \end{re} aa\end{toto}' + # inp = r '\begin{toto}tatie\end{toto}' + # inp = r 'tatie' + # inp = r '\documentclass[10pt]{article}' + # inp = \ + # r '{ yala {toto} \begin{align} tutu \begin{equation} toto \end{equation} \end{align} {\titi { tutu} } }' +# print(inp) _content = pp.ZeroOrMore(self.environment | self.block | self.ppCommand() | self.text | self.comment) _content.skipWhitespace = False self._content = LatexMain(_content.parseString(inp)) def buildLatexBlocks(self, filename, herited_types=dict()): fin = open(filename, 'r') inp = fin.readlines() inp = "".join(inp) latex_cmd_expr = r'(\\\w+(?:\[\w*\])*(?:{[\w|,|\.|(|)]*?})+)' splitted = re.split(latex_cmd_expr, inp) self.main_block = LatexBlock() self.current_block = self.main_block for i in splitted: m = re.match(r'\\begin{(.*?)}(.*)', i) if m: name = m.group(1) options = m.group(2) self.current_block = self.current_block.createSubBlock( name, options, herited_types) continue m = re.match(r'\\end{(.*?)}', i) if m: name = m.group(1) try: self.current_block = self.current_block.endSubBlock(name) except Exception as e: print("AAAAAAAAAAAAAAAAAA") print(e) continue self.current_block.appendContent(i) if not self.current_block == self.main_block: raise Exception( "one latex block was not closed: {0}".format( self.current_block.name)) - def pathInBlock(self, - block=None, - begin_functor=None, - end_functor=None, - text_functor=None): + def pathInBlockOld(self, + block=None, + begin_functor=None, + end_functor=None, + text_functor=None): if block is None: block = self.main_block if begin_functor is not None: begin_functor(block) for i in range(len(block.content)): c = block.content[i] if isinstance(c, types.InstanceType): try: self.pathInBlock(c, begin_functor, end_functor, text_functor) except Exception as e: print(e) else: if text_functor is not None: block.content[i] = text_functor(block, c) if end_functor is not None: end_functor(block) + def pathInBlock(self, + block=None, + begin_functor=None, + end_functor=None, + text_functor=None): + + if text_functor is None: + def text_functor(b, c): + return c + + if block is None: + block = self._content + + if begin_functor is not None: + begin_functor(block) + + for i, c in enumerate(block.content): + # print(type(c), c) + if isinstance(c, LatexEnvironment): + self.pathInBlock(c, + begin_functor, + end_functor, + text_functor) + else: + block.content[i] = text_functor(block, str(c)) + + if end_functor is not None: + end_functor(block) + def __str__(self): return str(self._content) @property def content(self): return self._content def __init__(self): self._content = None ################################################################ if __name__ == '__main__': import sys filename_in = sys.argv[1] filename_out = sys.argv[2] tex_struct = LatexStructure() tex_struct2 = LatexStructure() - # tex_struct.buildLatexBlocks(filename_in) +# tex_struct.buildLatexBlocks(filename_in) tex_struct2.parseLatexFile(filename_in) open(filename_out, 'w').write(str(tex_struct)) - open(filename_out+'-2', 'w').write(str(tex_struct2)) + open(filename_out + '-2', 'w').write(str(tex_struct2)) diff --git a/Slides/templates/html.css b/Slides/templates/html.css index 9f1be92..510b6b0 100644 --- a/Slides/templates/html.css +++ b/Slides/templates/html.css @@ -1,40 +1,186 @@ .reveal { font-size: {{font_size}}; } .reveal h1 { font-size: 200%; } .reveal h2 { font-size: 150%; } .text_cell_render { text-align: left; } a.anchor-link:link { text-decoration: none; visibility: hidden; } .slide { } div.slide{ border-style: solid; border-width: 2px; display: flex; flex-direction: row; flex-wrap: wrap; justify-content: center; margin-top: 5px; margin-bottom: 5px; padding: 100px; width: 1000px; } +/******************************* +** highing tpart +*******************************/ +.highlight_text { + color: blue; +} + +.highlight-base { + color: #000; +} +.highlight-variable { + color: #000; +} +.highlight-variable-2 { + color: #1a1a1a; +} +.highlight-variable-3 { + color: #333333; +} +.highlight-string { + color: #BA2121; +} +.highlight-comment { + color: #408080; + font-style: italic; +} +.highlight-number { + color: #080; +} +.highlight-atom { + color: #88F; +} +.highlight-keyword { + color: #008000; + font-weight: bold; +} +.highlight-builtin { + color: #008000; +} +.highlight-error { + color: #f00; +} +.highlight-operator { + color: #AA22FF; + font-weight: bold; +} +.highlight-meta { + color: #AA22FF; +} +.highlight-def { + color: #00f; +} +.highlight-string-2 { + color: #f50; +} +.highlight-qualifier { + color: #555; +} +.highlight-bracket { + color: #997; +} +.highlight-tag { + color: #170; +} +.highlight-attribute { + color: #00c; +} +.highlight-header { + color: blue; +} +.highlight-quote { + color: #090; +} +.highlight-link { + color: #00c; +} + +.highlight .hll { background-color: #ffffcc } +//.highlight { background: #f8f8f8; } +.highlight .c { color: #408080; font-style: italic } /* Comment */ +.highlight .err { border: 1px solid #FF0000 } /* Error */ +.highlight .k { color: #008000; font-weight: bold } /* Keyword */ +.highlight .o { color: #666666 } /* Operator */ +.highlight .ch { color: #408080; font-style: italic } /* Comment.Hashbang */ +.highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */ +.highlight .cp { color: #BC7A00 } /* Comment.Preproc */ +.highlight .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */ +.highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */ +.highlight .cs { color: #408080; font-style: italic } /* Comment.Special */ +.highlight .gd { color: #A00000 } /* Generic.Deleted */ +.highlight .ge { font-style: italic } /* Generic.Emph */ +.highlight .gr { color: #FF0000 } /* Generic.Error */ +.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ +.highlight .gi { color: #00A000 } /* Generic.Inserted */ +.highlight .go { color: #888888 } /* Generic.Output */ +.highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ +.highlight .gs { font-weight: bold } /* Generic.Strong */ +.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ +.highlight .gt { color: #0044DD } /* Generic.Traceback */ +.highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ +.highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ +.highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ +.highlight .kp { color: #008000 } /* Keyword.Pseudo */ +.highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ +.highlight .kt { color: #B00040 } /* Keyword.Type */ +.highlight .m { color: #666666 } /* Literal.Number */ +.highlight .s { color: #BA2121 } /* Literal.String */ +.highlight .na { color: #7D9029 } /* Name.Attribute */ +.highlight .nb { color: #008000 } /* Name.Builtin */ +.highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */ +.highlight .no { color: #880000 } /* Name.Constant */ +.highlight .nd { color: #AA22FF } /* Name.Decorator */ +.highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */ +.highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ +.highlight .nf { color: #0000FF } /* Name.Function */ +.highlight .nl { color: #A0A000 } /* Name.Label */ +.highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ +.highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */ +.highlight .nv { color: #19177C } /* Name.Variable */ +.highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ +.highlight .w { color: #bbbbbb } /* Text.Whitespace */ +.highlight .mb { color: #666666 } /* Literal.Number.Bin */ +.highlight .mf { color: #666666 } /* Literal.Number.Float */ +.highlight .mh { color: #666666 } /* Literal.Number.Hex */ +.highlight .mi { color: #666666 } /* Literal.Number.Integer */ +.highlight .mo { color: #666666 } /* Literal.Number.Oct */ +.highlight .sa { color: #BA2121 } /* Literal.String.Affix */ +.highlight .sb { color: #BA2121 } /* Literal.String.Backtick */ +.highlight .sc { color: #BA2121 } /* Literal.String.Char */ +.highlight .dl { color: #BA2121 } /* Literal.String.Delimiter */ +.highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ +.highlight .s2 { color: #BA2121 } /* Literal.String.Double */ +.highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ +.highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */ +.highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ +.highlight .sx { color: #008000 } /* Literal.String.Other */ +.highlight .sr { color: #BB6688 } /* Literal.String.Regex */ +.highlight .s1 { color: #BA2121 } /* Literal.String.Single */ +.highlight .ss { color: #19177C } /* Literal.String.Symbol */ +.highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */ +.highlight .fm { color: #0000FF } /* Name.Function.Magic */ +.highlight .vc { color: #19177C } /* Name.Variable.Class */ +.highlight .vg { color: #19177C } /* Name.Variable.Global */ +.highlight .vi { color: #19177C } /* Name.Variable.Instance */ +.highlight .vm { color: #19177C } /* Name.Variable.Magic */ +.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */ diff --git a/scripts/test.ptex b/scripts/test.ptex new file mode 100644 index 0000000..ffa10d5 --- /dev/null +++ b/scripts/test.ptex @@ -0,0 +1,19 @@ +\documentclass[9pt]{beamer} + +\begin{python}{header} +import os +\end{python} + + +\title{Test of ptex format} +\begin{document} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\maketitle +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}{Test} + \py{os.getcwd()} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\end{document}