From 952d12302ab156cc9b289c45a96d0e3f0e7766e0 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Mon, 20 Oct 2008 10:11:34 -0400 Subject: Combined the TextPreprocessors and Preprocessors into Preprocessors. Updated extensions and docs as well. --- docs/writing_extensions.txt | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) (limited to 'docs') diff --git a/docs/writing_extensions.txt b/docs/writing_extensions.txt index 617b92e..9d6fa42 100755 --- a/docs/writing_extensions.txt +++ b/docs/writing_extensions.txt @@ -19,8 +19,6 @@ helpful as well. For example, the [[Footnotes]] extension uses most of the features documented here. * [Preprocessors][] - * [TextPreprocessors][] - * [Line Preprocessors][] * [InlinePatterns][] * [Treeprocessors][] * [Postprocessors][] @@ -39,30 +37,7 @@ Preprocessors munge the source text before it is passed into the Markdown core. This is an excellent place to clean up bad syntax, extract things the parser may otherwise choke on and perhaps even store it for later retrieval. -There are two types of preprocessors: [TextPreprocessors][] and -[Line Preprocessors][]. - -

TextPreprocessors

- -TextPreprocessors should inherit from ``markdown.TextPreprocessor`` and -implement a ``run`` method with one argument ``text``. The ``run`` method of -each TextPreprocessor will be passed the entire source text as a single Unicode -string and should either return that single Unicode string, or an altered -version of it. - -For example, a simple TextPreprocessor that normalizes newlines [^1] might look -like this: - - class NormalizePreprocessor(markdown.TextPreprocessor): - def run(self, text): - return text.replace("\r\n", "\n").replace("\r", "\n") - -[^1]: It should be noted that Markdown already normalizes newlines. This -example is for illustrative purposes only. - -

Line Preprocessors

- -Line Preprocessors should inherit from ``markdown.Preprocessor`` and implement +Preprocessors should inherit from ``markdown.Preprocessor`` and implement a ``run`` method with one argument ``lines``. The ``run`` method of each Line Preprocessor will be passed the entire source text as a list of Unicode strings. Each string will contain one line of text. The ``run`` method should return @@ -457,8 +432,6 @@ This is useful if you need to implement a large number of extensions with more than one residing in a module. [Preprocessors]: #preprocessors -[TextPreprocessors]: #textpreprocessors -[Line Preprocessors]: #linepreprocessors [InlinePatterns]: #inlinepatterns [Treeprocessors]: #treeprocessors [Postprocessors]: #postprocessors -- cgit v1.2.3