Ken schrieb:
> Is there a simple way to add a hook to pre-process/filter input .rst
> files?
>
> I'm playing around with sphnix/rst to potentially replace writing some
> stuff in Latex, but I can't bring myself to write "::math:`N`" each
> time for "$N$"; and few other things like this...
>
> For now, I can run simple stand-alone scripts like this,
> r = re.compile(r'\$([^$]+)\$')
> print r.sub(r'::math:`\1`', sys.stdin.read())
>
> Can an 'extension' do this? I'm looking into the code a bit, but a
> point in the right direction would be appreciated.
Not until now, but I've now added a "source-read" event to Sphinx SVN
to be able to preprocess source text. Use it like this (e.g. in your conf.py):
r = re.compile(r'\$([^$]+)\$')
def substitute_math(app, docname, text):
text[0] = r.sub(r'::math:`\1`', text[0])
def setup(app):
app.connect('source-read', substitute_math)
Be aware, however, that this will replace really _all_ occurrences of
$abc$ anywhere in the source text.
cheers,
Georg
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sphinx-dev" 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/sphinx-dev?hl=en
-~----------~----~----~----~------~----~------~--~---