-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 16.02.2010 23:13, schrieb Mhs: > Hello group, > > after playing around with Sphinx (impressive piece of software!) for a > couple of weeks and writing a small custom directive, I'd now like to > implement a "custom pattern", i.e. I'd like a callback to be invoked > each time a certain pattern appears in the text (regardless or the context). > > To be more specific, I'd like to use patterns like "(X0)" to label and > reference parts of the text (lemmas, theorems and the like), so I need > to hook into Sphinx and have a callback invoked, preferable with the > context surrounding the pattern. I could then decide whether this > appearance defines a lemma or references it, I could add it to a TOC etc. > > I guess this is much harder to achieve than writing a custom directive, > maybe it is even too low-level for Sphinx and rather a problem of > extending Docutils than Sphinx ...
(Most Sphinx extensions extend both docutils and Sphinx in a stricter sense, since all new markup (roles/directives) is docutils zone.) Recognizing arbitrary patterns in the input text is something that is supported by docutils, if you subclass or monkey-patch the Inliner class (in the docutils.parsers.rst.states module) to recognize your patterns in addition to normal reST inline markup (roles, bold/italic etc.). If you want to go in this direction, I'd advise asking the docutils users list for guidance. cheers, Georg -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (GNU/Linux) iEYEARECAAYFAkuBTvwACgkQN9GcIYhpnLDRQACfcA3G2RzbjMHuGsl5lioxxK89 O6sAoIi3XI5DMW7kUBbm1cWppg9NyGaL =Vj6d -----END PGP SIGNATURE----- -- 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.
