Hi Noah,

Noah Kantrowitz <n...@...> writes:

> 
> You should probably be more specific about what you are trying to do. There
> is a decent chance that a wiki is not what you should be using if you want
> things like dynamic syntax processing.
> 
> --Noah
> 
> > -----Original Message-----
> > From: trac-us...@... [mailto:trac-us...@...]
> > On Behalf Of Rodrik
> > Sent: Tuesday, May 25, 2010 10:39 AM
> > To: trac-us...@...
> > Subject: [Trac] Button instead of Macro Processor
> > 
> > Hi there!
> > 
> > I'm creating a macro for Trac which should check,
> > if parenthesis are correctly opened and closed. Until now,
> > I wrote a macro, which is able to do the job.
> > I need your help on two issues:
> > 
> > 1 - How do it looks like, if I want to, let's say,
> > have a button on my wiki, which when clicked,
> > simply processes the text, without the need for
> > something like '#!macro' in the code.
> > 
> > 2 - If I do let the macro commando in my wiki text,
> > how can I avoid that {{{ }}}(blocks) are escaped?
> > Ex.:
> > {{{
> > #!myMacro
> > {{{
> > Here is a piece text, that should be processed, but shown as block!
> > }}}
> > }}}
> > ----
> > So, I want to have the text processed
> > without the intern {{{ }}} being literally shown.
> > Until now I'm using something like this to show the wiki content:
> > 
> > return '<pre class="wiki">%s</pre>' %text
> > 
> > I would be really thankful, if someone could help me!
> > 
> > Best greetings,
> > 
> > Rodrik.
> > 
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Trac Users" group.
> > To post to this group, send email to trac-us...@...
> > To unsubscribe from this group, send email to trac-
> > users+unsubscr...@...
> > For more options, visit this group at
> > http://groups.google.com/group/trac-users?hl=en.
> 

What I'm trying to do is to check if parenthesis in texts 
inserted into the wiki are balanced, i.e. if each '(' has its respective ')'. 
I have to do it for project, where people will insert text into the wiki,
so I can't bypass it.

My code looks something like this:

class SyntaxChecker(WikiMacroBase):
    def checkParentheses(string):
        //check if ()'s are balanced
    def get_macros(self):
       //some code

    def expand_macro(self, formatter, name, args):
        text = ''
        if args:
            lines = args.split('\n')
            for line in lines:
                if not checkParentheses(line): //if ()' are not balanced
                    text += '<h1 style="text-align: left; color: 
red">%s</h1>\n'          
                                     
%line.replace("<","<").replace(">",">")+'\n'
                else: //if ()'s are OK
                    text += line.replace("<","<").replace(">",">")+'\n'
            return '<pre class="wiki">%s</pre>' %text //How would be the best 
way to do this?

Thanks in advance for your help!

Rodrik.



-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/trac-users?hl=en.

Reply via email to