From: David G. <go...@py...> - 2003-03-05 16:16:22
|
Morten W. Petersen wrote: >> What do you mean? Remove marked-up text from a document, or remove >> functionality from the parser? > > Remove functionality from the parser, make the parser ignore certain > elements First, why? What's your use case? The simplest solution is, just don't use that markup in your documents. If it's important, make it a policy decision in your organization. Second, what should the parser do with the markup it ignores? Third, which type of markup do you want to suppress, inline markup or block-level markup? The parser (implemented in module docutils.parsers.rst.states) deals with the two separately and differently. Block-level markup is recognized via an ordered dispatch table; remove the entry for the markup you don't want, and it won't be recognized. Inline markup (class Inliner) is recognized with a large regular expression (Inliner.patterns.initial) that's built from a data structure (Inliner.parts), plus a table for standalone/implicit markup (URLs etc.; Inliner.implicit_dispatch). Alter the data structure, rebuild and reinstall the regexp, and go from there. Of course, you should work on subclasses or instances so as not to step on toes. The parser is not set up for this to be really easy to do, because it hasn't been needed yet. > (without using the :: markup). What does this mean? -- David Goodger http://starship.python.net/~goodger Programmer/sysadmin for hire: http://starship.python.net/~goodger/cv |