[Python-checkins] python/nondist/peps/docutils/parsers/rst __init__.py,1.1,1.2 states.py,1.2,1.3 .cvsignore,1.1,NONE
goodger@users.sourceforge.net
goodger@users.sourceforge.net
Tue, 31 Dec 2002 18:36:31 -0800
- Previous message: [Python-checkins] python/nondist/peps/docutils core.py,1.1,1.2 frontend.py,1.1,1.2 io.py,1.1,1.2 utils.py,1.1,1.2 .cvsignore,1.1,NONE
- Next message: [Python-checkins] python/nondist/peps/docutils/parsers/rst/directives misc.py,1.1,1.2 .cvsignore,1.1,NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/nondist/peps/docutils/parsers/rst
In directory sc8-pr-cvs1:/tmp/cvs-serv30174/parsers/rst
Modified Files:
__init__.py states.py
Removed Files:
.cvsignore
Log Message:
update from latest Docutils code
Index: __init__.py
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/docutils/parsers/rst/__init__.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** __init__.py 8 Nov 2002 23:47:52 -0000 1.1
--- __init__.py 1 Jan 2003 02:35:59 -0000 1.2
***************
*** 9,12 ****
--- 9,13 ----
the reStructuredText parser.
+
Usage
=====
***************
*** 14,21 ****
1. Create a parser::
! parser = docutils.parsers.restructuredtext.Parser()
Several optional arguments may be passed to modify the parser's behavior.
! Please see `docutils.parsers.Parser` for details.
2. Gather input (a multi-line string), by reading a file or the standard
--- 15,22 ----
1. Create a parser::
! parser = docutils.parsers.rst.Parser()
Several optional arguments may be passed to modify the parser's behavior.
! Please see `Customizing the Parser`_ below for details.
2. Gather input (a multi-line string), by reading a file or the standard
***************
*** 26,30 ****
3. Create a new empty `docutils.nodes.document` tree::
! document = docutils.utils.new_document(source)
See `docutils.utils.new_document()` for parameter details.
--- 27,31 ----
3. Create a new empty `docutils.nodes.document` tree::
! document = docutils.utils.new_document(source, settings)
See `docutils.utils.new_document()` for parameter details.
***************
*** 34,37 ****
--- 35,39 ----
parser.parse(input, document)
+
Parser Overview
===============
***************
*** 41,44 ****
--- 43,71 ----
become familiar with the `docutils.statemachine` module, then see the
`states` module.
+
+
+ Customizing the Parser
+ ----------------------
+
+ Anything that isn't already customizable is that way simply because that type
+ of customizability hasn't been implemented yet. Patches welcome!
+
+ When instantiating an object of the `Parser` class, two parameters may be
+ passed: ``rfc2822`` and ``inliner``. Pass ``rfc2822=1`` to enable an initial
+ RFC-2822 style header block, parsed as a "field_list" element (with "class"
+ attribute set to "rfc2822"). Currently this is the only body-level element
+ which is customizable without subclassing. (Tip: subclass `Parser` and change
+ its "state_classes" and "initial_state" attributes to refer to new classes.
+ Contact the author if you need more details.)
+
+ The ``inliner`` parameter takes an instance of `states.Inliner` or a subclass.
+ It handles inline markup recognition. A common extension is the addition of
+ further implicit hyperlinks, like "RFC 2822". This can be done by subclassing
+ `states.Inliner`, adding a new method for the implicit markup, and adding a
+ ``(pattern, method)`` pair to the "implicit_dispatch" attribute of the
+ subclass. See `states.Inliner.implicit_inline()` for details. Explicit
+ inline markup can be customized in a `states.Inliner` subclass via the
+ ``patterns.initial`` and ``dispatch`` attributes (and new methods as
+ appropriate).
"""
Index: states.py
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/docutils/parsers/rst/states.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** states.py 17 Nov 2002 00:09:19 -0000 1.2
--- states.py 1 Jan 2003 02:35:59 -0000 1.3
***************
*** 529,533 ****
closers = '\'")]}>'
start_string_prefix = (r'((?<=^)|(?<=[-/: \n%s]))' % re.escape(openers))
! end_string_suffix = (r'((?=$)|(?=[-/:.,;!? \n%s]))' % re.escape(closers))
non_whitespace_before = r'(?<![ \n])'
non_whitespace_escape_before = r'(?<![ \n\x00])'
--- 529,533 ----
closers = '\'")]}>'
start_string_prefix = (r'((?<=^)|(?<=[-/: \n%s]))' % re.escape(openers))
! end_string_suffix = (r'((?=$)|(?=[-/:.,;!? \n\x00%s]))' % re.escape(closers))
non_whitespace_before = r'(?<![ \n])'
non_whitespace_escape_before = r'(?<![ \n\x00])'
***************
*** 1802,1806 ****
arguments = []
options = {}
- content = []
argument_spec = getattr(directive_fn, 'arguments', None)
if argument_spec and argument_spec[:2] == (0, 0):
--- 1802,1805 ----
***************
*** 2384,2394 ****
"""Section title."""
lineno = self.state_machine.abs_line_number()
- if not self.state_machine.match_titles:
- blocktext = context[0] + '\n' + self.state_machine.line
- msg = self.reporter.severe(
- 'Unexpected section title.',
- nodes.literal_block(blocktext, blocktext), line=lineno)
- self.parent += msg
- return [], next_state, []
title = context[0].rstrip()
underline = match.string.rstrip()
--- 2383,2386 ----
***************
*** 2397,2405 ****
if len(title) > len(underline):
if len(underline) < 4:
! msg = self.reporter.info(
! 'Possible title underline, too short for the title.\n'
! "Treating it as ordinary text because it's so short.",
! line=lineno)
! self.parent += msg
raise statemachine.TransitionCorrection('text')
else:
--- 2389,2398 ----
if len(title) > len(underline):
if len(underline) < 4:
! if self.state_machine.match_titles:
! msg = self.reporter.info(
! 'Possible title underline, too short for the title.\n'
! "Treating it as ordinary text because it's so short.",
! line=lineno)
! self.parent += msg
raise statemachine.TransitionCorrection('text')
else:
***************
*** 2409,2412 ****
--- 2402,2413 ----
nodes.literal_block(blocktext, blocktext), line=lineno)
messages.append(msg)
+ if not self.state_machine.match_titles:
+ blocktext = context[0] + '\n' + self.state_machine.line
+ msg = self.reporter.severe(
+ 'Unexpected section title.',
+ nodes.literal_block(blocktext, blocktext), line=lineno)
+ self.parent += messages
+ self.parent += msg
+ return [], next_state, []
style = underline[0]
context[:] = []
--- .cvsignore DELETED ---
- Previous message: [Python-checkins] python/nondist/peps/docutils core.py,1.1,1.2 frontend.py,1.1,1.2 io.py,1.1,1.2 utils.py,1.1,1.2 .cvsignore,1.1,NONE
- Next message: [Python-checkins] python/nondist/peps/docutils/parsers/rst/directives misc.py,1.1,1.2 .cvsignore,1.1,NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]