On Fri, Nov 20, 2009 at 12:12 PM, John Hunter <[email protected]> wrote: > I am using Ondrej's "math_dollar" extension which lets you write latex > style dollar signs embraced math expressions like $x=1$ in a sphinx > document and they get expanded into sphinx math roles. This works > fine, expect in literal code blocks like:: > > you can use $x=1$ for math when using math_dollar > > or in the matplotlib plot directive extensions, where I do not want > dollar signs to be translated but passed literally into matplotlib for > rendering. > > .. plot:: > > import matplotlib.pyplot as plt > fig = plt.figure() > ax = fig.add_subplot(111) > # ...snip > ax.hist(fat, 20, normed=True) > ax.text(1.0, 0.045, r'$\mu=1.05, \sigma=0.019$', fontsize=18) > plt.show() > > > Is there a way to detect whether we are in a literal code block, or > some other way to figure out if we are in the main body or in a rest > directive? I'd like to turn math_dollar off when inside rest > directives, or even better when inside *certain* directives. > > I've attached the math_dollar extension -- thanks in advance for any help!
It'd be awesome to rewrite this using some rest parser inside sphinx. I just didn't have knowledge for it. The current version that John has attached is really rather a quick hack, that works most of the time, but it is not 100% robust. If anyone could improve it, I am sure lots of people would be grateful for it. :) Ondrej -- 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=.
