Modify

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#10370 closed defect (wontfix)

can we extend the mathjax to more latex contents?

Reported by: huang Owned by: Kamil Kisiel
Priority: normal Component: TracMathJaxPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description

I'd love to see the latex page can be copied and pasted to my trac wiki page without change from subsection to == and $$ to {{{ I make a simple python code to do this, but more ideally, if in the wiki page have #!latex, the whole page is filtered by this before feed to the mathjax, I will also look into how to program trac plugin myself. If anyone can show me this feature is already exist or how to implement it, that will be great

#!/usr/bin/env python


import sys, re

bullet_level=0
enum_level = 0
bdoc = None
end_line = 1

verbatim_mode = 0
math_mode = 0
eqnarry_mode = 0

tr_list1=[
    [r"\\_",r"_"]
]
tr_list2 = [
    [r"\$\$",r"\$\$",r"\n{{{\n#!latex\n\n",r"\n}}}\n"],
    [r"\$",r"\$",r"\(",r"\)"],
    [r"\\subsubsection{",r"}",r" ==== ",r" ==== "],
    [r"\\subsection{",r"}",r" === ",r" === "],
    [r"\\section{",r"}",r" == ",r" == "],
    [r"\\title{",r"}",r" = ",r" = "],
    ]

in_stream  = sys.stdin;
out_stream = sys.stdout

ms=re.search('\\\\begin\{document\}(.*?)\\\\end\{document\}',in_stream.read(),re.DOTALL)
if ms:
    stream=ms.group(1)
    for reg in tr_list1:
        p=re.compile(reg[0])
        stream=re.sub(p,reg[1],stream)
        print stream
    for reg in tr_list2:
        p=re.compile(reg[0]+'(.*?)'+reg[1],re.DOTALL)
        stream=re.sub(p,reg[2]+r'\1'+reg[3],stream,re.DOTALL)
    print >> out_stream, stream,

Attachments (0)

Change History (6)

comment:1 Changed 12 years ago by Kamil Kisiel

Resolution: wontfix
Status: newclosed

I think this is outside the scope of this particular plugin. Feel free to fork it and add the functionality yourself. The code is actually quite simple, you just need to modify the function at https://bitbucket.org/kisielk/tracmathjaxplugin/src/044b7fb93a9a/tracmathjax/tracmathjax.py#cl-63

You could pretty much insert your code there and replace in_stream.read() with the current value of content

comment:2 Changed 12 years ago by Huang

Sure, I agree this is outside the scope of this plugin. And I am going to start another plugin to implement this, that seems feasible. I foreseen the new plugin will use this plugin to handle the math, while the new plugin handle those title.

Then can we move the macro name of this plugin from latex to latexmathjax so we might use the latex for the new one? currently I am using traxlatex instead.

comment:3 Changed 12 years ago by Kamil Kisiel

I'd prefer to keep the macro name the same because it's what was used by the TracMath plugin that this one supersedes. It helps to ease in migration.

comment:4 in reply to:  2 Changed 12 years ago by Ryan J Ollos

Replying to Huang:

Sure, I agree this is outside the scope of this plugin. And I am going to start another plugin to implement this, that seems feasible. I foreseen the new plugin will use this plugin to handle the math, while the new plugin handle those title.

I just want to throw out the possibility that there are multiple latex plugins that are not currently maintained, and maybe you'd like to give those a look-over and see if you'd like to take over maintenance and use one of those as your starting point.

Is TracMathPlugin obsoleted by TracMathJaxPlugin?

comment:5 Changed 12 years ago by Kamil Kisiel

rjollos: They accomplish the same thing but work in different ways. TracMath is also slightly more configurable if someone has special needs for a particular LaTeX package. There may also be people who are using older browsers that may prefer to use it.

comment:6 Changed 12 years ago by Huang

I looked at the LatexMarco and Latex Formula Marco they all render formula to png file using local latex instead of mathjax somewhere What I am proposing is just change the format from latex to wiki, not special engine rendering formula, and I guess we can choose which one to use to render the formulas

I submitted another ticket here for that idea: http://trac-hacks.org/ticket/10373

Of course, it is not completed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Kamil Kisiel.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.