From 101671ae44e1686680c80cd07b452aabeb88fb63 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 20 Apr 2002 03:01:52 +0000 Subject: Initial revision git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@18 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/__init__.py | 37 + docutils/parsers/rst/__init__.py | 68 + docutils/parsers/rst/directives/__init__.py | 88 + docutils/parsers/rst/directives/admonitions.py | 55 + docutils/parsers/rst/directives/components.py | 59 + docutils/parsers/rst/directives/html.py | 89 + docutils/parsers/rst/directives/images.py | 97 ++ docutils/parsers/rst/directives/misc.py | 39 + docutils/parsers/rst/languages/__init__.py | 23 + docutils/parsers/rst/languages/en.py | 38 + docutils/parsers/rst/states.py | 2115 ++++++++++++++++++++++++ docutils/parsers/rst/tableparser.py | 313 ++++ 12 files changed, 3021 insertions(+) create mode 100644 docutils/parsers/__init__.py create mode 100644 docutils/parsers/rst/__init__.py create mode 100644 docutils/parsers/rst/directives/__init__.py create mode 100644 docutils/parsers/rst/directives/admonitions.py create mode 100644 docutils/parsers/rst/directives/components.py create mode 100644 docutils/parsers/rst/directives/html.py create mode 100644 docutils/parsers/rst/directives/images.py create mode 100644 docutils/parsers/rst/directives/misc.py create mode 100644 docutils/parsers/rst/languages/__init__.py create mode 100644 docutils/parsers/rst/languages/en.py create mode 100644 docutils/parsers/rst/states.py create mode 100644 docutils/parsers/rst/tableparser.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/__init__.py b/docutils/parsers/__init__.py new file mode 100644 index 000000000..72e2e4e49 --- /dev/null +++ b/docutils/parsers/__init__.py @@ -0,0 +1,37 @@ +#! /usr/bin/env python + +""" +:Author: David Goodger +:Contact: goodger@users.sourceforge.net +:Revision: $Revision$ +:Date: $Date$ +:Copyright: This module has been placed in the public domain. +""" + +__docformat__ = 'reStructuredText' + + +class Parser: + + def parse(self, inputstring, docroot): + """Override to parse `inputstring` into document tree `docroot`.""" + raise NotImplementedError('subclass must override this method') + + def setup_parse(self, inputstring, docroot): + """Initial setup, used by `parse()`.""" + self.inputstring = inputstring + self.docroot = docroot + + +_parser_aliases = { + 'restructuredtext': 'rst', + 'rest': 'rst', + 'rtxt': 'rst',} + +def get_parser_class(parsername): + """Return the Parser class from the `parsername` module.""" + parsername = parsername.lower() + if _parser_aliases.has_key(parsername): + parsername = _parser_aliases[parsername] + module = __import__(parsername, globals(), locals()) + return module.Parser diff --git a/docutils/parsers/rst/__init__.py b/docutils/parsers/rst/__init__.py new file mode 100644 index 000000000..06589513b --- /dev/null +++ b/docutils/parsers/rst/__init__.py @@ -0,0 +1,68 @@ +#! /usr/bin/env python + +""" +:Author: David Goodger +:Contact: goodger@users.sourceforge.net +:Revision: $Revision$ +:Date: $Date$ +:Copyright: This module has been placed in the public domain. + +This is ``the docutils.parsers.restructuredtext`` package. It exports a single +class, `Parser`. + +Usage +===== + +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 + input:: + + input = sys.stdin.read() + +3. Create a new empty `docutils.nodes.document` tree:: + + docroot = docutils.utils.newdocument() + + See `docutils.utils.newdocument()` for parameter details. + +4. Run the parser, populating the document tree:: + + document = parser.parse(input, docroot) + +Parser Overview +=============== + +The reStructuredText parser is implemented as a state machine, examining its +input one line at a time. To understand how the parser works, please first +become familiar with the `docutils.statemachine` module, then see the +`states` module. +""" + +__docformat__ = 'reStructuredText' + + +import docutils.parsers +import docutils.statemachine +import states + + +class Parser(docutils.parsers.Parser): + + """The reStructuredText parser.""" + + def parse(self, inputstring, docroot): + """Parse `inputstring` and populate `docroot`, a document tree.""" + self.setup_parse(inputstring, docroot) + debug = docroot.reporter[''].debug + self.statemachine = states.RSTStateMachine( + stateclasses=states.stateclasses, initialstate='Body', + debug=debug) + inputlines = docutils.statemachine.string2lines( + inputstring, convertwhitespace=1) + self.statemachine.run(inputlines, docroot) diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py new file mode 100644 index 000000000..43b0c1dd3 --- /dev/null +++ b/docutils/parsers/rst/directives/__init__.py @@ -0,0 +1,88 @@ +#! /usr/bin/env python + +""" +:Author: David Goodger +:Contact: goodger@users.sourceforge.net +:Revision: $Revision$ +:Date: $Date$ +:Copyright: This module has been placed in the public domain. + +This package contains directive implementation modules. + +The interface for directive functions is as follows:: + + def directivefn(match, type, data, state, statemachine, attributes) + +Where: + +- ``match`` is a regular expression match object which matched the first line + of the directive. ``match.group(1)`` gives the directive name. +- ``type`` is the directive type or name. +- ``data`` contains the remainder of the first line of the directive after the + "::". +- ``state`` is the state which called the directive function. +- ``statemachine`` is the state machine which controls the state which called + the directive function. +- ``attributes`` is a dictionary of extra attributes which may be added to the + element the directive produces. Currently, only an "alt" attribute is passed + by substitution definitions (value: the substitution name), which may by + used by an embedded image directive. +""" + +__docformat__ = 'reStructuredText' + + +_directive_registry = { + 'attention': ('admonitions', 'attention'), + 'caution': ('admonitions', 'caution'), + 'danger': ('admonitions', 'danger'), + 'error': ('admonitions', 'error'), + 'important': ('admonitions', 'important'), + 'note': ('admonitions', 'note'), + 'tip': ('admonitions', 'tip'), + 'hint': ('admonitions', 'hint'), + 'warning': ('admonitions', 'warning'), + 'image': ('images', 'image'), + 'figure': ('images', 'figure'), + 'contents': ('components', 'contents'), + 'footnotes': ('components', 'footnotes'), + 'citations': ('components', 'citations'), + 'topic': ('components', 'topic'), + 'meta': ('html', 'meta'), + 'imagemap': ('html', 'imagemap'), + 'raw': ('misc', 'raw'), + 'restructuredtext-test-directive': ('misc', 'directive_test_function'),} +"""Mapping of directive name to (module name, function name). The directive +'name' is canonical & must be lowercase; language-dependent names are defined +in the language package.""" + +_modules = {} +"""Cache of imported directive modules.""" + +_directives = {} +"""Cache of imported directive functions.""" + +def directive(directivename, languagemodule): + """ + Locate and return a directive function from its language-dependent name. + """ + normname = directivename.lower() + if _directives.has_key(normname): + return _directives[normname] + try: + canonicalname = languagemodule.directives[normname] + modulename, functionname = _directive_registry[canonicalname] + except KeyError: + return None + if _modules.has_key(modulename): + module = _modules[modulename] + else: + try: + module = __import__(modulename, globals(), locals()) + except ImportError: + return None + try: + function = getattr(module, functionname) + except AttributeError: + return None + return function diff --git a/docutils/parsers/rst/directives/admonitions.py b/docutils/parsers/rst/directives/admonitions.py new file mode 100644 index 000000000..f594cd431 --- /dev/null +++ b/docutils/parsers/rst/directives/admonitions.py @@ -0,0 +1,55 @@ +#! /usr/bin/env python + +""" +:Author: David Goodger +:Contact: goodger@users.sourceforge.net +:Revision: $Revision$ +:Date: $Date$ +:Copyright: This module has been placed in the public domain. + +Admonition directives. +""" + +__docformat__ = 'reStructuredText' + + +from docutils.parsers.rst import states +from docutils import nodes + + +def admonition(nodeclass, match, typename, data, state, statemachine, + attributes): + indented, indent, lineoffset, blankfinish \ + = statemachine.getfirstknownindented(match.end()) + text = '\n'.join(indented) + admonitionnode = nodeclass(text) + if text: + state.nestedparse(indented, lineoffset, admonitionnode) + return [admonitionnode], blankfinish + +def attention(*args, **kwargs): + return admonition(nodes.attention, *args, **kwargs) + +def caution(*args, **kwargs): + return admonition(nodes.caution, *args, **kwargs) + +def danger(*args, **kwargs): + return admonition(nodes.danger, *args, **kwargs) + +def error(*args, **kwargs): + return admonition(nodes.error, *args, **kwargs) + +def important(*args, **kwargs): + return admonition(nodes.important, *args, **kwargs) + +def note(*args, **kwargs): + return admonition(nodes.note, *args, **kwargs) + +def tip(*args, **kwargs): + return admonition(nodes.tip, *args, **kwargs) + +def hint(*args, **kwargs): + return admonition(nodes.hint, *args, **kwargs) + +def warning(*args, **kwargs): + return admonition(nodes.warning, *args, **kwargs) diff --git a/docutils/parsers/rst/directives/components.py b/docutils/parsers/rst/directives/components.py new file mode 100644 index 000000000..8463f41b0 --- /dev/null +++ b/docutils/parsers/rst/directives/components.py @@ -0,0 +1,59 @@ +#! /usr/bin/env python + +""" +:Author: David Goodger +:Contact: goodger@users.sourceforge.net +:Revision: $Revision$ +:Date: $Date$ +:Copyright: This module has been placed in the public domain. + +Document component directives. +""" + +__docformat__ = 'reStructuredText' + + +from docutils import nodes +import docutils.transforms.components + + +contents_attribute_spec = {'depth': int, + 'local': (lambda x: x)} + +def contents(match, typename, data, state, statemachine, attributes): + lineno = statemachine.abslineno() + lineoffset = statemachine.lineoffset + datablock, indent, offset, blankfinish = \ + statemachine.getfirstknownindented(match.end(), uptoblank=1) + blocktext = '\n'.join(statemachine.inputlines[ + lineoffset : lineoffset + len(datablock) + 1]) + for i in range(len(datablock)): + if datablock[i][:1] == ':': + attlines = datablock[i:] + datablock = datablock[:i] + break + else: + attlines = [] + i = 0 + titletext = ' '.join([line.strip() for line in datablock]) + if titletext: + textnodes, messages = state.inline_text(titletext, lineno) + title = nodes.title(titletext, '', *textnodes) + else: + messages = [] + title = None + pending = nodes.pending(docutils.transforms.components.Contents, + 'last_reader', {'title': title}, blocktext) + if attlines: + success, data, blankfinish = state.parse_extension_attributes( + contents_attribute_spec, attlines, blankfinish) + if success: # data is a dict of attributes + pending.details.update(data) + else: # data is an error string + error = statemachine.memo.reporter.error( + 'Error in "%s" directive attributes at line %s:\n%s.' + % (match.group(1), lineno, data), '', + nodes.literal_block(blocktext, blocktext)) + return [error] + messages, blankfinish + statemachine.memo.document.note_pending(pending) + return [pending] + messages, blankfinish diff --git a/docutils/parsers/rst/directives/html.py b/docutils/parsers/rst/directives/html.py new file mode 100644 index 000000000..d971300e0 --- /dev/null +++ b/docutils/parsers/rst/directives/html.py @@ -0,0 +1,89 @@ +#! /usr/bin/env python + +""" +:Author: David Goodger +:Contact: goodger@users.sourceforge.net +:Revision: $Revision$ +:Date: $Date$ +:Copyright: This module has been placed in the public domain. + +Directives for typically HTML-specific constructs. +""" + +__docformat__ = 'reStructuredText' + + +from docutils import nodes, utils +from docutils.parsers.rst import states + + +def meta(match, typename, data, state, statemachine, attributes): + lineoffset = statemachine.lineoffset + block, indent, offset, blankfinish = \ + statemachine.getfirstknownindented(match.end(), uptoblank=1) + node = nodes.Element() + if block: + newlineoffset, blankfinish = state.nestedlistparse( + block, offset, node, initialstate='MetaBody', + blankfinish=blankfinish, statemachinekwargs=metaSMkwargs) + if (newlineoffset - offset) != len(block): # incomplete parse of block? + blocktext = '\n'.join(statemachine.inputlines[ + lineoffset : statemachine.lineoffset+1]) + msg = statemachine.memo.reporter.error( + 'Invalid meta directive at line %s.' + % statemachine.abslineno(), '', + nodes.literal_block(blocktext, blocktext)) + node += msg + else: + msg = statemachine.memo.reporter.error( + 'Empty meta directive at line %s.' % statemachine.abslineno()) + node += msg + return node.getchildren(), blankfinish + +def imagemap(match, typename, data, state, statemachine, attributes): + return [], 0 + + +class MetaBody(states.SpecializedBody): + + class meta(nodes.Special, nodes.PreBibliographic, nodes.Element): + """HTML-specific "meta" element.""" + pass + + def field_marker(self, match, context, nextstate): + """Meta element.""" + node, blankfinish = self.parsemeta(match) + self.statemachine.node += node + return [], nextstate, [] + + def parsemeta(self, match): + name, args = self.parse_field_marker(match) + indented, indent, lineoffset, blankfinish = \ + self.statemachine.getfirstknownindented(match.end()) + node = self.meta() + node['content'] = ' '.join(indented) + if not indented: + line = self.statemachine.line + msg = self.statemachine.memo.reporter.info( + 'No content for meta tag "%s".' % name, '', + nodes.literal_block(line, line)) + self.statemachine.node += msg + try: + attname, val = utils.extract_name_value(name)[0] + node[attname.lower()] = val + except utils.NameValueError: + node['name'] = name + for arg in args: + try: + attname, val = utils.extract_name_value(arg)[0] + node[attname.lower()] = val + except utils.NameValueError, detail: + line = self.statemachine.line + msg = self.statemachine.memo.reporter.error( + 'Error parsing meta tag attribute "%s": %s' + % (arg, detail), '', nodes.literal_block(line, line)) + self.statemachine.node += msg + return node, blankfinish + + +metaSMkwargs = {'stateclasses': (MetaBody,)} diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py new file mode 100644 index 000000000..7a719333b --- /dev/null +++ b/docutils/parsers/rst/directives/images.py @@ -0,0 +1,97 @@ +#! /usr/bin/env python + +""" +:Author: David Goodger +:Contact: goodger@users.sourceforge.net +:Revision: $Revision$ +:Date: $Date$ +:Copyright: This module has been placed in the public domain. + +Directives for figures and simple images. +""" + +__docformat__ = 'reStructuredText' + + +import sys +from docutils.parsers.rst import states +from docutils import nodes, utils + +def unchanged(arg): + return arg # unchanged! + +image_attribute_spec = {'alt': unchanged, + 'height': int, + 'width': int, + 'scale': int} + +def image(match, typename, data, state, statemachine, attributes): + lineno = statemachine.abslineno() + lineoffset = statemachine.lineoffset + datablock, indent, offset, blankfinish = \ + statemachine.getfirstknownindented(match.end(), uptoblank=1) + blocktext = '\n'.join(statemachine.inputlines[ + lineoffset : lineoffset + len(datablock) + 1]) + for i in range(len(datablock)): + if datablock[i][:1] == ':': + attlines = datablock[i:] + datablock = datablock[:i] + break + else: + attlines = [] + if not datablock: + error = statemachine.memo.reporter.error( + 'Missing image URI argument at line %s.' % lineno, '', + nodes.literal_block(blocktext, blocktext)) + return [error], blankfinish + attoffset = lineoffset + i + reference = ''.join([line.strip() for line in datablock]) + if reference.find(' ') != -1: + error = statemachine.memo.reporter.error( + 'Image URI at line %s contains whitespace.' % lineno, '', + nodes.literal_block(blocktext, blocktext)) + return [error], blankfinish + if attlines: + success, data, blankfinish = state.parse_extension_attributes( + image_attribute_spec, attlines, blankfinish) + if success: # data is a dict of attributes + attributes.update(data) + else: # data is an error string + error = statemachine.memo.reporter.error( + 'Error in "%s" directive attributes at line %s:\n%s.' + % (match.group(1), lineno, data), '', + nodes.literal_block(blocktext, blocktext)) + return [error], blankfinish + attributes['uri'] = reference + imagenode = nodes.image(blocktext, **attributes) + return [imagenode], blankfinish + +def figure(match, typename, data, state, statemachine, attributes): + lineoffset = statemachine.lineoffset + (imagenode,), blankfinish = image(match, typename, data, state, + statemachine, attributes) + indented, indent, offset, blankfinish \ + = statemachine.getfirstknownindented(sys.maxint) + blocktext = '\n'.join(statemachine.inputlines[lineoffset: + statemachine.lineoffset+1]) + if isinstance(imagenode, nodes.system_message): + if indented: + imagenode[-1] = nodes.literal_block(blocktext, blocktext) + return [imagenode], blankfinish + figurenode = nodes.figure('', imagenode) + if indented: + node = nodes.Element() # anonymous container for parsing + state.nestedparse(indented, lineoffset, node) + firstnode = node[0] + if isinstance(firstnode, nodes.paragraph): + caption = nodes.caption(firstnode.rawsource, '', + *firstnode.children) + figurenode += caption + elif not (isinstance(firstnode, nodes.comment) and len(firstnode) == 0): + error = statemachine.memo.reporter.error( + 'Figure caption must be a paragraph or empty comment.', '', + nodes.literal_block(blocktext, blocktext)) + return [figurenode, error], blankfinish + if len(node) > 1: + figurenode += nodes.legend('', *node[1:]) + return [figurenode], blankfinish diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py new file mode 100644 index 000000000..f8a9d5217 --- /dev/null +++ b/docutils/parsers/rst/directives/misc.py @@ -0,0 +1,39 @@ +#! /usr/bin/env python + +""" +:Author: David Goodger +:Contact: goodger@users.sourceforge.net +:Revision: $Revision$ +:Date: $Date$ +:Copyright: This module has been placed in the public domain. + +Miscellaneous directives. +""" + +__docformat__ = 'reStructuredText' + + +from docutils import nodes + + +def raw(match, typename, data, state, statemachine, attributes): + return [], 1 + +def directive_test_function(match, typename, data, state, statemachine, + attributes): + try: + statemachine.nextline() + indented, indent, offset, blankfinish = statemachine.getindented() + text = '\n'.join(indented) + except IndexError: + text = '' + blankfinish = 1 + if text: + info = statemachine.memo.reporter.info( + 'Directive processed. Type="%s", data="%s", directive block:' + % (typename, data), '', nodes.literal_block(text, text)) + else: + info = statemachine.memo.reporter.info( + 'Directive processed. Type="%s", data="%s", directive block: None' + % (typename, data)) + return [info], blankfinish diff --git a/docutils/parsers/rst/languages/__init__.py b/docutils/parsers/rst/languages/__init__.py new file mode 100644 index 000000000..ee36d1148 --- /dev/null +++ b/docutils/parsers/rst/languages/__init__.py @@ -0,0 +1,23 @@ +#! /usr/bin/env python + +""" +:Author: David Goodger +:Contact: goodger@users.sourceforge.net +:Revision: $Revision$ +:Date: $Date$ +:Copyright: This module has been placed in the public domain. + +This package contains modules for language-dependent features of +reStructuredText. +""" + +__docformat__ = 'reStructuredText' + +_languages = {} + +def getlanguage(languagecode): + if _languages.has_key(languagecode): + return _languages[languagecode] + module = __import__(languagecode, globals(), locals()) + _languages[languagecode] = module + return module diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py new file mode 100644 index 000000000..2b1c52649 --- /dev/null +++ b/docutils/parsers/rst/languages/en.py @@ -0,0 +1,38 @@ +#! /usr/bin/env python + +""" +:Author: David Goodger +:Contact: goodger@users.sourceforge.net +:Revision: $Revision$ +:Date: $Date$ +:Copyright: This module has been placed in the public domain. + +English-language mappings for language-dependent features of +reStructuredText. +""" + +__docformat__ = 'reStructuredText' + + +directives = { + 'attention': 'attention', + 'caution': 'caution', + 'danger': 'danger', + 'error': 'error', + 'hint': 'hint', + 'important': 'important', + 'note': 'note', + 'tip': 'tip', + 'warning': 'warning', + 'image': 'image', + 'figure': 'figure', + 'contents': 'contents', + 'footnotes': 'footnotes', + 'citations': 'citations', + 'topic': 'topic', + 'meta': 'meta', + 'imagemap': 'imagemap', + 'raw': 'raw', + 'restructuredtext-test-directive': 'restructuredtext-test-directive'} +"""English name to registered (in directives/__init__.py) directive name +mapping.""" diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py new file mode 100644 index 000000000..b2dbf9b3e --- /dev/null +++ b/docutils/parsers/rst/states.py @@ -0,0 +1,2115 @@ +""" +:Author: David Goodger +:Contact: goodger@users.sourceforge.net +:Revision: $Revision$ +:Date: $Date$ +:Copyright: This module has been placed in the public domain. + +This is the ``docutils.parsers.restructuredtext.states`` module, the core of +the reStructuredText parser. It defines the following: + +:Classes: + - `RSTStateMachine`: reStructuredText parser's entry point. + - `NestedStateMachine`: recursive StateMachine. + - `RSTState`: reStructuredText State superclass. + - `Body`: Generic classifier of the first line of a block. + - `BulletList`: Second and subsequent bullet_list list_items + - `DefinitionList`: Second and subsequent definition_list_items. + - `EnumeratedList`: Second and subsequent enumerated_list list_items. + - `FieldList`: Second and subsequent fields. + - `OptionList`: Second and subsequent option_list_items. + - `Explicit`: Second and subsequent explicit markup constructs. + - `SubstitutionDef`: For embedded directives in substitution definitions. + - `Text`: Classifier of second line of a text block. + - `Definition`: Second line of potential definition_list_item. + - `Line`: Second line of overlined section title or transition marker. + - `Stuff`: An auxilliary collection class. + +:Exception classes: + - `MarkupError` + - `ParserError` + - `TransformationError` + +:Functions: + - `escape2null()`: Return a string, escape-backslashes converted to nulls. + - `unescape()`: Return a string, nulls removed or restored to backslashes. + - `normname()`: Return a case- and whitespace-normalized name. + +:Attributes: + - `stateclasses`: set of State classes used with `RSTStateMachine`. + +Parser Overview +=============== + +The reStructuredText parser is implemented as a state machine, examining its +input one line at a time. To understand how the parser works, please first +become familiar with the `docutils.statemachine` module. In the description +below, references are made to classes defined in this module; please see the +individual classes for details. + +Parsing proceeds as follows: + +1. The state machine examines each line of input, checking each of the + transition patterns of the state `Body`, in order, looking for a match. The + implicit transitions (blank lines and indentation) are checked before any + others. The 'text' transition is a catch-all (matches anything). + +2. The method associated with the matched transition pattern is called. + + A. Some transition methods are self-contained, appending elements to the + document tree ('doctest' parses a doctest block). The parser's current + line index is advanced to the end of the element, and parsing continues + with step 1. + + B. Others trigger the creation of a nested state machine, whose job is to + parse a compound construct ('indent' does a block quote, 'bullet' does a + bullet list, 'overline' does a section [first checking for a valid + section header]). + + - In the case of lists and explicit markup, a new state machine is + created and run to parse the first item. + + - A new state machine is created and its initial state is set to the + appropriate specialized state (`BulletList` in the case of the + 'bullet' transition). This state machine is run to parse the compound + element (or series of explicit markup elements), and returns as soon + as a non-member element is encountered. For example, the `BulletList` + state machine aborts as soon as it encounters an element which is not + a list item of that bullet list. The optional omission of + inter-element blank lines is handled by the nested state machine. + + - The current line index is advanced to the end of the elements parsed, + and parsing continues with step 1. + + C. The result of the 'text' transition depends on the next line of text. + The current state is changed to `Text`, under which the second line is + examined. If the second line is: + + - Indented: The element is a definition list item, and parsing proceeds + similarly to step 2.B, using the `DefinitionList` state. + + - A line of uniform punctuation characters: The element is a section + header; again, parsing proceeds as in step 2.B, and `Body` is still + used. + + - Anything else: The element is a paragraph, which is examined for + inline markup and appended to the parent element. Processing continues + with step 1. +""" + +__docformat__ = 'reStructuredText' + + +import sys, re, string +from docutils import nodes, statemachine, utils, roman, urischemes +from docutils.statemachine import StateMachineWS, StateWS +from docutils.utils import normname +import directives, languages +from tableparser import TableParser, TableMarkupError + + +class MarkupError(Exception): pass +class ParserError(Exception): pass + + +class Stuff: + + """Stores a bunch of stuff for dotted-attribute access.""" + + def __init__(self, **keywordargs): + self.__dict__.update(keywordargs) + + +class RSTStateMachine(StateMachineWS): + + """ + reStructuredText's master StateMachine. + + The entry point to reStructuredText parsing is the `run()` method. + """ + + def run(self, inputlines, docroot, inputoffset=0, matchtitles=1): + """ + Parse `inputlines` and return a `docutils.nodes.document` instance. + + Extend `StateMachineWS.run()`: set up parse-global data, run the + StateMachine, and return the resulting + document. + """ + self.language = languages.getlanguage(docroot.languagecode) + self.matchtitles = matchtitles + self.memo = Stuff(document=docroot, + reporter=docroot.reporter, + language=self.language, + titlestyles=[], + sectionlevel=0) + self.node = docroot + results = StateMachineWS.run(self, inputlines, inputoffset) + assert results == [], 'RSTStateMachine.run() results should be empty.' + self.node = self.memo = None # remove unneeded references + + +class NestedStateMachine(StateMachineWS): + + """ + StateMachine run from within other StateMachine runs, to parse nested + document structures. + """ + + def run(self, inputlines, inputoffset, memo, node, matchtitles=1): + """ + Parse `inputlines` and populate a `docutils.nodes.document` instance. + + Extend `StateMachineWS.run()`: set up document-wide data. + """ + self.matchtitles = matchtitles + self.memo = memo + self.node = node + results = StateMachineWS.run(self, inputlines, inputoffset) + assert results == [], 'NestedStateMachine.run() results should be empty' + return results + + +class RSTState(StateWS): + + """ + reStructuredText State superclass. + + Contains methods used by all State subclasses. + """ + + nestedSM = NestedStateMachine + + def __init__(self, statemachine, debug=0): + self.nestedSMkwargs = {'stateclasses': stateclasses, + 'initialstate': 'Body'} + StateWS.__init__(self, statemachine, debug) + + def gotoline(self, abslineoffset): + """Jump to input line `abslineoffset`, ignoring jumps past the end.""" + try: + self.statemachine.gotoline(abslineoffset) + except IndexError: + pass + + def bof(self, context): + """Called at beginning of file.""" + return [], [] + + def nestedparse(self, block, inputoffset, node, matchtitles=0, + statemachineclass=None, statemachinekwargs=None): + """ + Create a new StateMachine rooted at `node` and run it over the input + `block`. + """ + if statemachineclass is None: + statemachineclass = self.nestedSM + if statemachinekwargs is None: + statemachinekwargs = self.nestedSMkwargs + statemachine = statemachineclass(debug=self.debug, **statemachinekwargs) + statemachine.run(block, inputoffset, memo=self.statemachine.memo, + node=node, matchtitles=matchtitles) + statemachine.unlink() + return statemachine.abslineoffset() + + def nestedlistparse(self, block, inputoffset, node, initialstate, + blankfinish, blankfinishstate=None, extrasettings={}, + matchtitles=0, statemachineclass=None, + statemachinekwargs=None): + """ + Create a new StateMachine rooted at `node` and run it over the input + `block`. Also keep track of optional intermdediate blank lines and the + required final one. + """ + if statemachineclass is None: + statemachineclass = self.nestedSM + if statemachinekwargs is None: + statemachinekwargs = self.nestedSMkwargs.copy() + statemachinekwargs['initialstate'] = initialstate + statemachine = statemachineclass(debug=self.debug, **statemachinekwargs) + if blankfinishstate is None: + blankfinishstate = initialstate + statemachine.states[blankfinishstate].blankfinish = blankfinish + for key, value in extrasettings.items(): + setattr(statemachine.states[initialstate], key, value) + statemachine.run(block, inputoffset, memo=self.statemachine.memo, + node=node, matchtitles=matchtitles) + blankfinish = statemachine.states[blankfinishstate].blankfinish + statemachine.unlink() + return statemachine.abslineoffset(), blankfinish + + def section(self, title, source, style, lineno): + """ + When a new section is reached that isn't a subsection of the current + section, back up the line count (use previousline(-x)), then raise + EOFError. The current StateMachine will finish, then the calling + StateMachine can re-examine the title. This will work its way back up + the calling chain until the correct section level isreached. + + Alternative: Evaluate the title, store the title info & level, and + back up the chain until that level is reached. Store in memo? Or + return in results? + """ + if self.checksubsection(source, style, lineno): + self.newsubsection(title, lineno) + + def checksubsection(self, source, style, lineno): + """ + Check for a valid subsection header. Return 1 (true) or None (false). + + :Exception: `EOFError` when a sibling or supersection encountered. + """ + memo = self.statemachine.memo + titlestyles = memo.titlestyles + mylevel = memo.sectionlevel + try: # check for existing title style + level = titlestyles.index(style) + 1 + except ValueError: # new title style + if len(titlestyles) == memo.sectionlevel: # new subsection + titlestyles.append(style) + return 1 + else: # not at lowest level + self.statemachine.node += self.titleinconsistent(source, lineno) + return None + if level <= mylevel: # sibling or supersection + memo.sectionlevel = level # bubble up to parent section + # back up 2 lines for underline title, 3 for overline title + self.statemachine.previousline(len(style) + 1) + raise EOFError # let parent section re-evaluate + if level == mylevel + 1: # immediate subsection + return 1 + else: # invalid subsection + self.statemachine.node += self.titleinconsistent(source, lineno) + return None + + def titleinconsistent(self, sourcetext, lineno): + literalblock = nodes.literal_block('', sourcetext) + error = self.statemachine.memo.reporter.severe( + 'Title level inconsistent at line %s:' % lineno, '', literalblock) + return error + + def newsubsection(self, title, lineno): + """Append new subsection to document tree. On return, check level.""" + memo = self.statemachine.memo + mylevel = memo.sectionlevel + memo.sectionlevel += 1 + sectionnode = nodes.section() + self.statemachine.node += sectionnode + textnodes, messages = self.inline_text(title, lineno) + titlenode = nodes.title(title, '', *textnodes) + name = normname(titlenode.astext()) + sectionnode['name'] = name + sectionnode += titlenode + sectionnode += messages + memo.document.note_implicit_target(sectionnode, sectionnode) + offset = self.statemachine.lineoffset + 1 + absoffset = self.statemachine.abslineoffset() + 1 + newabsoffset = self.nestedparse( + self.statemachine.inputlines[offset:], inputoffset=absoffset, + node=sectionnode, matchtitles=1) + self.gotoline(newabsoffset) + if memo.sectionlevel <= mylevel: # can't handle next section? + raise EOFError # bubble up to supersection + # reset sectionlevel; next pass will detect it properly + memo.sectionlevel = mylevel + + def paragraph(self, lines, lineno): + """ + Return a list (paragraph & messages) and a boolean: literal_block next? + """ + data = '\n'.join(lines).rstrip() + if data[-2:] == '::': + if len(data) == 2: + return [], 1 + elif data[-3] == ' ': + text = data[:-3].rstrip() + else: + text = data[:-1] + literalnext = 1 + else: + text = data + literalnext = 0 + textnodes, messages = self.inline_text(text, lineno) + p = nodes.paragraph(data, '', *textnodes) + return [p] + messages, literalnext + + inline = Stuff() + """Patterns and constants used for inline markup recognition.""" + + inline.openers = '\'"([{<' + inline.closers = '\'")]}>' + inline.start_string_prefix = (r'(?:(?<=^)|(?<=[ \n%s]))' + % re.escape(inline.openers)) + inline.end_string_suffix = (r'(?:(?=$)|(?=[- \n.,:;!?%s]))' + % re.escape(inline.closers)) + inline.non_whitespace_before = r'(? 0: + textnodes.append(nodes.Text(unescape( + remainder[:match.start(whole)]))) + if match.group(email): + addscheme = 'mailto:' + else: + addscheme = '' + text = match.group(whole) + unescaped = unescape(text, 0) + textnodes.append( + nodes.reference(unescape(text, 1), unescaped, + refuri=addscheme + unescaped)) + remainder = remainder[match.end(whole):] + start = 0 + else: # not a valid scheme + start = match.end(whole) + else: + if remainder: + textnodes.append(nodes.Text(unescape(remainder))) + break + return textnodes + + inline.dispatch = {'*': emphasis, + '**': strong, + '`': interpreted_or_phrase_ref, + '``': literal, + '_`': inline_target, + ']_': footnote_reference, + '|': substitution_reference, + '_': reference, + '__': anonymous_reference} + + def inline_text(self, text, lineno): + """ + Return 2 lists: nodes (text and inline elements), and system_messages. + + Using a `pattern` matching start-strings (for emphasis, strong, + interpreted, phrase reference, literal, substitution reference, and + inline target) or complete constructs (simple reference, footnote + reference) we search for a candidate. When one is found, we check for + validity (e.g., not a quoted '*' character). If valid, search for the + corresponding end string if applicable, and check for validity. If not + found or invalid, generate a warning and ignore the start-string. + Standalone hyperlinks are found last. + """ + pattern = self.inline.patterns.initial + dispatch = self.inline.dispatch + start = self.inline.groups.initial.start - 1 + backquote = self.inline.groups.initial.backquote - 1 + refend = self.inline.groups.initial.refend - 1 + fnend = self.inline.groups.initial.fnend - 1 + remaining = escape2null(text) + processed = [] + unprocessed = [] + messages = [] + while remaining: + match = pattern.search(remaining) + if match: + groups = match.groups() + before, inlines, remaining, sysmessages = \ + dispatch[groups[start] or groups[backquote] + or groups[refend] + or groups[fnend]](self, match, lineno) + unprocessed.append(before) + messages += sysmessages + if inlines: + processed += self.standalone_uri(''.join(unprocessed), + lineno) + processed += inlines + unprocessed = [] + else: + break + remaining = ''.join(unprocessed) + remaining + if remaining: + processed += self.standalone_uri(remaining, lineno) + return processed, messages + + def unindentwarning(self): + return self.statemachine.memo.reporter.warning( + ('Unindent without blank line at line %s.' + % (self.statemachine.abslineno() + 1))) + + +class Body(RSTState): + + """ + Generic classifier of the first line of a block. + """ + + enum = Stuff() + """Enumerated list parsing information.""" + + enum.formatinfo = { + 'parens': Stuff(prefix='(', suffix=')', start=1, end=-1), + 'rparen': Stuff(prefix='', suffix=')', start=0, end=-1), + 'period': Stuff(prefix='', suffix='.', start=0, end=-1)} + enum.formats = enum.formatinfo.keys() + enum.sequences = ['arabic', 'loweralpha', 'upperalpha', + 'lowerroman', 'upperroman'] # ORDERED! + enum.sequencepats = {'arabic': '[0-9]+', + 'loweralpha': '[a-z]', + 'upperalpha': '[A-Z]', + 'lowerroman': '[ivxlcdm]+', + 'upperroman': '[IVXLCDM]+',} + enum.converters = {'arabic': int, + 'loweralpha': + lambda s, zero=(ord('a')-1): ord(s) - zero, + 'upperalpha': + lambda s, zero=(ord('A')-1): ord(s) - zero, + 'lowerroman': + lambda s: roman.fromRoman(s.upper()), + 'upperroman': roman.fromRoman} + + enum.sequenceregexps = {} + for sequence in enum.sequences: + enum.sequenceregexps[sequence] = re.compile(enum.sequencepats[sequence] + + '$') + + tabletoppat = re.compile(r'\+-[-+]+-\+ *$') + """Matches the top (& bottom) of a table).""" + + tableparser = TableParser() + + pats = {} + """Fragments of patterns used by transitions.""" + + pats['nonalphanum7bit'] = '[!-/:-@[-`{-~]' + pats['alpha'] = '[a-zA-Z]' + pats['alphanum'] = '[a-zA-Z0-9]' + pats['alphanumplus'] = '[a-zA-Z0-9_-]' + pats['enum'] = ('(%(arabic)s|%(loweralpha)s|%(upperalpha)s|%(lowerroman)s' + '|%(upperroman)s)' % enum.sequencepats) + pats['optname'] = '%(alphanum)s%(alphanumplus)s*' % pats + pats['optarg'] = '%(alpha)s%(alphanumplus)s*' % pats + pats['option'] = r'(--?|\+|/)%(optname)s([ =]%(optarg)s)?' % pats + + for format in enum.formats: + pats[format] = '(?P<%s>%s%s%s)' % ( + format, re.escape(enum.formatinfo[format].prefix), + pats['enum'], re.escape(enum.formatinfo[format].suffix)) + + patterns = {'bullet': r'[-+*]( +|$)', + 'enumerator': r'(%(parens)s|%(rparen)s|%(period)s)( +|$)' + % pats, + 'field_marker': r':[^: ]([^:]*[^: ])?:( +|$)', + 'option_marker': r'%(option)s(, %(option)s)*( +| ?$)' % pats, + 'doctest': r'>>>( +|$)', + 'tabletop': tabletoppat, + 'explicit_markup': r'\.\.( +|$)', + 'anonymous': r'__( +|$)', + 'line': r'(%(nonalphanum7bit)s)\1\1\1+ *$' % pats, + #'rfc822': r'[!-9;-~]+:( +|$)', + 'text': r''} + initialtransitions = ['bullet', + 'enumerator', + 'field_marker', + 'option_marker', + 'doctest', + 'tabletop', + 'explicit_markup', + 'anonymous', + 'line', + 'text'] + + def indent(self, match, context, nextstate): + """Block quote.""" + indented, indent, lineoffset, blankfinish = \ + self.statemachine.getindented() + blockquote = self.block_quote(indented, lineoffset) + self.statemachine.node += blockquote + if not blankfinish: + self.statemachine.node += self.unindentwarning() + return context, nextstate, [] + + def block_quote(self, indented, lineoffset): + blockquote = nodes.block_quote() + self.nestedparse(indented, lineoffset, blockquote) + return blockquote + + def bullet(self, match, context, nextstate): + """Bullet list item.""" + bulletlist = nodes.bullet_list() + self.statemachine.node += bulletlist + bulletlist['bullet'] = match.string[0] + i, blankfinish = self.list_item(match.end()) + bulletlist += i + offset = self.statemachine.lineoffset + 1 # next line + newlineoffset, blankfinish = self.nestedlistparse( + self.statemachine.inputlines[offset:], + inputoffset=self.statemachine.abslineoffset() + 1, + node=bulletlist, initialstate='BulletList', + blankfinish=blankfinish) + if not blankfinish: + self.statemachine.node += self.unindentwarning() + self.gotoline(newlineoffset) + return [], nextstate, [] + + def list_item(self, indent): + indented, lineoffset, blankfinish = \ + self.statemachine.getknownindented(indent) + listitem = nodes.list_item('\n'.join(indented)) + if indented: + self.nestedparse(indented, inputoffset=lineoffset, node=listitem) + return listitem, blankfinish + + def enumerator(self, match, context, nextstate): + """Enumerated List Item""" + format, sequence, text, ordinal = self.parse_enumerator(match) + if ordinal is None: + msg = self.statemachine.memo.reporter.error( + ('Enumerated list start value invalid at line %s: ' + '%r (sequence %r)' % (self.statemachine.abslineno(), + text, sequence))) + self.statemachine.node += msg + indented, lineoffset, blankfinish = \ + self.statemachine.getknownindented(match.end()) + bq = self.block_quote(indented, lineoffset) + self.statemachine.node += bq + if not blankfinish: + self.statemachine.node += self.unindentwarning() + return [], nextstate, [] + if ordinal != 1: + msg = self.statemachine.memo.reporter.info( + ('Enumerated list start value not ordinal-1 at line %s: ' + '%r (ordinal %s)' % (self.statemachine.abslineno(), + text, ordinal))) + self.statemachine.node += msg + enumlist = nodes.enumerated_list() + self.statemachine.node += enumlist + enumlist['enumtype'] = sequence + if ordinal != 1: + enumlist['start'] = ordinal + enumlist['prefix'] = self.enum.formatinfo[format].prefix + enumlist['suffix'] = self.enum.formatinfo[format].suffix + listitem, blankfinish = self.list_item(match.end()) + enumlist += listitem + offset = self.statemachine.lineoffset + 1 # next line + newlineoffset, blankfinish = self.nestedlistparse( + self.statemachine.inputlines[offset:], + inputoffset=self.statemachine.abslineoffset() + 1, + node=enumlist, initialstate='EnumeratedList', + blankfinish=blankfinish, + extrasettings={'lastordinal': ordinal, 'format': format}) + if not blankfinish: + self.statemachine.node += self.unindentwarning() + self.gotoline(newlineoffset) + return [], nextstate, [] + + def parse_enumerator(self, match, expectedsequence=None): + """ + Analyze an enumerator and return the results. + + :Return: + - the enumerator format ('period', 'parens', or 'rparen'), + - the sequence used ('arabic', 'loweralpha', 'upperroman', etc.), + - the text of the enumerator, stripped of formatting, and + - the ordinal value of the enumerator ('a' -> 1, 'ii' -> 2, etc.; + ``None`` is returned for invalid enumerator text). + + The enumerator format has already been determined by the regular + expression match. If `expectedsequence` is given, that sequence is + tried first. If not, we check for Roman numeral 1. This way, + single-character Roman numerals (which are also alphabetical) can be + matched. If no sequence has been matched, all sequences are checked in + order. + """ + groupdict = match.groupdict() + sequence = '' + for format in self.enum.formats: + if groupdict[format]: # was this the format matched? + break # yes; keep `format` + else: # shouldn't happen + raise ParserError, 'enumerator format not matched' + text = groupdict[format][self.enum.formatinfo[format].start + :self.enum.formatinfo[format].end] + if expectedsequence: + try: + if self.enum.sequenceregexps[expectedsequence].match(text): + sequence = expectedsequence + except KeyError: # shouldn't happen + raise ParserError, 'unknown sequence: %s' % sequence + else: + if text == 'i': + sequence = 'lowerroman' + elif text == 'I': + sequence = 'upperroman' + if not sequence: + for sequence in self.enum.sequences: + if self.enum.sequenceregexps[sequence].match(text): + break + else: # shouldn't happen + raise ParserError, 'enumerator sequence not matched' + try: + ordinal = self.enum.converters[sequence](text) + except roman.InvalidRomanNumeralError: + ordinal = None + return format, sequence, text, ordinal + + def field_marker(self, match, context, nextstate): + """Field list item.""" + fieldlist = nodes.field_list() + self.statemachine.node += fieldlist + field, blankfinish = self.field(match) + fieldlist += field + offset = self.statemachine.lineoffset + 1 # next line + newlineoffset, blankfinish = self.nestedlistparse( + self.statemachine.inputlines[offset:], + inputoffset=self.statemachine.abslineoffset() + 1, + node=fieldlist, initialstate='FieldList', + blankfinish=blankfinish) + if not blankfinish: + self.statemachine.node += self.unindentwarning() + self.gotoline(newlineoffset) + return [], nextstate, [] + + def field(self, match): + name, args = self.parse_field_marker(match) + indented, indent, lineoffset, blankfinish = \ + self.statemachine.getfirstknownindented(match.end()) + fieldnode = nodes.field() + fieldnode += nodes.field_name(name, name) + for arg in args: + fieldnode += nodes.field_argument(arg, arg) + fieldbody = nodes.field_body('\n'.join(indented)) + fieldnode += fieldbody + if indented: + self.nestedparse(indented, inputoffset=lineoffset, node=fieldbody) + return fieldnode, blankfinish + + def parse_field_marker(self, match): + """Extract & return name & argument list from a field marker match.""" + field = match.string[1:] # strip off leading ':' + field = field[:field.find(':')] # strip off trailing ':' etc. + tokens = field.split() + return tokens[0], tokens[1:] # first == name, others == args + + def option_marker(self, match, context, nextstate): + """Option list item.""" + optionlist = nodes.option_list() + try: + listitem, blankfinish = self.option_list_item(match) + except MarkupError, detail: # shouldn't happen; won't match pattern + msg = self.statemachine.memo.reporter.error( + ('Invalid option list marker at line %s: %s' + % (self.statemachine.abslineno(), detail))) + self.statemachine.node += msg + indented, indent, lineoffset, blankfinish = \ + self.statemachine.getfirstknownindented(match.end()) + blockquote = self.block_quote(indented, lineoffset) + self.statemachine.node += blockquote + if not blankfinish: + self.statemachine.node += self.unindentwarning() + return [], nextstate, [] + self.statemachine.node += optionlist + optionlist += listitem + offset = self.statemachine.lineoffset + 1 # next line + newlineoffset, blankfinish = self.nestedlistparse( + self.statemachine.inputlines[offset:], + inputoffset=self.statemachine.abslineoffset() + 1, + node=optionlist, initialstate='OptionList', + blankfinish=blankfinish) + if not blankfinish: + self.statemachine.node += self.unindentwarning() + self.gotoline(newlineoffset) + return [], nextstate, [] + + def option_list_item(self, match): + options = self.parse_option_marker(match) + indented, indent, lineoffset, blankfinish = \ + self.statemachine.getfirstknownindented(match.end()) + if not indented: # not an option list item + raise statemachine.TransitionCorrection('text') + option_group = nodes.option_group('', *options) + description = nodes.description('\n'.join(indented)) + option_list_item = nodes.option_list_item('', option_group, description) + if indented: + self.nestedparse(indented, inputoffset=lineoffset, node=description) + return option_list_item, blankfinish + + def parse_option_marker(self, match): + """ + Return a list of `node.option` and `node.option_argument` objects, + parsed from an option marker match. + + :Exception: `MarkupError` for invalid option markers. + """ + optlist = [] + optionstrings = match.group().rstrip().split(', ') + for optionstring in optionstrings: + tokens = optionstring.split() + delimiter = ' ' + firstopt = tokens[0].split('=') + if len(firstopt) > 1: + tokens[:1] = firstopt + delimiter = '=' + if 0 < len(tokens) <= 2: + option = nodes.option(optionstring) + option += nodes.option_string(tokens[0], tokens[0]) + if len(tokens) > 1: + option += nodes.option_argument(tokens[1], tokens[1], + delimiter=delimiter) + optlist.append(option) + else: + raise MarkupError('wrong numer of option tokens (=%s), ' + 'should be 1 or 2: %r' % (len(tokens), + optionstring)) + return optlist + + def doctest(self, match, context, nextstate): + data = '\n'.join(self.statemachine.gettextblock()) + self.statemachine.node += nodes.doctest_block(data, data) + return [], nextstate, [] + + def tabletop(self, match, context, nextstate): + """Top border of a table.""" + nodelist, blankfinish = self.table() + self.statemachine.node += nodelist + if not blankfinish: + msg = self.statemachine.memo.reporter.warning( + 'Blank line required after table at line %s.' + % (self.statemachine.abslineno() + 1)) + self.statemachine.node += msg + return [], nextstate, [] + + def table(self): + """Parse a table.""" + block, messages, blankfinish = self.isolatetable() + if block: + try: + tabledata = self.tableparser.parse(block) + tableline = self.statemachine.abslineno() - len(block) + 1 + table = self.buildtable(tabledata, tableline) + nodelist = [table] + messages + except TableMarkupError, detail: + nodelist = self.malformedtable(block, str(detail)) + messages + else: + nodelist = messages + return nodelist, blankfinish + + def isolatetable(self): + messages = [] + blankfinish = 1 + try: + block = self.statemachine.getunindented() + except statemachine.UnexpectedIndentationError, instance: + block, lineno = instance.args + messages.append(self.statemachine.memo.reporter.error( + 'Unexpected indentation at line %s.' % lineno)) + blankfinish = 0 + width = len(block[0].strip()) + for i in range(len(block)): + block[i] = block[i].strip() + if block[i][0] not in '+|': # check left edge + blankfinish = 0 + self.statemachine.previousline(len(block) - i) + del block[i:] + break + if not self.tabletoppat.match(block[-1]): # find bottom + blankfinish = 0 + # from second-last to third line of table: + for i in range(len(block) - 2, 1, -1): + if self.tabletoppat.match(block[i]): + self.statemachine.previousline(len(block) - i + 1) + del block[i+1:] + break + else: + messages.extend(self.malformedtable(block)) + return [], messages, blankfinish + for i in range(len(block)): # check right edge + if len(block[i]) != width or block[i][-1] not in '+|': + messages.extend(self.malformedtable(block)) + return [], messages, blankfinish + return block, messages, blankfinish + + def malformedtable(self, block, detail=''): + data = '\n'.join(block) + message = 'Malformed table at line %s; formatting as a ' \ + 'literal block.' % (self.statemachine.abslineno() + - len(block) + 1) + if detail: + message += '\n' + detail + nodelist = [self.statemachine.memo.reporter.error(message), + nodes.literal_block(data, data)] + return nodelist + + def buildtable(self, tabledata, tableline): + colspecs, headrows, bodyrows = tabledata + table = nodes.table() + tgroup = nodes.tgroup(cols=len(colspecs)) + table += tgroup + for colspec in colspecs: + tgroup += nodes.colspec(colwidth=colspec) + if headrows: + thead = nodes.thead() + tgroup += thead + for row in headrows: + thead += self.buildtablerow(row, tableline) + tbody = nodes.tbody() + tgroup += tbody + for row in bodyrows: + tbody += self.buildtablerow(row, tableline) + return table + + def buildtablerow(self, rowdata, tableline): + row = nodes.row() + for cell in rowdata: + if cell is None: + continue + morerows, morecols, offset, cellblock = cell + attributes = {} + if morerows: + attributes['morerows'] = morerows + if morecols: + attributes['morecols'] = morecols + entry = nodes.entry(**attributes) + row += entry + if ''.join(cellblock): + self.nestedparse(cellblock, inputoffset=tableline+offset, + node=entry) + return row + + + explicit = Stuff() + """Patterns and constants used for explicit markup recognition.""" + + explicit.patterns = Stuff( + target=re.compile(r""" + (?: + _ # anonymous target + | # *OR* + (`?) # optional open quote + (?![ `]) # first char. not space or backquote + ( # reference name + .+? + ) + %s # not whitespace or escape + \1 # close quote if open quote used + ) + %s # not whitespace or escape + : # end of reference name + (?:[ ]+|$) # followed by whitespace + """ + % (RSTState.inline.non_whitespace_escape_before, + RSTState.inline.non_whitespace_escape_before), + re.VERBOSE), + reference=re.compile(r""" + (?: + (%s)_ # simple reference name + | # *OR* + ` # open backquote + (?![ ]) # not space + (.+?) # hyperlink phrase + %s # not whitespace or escape + `_ # close backquote & reference mark + ) + $ # end of string + """ % + (RSTState.inline.simplename, + RSTState.inline.non_whitespace_escape_before,), + re.VERBOSE), + substitution=re.compile(r""" + (?: + (?![ ]) # first char. not space + (.+?) # substitution text + %s # not whitespace or escape + \| # close delimiter + ) + (?:[ ]+|$) # followed by whitespace + """ % + RSTState.inline.non_whitespace_escape_before, + re.VERBOSE),) + explicit.groups = Stuff( + target=Stuff(quote=1, name=2), + reference=Stuff(simple=1, phrase=2), + substitution=Stuff(name=1)) + + def footnote(self, match): + indented, indent, offset, blankfinish = \ + self.statemachine.getfirstknownindented(match.end()) + label = match.group(1) + name = normname(label) + footnote = nodes.footnote('\n'.join(indented)) + if name[0] == '#': # auto-numbered + name = name[1:] # autonumber label + footnote['auto'] = 1 + if name: + footnote['name'] = name + self.statemachine.memo.document.note_autofootnote(footnote) + elif name == '*': # auto-symbol + name = '' + footnote['auto'] = '*' + self.statemachine.memo.document.note_symbol_footnote(footnote) + else: # manually numbered + footnote += nodes.label('', label) + footnote['name'] = name + self.statemachine.memo.document.note_footnote(footnote) + if name: + self.statemachine.memo.document.note_explicit_target(footnote, + footnote) + if indented: + self.nestedparse(indented, inputoffset=offset, node=footnote) + return [footnote], blankfinish + + def citation(self, match): + indented, indent, offset, blankfinish = \ + self.statemachine.getfirstknownindented(match.end()) + label = match.group(1) + name = normname(label) + citation = nodes.citation('\n'.join(indented)) + citation += nodes.label('', label) + citation['name'] = name + self.statemachine.memo.document.note_citation(citation) + self.statemachine.memo.document.note_explicit_target(citation, citation) + if indented: + self.nestedparse(indented, inputoffset=offset, node=citation) + return [citation], blankfinish + + def hyperlink_target(self, match): + pattern = self.explicit.patterns.target + namegroup = self.explicit.groups.target.name + lineno = self.statemachine.abslineno() + block, indent, offset, blankfinish = \ + self.statemachine.getfirstknownindented(match.end(), uptoblank=1, + stripindent=0) + blocktext = match.string[:match.end()] + '\n'.join(block) + block = [escape2null(line) for line in block] + escaped = block[0] + blockindex = 0 + while 1: + targetmatch = pattern.match(escaped) + if targetmatch: + break + blockindex += 1 + try: + escaped += block[blockindex] + except (IndexError, MarkupError): + raise MarkupError('malformed hyperlink target at line %s.' + % lineno) + del block[:blockindex] + block[0] = (block[0] + ' ')[targetmatch.end()-len(escaped)-1:].strip() + if block and block[-1].strip()[-1:] == '_': # possible indirect target + reference = ' '.join([line.strip() for line in block]) + refname = self.isreference(reference) + if refname: + target = nodes.target(blocktext, '', refname=refname) + self.addtarget(targetmatch.group(namegroup), '', target) + self.statemachine.memo.document.note_indirect_target(target) + return [target], blankfinish + nodelist = [] + reference = ''.join([line.strip() for line in block]) + if reference.find(' ') != -1: + warning = self.statemachine.memo.reporter.warning( + 'Hyperlink target at line %s contains whitespace. ' + 'Perhaps a footnote was intended?' + % (self.statemachine.abslineno() - len(block) + 1), '', + nodes.literal_block(blocktext, blocktext)) + nodelist.append(warning) + else: + unescaped = unescape(reference) + target = nodes.target(blocktext, '') + self.addtarget(targetmatch.group(namegroup), unescaped, target) + nodelist.append(target) + return nodelist, blankfinish + + def isreference(self, reference): + match = self.explicit.patterns.reference.match(normname(reference)) + if not match: + return None + return unescape(match.group(self.explicit.groups.reference.simple) + or match.group(self.explicit.groups.reference.phrase)) + + def addtarget(self, targetname, refuri, target): + if targetname: + name = normname(unescape(targetname)) + target['name'] = name + if refuri: + target['refuri'] = refuri + self.statemachine.memo.document.note_external_target(target) + else: + self.statemachine.memo.document.note_internal_target(target) + self.statemachine.memo.document.note_explicit_target( + target, self.statemachine.node) + else: # anonymous target + if refuri: + target['refuri'] = refuri + target['anonymous'] = 1 + self.statemachine.memo.document.note_anonymous_target(target) + + def substitutiondef(self, match): + pattern = self.explicit.patterns.substitution + lineno = self.statemachine.abslineno() + block, indent, offset, blankfinish = \ + self.statemachine.getfirstknownindented(match.end(), + stripindent=0) + blocktext = (match.string[:match.end()] + '\n'.join(block)) + block = [escape2null(line) for line in block] + escaped = block[0].rstrip() + blockindex = 0 + while 1: + subdefmatch = pattern.match(escaped) + if subdefmatch: + break + blockindex += 1 + try: + escaped = escaped + ' ' + block[blockindex].strip() + except (IndexError, MarkupError): + raise MarkupError('malformed substitution definition ' + 'at line %s.' % lineno) + del block[:blockindex] # strip out the substitution marker + block[0] = (block[0] + ' ')[subdefmatch.end()-len(escaped)-1:].strip() + if not block[0]: + del block[0] + offset += 1 + subname = subdefmatch.group(self.explicit.groups.substitution.name) + name = normname(subname) + substitutionnode = nodes.substitution_definition( + blocktext, name=name, alt=subname) + if block: + block[0] = block[0].strip() + newabsoffset, blankfinish = self.nestedlistparse( + block, inputoffset=offset, node=substitutionnode, + initialstate='SubstitutionDef', blankfinish=blankfinish) + self.statemachine.previousline( + len(block) + offset - newabsoffset - 1) + i = 0 + for node in substitutionnode[:]: + if not (isinstance(node, nodes.Inline) or + isinstance(node, nodes.Text)): + self.statemachine.node += substitutionnode[i] + del substitutionnode[i] + else: + i += 1 + if len(substitutionnode) == 0: + msg = self.statemachine.memo.reporter.warning( + 'Substitution definition "%s" empty or invalid at line ' + '%s.' % (subname, self.statemachine.abslineno()), '', + nodes.literal_block(blocktext, blocktext)) + self.statemachine.node += msg + else: + del substitutionnode['alt'] + self.statemachine.memo.document.note_substitution_def( + substitutionnode, self.statemachine.node) + return [substitutionnode], blankfinish + else: + msg = self.statemachine.memo.reporter.warning( + 'Substitution definition "%s" missing contents at line %s.' + % (subname, self.statemachine.abslineno()), '', + nodes.literal_block(blocktext, blocktext)) + self.statemachine.node += msg + return [], blankfinish + + def directive(self, match, **attributes): + typename = match.group(1) + directivefunction = directives.directive( + typename, self.statemachine.memo.language) + data = match.string[match.end():].strip() + if directivefunction: + return directivefunction(match, typename, data, self, + self.statemachine, attributes) + else: + return self.unknowndirective(typename, data) + + def unknowndirective(self, typename, data): + lineno = self.statemachine.abslineno() + indented, indent, offset, blankfinish = \ + self.statemachine.getfirstknownindented(0, stripindent=0) + text = '\n'.join(indented) + error = self.statemachine.memo.reporter.error( + 'Unknown directive type "%s" at line %s.' % (typename, lineno), + '', nodes.literal_block(text, text)) + return [error], blankfinish + + def parse_extension_attributes(self, attribute_spec, datalines, blankfinish): + """ + Parse `datalines` for a field list containing extension attributes + matching `attribute_spec`. + + :Parameters: + - `attribute_spec`: a mapping of attribute name to conversion + function, which should raise an exception on bad input. + - `datalines`: a list of input strings. + - `blankfinish`: + + :Return: + - Success value, 1 or 0. + - An attribute dictionary on success, an error string on failure. + - Updated `blankfinish` flag. + """ + node = nodes.field_list() + newlineoffset, blankfinish = self.nestedlistparse( + datalines, 0, node, initialstate='FieldList', + blankfinish=blankfinish) + if newlineoffset != len(datalines): # incomplete parse of block + return 0, 'invalid attribute block', blankfinish + try: + attributes = utils.extract_extension_attributes(node, attribute_spec) + except KeyError, detail: + return 0, ('unknown attribute: "%s"' % detail), blankfinish + except (ValueError, TypeError), detail: + return 0, ('invalid attribute value:\n%s' % detail), blankfinish + except utils.ExtensionAttributeError, detail: + return 0, ('invalid attribute data: %s' % detail), blankfinish + return 1, attributes, blankfinish + + def comment(self, match): + if not match.string[match.end():].strip() \ + and self.statemachine.nextlineblank(): # an empty comment? + return [nodes.comment()], 1 # "A tiny but practical wart." + indented, indent, offset, blankfinish = \ + self.statemachine.getfirstknownindented(match.end()) + text = '\n'.join(indented) + return [nodes.comment(text, text)], blankfinish + + explicit.constructs = [ + (footnote, + re.compile(r""" + \.\.[ ]+ # explicit markup start + \[ + ( # footnote label: + [0-9]+ # manually numbered footnote + | # *OR* + \# # anonymous auto-numbered footnote + | # *OR* + \#%s # auto-number ed?) footnote label + | # *OR* + \* # auto-symbol footnote + ) + \] + (?:[ ]+|$) # whitespace or end of line + """ % RSTState.inline.simplename, re.VERBOSE)), + (citation, + re.compile(r""" + \.\.[ ]+ # explicit markup start + \[(%s)\] # citation label + (?:[ ]+|$) # whitespace or end of line + """ % RSTState.inline.simplename, re.VERBOSE)), + (hyperlink_target, + re.compile(r""" + \.\.[ ]+ # explicit markup start + _ # target indicator + (?![ ]) # first char. not space + """, re.VERBOSE)), + (substitutiondef, + re.compile(r""" + \.\.[ ]+ # explicit markup start + \| # substitution indicator + (?![ ]) # first char. not space + """, re.VERBOSE)), + (directive, + re.compile(r""" + \.\.[ ]+ # explicit markup start + (%s) # directive name + :: # directive delimiter + (?:[ ]+|$) # whitespace or end of line + """ % RSTState.inline.simplename, re.VERBOSE))] + + def explicit_markup(self, match, context, nextstate): + """Footnotes, hyperlink targets, directives, comments.""" + nodelist, blankfinish = self.explicit_construct(match) + self.statemachine.node += nodelist + self.explicitlist(blankfinish) + return [], nextstate, [] + + def explicit_construct(self, match): + """Determine which explicit construct this is, parse & return it.""" + errors = [] + for method, pattern in self.explicit.constructs: + expmatch = pattern.match(match.string) + if expmatch: + try: + return method(self, expmatch) + except MarkupError, detail: # never reached? + errors.append( + self.statemachine.memo.reporter.warning('%s: %s' + % (detail.__class__.__name__, detail))) + break + nodelist, blankfinish = self.comment(match) + return nodelist + errors, blankfinish + + def explicitlist(self, blankfinish): + """ + Create a nested state machine for a series of explicit markup constructs + (including anonymous hyperlink targets). + """ + offset = self.statemachine.lineoffset + 1 # next line + newlineoffset, blankfinish = self.nestedlistparse( + self.statemachine.inputlines[offset:], + inputoffset=self.statemachine.abslineoffset() + 1, + node=self.statemachine.node, initialstate='Explicit', + blankfinish=blankfinish) + self.gotoline(newlineoffset) + if not blankfinish: + self.statemachine.node += self.unindentwarning() + + def anonymous(self, match, context, nextstate): + """Anonymous hyperlink targets.""" + nodelist, blankfinish = self.anonymous_target(match) + self.statemachine.node += nodelist + self.explicitlist(blankfinish) + return [], nextstate, [] + + def anonymous_target(self, match): + block, indent, offset, blankfinish \ + = self.statemachine.getfirstknownindented(match.end(), + uptoblank=1) + blocktext = match.string[:match.end()] + '\n'.join(block) + if block and block[-1].strip()[-1:] == '_': # possible indirect target + reference = escape2null(' '.join([line.strip() for line in block])) + refname = self.isreference(reference) + if refname: + target = nodes.target(blocktext, '', refname=refname, + anonymous=1) + self.statemachine.memo.document.note_anonymous_target(target) + self.statemachine.memo.document.note_indirect_target(target) + return [target], blankfinish + nodelist = [] + reference = escape2null(''.join([line.strip() for line in block])) + if reference.find(' ') != -1: + warning = self.statemachine.memo.reporter.warning( + 'Anonymous hyperlink target at line %s contains whitespace. ' + 'Perhaps a footnote was intended?' + % (self.statemachine.abslineno() - len(block) + 1), '', + nodes.literal_block(blocktext, blocktext)) + nodelist.append(warning) + else: + target = nodes.target(blocktext, '', anonymous=1) + if reference: + unescaped = unescape(reference) + target['refuri'] = unescaped + self.statemachine.memo.document.note_anonymous_target(target) + nodelist.append(target) + return nodelist, blankfinish + + def line(self, match, context, nextstate): + """Section title overline or transition marker.""" + if self.statemachine.matchtitles: + return [match.string], 'Line', [] + else: + blocktext = self.statemachine.line + msg = self.statemachine.memo.reporter.severe( + 'Unexpected section title or transition at line %s.' + % self.statemachine.abslineno(), '', + nodes.literal_block(blocktext, blocktext)) + self.statemachine.node += msg + return [], nextstate, [] + + def text(self, match, context, nextstate): + """Titles, definition lists, paragraphs.""" + return [match.string], 'Text', [] + + +class SpecializedBody(Body): + + """ + Superclass for second and subsequent compound element members. + + All transition methods are disabled. Override individual methods in + subclasses to re-enable. + """ + + def invalid_input(self, match=None, context=None, nextstate=None): + """Not a compound element member. Abort this state machine.""" + self.statemachine.previousline() # back up so parent SM can reassess + raise EOFError + + indent = invalid_input + bullet = invalid_input + enumerator = invalid_input + field_marker = invalid_input + option_marker = invalid_input + doctest = invalid_input + tabletop = invalid_input + explicit_markup = invalid_input + anonymous = invalid_input + line = invalid_input + text = invalid_input + + +class BulletList(SpecializedBody): + + """Second and subsequent bullet_list list_items.""" + + def bullet(self, match, context, nextstate): + """Bullet list item.""" + if match.string[0] != self.statemachine.node['bullet']: + # different bullet: new list + self.invalid_input() + listitem, blankfinish = self.list_item(match.end()) + self.statemachine.node += listitem + self.blankfinish = blankfinish + return [], 'BulletList', [] + + +class DefinitionList(SpecializedBody): + + """Second and subsequent definition_list_items.""" + + def text(self, match, context, nextstate): + """Definition lists.""" + return [match.string], 'Definition', [] + + +class EnumeratedList(SpecializedBody): + + """Second and subsequent enumerated_list list_items.""" + + def enumerator(self, match, context, nextstate): + """Enumerated list item.""" + format, sequence, text, ordinal = self.parse_enumerator( + match, self.statemachine.node['enumtype']) + if (sequence != self.statemachine.node['enumtype'] or + format != self.format or + ordinal != self.lastordinal + 1): + # different enumeration: new list + self.invalid_input() + listitem, blankfinish = self.list_item(match.end()) + self.statemachine.node += listitem + self.blankfinish = blankfinish + self.lastordinal = ordinal + return [], 'EnumeratedList', [] + + +class FieldList(SpecializedBody): + + """Second and subsequent field_list fields.""" + + def field_marker(self, match, context, nextstate): + """Field list field.""" + field, blankfinish = self.field(match) + self.statemachine.node += field + self.blankfinish = blankfinish + return [], 'FieldList', [] + + +class OptionList(SpecializedBody): + + """Second and subsequent option_list option_list_items.""" + + def option_marker(self, match, context, nextstate): + """Option list item.""" + try: + option_list_item, blankfinish = self.option_list_item(match) + except MarkupError, detail: + self.invalid_input() + self.statemachine.node += option_list_item + self.blankfinish = blankfinish + return [], 'OptionList', [] + + +class RFC822List(SpecializedBody): + + """Second and subsequent RFC822 field_list fields.""" + + pass + + +class Explicit(SpecializedBody): + + """Second and subsequent explicit markup construct.""" + + def explicit_markup(self, match, context, nextstate): + """Footnotes, hyperlink targets, directives, comments.""" + nodelist, blankfinish = self.explicit_construct(match) + self.statemachine.node += nodelist + self.blankfinish = blankfinish + return [], nextstate, [] + + def anonymous(self, match, context, nextstate): + """Anonymous hyperlink targets.""" + nodelist, blankfinish = self.anonymous_target(match) + self.statemachine.node += nodelist + self.blankfinish = blankfinish + return [], nextstate, [] + + +class SubstitutionDef(Body): + + """ + Parser for the contents of a substitution_definition element. + """ + + patterns = { + 'embedded_directive': r'(%s)::( +|$)' % RSTState.inline.simplename, + 'text': r''} + initialtransitions = ['embedded_directive', 'text'] + + def embedded_directive(self, match, context, nextstate): + if self.statemachine.node.has_key('alt'): + attributes = {'alt': self.statemachine.node['alt']} + else: + attributes = {} + nodelist, blankfinish = self.directive(match, **attributes) + self.statemachine.node += nodelist + if not self.statemachine.ateof(): + self.blankfinish = blankfinish + raise EOFError + + def text(self, match, context, nextstate): + if not self.statemachine.ateof(): + self.blankfinish = self.statemachine.nextlineblank() + raise EOFError + + +class Text(RSTState): + + """ + Classifier of second line of a text block. + + Could be a paragraph, a definition list item, or a title. + """ + + patterns = {'underline': Body.patterns['line'], + 'text': r''} + initialtransitions = [('underline', 'Body'), ('text', 'Body')] + + def blank(self, match, context, nextstate): + """End of paragraph.""" + paragraph, literalnext = self.paragraph( + context, self.statemachine.abslineno() - 1) + self.statemachine.node += paragraph + if literalnext: + self.statemachine.node += self.literal_block() + return [], 'Body', [] + + def eof(self, context): + if context: + paragraph, literalnext = self.paragraph( + context, self.statemachine.abslineno() - 1) + self.statemachine.node += paragraph + if literalnext: + self.statemachine.node += self.literal_block() + return [] + + def indent(self, match, context, nextstate): + """Definition list item.""" + definitionlist = nodes.definition_list() + definitionlistitem, blankfinish = self.definition_list_item(context) + definitionlist += definitionlistitem + self.statemachine.node += definitionlist + offset = self.statemachine.lineoffset + 1 # next line + newlineoffset, blankfinish = self.nestedlistparse( + self.statemachine.inputlines[offset:], + inputoffset=self.statemachine.abslineoffset() + 1, + node=definitionlist, initialstate='DefinitionList', + blankfinish=blankfinish, blankfinishstate='Definition') + if not blankfinish: + self.statemachine.node += self.unindentwarning() + self.gotoline(newlineoffset) + return [], 'Body', [] + + def underline(self, match, context, nextstate): + """Section title.""" + lineno = self.statemachine.abslineno() + if not self.statemachine.matchtitles: + blocktext = context[0] + '\n' + self.statemachine.line + msg = self.statemachine.memo.reporter.severe( + 'Unexpected section title at line %s.' % lineno, '', + nodes.literal_block(blocktext, blocktext)) + self.statemachine.node += msg + return [], nextstate, [] + title = context[0].rstrip() + underline = match.string.rstrip() + source = title + '\n' + underline + if len(title) > len(underline): + blocktext = context[0] + '\n' + self.statemachine.line + msg = self.statemachine.memo.reporter.info( + 'Title underline too short at line %s.' % lineno, '', + nodes.literal_block(blocktext, blocktext)) + self.statemachine.node += msg + style = underline[0] + context[:] = [] + self.section(title, source, style, lineno - 1) + return [], nextstate, [] + + def text(self, match, context, nextstate): + """Paragraph.""" + startline = self.statemachine.abslineno() - 1 + msg = None + try: + block = self.statemachine.getunindented() + except statemachine.UnexpectedIndentationError, instance: + block, lineno = instance.args + msg = self.statemachine.memo.reporter.error( + 'Unexpected indentation at line %s.' % lineno) + lines = context + block + paragraph, literalnext = self.paragraph(lines, startline) + self.statemachine.node += paragraph + self.statemachine.node += msg + if literalnext: + try: + self.statemachine.nextline() + except IndexError: + pass + self.statemachine.node += self.literal_block() + return [], nextstate, [] + + def literal_block(self): + """Return a list of nodes.""" + indented, indent, offset, blankfinish = \ + self.statemachine.getindented() + nodelist = [] + while indented and not indented[-1].strip(): + indented.pop() + if indented: + data = '\n'.join(indented) + nodelist.append(nodes.literal_block(data, data)) + if not blankfinish: + nodelist.append(self.unindentwarning()) + else: + nodelist.append(self.statemachine.memo.reporter.warning( + 'Literal block expected at line %s; none found.' + % self.statemachine.abslineno())) + return nodelist + + def definition_list_item(self, termline): + indented, indent, lineoffset, blankfinish = \ + self.statemachine.getindented() + definitionlistitem = nodes.definition_list_item('\n'.join(termline + + indented)) + termlist, messages = self.term(termline, + self.statemachine.abslineno() - 1) + definitionlistitem += termlist + definition = nodes.definition('', *messages) + definitionlistitem += definition + if termline[0][-2:] == '::': + definition += self.statemachine.memo.reporter.info( + 'Blank line missing before literal block? Interpreted as a ' + 'definition list item. At line %s.' % (lineoffset + 1)) + self.nestedparse(indented, inputoffset=lineoffset, node=definition) + return definitionlistitem, blankfinish + + def term(self, lines, lineno): + """Return a definition_list's term and optional classifier.""" + assert len(lines) == 1 + nodelist = [] + parts = lines[0].split(' : ', 1) # split into 1 or 2 parts + termpart = parts[0].rstrip() + textnodes, messages = self.inline_text(termpart, lineno) + nodelist = [nodes.term(termpart, '', *textnodes)] + if len(parts) == 2: + classifierpart = parts[1].lstrip() + textnodes, cpmessages = self.inline_text(classifierpart, lineno) + nodelist.append(nodes.classifier(classifierpart, '', *textnodes)) + messages += cpmessages + return nodelist, messages + + +class SpecializedText(Text): + + """ + Superclass for second and subsequent lines of Text-variants. + + All transition methods are disabled. Override individual methods in + subclasses to re-enable. + """ + + def eof(self, context): + """Incomplete construct.""" + return [] + + def invalid_input(self, match=None, context=None, nextstate=None): + """Not a compound element member. Abort this state machine.""" + raise EOFError + + blank = invalid_input + indent = invalid_input + underline = invalid_input + text = invalid_input + + +class Definition(SpecializedText): + + """Second line of potential definition_list_item.""" + + def eof(self, context): + """Not a definition.""" + self.statemachine.previousline(2) # back up so parent SM can reassess + return [] + + def indent(self, match, context, nextstate): + """Definition list item.""" + definitionlistitem, blankfinish = self.definition_list_item(context) + self.statemachine.node += definitionlistitem + self.blankfinish = blankfinish + return [], 'DefinitionList', [] + + +class Line(SpecializedText): + + """Second line of over- & underlined section title or transition marker.""" + + eofcheck = 1 # @@@ ??? + """Set to 0 while parsing sections, so that we don't catch the EOF.""" + + def eof(self, context): + """Transition marker at end of section or document.""" + if self.eofcheck: # ignore EOFError with sections + transition = nodes.transition(context[0]) + self.statemachine.node += transition + msg = self.statemachine.memo.reporter.error( + 'Document or section may not end with a transition ' + '(line %s).' % (self.statemachine.abslineno() - 1)) + self.statemachine.node += msg + self.eofcheck = 1 + return [] + + def blank(self, match, context, nextstate): + """Transition marker.""" + transition = nodes.transition(context[0]) + if len(self.statemachine.node) == 0: + msg = self.statemachine.memo.reporter.error( + 'Document or section may not begin with a transition ' + '(line %s).' % (self.statemachine.abslineno() - 1)) + self.statemachine.node += msg + elif isinstance(self.statemachine.node[-1], nodes.transition): + msg = self.statemachine.memo.reporter.error( + 'At least one body element must separate transitions; ' + 'adjacent transitions at line %s.' + % (self.statemachine.abslineno() - 1)) + self.statemachine.node += msg + self.statemachine.node += transition + return [], 'Body', [] + + def text(self, match, context, nextstate): + """Potential over- & underlined title.""" + lineno = self.statemachine.abslineno() - 1 + overline = context[0] + title = match.string + underline = '' + try: + underline = self.statemachine.nextline() + except IndexError: + blocktext = overline + '\n' + title + msg = self.statemachine.memo.reporter.severe( + 'Incomplete section title at line %s.' % lineno, '', + nodes.literal_block(blocktext, blocktext)) + self.statemachine.node += msg + return [], 'Body', [] + source = '%s\n%s\n%s' % (overline, title, underline) + overline = overline.rstrip() + underline = underline.rstrip() + if not self.transitions['underline'][0].match(underline): + msg = self.statemachine.memo.reporter.severe( + 'Missing underline for overline at line %s.' % lineno, '', + nodes.literal_block(source, source)) + self.statemachine.node += msg + return [], 'Body', [] + elif overline != underline: + msg = self.statemachine.memo.reporter.severe( + 'Title overline & underline mismatch at ' 'line %s.' % lineno, + '', nodes.literal_block(source, source)) + self.statemachine.node += msg + return [], 'Body', [] + title = title.rstrip() + if len(title) > len(overline): + msg = self.statemachine.memo.reporter.info( + 'Title overline too short at line %s.'% lineno, '', + nodes.literal_block(source, source)) + self.statemachine.node += msg + style = (overline[0], underline[0]) + self.eofcheck = 0 # @@@ not sure this is correct + self.section(title.lstrip(), source, style, lineno + 1) + self.eofcheck = 1 + return [], 'Body', [] + + indent = text # indented title + + def underline(self, match=None, context=None, nextstate=None): + blocktext = context[0] + '\n' + self.statemachine.line + msg = self.statemachine.memo.reporter.error( + 'Invalid section title or transition marker at line %s.' + % (self.statemachine.abslineno() - 1), '', + nodes.literal_block(blocktext, blocktext)) + self.statemachine.node += msg + return [], 'Body', [] + + +stateclasses = [Body, BulletList, DefinitionList, EnumeratedList, FieldList, + OptionList, RFC822List, Explicit, Text, Definition, Line, + SubstitutionDef] +"""Standard set of State classes used to start `RSTStateMachine`.""" + + +def escape2null(text): + """Return a string with escape-backslashes converted to nulls.""" + parts = [] + start = 0 + while 1: + found = text.find('\\', start) + if found == -1: + parts.append(text[start:]) + return ''.join(parts) + parts.append(text[start:found]) + parts.append('\x00' + text[found+1:found+2]) + start = found + 2 # skip character after escape + +def unescape(text, restorebackslashes=0): + """Return a string with nulls removed or restored to backslashes.""" + if restorebackslashes: + return text.translate(RSTState.inline.null2backslash) + else: + return text.translate(RSTState.inline.identity, '\x00') diff --git a/docutils/parsers/rst/tableparser.py b/docutils/parsers/rst/tableparser.py new file mode 100644 index 000000000..7bacf99cd --- /dev/null +++ b/docutils/parsers/rst/tableparser.py @@ -0,0 +1,313 @@ +""" +:Author: David Goodger +:Contact: goodger@users.sourceforge.net +:Revision: $Revision$ +:Date: $Date$ +:Copyright: This module has been placed in the public domain. + +This module defines the `TableParser` class, which parses a plaintext-graphic +table and produces a well-formed data structure suitable for building a CALS +table. + +:Exception class: `TableMarkupError` + +:Function: + `update_dictoflists()`: Merge two dictionaries containing list values. +""" + +__docformat__ = 'reStructuredText' + + +import re + + +class TableMarkupError(Exception): pass + + +class TableParser: + + """ + Parse a plaintext graphic table using `parse()`. + + Here's an example of a plaintext graphic table:: + + +------------------------+------------+----------+----------+ + | Header row, column 1 | Header 2 | Header 3 | Header 4 | + +========================+============+==========+==========+ + | body row 1, column 1 | column 2 | column 3 | column 4 | + +------------------------+------------+----------+----------+ + | body row 2 | Cells may span columns. | + +------------------------+------------+---------------------+ + | body row 3 | Cells may | - Table cells | + +------------------------+ span rows. | - contain | + | body row 4 | | - body elements. | + +------------------------+------------+---------------------+ + + Intersections use '+', row separators use '-' (except for one optional + head/body row separator, which uses '='), and column separators use '|'. + + Passing the above table to the `parse()` method will result in the + following data structure:: + + ([24, 12, 10, 10], + [[(0, 0, 1, ['Header row, column 1']), + (0, 0, 1, ['Header 2']), + (0, 0, 1, ['Header 3']), + (0, 0, 1, ['Header 4'])]], + [[(0, 0, 3, ['body row 1, column 1']), + (0, 0, 3, ['column 2']), + (0, 0, 3, ['column 3']), + (0, 0, 3, ['column 4'])], + [(0, 0, 5, ['body row 2']), + (0, 2, 5, ['Cells may span columns.']), + None, + None], + [(0, 0, 7, ['body row 3']), + (1, 0, 7, ['Cells may', 'span rows.', '']), + (1, 1, 7, ['- Table cells', '- contain', '- body elements.']), + None], + [(0, 0, 9, ['body row 4']), None, None, None]]) + + The first item is a list containing column widths (colspecs). The second + item is a list of head rows, and the third is a list of body rows. Each + row contains a list of cells. Each cell is either None (for a cell unused + because of another cell's span), or a tuple. A cell tuple contains four + items: the number of extra rows used by the cell in a vertical span + (morerows); the number of extra columns used by the cell in a horizontal + span (morecols); the line offset of the first line of the cell contents; + and the cell contents, a list of lines of text. + """ + + headbodyseparatorpat = re.compile(r'\+=[=+]+=\+$') + """Matches the row separator between head rows and body rows.""" + + def parse(self, block): + """ + Analyze the text `block` and return a table data structure. + + Given a plaintext-graphic table in `block` (list of lines of text; no + whitespace padding), parse the table, construct and return the data + necessary to construct a CALS table or equivalent. + + Raise `TableMarkupError` if there is any problem with the markup. + """ + self.setup(block) + self.findheadbodysep() + self.parsegrid() + structure = self.structurefromcells() + return structure + + def setup(self, block): + self.block = block[:] # make a copy; it may be modified + self.bottom = len(block) - 1 + self.right = len(block[0]) - 1 + self.headbodysep = None + self.done = [-1] * len(block[0]) + self.cells = [] + self.rowseps = {0: [0]} + self.colseps = {0: [0]} + + def findheadbodysep(self): + """Look for a head/body row separator line; store the line index.""" + for i in range(len(self.block)): + line = self.block[i] + if self.headbodyseparatorpat.match(line): + if self.headbodysep: + raise TableMarkupError, ( + 'Multiple head/body row separators in table (at line ' + 'offset %s and %s); only one allowed.' + % (self.headbodysep, i)) + else: + self.headbodysep = i + self.block[i] = line.replace('=', '-') + if self.headbodysep == 0 or self.headbodysep == len(self.block) - 1: + raise TableMarkupError, ( + 'The head/body row separator may not be the first or last ' + 'line of the table.' % (self.headbodysep, i)) + + def parsegrid(self): + """ + Start with a queue of upper-left corners, containing the upper-left + corner of the table itself. Trace out one rectangular cell, remember + it, and add its upper-right and lower-left corners to the queue of + potential upper-left corners of further cells. Process the queue in + top-to-bottom order, keeping track of how much of each text column has + been seen. + + We'll end up knowing all the row and column boundaries, cell positions + and their dimensions. + """ + corners = [(0, 0)] + while corners: + top, left = corners.pop(0) + if top == self.bottom or left == self.right \ + or top <= self.done[left]: + continue + result = self.scancell(top, left) + if not result: + continue + bottom, right, rowseps, colseps = result + update_dictoflists(self.rowseps, rowseps) + update_dictoflists(self.colseps, colseps) + self.markdone(top, left, bottom, right) + cellblock = self.getcellblock(top, left, bottom, right) + self.cells.append((top, left, bottom, right, cellblock)) + corners.extend([(top, right), (bottom, left)]) + corners.sort() + if not self.checkparsecomplete(): + raise TableMarkupError, 'Malformed table; parse incomplete.' + + def markdone(self, top, left, bottom, right): + """For keeping track of how much of each text column has been seen.""" + before = top - 1 + after = bottom - 1 + for col in range(left, right): + assert self.done[col] == before + self.done[col] = after + + def checkparsecomplete(self): + """Each text column should have been completely seen.""" + last = self.bottom - 1 + for col in range(self.right): + if self.done[col] != last: + return None + return 1 + + def getcellblock(self, top, left, bottom, right): + """Given the corners, extract the text of a cell.""" + cellblock = [] + margin = right + for lineno in range(top + 1, bottom): + line = self.block[lineno][left + 1 : right].rstrip() + cellblock.append(line) + if line: + margin = margin and min(margin, len(line) - len(line.lstrip())) + if 0 < margin < right: + cellblock = [line[margin:] for line in cellblock] + return cellblock + + def scancell(self, top, left): + """Starting at the top-left corner, start tracing out a cell.""" + assert self.block[top][left] == '+' + result = self.scanright(top, left) + return result + + def scanright(self, top, left): + """ + Look for the top-right corner of the cell, and make note of all column + boundaries ('+'). + """ + colseps = {} + line = self.block[top] + for i in range(left + 1, self.right + 1): + if line[i] == '+': + colseps[i] = [top] + result = self.scandown(top, left, i) + if result: + bottom, rowseps, newcolseps = result + update_dictoflists(colseps, newcolseps) + return bottom, i, rowseps, colseps + elif line[i] != '-': + return None + return None + + def scandown(self, top, left, right): + """ + Look for the bottom-right corner of the cell, making note of all row + boundaries. + """ + rowseps = {} + for i in range(top + 1, self.bottom + 1): + if self.block[i][right] == '+': + rowseps[i] = [right] + result = self.scanleft(top, left, i, right) + if result: + newrowseps, colseps = result + update_dictoflists(rowseps, newrowseps) + return i, rowseps, colseps + elif self.block[i][right] != '|': + return None + return None + + def scanleft(self, top, left, bottom, right): + """ + Noting column boundaries, look for the bottom-left corner of the cell. + It must line up with the starting point. + """ + colseps = {} + line = self.block[bottom] + for i in range(right - 1, left, -1): + if line[i] == '+': + colseps[i] = [bottom] + elif line[i] != '-': + return None + if line[left] != '+': + return None + result = self.scanup(top, left, bottom, right) + if result is not None: + rowseps = result + return rowseps, colseps + return None + + def scanup(self, top, left, bottom, right): + """Noting row boundaries, see if we can return to the starting point.""" + rowseps = {} + for i in range(bottom - 1, top, -1): + if self.block[i][left] == '+': + rowseps[i] = [left] + elif self.block[i][left] != '|': + return None + return rowseps + + def structurefromcells(self): + """ + From the data colledted by `scancell()`, convert to the final data + structure. + """ + rowseps = self.rowseps.keys() # list of row boundaries + rowseps.sort() + rowindex = {} + for i in range(len(rowseps)): + rowindex[rowseps[i]] = i # row boundary -> row number mapping + colseps = self.colseps.keys() # list of column boundaries + colseps.sort() + colindex = {} + for i in range(len(colseps)): + colindex[colseps[i]] = i # column boundary -> col number mapping + colspecs = [(colseps[i] - colseps[i - 1] - 1) + for i in range(1, len(colseps))] # list of column widths + # prepare an empty table with the correct number of rows & columns + onerow = [None for i in range(len(colseps) - 1)] + rows = [onerow[:] for i in range(len(rowseps) - 1)] + # keep track of # of cells remaining; should reduce to zero + remaining = (len(rowseps) - 1) * (len(colseps) - 1) + for top, left, bottom, right, block in self.cells: + rownum = rowindex[top] + colnum = colindex[left] + assert rows[rownum][colnum] is None, ( + 'Cell (row %s, column %s) already used.' + % (rownum + 1, colnum + 1)) + morerows = rowindex[bottom] - rownum - 1 + morecols = colindex[right] - colnum - 1 + remaining -= (morerows + 1) * (morecols + 1) + # write the cell into the table + rows[rownum][colnum] = (morerows, morecols, top + 1, block) + assert remaining == 0, 'Unused cells remaining.' + if self.headbodysep: # separate head rows from body rows + numheadrows = rowindex[self.headbodysep] + headrows = rows[:numheadrows] + bodyrows = rows[numheadrows:] + else: + headrows = [] + bodyrows = rows + return (colspecs, headrows, bodyrows) + + +def update_dictoflists(master, newdata): + """ + Extend the list values of `master` with those from `newdata`. + + Both parameters must be dictionaries containing list values. + """ + for key, values in newdata.items(): + master.setdefault(key, []).extend(values) -- cgit v1.2.1 From 6381b74ce6924bc0f14b7f377ee57496e2ebb2d9 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 20 Apr 2002 16:36:24 +0000 Subject: - Improved diagnostic system messages for missing blank lines. - Fixed substitution_reference bug. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@29 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 68 ++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 32 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index b2dbf9b3e..706ed6106 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -626,24 +626,27 @@ class RSTState(StateWS): before, inlines, remaining, sysmessages, endstring = self.inlineobj( match, lineno, self.inline.patterns.substitution_ref, nodes.substitution_reference) - if inlines: - assert len(inlines) == 1 + if len(inlines) == 1: subrefnode = inlines[0] - assert isinstance(subrefnode, nodes.substitution_reference) - subreftext = subrefnode.astext() - refname = normname(subreftext) - subrefnode['refname'] = refname - self.statemachine.memo.document.note_substitution_ref(subrefnode) - if endstring[-1:] == '_': - referencenode = nodes.reference('|%s%s' % (subreftext, endstring), '') - if endstring[-2:] == '__': - referencenode['anonymous'] = 1 - self.statemachine.memo.document.note_anonymous_ref(referencenode) - else: - referencenode['refname'] = refname - self.statemachine.memo.document.note_refname(referencenode) - referencenode += subrefnode - inlines = [referencenode] + if isinstance(subrefnode, nodes.substitution_reference): + subreftext = subrefnode.astext() + refname = normname(subreftext) + subrefnode['refname'] = refname + self.statemachine.memo.document.note_substitution_ref( + subrefnode) + if endstring[-1:] == '_': + referencenode = nodes.reference( + '|%s%s' % (subreftext, endstring), '') + if endstring[-2:] == '__': + referencenode['anonymous'] = 1 + self.statemachine.memo.document.note_anonymous_ref( + referencenode) + else: + referencenode['refname'] = refname + self.statemachine.memo.document.note_refname( + referencenode) + referencenode += subrefnode + inlines = [referencenode] return before, inlines, remaining, sysmessages def footnote_reference(self, match, lineno): @@ -788,10 +791,10 @@ class RSTState(StateWS): processed += self.standalone_uri(remaining, lineno) return processed, messages - def unindentwarning(self): + def unindent_warning(self, node_name): return self.statemachine.memo.reporter.warning( - ('Unindent without blank line at line %s.' - % (self.statemachine.abslineno() + 1))) + ('%s ends without a blank line; unexpected unindent at line %s.' + % (node_name, self.statemachine.abslineno() + 1))) class Body(RSTState): @@ -882,7 +885,7 @@ class Body(RSTState): blockquote = self.block_quote(indented, lineoffset) self.statemachine.node += blockquote if not blankfinish: - self.statemachine.node += self.unindentwarning() + self.statemachine.node += self.unindent_warning('Block quote') return context, nextstate, [] def block_quote(self, indented, lineoffset): @@ -904,7 +907,7 @@ class Body(RSTState): node=bulletlist, initialstate='BulletList', blankfinish=blankfinish) if not blankfinish: - self.statemachine.node += self.unindentwarning() + self.statemachine.node += self.unindent_warning('Bullet list') self.gotoline(newlineoffset) return [], nextstate, [] @@ -930,7 +933,8 @@ class Body(RSTState): bq = self.block_quote(indented, lineoffset) self.statemachine.node += bq if not blankfinish: - self.statemachine.node += self.unindentwarning() + self.statemachine.node += self.unindent_warning( + 'Enumerated list') return [], nextstate, [] if ordinal != 1: msg = self.statemachine.memo.reporter.info( @@ -955,7 +959,7 @@ class Body(RSTState): blankfinish=blankfinish, extrasettings={'lastordinal': ordinal, 'format': format}) if not blankfinish: - self.statemachine.node += self.unindentwarning() + self.statemachine.node += self.unindent_warning('Enumerated list') self.gotoline(newlineoffset) return [], nextstate, [] @@ -1022,7 +1026,7 @@ class Body(RSTState): node=fieldlist, initialstate='FieldList', blankfinish=blankfinish) if not blankfinish: - self.statemachine.node += self.unindentwarning() + self.statemachine.node += self.unindent_warning('Field list') self.gotoline(newlineoffset) return [], nextstate, [] @@ -1062,7 +1066,7 @@ class Body(RSTState): blockquote = self.block_quote(indented, lineoffset) self.statemachine.node += blockquote if not blankfinish: - self.statemachine.node += self.unindentwarning() + self.statemachine.node += self.unindent_warning('Option list') return [], nextstate, [] self.statemachine.node += optionlist optionlist += listitem @@ -1073,7 +1077,7 @@ class Body(RSTState): node=optionlist, initialstate='OptionList', blankfinish=blankfinish) if not blankfinish: - self.statemachine.node += self.unindentwarning() + self.statemachine.node += self.unindent_warning('Option list') self.gotoline(newlineoffset) return [], nextstate, [] @@ -1592,8 +1596,8 @@ class Body(RSTState): def explicitlist(self, blankfinish): """ - Create a nested state machine for a series of explicit markup constructs - (including anonymous hyperlink targets). + Create a nested state machine for a series of explicit markup + constructs (including anonymous hyperlink targets). """ offset = self.statemachine.lineoffset + 1 # next line newlineoffset, blankfinish = self.nestedlistparse( @@ -1603,7 +1607,7 @@ class Body(RSTState): blankfinish=blankfinish) self.gotoline(newlineoffset) if not blankfinish: - self.statemachine.node += self.unindentwarning() + self.statemachine.node += self.unindent_warning('Explicit markup') def anonymous(self, match, context, nextstate): """Anonymous hyperlink targets.""" @@ -1857,7 +1861,7 @@ class Text(RSTState): node=definitionlist, initialstate='DefinitionList', blankfinish=blankfinish, blankfinishstate='Definition') if not blankfinish: - self.statemachine.node += self.unindentwarning() + self.statemachine.node += self.unindent_warning('Definition list') self.gotoline(newlineoffset) return [], 'Body', [] @@ -1918,7 +1922,7 @@ class Text(RSTState): data = '\n'.join(indented) nodelist.append(nodes.literal_block(data, data)) if not blankfinish: - nodelist.append(self.unindentwarning()) + nodelist.append(self.unindent_warning('Literal block')) else: nodelist.append(self.statemachine.memo.reporter.warning( 'Literal block expected at line %s; none found.' -- cgit v1.2.1 From 630e79abef4ea3263ee70235cd85e1d8159e0321 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 25 Apr 2002 03:25:44 +0000 Subject: - Added RFC-2822 header support. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@36 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/__init__.py | 9 +++- docutils/parsers/rst/states.py | 105 +++++++++++++++++++++++++++++---------- 2 files changed, 87 insertions(+), 27 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/__init__.py b/docutils/parsers/rst/__init__.py index 06589513b..bbe7dfee6 100644 --- a/docutils/parsers/rst/__init__.py +++ b/docutils/parsers/rst/__init__.py @@ -56,12 +56,19 @@ class Parser(docutils.parsers.Parser): """The reStructuredText parser.""" + def __init__(self, rfc2822=None): + if rfc2822: + self.initialstate = 'RFC2822Body' + else: + self.initialstate = 'Body' + def parse(self, inputstring, docroot): """Parse `inputstring` and populate `docroot`, a document tree.""" self.setup_parse(inputstring, docroot) debug = docroot.reporter[''].debug self.statemachine = states.RSTStateMachine( - stateclasses=states.stateclasses, initialstate='Body', + stateclasses=states.stateclasses, + initialstate=self.initialstate, debug=debug) inputlines = docutils.statemachine.string2lines( inputstring, convertwhitespace=1) diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 706ed6106..efce3b4f1 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -6,21 +6,24 @@ :Copyright: This module has been placed in the public domain. This is the ``docutils.parsers.restructuredtext.states`` module, the core of -the reStructuredText parser. It defines the following: +the reStructuredText parser. It defines the following: :Classes: - `RSTStateMachine`: reStructuredText parser's entry point. - `NestedStateMachine`: recursive StateMachine. - `RSTState`: reStructuredText State superclass. - `Body`: Generic classifier of the first line of a block. + - `SpecializedBody`: Superclass for compound element members. - `BulletList`: Second and subsequent bullet_list list_items - - `DefinitionList`: Second and subsequent definition_list_items. - - `EnumeratedList`: Second and subsequent enumerated_list list_items. - - `FieldList`: Second and subsequent fields. - - `OptionList`: Second and subsequent option_list_items. - - `Explicit`: Second and subsequent explicit markup constructs. + - `DefinitionList`: Second+ definition_list_items. + - `EnumeratedList`: Second+ enumerated_list list_items. + - `FieldList`: Second+ fields. + - `OptionList`: Second+ option_list_items. + - `RFC2822List`: Second+ RFC2822-style fields. + - `Explicit`: Second+ explicit markup constructs. - `SubstitutionDef`: For embedded directives in substitution definitions. - `Text`: Classifier of second line of a text block. + - `SpecializedText`: Superclass for continuation lines of Text-variants. - `Definition`: Second line of potential definition_list_item. - `Line`: Second line of overlined section title or transition marker. - `Stuff`: An auxilliary collection class. @@ -28,12 +31,10 @@ the reStructuredText parser. It defines the following: :Exception classes: - `MarkupError` - `ParserError` - - `TransformationError` :Functions: - `escape2null()`: Return a string, escape-backslashes converted to nulls. - `unescape()`: Return a string, nulls removed or restored to backslashes. - - `normname()`: Return a case- and whitespace-normalized name. :Attributes: - `stateclasses`: set of State classes used with `RSTStateMachine`. @@ -42,22 +43,22 @@ Parser Overview =============== The reStructuredText parser is implemented as a state machine, examining its -input one line at a time. To understand how the parser works, please first -become familiar with the `docutils.statemachine` module. In the description +input one line at a time. To understand how the parser works, please first +become familiar with the `docutils.statemachine` module. In the description below, references are made to classes defined in this module; please see the individual classes for details. Parsing proceeds as follows: 1. The state machine examines each line of input, checking each of the - transition patterns of the state `Body`, in order, looking for a match. The - implicit transitions (blank lines and indentation) are checked before any - others. The 'text' transition is a catch-all (matches anything). + transition patterns of the state `Body`, in order, looking for a match. + The implicit transitions (blank lines and indentation) are checked before + any others. The 'text' transition is a catch-all (matches anything). 2. The method associated with the matched transition pattern is called. A. Some transition methods are self-contained, appending elements to the - document tree ('doctest' parses a doctest block). The parser's current + document tree ('doctest' parses a doctest block). The parser's current line index is advanced to the end of the element, and parsing continues with step 1. @@ -71,11 +72,11 @@ Parsing proceeds as follows: - A new state machine is created and its initial state is set to the appropriate specialized state (`BulletList` in the case of the - 'bullet' transition). This state machine is run to parse the compound + 'bullet' transition). This state machine is run to parse the compound element (or series of explicit markup elements), and returns as soon - as a non-member element is encountered. For example, the `BulletList` + as a non-member element is encountered. For example, the `BulletList` state machine aborts as soon as it encounters an element which is not - a list item of that bullet list. The optional omission of + a list item of that bullet list. The optional omission of inter-element blank lines is handled by the nested state machine. - The current line index is advanced to the end of the elements parsed, @@ -83,7 +84,7 @@ Parsing proceeds as follows: C. The result of the 'text' transition depends on the next line of text. The current state is changed to `Text`, under which the second line is - examined. If the second line is: + examined. If the second line is: - Indented: The element is a definition list item, and parsing proceeds similarly to step 2.B, using the `DefinitionList` state. @@ -93,8 +94,8 @@ Parsing proceeds as follows: used. - Anything else: The element is a paragraph, which is examined for - inline markup and appended to the parent element. Processing continues - with step 1. + inline markup and appended to the parent element. Processing + continues with step 1. """ __docformat__ = 'reStructuredText' @@ -865,7 +866,6 @@ class Body(RSTState): 'explicit_markup': r'\.\.( +|$)', 'anonymous': r'__( +|$)', 'line': r'(%(nonalphanum7bit)s)\1\1\1+ *$' % pats, - #'rfc822': r'[!-9;-~]+:( +|$)', 'text': r''} initialtransitions = ['bullet', 'enumerator', @@ -1666,6 +1666,49 @@ class Body(RSTState): return [match.string], 'Text', [] +class RFC2822Body(Body): + + """ + RFC2822 headers are only valid as the first constructs in documents. As + soon as anything else appears, the `Body` state should take over. + """ + + patterns = Body.patterns.copy() # can't modify the original + patterns['rfc2822'] = r'[!-9;-~]+:( +|$)' + initialtransitions = [(name, 'Body') for name in Body.initialtransitions] + initialtransitions.insert(-1, ('rfc2822', 'Body')) # just before 'text' + + def rfc2822(self, match, context, nextstate): + """RFC2822-style field list item.""" + fieldlist = nodes.field_list() + self.statemachine.node += fieldlist + field, blankfinish = self.rfc2822_field(match) + fieldlist += field + offset = self.statemachine.lineoffset + 1 # next line + newlineoffset, blankfinish = self.nestedlistparse( + self.statemachine.inputlines[offset:], + inputoffset=self.statemachine.abslineoffset() + 1, + node=fieldlist, initialstate='RFC2822List', + blankfinish=blankfinish) + if not blankfinish: + self.statemachine.node += self.unindent_warning( + 'RFC2822-style field list') + self.gotoline(newlineoffset) + return [], nextstate, [] + + def rfc2822_field(self, match): + name = match.string[:match.string.find(':')] + indented, indent, lineoffset, blankfinish = \ + self.statemachine.getfirstknownindented(match.end()) + fieldnode = nodes.field() + fieldnode += nodes.field_name(name, name) + fieldbody = nodes.field_body('\n'.join(indented)) + fieldnode += fieldbody + if indented: + self.nestedparse(indented, inputoffset=lineoffset, node=fieldbody) + return fieldnode, blankfinish + + class SpecializedBody(Body): """ @@ -1764,11 +1807,21 @@ class OptionList(SpecializedBody): return [], 'OptionList', [] -class RFC822List(SpecializedBody): +class RFC2822List(SpecializedBody, RFC2822Body): - """Second and subsequent RFC822 field_list fields.""" + """Second and subsequent RFC2822-style field_list fields.""" + + patterns = RFC2822Body.patterns + initialtransitions = RFC2822Body.initialtransitions + + def rfc2822(self, match, context, nextstate): + """RFC2822-style field list item.""" + field, blankfinish = self.rfc2822_field(match) + self.statemachine.node += field + self.blankfinish = blankfinish + return [], 'RFC2822List', [] - pass + blank = SpecializedBody.invalid_input class Explicit(SpecializedBody): @@ -2093,8 +2146,8 @@ class Line(SpecializedText): stateclasses = [Body, BulletList, DefinitionList, EnumeratedList, FieldList, - OptionList, RFC822List, Explicit, Text, Definition, Line, - SubstitutionDef] + OptionList, Explicit, Text, Definition, Line, SubstitutionDef, + RFC2822Body, RFC2822List] """Standard set of State classes used to start `RSTStateMachine`.""" -- cgit v1.2.1 From 73710935431dbf51b075781b9a5409eea6c41393 Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 5 May 2002 15:15:54 +0000 Subject: renamed parts.py from compontents.py git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@71 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/components.py | 59 ------------------------- docutils/parsers/rst/directives/parts.py | 62 +++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 59 deletions(-) delete mode 100644 docutils/parsers/rst/directives/components.py create mode 100644 docutils/parsers/rst/directives/parts.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/components.py b/docutils/parsers/rst/directives/components.py deleted file mode 100644 index 8463f41b0..000000000 --- a/docutils/parsers/rst/directives/components.py +++ /dev/null @@ -1,59 +0,0 @@ -#! /usr/bin/env python - -""" -:Author: David Goodger -:Contact: goodger@users.sourceforge.net -:Revision: $Revision$ -:Date: $Date$ -:Copyright: This module has been placed in the public domain. - -Document component directives. -""" - -__docformat__ = 'reStructuredText' - - -from docutils import nodes -import docutils.transforms.components - - -contents_attribute_spec = {'depth': int, - 'local': (lambda x: x)} - -def contents(match, typename, data, state, statemachine, attributes): - lineno = statemachine.abslineno() - lineoffset = statemachine.lineoffset - datablock, indent, offset, blankfinish = \ - statemachine.getfirstknownindented(match.end(), uptoblank=1) - blocktext = '\n'.join(statemachine.inputlines[ - lineoffset : lineoffset + len(datablock) + 1]) - for i in range(len(datablock)): - if datablock[i][:1] == ':': - attlines = datablock[i:] - datablock = datablock[:i] - break - else: - attlines = [] - i = 0 - titletext = ' '.join([line.strip() for line in datablock]) - if titletext: - textnodes, messages = state.inline_text(titletext, lineno) - title = nodes.title(titletext, '', *textnodes) - else: - messages = [] - title = None - pending = nodes.pending(docutils.transforms.components.Contents, - 'last_reader', {'title': title}, blocktext) - if attlines: - success, data, blankfinish = state.parse_extension_attributes( - contents_attribute_spec, attlines, blankfinish) - if success: # data is a dict of attributes - pending.details.update(data) - else: # data is an error string - error = statemachine.memo.reporter.error( - 'Error in "%s" directive attributes at line %s:\n%s.' - % (match.group(1), lineno, data), '', - nodes.literal_block(blocktext, blocktext)) - return [error] + messages, blankfinish - statemachine.memo.document.note_pending(pending) - return [pending] + messages, blankfinish diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py new file mode 100644 index 000000000..7b3d63697 --- /dev/null +++ b/docutils/parsers/rst/directives/parts.py @@ -0,0 +1,62 @@ +#! /usr/bin/env python + +""" +:Author: David Goodger +:Contact: goodger@users.sourceforge.net +:Revision: $Revision$ +:Date: $Date$ +:Copyright: This module has been placed in the public domain. + +Directives for document parts. +""" + +__docformat__ = 'reStructuredText' + +from docutils import nodes +from docutils.transforms import parts + + +def unchanged(arg): + return arg # unchanged! + +contents_attribute_spec = {'depth': int, + 'local': unchanged, + 'qa': unchanged} + +def contents(match, type_name, data, state, state_machine, attributes): + lineno = state_machine.abs_line_number() + line_offset = state_machine.line_offset + datablock, indent, offset, blank_finish = \ + state_machine.get_first_known_indented(match.end(), until_blank=1) + blocktext = '\n'.join(state_machine.input_lines[ + line_offset : line_offset + len(datablock) + 1]) + for i in range(len(datablock)): + if datablock[i][:1] == ':': + attlines = datablock[i:] + datablock = datablock[:i] + break + else: + attlines = [] + i = 0 + titletext = ' '.join([line.strip() for line in datablock]) + if titletext: + textnodes, messages = state.inline_text(titletext, lineno) + title = nodes.title(titletext, '', *textnodes) + else: + messages = [] + title = None + pending = nodes.pending(parts.Contents, 'last reader', {'title': title}, + blocktext) + if attlines: + success, data, blank_finish = state.parse_extension_attributes( + contents_attribute_spec, attlines, blank_finish) + if success: # data is a dict of attributes + pending.details.update(data) + else: # data is an error string + error = state_machine.reporter.error( + 'Error in "%s" directive attributes at line %s:\n%s.' + % (match.group(1), lineno, data), '', + nodes.literal_block(blocktext, blocktext)) + return [error] + messages, blank_finish + state_machine.document.note_pending(pending) + return [pending] + messages, blank_finish -- cgit v1.2.1 From f51354f5a1a68947246017a9c0e27644419d49bf Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 5 May 2002 15:16:56 +0000 Subject: Changed the ``meta`` directive to use a ``pending`` element, used only by HTML writers. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@72 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/html.py | 74 ++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 34 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/html.py b/docutils/parsers/rst/directives/html.py index d971300e0..262a124c8 100644 --- a/docutils/parsers/rst/directives/html.py +++ b/docutils/parsers/rst/directives/html.py @@ -15,32 +15,33 @@ __docformat__ = 'reStructuredText' from docutils import nodes, utils from docutils.parsers.rst import states +from docutils.transforms import components -def meta(match, typename, data, state, statemachine, attributes): - lineoffset = statemachine.lineoffset - block, indent, offset, blankfinish = \ - statemachine.getfirstknownindented(match.end(), uptoblank=1) +def meta(match, type_name, data, state, state_machine, attributes): + line_offset = state_machine.line_offset + block, indent, offset, blank_finish = \ + state_machine.get_first_known_indented(match.end(), until_blank=1) node = nodes.Element() if block: - newlineoffset, blankfinish = state.nestedlistparse( - block, offset, node, initialstate='MetaBody', - blankfinish=blankfinish, statemachinekwargs=metaSMkwargs) - if (newlineoffset - offset) != len(block): # incomplete parse of block? - blocktext = '\n'.join(statemachine.inputlines[ - lineoffset : statemachine.lineoffset+1]) - msg = statemachine.memo.reporter.error( + new_line_offset, blank_finish = state.nested_list_parse( + block, offset, node, initial_state='MetaBody', + blank_finish=blank_finish, state_machine_kwargs=metaSMkwargs) + if (new_line_offset - offset) != len(block): # incomplete parse of block? + blocktext = '\n'.join(state_machine.input_lines[ + line_offset : state_machine.line_offset+1]) + msg = state_machine.reporter.error( 'Invalid meta directive at line %s.' - % statemachine.abslineno(), '', + % state_machine.abs_line_number(), '', nodes.literal_block(blocktext, blocktext)) node += msg else: - msg = statemachine.memo.reporter.error( - 'Empty meta directive at line %s.' % statemachine.abslineno()) + msg = state_machine.reporter.error('Empty meta directive at line %s.' + % state_machine.abs_line_number()) node += msg - return node.getchildren(), blankfinish + return node.getchildren(), blank_finish -def imagemap(match, typename, data, state, statemachine, attributes): +def imagemap(match, type_name, data, state, state_machine, attributes): return [], 0 @@ -50,24 +51,27 @@ class MetaBody(states.SpecializedBody): """HTML-specific "meta" element.""" pass - def field_marker(self, match, context, nextstate): + def field_marker(self, match, context, next_state): """Meta element.""" - node, blankfinish = self.parsemeta(match) - self.statemachine.node += node - return [], nextstate, [] + node, blank_finish = self.parsemeta(match) + self.parent += node + return [], next_state, [] def parsemeta(self, match): name, args = self.parse_field_marker(match) - indented, indent, lineoffset, blankfinish = \ - self.statemachine.getfirstknownindented(match.end()) + indented, indent, line_offset, blank_finish = \ + self.state_machine.get_first_known_indented(match.end()) node = self.meta() + pending = nodes.pending(components.Filter, 'first writer', + {'writer': 'html', 'nodes': [node]}) node['content'] = ' '.join(indented) if not indented: - line = self.statemachine.line - msg = self.statemachine.memo.reporter.info( - 'No content for meta tag "%s".' % name, '', - nodes.literal_block(line, line)) - self.statemachine.node += msg + line = self.state_machine.line + msg = self.reporter.info( + 'No content for meta tag "%s" at line %s.' + % (name, self.state_machine.abs_line_number()), + '', nodes.literal_block(line, line)) + return msg, blank_finish try: attname, val = utils.extract_name_value(name)[0] node[attname.lower()] = val @@ -78,12 +82,14 @@ class MetaBody(states.SpecializedBody): attname, val = utils.extract_name_value(arg)[0] node[attname.lower()] = val except utils.NameValueError, detail: - line = self.statemachine.line - msg = self.statemachine.memo.reporter.error( - 'Error parsing meta tag attribute "%s": %s' - % (arg, detail), '', nodes.literal_block(line, line)) - self.statemachine.node += msg - return node, blankfinish + line = self.state_machine.line + msg = self.reporter.error( + 'Error parsing meta tag attribute "%s" at line %s: %s.' + % (arg, self.state_machine.abs_line_number(), detail), + '', nodes.literal_block(line, line)) + return msg, blank_finish + self.document.note_pending(pending) + return pending, blank_finish -metaSMkwargs = {'stateclasses': (MetaBody,)} +metaSMkwargs = {'state_classes': (MetaBody,)} -- cgit v1.2.1 From e13920cf12052d05709108e6c787817b8b36c42e Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 5 May 2002 15:19:18 +0000 Subject: refactored; improved compound names git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@73 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/__init__.py | 25 ++++++----- docutils/parsers/rst/__init__.py | 38 ++++++++-------- docutils/parsers/rst/directives/__init__.py | 19 ++++---- docutils/parsers/rst/directives/admonitions.py | 12 +++--- docutils/parsers/rst/directives/images.py | 60 +++++++++++++------------- docutils/parsers/rst/directives/misc.py | 22 +++++----- 6 files changed, 92 insertions(+), 84 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/__init__.py b/docutils/parsers/__init__.py index 72e2e4e49..0294da0f8 100644 --- a/docutils/parsers/__init__.py +++ b/docutils/parsers/__init__.py @@ -10,28 +10,31 @@ __docformat__ = 'reStructuredText' +from docutils import Component -class Parser: - def parse(self, inputstring, docroot): - """Override to parse `inputstring` into document tree `docroot`.""" +class Parser(Component): + + def parse(self, inputstring, document): + """Override to parse `inputstring` into document tree `document`.""" raise NotImplementedError('subclass must override this method') - def setup_parse(self, inputstring, docroot): + def setup_parse(self, inputstring, document): """Initial setup, used by `parse()`.""" self.inputstring = inputstring - self.docroot = docroot + self.document = document _parser_aliases = { 'restructuredtext': 'rst', 'rest': 'rst', + 'restx': 'rst', 'rtxt': 'rst',} -def get_parser_class(parsername): - """Return the Parser class from the `parsername` module.""" - parsername = parsername.lower() - if _parser_aliases.has_key(parsername): - parsername = _parser_aliases[parsername] - module = __import__(parsername, globals(), locals()) +def get_parser_class(parser_name): + """Return the Parser class from the `parser_name` module.""" + parser_name = parser_name.lower() + if _parser_aliases.has_key(parser_name): + parser_name = _parser_aliases[parser_name] + module = __import__(parser_name, globals(), locals()) return module.Parser diff --git a/docutils/parsers/rst/__init__.py b/docutils/parsers/rst/__init__.py index bbe7dfee6..506a9e9fb 100644 --- a/docutils/parsers/rst/__init__.py +++ b/docutils/parsers/rst/__init__.py @@ -7,8 +7,7 @@ :Date: $Date$ :Copyright: This module has been placed in the public domain. -This is ``the docutils.parsers.restructuredtext`` package. It exports a single -class, `Parser`. +This is ``docutils.parsers.rst`` package. It exports a single class, `Parser`. Usage ===== @@ -27,13 +26,13 @@ Usage 3. Create a new empty `docutils.nodes.document` tree:: - docroot = docutils.utils.newdocument() + document = docutils.utils.new_document() - See `docutils.utils.newdocument()` for parameter details. + See `docutils.utils.new_document()` for parameter details. 4. Run the parser, populating the document tree:: - document = parser.parse(input, docroot) + parser.parse(input, document) Parser Overview =============== @@ -56,20 +55,25 @@ class Parser(docutils.parsers.Parser): """The reStructuredText parser.""" - def __init__(self, rfc2822=None): + supported = ('restructuredtext', 'rst', 'rest', 'restx', 'rtxt', 'rstx') + """Aliases this parser supports.""" + + def __init__(self, rfc2822=None, inliner=None): if rfc2822: - self.initialstate = 'RFC2822Body' + self.initial_state = 'RFC2822Body' else: - self.initialstate = 'Body' - - def parse(self, inputstring, docroot): - """Parse `inputstring` and populate `docroot`, a document tree.""" - self.setup_parse(inputstring, docroot) - debug = docroot.reporter[''].debug + self.initial_state = 'Body' + self.state_classes = states.state_classes + self.inliner = inliner + + def parse(self, inputstring, document): + """Parse `inputstring` and populate `document`, a document tree.""" + self.setup_parse(inputstring, document) + debug = document.reporter[''].debug self.statemachine = states.RSTStateMachine( - stateclasses=states.stateclasses, - initialstate=self.initialstate, + state_classes=self.state_classes, + initial_state=self.initial_state, debug=debug) inputlines = docutils.statemachine.string2lines( - inputstring, convertwhitespace=1) - self.statemachine.run(inputlines, docroot) + inputstring, convert_whitespace=1) + self.statemachine.run(inputlines, document, inliner=self.inliner) diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 43b0c1dd3..89d273651 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -11,17 +11,17 @@ This package contains directive implementation modules. The interface for directive functions is as follows:: - def directivefn(match, type, data, state, statemachine, attributes) + def directivefn(match, type_name, data, state, state_machine, attributes) Where: - ``match`` is a regular expression match object which matched the first line of the directive. ``match.group(1)`` gives the directive name. -- ``type`` is the directive type or name. +- ``type_name`` is the directive type or name. - ``data`` contains the remainder of the first line of the directive after the "::". - ``state`` is the state which called the directive function. -- ``statemachine`` is the state machine which controls the state which called +- ``state_machine`` is the state machine which controls the state which called the directive function. - ``attributes`` is a dictionary of extra attributes which may be added to the element the directive produces. Currently, only an "alt" attribute is passed @@ -42,15 +42,16 @@ _directive_registry = { 'tip': ('admonitions', 'tip'), 'hint': ('admonitions', 'hint'), 'warning': ('admonitions', 'warning'), + 'questions': ('body', 'question_list'), 'image': ('images', 'image'), 'figure': ('images', 'figure'), - 'contents': ('components', 'contents'), - 'footnotes': ('components', 'footnotes'), - 'citations': ('components', 'citations'), - 'topic': ('components', 'topic'), + 'contents': ('parts', 'contents'), + #'footnotes': ('parts', 'footnotes'), + #'citations': ('parts', 'citations'), + #'topic': ('parts', 'topic'), 'meta': ('html', 'meta'), - 'imagemap': ('html', 'imagemap'), - 'raw': ('misc', 'raw'), + #'imagemap': ('html', 'imagemap'), + #'raw': ('misc', 'raw'), 'restructuredtext-test-directive': ('misc', 'directive_test_function'),} """Mapping of directive name to (module name, function name). The directive 'name' is canonical & must be lowercase; language-dependent names are defined diff --git a/docutils/parsers/rst/directives/admonitions.py b/docutils/parsers/rst/directives/admonitions.py index f594cd431..9e6b0ebf7 100644 --- a/docutils/parsers/rst/directives/admonitions.py +++ b/docutils/parsers/rst/directives/admonitions.py @@ -17,15 +17,15 @@ from docutils.parsers.rst import states from docutils import nodes -def admonition(nodeclass, match, typename, data, state, statemachine, +def admonition(node_class, match, type_name, data, state, state_machine, attributes): - indented, indent, lineoffset, blankfinish \ - = statemachine.getfirstknownindented(match.end()) + indented, indent, line_offset, blank_finish \ + = state_machine.get_first_known_indented(match.end()) text = '\n'.join(indented) - admonitionnode = nodeclass(text) + admonition_node = node_class(text) if text: - state.nestedparse(indented, lineoffset, admonitionnode) - return [admonitionnode], blankfinish + state.nested_parse(indented, line_offset, admonition_node) + return [admonition_node], blank_finish def attention(*args, **kwargs): return admonition(nodes.attention, *args, **kwargs) diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index 7a719333b..76e5d6f47 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -25,13 +25,13 @@ image_attribute_spec = {'alt': unchanged, 'width': int, 'scale': int} -def image(match, typename, data, state, statemachine, attributes): - lineno = statemachine.abslineno() - lineoffset = statemachine.lineoffset - datablock, indent, offset, blankfinish = \ - statemachine.getfirstknownindented(match.end(), uptoblank=1) - blocktext = '\n'.join(statemachine.inputlines[ - lineoffset : lineoffset + len(datablock) + 1]) +def image(match, type_name, data, state, state_machine, attributes): + lineno = state_machine.abs_line_number() + line_offset = state_machine.line_offset + datablock, indent, offset, blank_finish = \ + state_machine.get_first_known_indented(match.end(), until_blank=1) + blocktext = '\n'.join(state_machine.input_lines[ + line_offset : line_offset + len(datablock) + 1]) for i in range(len(datablock)): if datablock[i][:1] == ':': attlines = datablock[i:] @@ -40,58 +40,58 @@ def image(match, typename, data, state, statemachine, attributes): else: attlines = [] if not datablock: - error = statemachine.memo.reporter.error( + error = state_machine.reporter.error( 'Missing image URI argument at line %s.' % lineno, '', nodes.literal_block(blocktext, blocktext)) - return [error], blankfinish - attoffset = lineoffset + i + return [error], blank_finish + attoffset = line_offset + i reference = ''.join([line.strip() for line in datablock]) if reference.find(' ') != -1: - error = statemachine.memo.reporter.error( + error = state_machine.reporter.error( 'Image URI at line %s contains whitespace.' % lineno, '', nodes.literal_block(blocktext, blocktext)) - return [error], blankfinish + return [error], blank_finish if attlines: - success, data, blankfinish = state.parse_extension_attributes( - image_attribute_spec, attlines, blankfinish) + success, data, blank_finish = state.parse_extension_attributes( + image_attribute_spec, attlines, blank_finish) if success: # data is a dict of attributes attributes.update(data) else: # data is an error string - error = statemachine.memo.reporter.error( + error = state_machine.reporter.error( 'Error in "%s" directive attributes at line %s:\n%s.' % (match.group(1), lineno, data), '', nodes.literal_block(blocktext, blocktext)) - return [error], blankfinish + return [error], blank_finish attributes['uri'] = reference imagenode = nodes.image(blocktext, **attributes) - return [imagenode], blankfinish + return [imagenode], blank_finish -def figure(match, typename, data, state, statemachine, attributes): - lineoffset = statemachine.lineoffset - (imagenode,), blankfinish = image(match, typename, data, state, - statemachine, attributes) - indented, indent, offset, blankfinish \ - = statemachine.getfirstknownindented(sys.maxint) - blocktext = '\n'.join(statemachine.inputlines[lineoffset: - statemachine.lineoffset+1]) +def figure(match, type_name, data, state, state_machine, attributes): + line_offset = state_machine.line_offset + (imagenode,), blank_finish = image(match, type_name, data, state, + state_machine, attributes) + indented, indent, offset, blank_finish \ + = state_machine.get_first_known_indented(sys.maxint) + blocktext = '\n'.join(state_machine.input_lines[line_offset: + state_machine.line_offset+1]) if isinstance(imagenode, nodes.system_message): if indented: imagenode[-1] = nodes.literal_block(blocktext, blocktext) - return [imagenode], blankfinish + return [imagenode], blank_finish figurenode = nodes.figure('', imagenode) if indented: node = nodes.Element() # anonymous container for parsing - state.nestedparse(indented, lineoffset, node) + state.nested_parse(indented, line_offset, node) firstnode = node[0] if isinstance(firstnode, nodes.paragraph): caption = nodes.caption(firstnode.rawsource, '', *firstnode.children) figurenode += caption elif not (isinstance(firstnode, nodes.comment) and len(firstnode) == 0): - error = statemachine.memo.reporter.error( + error = state_machine.reporter.error( 'Figure caption must be a paragraph or empty comment.', '', nodes.literal_block(blocktext, blocktext)) - return [figurenode, error], blankfinish + return [figurenode, error], blank_finish if len(node) > 1: figurenode += nodes.legend('', *node[1:]) - return [figurenode], blankfinish + return [figurenode], blank_finish diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index f8a9d5217..3a23f9226 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -16,24 +16,24 @@ __docformat__ = 'reStructuredText' from docutils import nodes -def raw(match, typename, data, state, statemachine, attributes): +def raw(match, type_name, data, state, state_machine, attributes): return [], 1 -def directive_test_function(match, typename, data, state, statemachine, +def directive_test_function(match, type_name, data, state, state_machine, attributes): try: - statemachine.nextline() - indented, indent, offset, blankfinish = statemachine.getindented() + state_machine.next_line() + indented, indent, offset, blank_finish = state_machine.get_indented() text = '\n'.join(indented) except IndexError: text = '' - blankfinish = 1 + blank_finish = 1 if text: - info = statemachine.memo.reporter.info( + info = state_machine.reporter.info( 'Directive processed. Type="%s", data="%s", directive block:' - % (typename, data), '', nodes.literal_block(text, text)) + % (type_name, data), '', nodes.literal_block(text, text)) else: - info = statemachine.memo.reporter.info( - 'Directive processed. Type="%s", data="%s", directive block: None' - % (typename, data)) - return [info], blankfinish + info = state_machine.reporter.info( + 'Directive processed. Type="%s", data="%s", directive block: ' + 'None' % (type_name, data)) + return [info], blank_finish -- cgit v1.2.1 From 409668ba1ca8fbe197893dd7874acdf5f81c41eb Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 5 May 2002 15:19:26 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@74 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/tableparser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/tableparser.py b/docutils/parsers/rst/tableparser.py index 7bacf99cd..3f7575040 100644 --- a/docutils/parsers/rst/tableparser.py +++ b/docutils/parsers/rst/tableparser.py @@ -19,9 +19,10 @@ __docformat__ = 'reStructuredText' import re +from docutils import DataError -class TableMarkupError(Exception): pass +class TableMarkupError(DataError): pass class TableParser: -- cgit v1.2.1 From c854d0803dd10573ea908840b85d12499904b060 Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 5 May 2002 15:22:30 +0000 Subject: - Added underscores to improve many awkward names. - Extracted the inline parsing code from ``RSTState`` to a separate class, ``Inliner``, which will allow easy subclassing. - Made local bindings for ``memo`` container & often-used contents (reduces code complexity a lot). See ``RSTState.runtime_init()``. - ``RSTState.parent`` replaces ``RSTState.statemachine.node``. - Added ``MarkupMismatch`` exception; for late corrections. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@75 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 1787 +++++++++++++++++++++------------------- 1 file changed, 919 insertions(+), 868 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index efce3b4f1..d2a133198 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -31,13 +31,14 @@ the reStructuredText parser. It defines the following: :Exception classes: - `MarkupError` - `ParserError` + - `MarkupMismatch` :Functions: - `escape2null()`: Return a string, escape-backslashes converted to nulls. - `unescape()`: Return a string, nulls removed or restored to backslashes. :Attributes: - - `stateclasses`: set of State classes used with `RSTStateMachine`. + - `state_classes`: set of State classes used with `RSTStateMachine`. Parser Overview =============== @@ -102,15 +103,17 @@ __docformat__ = 'reStructuredText' import sys, re, string -from docutils import nodes, statemachine, utils, roman, urischemes +from docutils import nodes, statemachine, utils, roman, urischemes, \ + ApplicationError, DataError from docutils.statemachine import StateMachineWS, StateWS -from docutils.utils import normname +from docutils.utils import normalize_name import directives, languages from tableparser import TableParser, TableMarkupError -class MarkupError(Exception): pass -class ParserError(Exception): pass +class MarkupError(DataError): pass +class ParserError(ApplicationError): pass +class MarkupMismatch(Exception): pass class Stuff: @@ -129,24 +132,30 @@ class RSTStateMachine(StateMachineWS): The entry point to reStructuredText parsing is the `run()` method. """ - def run(self, inputlines, docroot, inputoffset=0, matchtitles=1): + def run(self, input_lines, document, input_offset=0, match_titles=1, + inliner=None): """ - Parse `inputlines` and return a `docutils.nodes.document` instance. + Parse `input_lines` and return a `docutils.nodes.document` instance. Extend `StateMachineWS.run()`: set up parse-global data, run the StateMachine, and return the resulting document. """ - self.language = languages.getlanguage(docroot.languagecode) - self.matchtitles = matchtitles - self.memo = Stuff(document=docroot, - reporter=docroot.reporter, + self.language = languages.getlanguage(document.language_code) + self.match_titles = match_titles + if inliner is None: + inliner = Inliner() + self.memo = Stuff(document=document, + reporter=document.reporter, language=self.language, - titlestyles=[], - sectionlevel=0) - self.node = docroot - results = StateMachineWS.run(self, inputlines, inputoffset) - assert results == [], 'RSTStateMachine.run() results should be empty.' + title_styles=[], + section_level=0, + inliner=inliner) + self.document = self.memo.document + self.reporter = self.memo.reporter + self.node = document + results = StateMachineWS.run(self, input_lines, input_offset) + assert results == [], 'RSTStateMachine.run() results should be empty!' self.node = self.memo = None # remove unneeded references @@ -157,17 +166,20 @@ class NestedStateMachine(StateMachineWS): document structures. """ - def run(self, inputlines, inputoffset, memo, node, matchtitles=1): + def run(self, input_lines, input_offset, memo, node, match_titles=1): """ - Parse `inputlines` and populate a `docutils.nodes.document` instance. + Parse `input_lines` and populate a `docutils.nodes.document` instance. Extend `StateMachineWS.run()`: set up document-wide data. """ - self.matchtitles = matchtitles + self.match_titles = match_titles self.memo = memo + self.document = memo.document + self.reporter = memo.reporter self.node = node - results = StateMachineWS.run(self, inputlines, inputoffset) - assert results == [], 'NestedStateMachine.run() results should be empty' + results = StateMachineWS.run(self, input_lines, input_offset) + assert results == [], ('NestedStateMachine.run() results should be ' + 'empty!') return results @@ -179,17 +191,28 @@ class RSTState(StateWS): Contains methods used by all State subclasses. """ - nestedSM = NestedStateMachine + nested_sm = NestedStateMachine - def __init__(self, statemachine, debug=0): - self.nestedSMkwargs = {'stateclasses': stateclasses, - 'initialstate': 'Body'} - StateWS.__init__(self, statemachine, debug) + def __init__(self, state_machine, debug=0): + self.nested_sm_kwargs = {'state_classes': state_classes, + 'initial_state': 'Body'} + StateWS.__init__(self, state_machine, debug) - def gotoline(self, abslineoffset): - """Jump to input line `abslineoffset`, ignoring jumps past the end.""" + def runtime_init(self): + StateWS.runtime_init(self) + memo = self.state_machine.memo + self.memo = memo + self.reporter = memo.reporter + self.inliner = memo.inliner + self.document = memo.document + self.parent = self.state_machine.node + + def goto_line(self, abs_line_offset): + """ + Jump to input line `abs_line_offset`, ignoring jumps past the end. + """ try: - self.statemachine.gotoline(abslineoffset) + self.state_machine.goto_line(abs_line_offset) except IndexError: pass @@ -197,126 +220,131 @@ class RSTState(StateWS): """Called at beginning of file.""" return [], [] - def nestedparse(self, block, inputoffset, node, matchtitles=0, - statemachineclass=None, statemachinekwargs=None): + def nested_parse(self, block, input_offset, node, match_titles=0, + state_machine_class=None, state_machine_kwargs=None): """ Create a new StateMachine rooted at `node` and run it over the input `block`. """ - if statemachineclass is None: - statemachineclass = self.nestedSM - if statemachinekwargs is None: - statemachinekwargs = self.nestedSMkwargs - statemachine = statemachineclass(debug=self.debug, **statemachinekwargs) - statemachine.run(block, inputoffset, memo=self.statemachine.memo, - node=node, matchtitles=matchtitles) - statemachine.unlink() - return statemachine.abslineoffset() - - def nestedlistparse(self, block, inputoffset, node, initialstate, - blankfinish, blankfinishstate=None, extrasettings={}, - matchtitles=0, statemachineclass=None, - statemachinekwargs=None): + if state_machine_class is None: + state_machine_class = self.nested_sm + if state_machine_kwargs is None: + state_machine_kwargs = self.nested_sm_kwargs + state_machine = state_machine_class(debug=self.debug, + **state_machine_kwargs) + state_machine.run(block, input_offset, memo=self.memo, + node=node, match_titles=match_titles) + state_machine.unlink() + return state_machine.abs_line_offset() + + def nested_list_parse(self, block, input_offset, node, initial_state, + blank_finish, + blank_finish_state=None, + extra_settings={}, + match_titles=0, + state_machine_class=None, + state_machine_kwargs=None): """ Create a new StateMachine rooted at `node` and run it over the input `block`. Also keep track of optional intermdediate blank lines and the required final one. """ - if statemachineclass is None: - statemachineclass = self.nestedSM - if statemachinekwargs is None: - statemachinekwargs = self.nestedSMkwargs.copy() - statemachinekwargs['initialstate'] = initialstate - statemachine = statemachineclass(debug=self.debug, **statemachinekwargs) - if blankfinishstate is None: - blankfinishstate = initialstate - statemachine.states[blankfinishstate].blankfinish = blankfinish - for key, value in extrasettings.items(): - setattr(statemachine.states[initialstate], key, value) - statemachine.run(block, inputoffset, memo=self.statemachine.memo, - node=node, matchtitles=matchtitles) - blankfinish = statemachine.states[blankfinishstate].blankfinish - statemachine.unlink() - return statemachine.abslineoffset(), blankfinish + if state_machine_class is None: + state_machine_class = self.nested_sm + if state_machine_kwargs is None: + state_machine_kwargs = self.nested_sm_kwargs.copy() + state_machine_kwargs['initial_state'] = initial_state + state_machine = state_machine_class(debug=self.debug, + **state_machine_kwargs) + if blank_finish_state is None: + blank_finish_state = initial_state + state_machine.states[blank_finish_state].blank_finish = blank_finish + for key, value in extra_settings.items(): + setattr(state_machine.states[initial_state], key, value) + state_machine.run(block, input_offset, memo=self.memo, + node=node, match_titles=match_titles) + blank_finish = state_machine.states[blank_finish_state].blank_finish + state_machine.unlink() + return state_machine.abs_line_offset(), blank_finish def section(self, title, source, style, lineno): + """Check for a valid subsection and create one if it checks out.""" + if self.check_subsection(source, style, lineno): + self.new_subsection(title, lineno) + + def check_subsection(self, source, style, lineno): """ + Check for a valid subsection header. Return 1 (true) or None (false). + When a new section is reached that isn't a subsection of the current - section, back up the line count (use previousline(-x)), then raise - EOFError. The current StateMachine will finish, then the calling - StateMachine can re-examine the title. This will work its way back up - the calling chain until the correct section level isreached. + section, back up the line count (use ``previous_line(-x)``), then + ``raise EOFError``. The current StateMachine will finish, then the + calling StateMachine can re-examine the title. This will work its way + back up the calling chain until the correct section level isreached. - Alternative: Evaluate the title, store the title info & level, and - back up the chain until that level is reached. Store in memo? Or + @@@ Alternative: Evaluate the title, store the title info & level, and + back up the chain until that level is reached. Store in memo? Or return in results? - """ - if self.checksubsection(source, style, lineno): - self.newsubsection(title, lineno) - - def checksubsection(self, source, style, lineno): - """ - Check for a valid subsection header. Return 1 (true) or None (false). :Exception: `EOFError` when a sibling or supersection encountered. """ - memo = self.statemachine.memo - titlestyles = memo.titlestyles - mylevel = memo.sectionlevel + memo = self.memo + title_styles = memo.title_styles + mylevel = memo.section_level try: # check for existing title style - level = titlestyles.index(style) + 1 + level = title_styles.index(style) + 1 except ValueError: # new title style - if len(titlestyles) == memo.sectionlevel: # new subsection - titlestyles.append(style) + if len(title_styles) == memo.section_level: # new subsection + title_styles.append(style) return 1 else: # not at lowest level - self.statemachine.node += self.titleinconsistent(source, lineno) + self.parent += self.title_inconsistent(source, lineno) return None if level <= mylevel: # sibling or supersection - memo.sectionlevel = level # bubble up to parent section + memo.section_level = level # bubble up to parent section # back up 2 lines for underline title, 3 for overline title - self.statemachine.previousline(len(style) + 1) + self.state_machine.previous_line(len(style) + 1) raise EOFError # let parent section re-evaluate if level == mylevel + 1: # immediate subsection return 1 else: # invalid subsection - self.statemachine.node += self.titleinconsistent(source, lineno) + self.parent += self.title_inconsistent(source, lineno) return None - def titleinconsistent(self, sourcetext, lineno): + def title_inconsistent(self, sourcetext, lineno): literalblock = nodes.literal_block('', sourcetext) - error = self.statemachine.memo.reporter.severe( - 'Title level inconsistent at line %s:' % lineno, '', literalblock) + error = self.reporter.severe('Title level inconsistent at line %s:' + % lineno, '', literalblock) return error - def newsubsection(self, title, lineno): + def new_subsection(self, title, lineno): """Append new subsection to document tree. On return, check level.""" - memo = self.statemachine.memo - mylevel = memo.sectionlevel - memo.sectionlevel += 1 + memo = self.memo + mylevel = memo.section_level + memo.section_level += 1 sectionnode = nodes.section() - self.statemachine.node += sectionnode + self.parent += sectionnode textnodes, messages = self.inline_text(title, lineno) titlenode = nodes.title(title, '', *textnodes) - name = normname(titlenode.astext()) + name = normalize_name(titlenode.astext()) sectionnode['name'] = name sectionnode += titlenode sectionnode += messages - memo.document.note_implicit_target(sectionnode, sectionnode) - offset = self.statemachine.lineoffset + 1 - absoffset = self.statemachine.abslineoffset() + 1 - newabsoffset = self.nestedparse( - self.statemachine.inputlines[offset:], inputoffset=absoffset, - node=sectionnode, matchtitles=1) - self.gotoline(newabsoffset) - if memo.sectionlevel <= mylevel: # can't handle next section? + self.document.note_implicit_target(sectionnode, sectionnode) + offset = self.state_machine.line_offset + 1 + absoffset = self.state_machine.abs_line_offset() + 1 + newabsoffset = self.nested_parse( + self.state_machine.input_lines[offset:], input_offset=absoffset, + node=sectionnode, match_titles=1) + self.goto_line(newabsoffset) + if memo.section_level <= mylevel: # can't handle next section? raise EOFError # bubble up to supersection - # reset sectionlevel; next pass will detect it properly - memo.sectionlevel = mylevel + # reset section_level; next pass will detect it properly + memo.section_level = mylevel def paragraph(self, lines, lineno): """ - Return a list (paragraph & messages) and a boolean: literal_block next? + Return a list (paragraph & messages) & a boolean: literal_block next? """ data = '\n'.join(lines).rstrip() if data[-2:] == '::': @@ -334,143 +362,203 @@ class RSTState(StateWS): p = nodes.paragraph(data, '', *textnodes) return [p] + messages, literalnext - inline = Stuff() - """Patterns and constants used for inline markup recognition.""" - - inline.openers = '\'"([{<' - inline.closers = '\'")]}>' - inline.start_string_prefix = (r'(?:(?<=^)|(?<=[ \n%s]))' - % re.escape(inline.openers)) - inline.end_string_suffix = (r'(?:(?=$)|(?=[- \n.,:;!?%s]))' - % re.escape(inline.closers)) - inline.non_whitespace_before = r'(?' + start_string_prefix = (r'(?:(?<=^)|(?<=[ \n%s]))' + % re.escape(openers)) + end_string_suffix = (r'(?:(?=$)|(?=[- \n.,:;!?%s]))' + % re.escape(closers)) + non_whitespace_before = r'(? 0: - textnodes.append(nodes.Text(unescape( - remainder[:match.start(whole)]))) - if match.group(email): - addscheme = 'mailto:' - else: - addscheme = '' - text = match.group(whole) - unescaped = unescape(text, 0) - textnodes.append( - nodes.reference(unescape(text, 1), unescaped, - refuri=addscheme + unescaped)) - remainder = remainder[match.end(whole):] - start = 0 - else: # not a valid scheme - start = match.end(whole) + def standalone_uri(self, match, lineno): + scheme = self.groups.uri.scheme + if not match.group(scheme) or urischemes.schemes.has_key( + match.group(scheme).lower()): + if match.group(self.groups.uri.email): + addscheme = 'mailto:' else: - if remainder: - textnodes.append(nodes.Text(unescape(remainder))) - break - return textnodes - - inline.dispatch = {'*': emphasis, - '**': strong, - '`': interpreted_or_phrase_ref, - '``': literal, - '_`': inline_target, - ']_': footnote_reference, - '|': substitution_reference, - '_': reference, - '__': anonymous_reference} - - def inline_text(self, text, lineno): + addscheme = '' + text = match.group(self.groups.uri.whole) + unescaped = unescape(text, 0) + return [nodes.reference(unescape(text, 1), unescaped, + refuri=addscheme + unescaped)] + else: # not a valid scheme + raise MarkupMismatch + + implicit = ((patterns.uri, standalone_uri),) + """List of (pattern, dispatch method) pairs.""" + + def implicit_inline(self, text, lineno): """ - Return 2 lists: nodes (text and inline elements), and system_messages. - - Using a `pattern` matching start-strings (for emphasis, strong, - interpreted, phrase reference, literal, substitution reference, and - inline target) or complete constructs (simple reference, footnote - reference) we search for a candidate. When one is found, we check for - validity (e.g., not a quoted '*' character). If valid, search for the - corresponding end string if applicable, and check for validity. If not - found or invalid, generate a warning and ignore the start-string. - Standalone hyperlinks are found last. + Check each of the patterns in `self.implicit` for a match, and + dispatch to the stored method for the pattern. Recursively check the + text before and after the match. """ - pattern = self.inline.patterns.initial - dispatch = self.inline.dispatch - start = self.inline.groups.initial.start - 1 - backquote = self.inline.groups.initial.backquote - 1 - refend = self.inline.groups.initial.refend - 1 - fnend = self.inline.groups.initial.fnend - 1 - remaining = escape2null(text) - processed = [] - unprocessed = [] - messages = [] - while remaining: - match = pattern.search(remaining) + if not text: + return [] + for pattern, dispatch in self.implicit: + match = pattern.search(text) if match: - groups = match.groups() - before, inlines, remaining, sysmessages = \ - dispatch[groups[start] or groups[backquote] - or groups[refend] - or groups[fnend]](self, match, lineno) - unprocessed.append(before) - messages += sysmessages - if inlines: - processed += self.standalone_uri(''.join(unprocessed), - lineno) - processed += inlines - unprocessed = [] - else: - break - remaining = ''.join(unprocessed) + remaining - if remaining: - processed += self.standalone_uri(remaining, lineno) - return processed, messages - - def unindent_warning(self, node_name): - return self.statemachine.memo.reporter.warning( - ('%s ends without a blank line; unexpected unindent at line %s.' - % (node_name, self.statemachine.abslineno() + 1))) + try: + return (self.implicit_inline(text[:match.start()], lineno) + + dispatch(self, match, lineno) + + self.implicit_inline(text[match.end():], lineno)) + except MarkupMismatch: + pass + return [nodes.Text(unescape(text))] + + dispatch = {'*': emphasis, + '**': strong, + '`': interpreted_or_phrase_ref, + '``': literal, + '_`': inline_target, + ']_': footnote_reference, + '|': substitution_reference, + '_': reference, + '__': anonymous_reference} class Body(RSTState): @@ -830,10 +870,10 @@ class Body(RSTState): enum.sequenceregexps = {} for sequence in enum.sequences: - enum.sequenceregexps[sequence] = re.compile(enum.sequencepats[sequence] - + '$') + enum.sequenceregexps[sequence] = re.compile( + enum.sequencepats[sequence] + '$') - tabletoppat = re.compile(r'\+-[-+]+-\+ *$') + table_top_pat = re.compile(r'\+-[-+]+-\+ *$') """Matches the top (& bottom) of a table).""" tableparser = TableParser() @@ -856,114 +896,116 @@ class Body(RSTState): format, re.escape(enum.formatinfo[format].prefix), pats['enum'], re.escape(enum.formatinfo[format].suffix)) - patterns = {'bullet': r'[-+*]( +|$)', - 'enumerator': r'(%(parens)s|%(rparen)s|%(period)s)( +|$)' - % pats, - 'field_marker': r':[^: ]([^:]*[^: ])?:( +|$)', - 'option_marker': r'%(option)s(, %(option)s)*( +| ?$)' % pats, - 'doctest': r'>>>( +|$)', - 'tabletop': tabletoppat, - 'explicit_markup': r'\.\.( +|$)', - 'anonymous': r'__( +|$)', - 'line': r'(%(nonalphanum7bit)s)\1\1\1+ *$' % pats, - 'text': r''} - initialtransitions = ['bullet', - 'enumerator', - 'field_marker', - 'option_marker', - 'doctest', - 'tabletop', - 'explicit_markup', - 'anonymous', - 'line', - 'text'] - - def indent(self, match, context, nextstate): + patterns = { + 'bullet': r'[-+*]( +|$)', + 'enumerator': r'(%(parens)s|%(rparen)s|%(period)s)( +|$)' % pats, + 'field_marker': r':[^: ]([^:]*[^: ])?:( +|$)', + 'option_marker': r'%(option)s(, %(option)s)*( +| ?$)' % pats, + 'doctest': r'>>>( +|$)', + 'table_top': table_top_pat, + 'explicit_markup': r'\.\.( +|$)', + 'anonymous': r'__( +|$)', + 'line': r'(%(nonalphanum7bit)s)\1\1\1+ *$' % pats, + 'text': r''} + initial_transitions = ( + 'bullet', + 'enumerator', + 'field_marker', + 'option_marker', + 'doctest', + 'table_top', + 'explicit_markup', + 'anonymous', + 'line', + 'text') + + def indent(self, match, context, next_state): """Block quote.""" - indented, indent, lineoffset, blankfinish = \ - self.statemachine.getindented() - blockquote = self.block_quote(indented, lineoffset) - self.statemachine.node += blockquote - if not blankfinish: - self.statemachine.node += self.unindent_warning('Block quote') - return context, nextstate, [] - - def block_quote(self, indented, lineoffset): + indented, indent, line_offset, blank_finish = \ + self.state_machine.get_indented() + blockquote = self.block_quote(indented, line_offset) + self.parent += blockquote + if not blank_finish: + self.parent += self.unindent_warning('Block quote') + return context, next_state, [] + + def block_quote(self, indented, line_offset): blockquote = nodes.block_quote() - self.nestedparse(indented, lineoffset, blockquote) + self.nested_parse(indented, line_offset, blockquote) return blockquote - def bullet(self, match, context, nextstate): + def bullet(self, match, context, next_state): """Bullet list item.""" bulletlist = nodes.bullet_list() - self.statemachine.node += bulletlist + self.parent += bulletlist bulletlist['bullet'] = match.string[0] - i, blankfinish = self.list_item(match.end()) + i, blank_finish = self.list_item(match.end()) bulletlist += i - offset = self.statemachine.lineoffset + 1 # next line - newlineoffset, blankfinish = self.nestedlistparse( - self.statemachine.inputlines[offset:], - inputoffset=self.statemachine.abslineoffset() + 1, - node=bulletlist, initialstate='BulletList', - blankfinish=blankfinish) - if not blankfinish: - self.statemachine.node += self.unindent_warning('Bullet list') - self.gotoline(newlineoffset) - return [], nextstate, [] + offset = self.state_machine.line_offset + 1 # next line + newline_offset, blank_finish = self.nested_list_parse( + self.state_machine.input_lines[offset:], + input_offset=self.state_machine.abs_line_offset() + 1, + node=bulletlist, initial_state='BulletList', + blank_finish=blank_finish) + if not blank_finish: + self.parent += self.unindent_warning('Bullet list') + self.goto_line(newline_offset) + return [], next_state, [] def list_item(self, indent): - indented, lineoffset, blankfinish = \ - self.statemachine.getknownindented(indent) + indented, line_offset, blank_finish = \ + self.state_machine.get_known_indented(indent) listitem = nodes.list_item('\n'.join(indented)) if indented: - self.nestedparse(indented, inputoffset=lineoffset, node=listitem) - return listitem, blankfinish + self.nested_parse(indented, input_offset=line_offset, + node=listitem) + return listitem, blank_finish - def enumerator(self, match, context, nextstate): + def enumerator(self, match, context, next_state): """Enumerated List Item""" format, sequence, text, ordinal = self.parse_enumerator(match) if ordinal is None: - msg = self.statemachine.memo.reporter.error( + msg = self.reporter.error( ('Enumerated list start value invalid at line %s: ' - '%r (sequence %r)' % (self.statemachine.abslineno(), + '%r (sequence %r)' % (self.state_machine.abs_line_number(), text, sequence))) - self.statemachine.node += msg - indented, lineoffset, blankfinish = \ - self.statemachine.getknownindented(match.end()) - bq = self.block_quote(indented, lineoffset) - self.statemachine.node += bq - if not blankfinish: - self.statemachine.node += self.unindent_warning( + self.parent += msg + indented, line_offset, blank_finish = \ + self.state_machine.get_known_indented(match.end()) + bq = self.block_quote(indented, line_offset) + self.parent += bq + if not blank_finish: + self.parent += self.unindent_warning( 'Enumerated list') - return [], nextstate, [] + return [], next_state, [] if ordinal != 1: - msg = self.statemachine.memo.reporter.info( + msg = self.reporter.info( ('Enumerated list start value not ordinal-1 at line %s: ' - '%r (ordinal %s)' % (self.statemachine.abslineno(), - text, ordinal))) - self.statemachine.node += msg + '%r (ordinal %s)' % (self.state_machine.abs_line_number(), + text, ordinal))) + self.parent += msg enumlist = nodes.enumerated_list() - self.statemachine.node += enumlist + self.parent += enumlist enumlist['enumtype'] = sequence if ordinal != 1: enumlist['start'] = ordinal enumlist['prefix'] = self.enum.formatinfo[format].prefix enumlist['suffix'] = self.enum.formatinfo[format].suffix - listitem, blankfinish = self.list_item(match.end()) + listitem, blank_finish = self.list_item(match.end()) enumlist += listitem - offset = self.statemachine.lineoffset + 1 # next line - newlineoffset, blankfinish = self.nestedlistparse( - self.statemachine.inputlines[offset:], - inputoffset=self.statemachine.abslineoffset() + 1, - node=enumlist, initialstate='EnumeratedList', - blankfinish=blankfinish, - extrasettings={'lastordinal': ordinal, 'format': format}) - if not blankfinish: - self.statemachine.node += self.unindent_warning('Enumerated list') - self.gotoline(newlineoffset) - return [], nextstate, [] - - def parse_enumerator(self, match, expectedsequence=None): + offset = self.state_machine.line_offset + 1 # next line + newline_offset, blank_finish = self.nested_list_parse( + self.state_machine.input_lines[offset:], + input_offset=self.state_machine.abs_line_offset() + 1, + node=enumlist, initial_state='EnumeratedList', + blank_finish=blank_finish, + extra_settings={'lastordinal': ordinal, 'format': format}) + if not blank_finish: + self.parent += self.unindent_warning('Enumerated list') + self.goto_line(newline_offset) + return [], next_state, [] + + def parse_enumerator(self, match, expected_sequence=None): """ Analyze an enumerator and return the results. @@ -975,7 +1017,7 @@ class Body(RSTState): ``None`` is returned for invalid enumerator text). The enumerator format has already been determined by the regular - expression match. If `expectedsequence` is given, that sequence is + expression match. If `expected_sequence` is given, that sequence is tried first. If not, we check for Roman numeral 1. This way, single-character Roman numerals (which are also alphabetical) can be matched. If no sequence has been matched, all sequences are checked in @@ -990,10 +1032,10 @@ class Body(RSTState): raise ParserError, 'enumerator format not matched' text = groupdict[format][self.enum.formatinfo[format].start :self.enum.formatinfo[format].end] - if expectedsequence: + if expected_sequence: try: - if self.enum.sequenceregexps[expectedsequence].match(text): - sequence = expectedsequence + if self.enum.sequenceregexps[expected_sequence].match(text): + sequence = expected_sequence except KeyError: # shouldn't happen raise ParserError, 'unknown sequence: %s' % sequence else: @@ -1013,27 +1055,27 @@ class Body(RSTState): ordinal = None return format, sequence, text, ordinal - def field_marker(self, match, context, nextstate): + def field_marker(self, match, context, next_state): """Field list item.""" fieldlist = nodes.field_list() - self.statemachine.node += fieldlist - field, blankfinish = self.field(match) + self.parent += fieldlist + field, blank_finish = self.field(match) fieldlist += field - offset = self.statemachine.lineoffset + 1 # next line - newlineoffset, blankfinish = self.nestedlistparse( - self.statemachine.inputlines[offset:], - inputoffset=self.statemachine.abslineoffset() + 1, - node=fieldlist, initialstate='FieldList', - blankfinish=blankfinish) - if not blankfinish: - self.statemachine.node += self.unindent_warning('Field list') - self.gotoline(newlineoffset) - return [], nextstate, [] + offset = self.state_machine.line_offset + 1 # next line + newline_offset, blank_finish = self.nested_list_parse( + self.state_machine.input_lines[offset:], + input_offset=self.state_machine.abs_line_offset() + 1, + node=fieldlist, initial_state='FieldList', + blank_finish=blank_finish) + if not blank_finish: + self.parent += self.unindent_warning('Field list') + self.goto_line(newline_offset) + return [], next_state, [] def field(self, match): name, args = self.parse_field_marker(match) - indented, indent, lineoffset, blankfinish = \ - self.statemachine.getfirstknownindented(match.end()) + indented, indent, line_offset, blank_finish = \ + self.state_machine.get_first_known_indented(match.end()) fieldnode = nodes.field() fieldnode += nodes.field_name(name, name) for arg in args: @@ -1041,8 +1083,9 @@ class Body(RSTState): fieldbody = nodes.field_body('\n'.join(indented)) fieldnode += fieldbody if indented: - self.nestedparse(indented, inputoffset=lineoffset, node=fieldbody) - return fieldnode, blankfinish + self.nested_parse(indented, input_offset=line_offset, + node=fieldbody) + return fieldnode, blank_finish def parse_field_marker(self, match): """Extract & return name & argument list from a field marker match.""" @@ -1051,48 +1094,50 @@ class Body(RSTState): tokens = field.split() return tokens[0], tokens[1:] # first == name, others == args - def option_marker(self, match, context, nextstate): + def option_marker(self, match, context, next_state): """Option list item.""" optionlist = nodes.option_list() try: - listitem, blankfinish = self.option_list_item(match) - except MarkupError, detail: # shouldn't happen; won't match pattern - msg = self.statemachine.memo.reporter.error( + listitem, blank_finish = self.option_list_item(match) + except MarkupError, detail: # shouldn't happen; won't match pattern + msg = self.reporter.error( ('Invalid option list marker at line %s: %s' - % (self.statemachine.abslineno(), detail))) - self.statemachine.node += msg - indented, indent, lineoffset, blankfinish = \ - self.statemachine.getfirstknownindented(match.end()) - blockquote = self.block_quote(indented, lineoffset) - self.statemachine.node += blockquote - if not blankfinish: - self.statemachine.node += self.unindent_warning('Option list') - return [], nextstate, [] - self.statemachine.node += optionlist + % (self.state_machine.abs_line_number(), detail))) + self.parent += msg + indented, indent, line_offset, blank_finish = \ + self.state_machine.get_first_known_indented(match.end()) + blockquote = self.block_quote(indented, line_offset) + self.parent += blockquote + if not blank_finish: + self.parent += self.unindent_warning('Option list') + return [], next_state, [] + self.parent += optionlist optionlist += listitem - offset = self.statemachine.lineoffset + 1 # next line - newlineoffset, blankfinish = self.nestedlistparse( - self.statemachine.inputlines[offset:], - inputoffset=self.statemachine.abslineoffset() + 1, - node=optionlist, initialstate='OptionList', - blankfinish=blankfinish) - if not blankfinish: - self.statemachine.node += self.unindent_warning('Option list') - self.gotoline(newlineoffset) - return [], nextstate, [] + offset = self.state_machine.line_offset + 1 # next line + newline_offset, blank_finish = self.nested_list_parse( + self.state_machine.input_lines[offset:], + input_offset=self.state_machine.abs_line_offset() + 1, + node=optionlist, initial_state='OptionList', + blank_finish=blank_finish) + if not blank_finish: + self.parent += self.unindent_warning('Option list') + self.goto_line(newline_offset) + return [], next_state, [] def option_list_item(self, match): options = self.parse_option_marker(match) - indented, indent, lineoffset, blankfinish = \ - self.statemachine.getfirstknownindented(match.end()) + indented, indent, line_offset, blank_finish = \ + self.state_machine.get_first_known_indented(match.end()) if not indented: # not an option list item raise statemachine.TransitionCorrection('text') option_group = nodes.option_group('', *options) description = nodes.description('\n'.join(indented)) - option_list_item = nodes.option_list_item('', option_group, description) + option_list_item = nodes.option_list_item('', option_group, + description) if indented: - self.nestedparse(indented, inputoffset=lineoffset, node=description) - return option_list_item, blankfinish + self.nested_parse(indented, input_offset=line_offset, + node=description) + return option_list_item, blank_finish def parse_option_marker(self, match): """ @@ -1123,84 +1168,85 @@ class Body(RSTState): optionstring)) return optlist - def doctest(self, match, context, nextstate): - data = '\n'.join(self.statemachine.gettextblock()) - self.statemachine.node += nodes.doctest_block(data, data) - return [], nextstate, [] + def doctest(self, match, context, next_state): + data = '\n'.join(self.state_machine.get_text_block()) + self.parent += nodes.doctest_block(data, data) + return [], next_state, [] - def tabletop(self, match, context, nextstate): + def table_top(self, match, context, next_state): """Top border of a table.""" - nodelist, blankfinish = self.table() - self.statemachine.node += nodelist - if not blankfinish: - msg = self.statemachine.memo.reporter.warning( + nodelist, blank_finish = self.table() + self.parent += nodelist + if not blank_finish: + msg = self.reporter.warning( 'Blank line required after table at line %s.' - % (self.statemachine.abslineno() + 1)) - self.statemachine.node += msg - return [], nextstate, [] + % (self.state_machine.abs_line_number() + 1)) + self.parent += msg + return [], next_state, [] def table(self): """Parse a table.""" - block, messages, blankfinish = self.isolatetable() + block, messages, blank_finish = self.isolate_table() if block: try: tabledata = self.tableparser.parse(block) - tableline = self.statemachine.abslineno() - len(block) + 1 - table = self.buildtable(tabledata, tableline) + tableline = (self.state_machine.abs_line_number() - len(block) + + 1) + table = self.build_table(tabledata, tableline) nodelist = [table] + messages except TableMarkupError, detail: - nodelist = self.malformedtable(block, str(detail)) + messages + nodelist = self.malformed_table(block, str(detail)) + messages else: nodelist = messages - return nodelist, blankfinish + return nodelist, blank_finish - def isolatetable(self): + def isolate_table(self): messages = [] - blankfinish = 1 + blank_finish = 1 try: - block = self.statemachine.getunindented() + block = self.state_machine.get_text_block(flush_left=1) except statemachine.UnexpectedIndentationError, instance: block, lineno = instance.args - messages.append(self.statemachine.memo.reporter.error( + messages.append(self.reporter.error( 'Unexpected indentation at line %s.' % lineno)) - blankfinish = 0 + blank_finish = 0 width = len(block[0].strip()) for i in range(len(block)): block[i] = block[i].strip() if block[i][0] not in '+|': # check left edge - blankfinish = 0 - self.statemachine.previousline(len(block) - i) + blank_finish = 0 + self.state_machine.previous_line(len(block) - i) del block[i:] break - if not self.tabletoppat.match(block[-1]): # find bottom - blankfinish = 0 + if not self.table_top_pat.match(block[-1]): # find bottom + blank_finish = 0 # from second-last to third line of table: for i in range(len(block) - 2, 1, -1): - if self.tabletoppat.match(block[i]): - self.statemachine.previousline(len(block) - i + 1) + if self.table_top_pat.match(block[i]): + self.state_machine.previous_line(len(block) - i + 1) del block[i+1:] break else: - messages.extend(self.malformedtable(block)) - return [], messages, blankfinish + messages.extend(self.malformed_table(block)) + return [], messages, blank_finish for i in range(len(block)): # check right edge if len(block[i]) != width or block[i][-1] not in '+|': - messages.extend(self.malformedtable(block)) - return [], messages, blankfinish - return block, messages, blankfinish + messages.extend(self.malformed_table(block)) + return [], messages, blank_finish + return block, messages, blank_finish - def malformedtable(self, block, detail=''): + def malformed_table(self, block, detail=''): data = '\n'.join(block) message = 'Malformed table at line %s; formatting as a ' \ - 'literal block.' % (self.statemachine.abslineno() + 'literal block.' % (self.state_machine.abs_line_number() - len(block) + 1) if detail: message += '\n' + detail - nodelist = [self.statemachine.memo.reporter.error(message), + nodelist = [self.reporter.error(message), nodes.literal_block(data, data)] return nodelist - def buildtable(self, tabledata, tableline): + def build_table(self, tabledata, tableline): colspecs, headrows, bodyrows = tabledata table = nodes.table() tgroup = nodes.tgroup(cols=len(colspecs)) @@ -1211,14 +1257,14 @@ class Body(RSTState): thead = nodes.thead() tgroup += thead for row in headrows: - thead += self.buildtablerow(row, tableline) + thead += self.build_table_row(row, tableline) tbody = nodes.tbody() tgroup += tbody for row in bodyrows: - tbody += self.buildtablerow(row, tableline) + tbody += self.build_table_row(row, tableline) return table - def buildtablerow(self, rowdata, tableline): + def build_table_row(self, rowdata, tableline): row = nodes.row() for cell in rowdata: if cell is None: @@ -1232,8 +1278,8 @@ class Body(RSTState): entry = nodes.entry(**attributes) row += entry if ''.join(cellblock): - self.nestedparse(cellblock, inputoffset=tableline+offset, - node=entry) + self.nested_parse(cellblock, input_offset=tableline+offset, + node=entry) return row @@ -1257,8 +1303,8 @@ class Body(RSTState): : # end of reference name (?:[ ]+|$) # followed by whitespace """ - % (RSTState.inline.non_whitespace_escape_before, - RSTState.inline.non_whitespace_escape_before), + % (Inliner.non_whitespace_escape_before, + Inliner.non_whitespace_escape_before), re.VERBOSE), reference=re.compile(r""" (?: @@ -1268,12 +1314,12 @@ class Body(RSTState): (?![ ]) # not space (.+?) # hyperlink phrase %s # not whitespace or escape - `_ # close backquote & reference mark + `_ # close backquote, reference mark ) $ # end of string """ % - (RSTState.inline.simplename, - RSTState.inline.non_whitespace_escape_before,), + (Inliner.simplename, + Inliner.non_whitespace_escape_before,), re.VERBOSE), substitution=re.compile(r""" (?: @@ -1284,7 +1330,7 @@ class Body(RSTState): ) (?:[ ]+|$) # followed by whitespace """ % - RSTState.inline.non_whitespace_escape_before, + Inliner.non_whitespace_escape_before, re.VERBOSE),) explicit.groups = Stuff( target=Stuff(quote=1, name=2), @@ -1292,53 +1338,53 @@ class Body(RSTState): substitution=Stuff(name=1)) def footnote(self, match): - indented, indent, offset, blankfinish = \ - self.statemachine.getfirstknownindented(match.end()) + indented, indent, offset, blank_finish = \ + self.state_machine.get_first_known_indented(match.end()) label = match.group(1) - name = normname(label) + name = normalize_name(label) footnote = nodes.footnote('\n'.join(indented)) if name[0] == '#': # auto-numbered name = name[1:] # autonumber label footnote['auto'] = 1 if name: footnote['name'] = name - self.statemachine.memo.document.note_autofootnote(footnote) + self.document.note_autofootnote(footnote) elif name == '*': # auto-symbol name = '' footnote['auto'] = '*' - self.statemachine.memo.document.note_symbol_footnote(footnote) + self.document.note_symbol_footnote(footnote) else: # manually numbered footnote += nodes.label('', label) footnote['name'] = name - self.statemachine.memo.document.note_footnote(footnote) + self.document.note_footnote(footnote) if name: - self.statemachine.memo.document.note_explicit_target(footnote, + self.document.note_explicit_target(footnote, footnote) if indented: - self.nestedparse(indented, inputoffset=offset, node=footnote) - return [footnote], blankfinish + self.nested_parse(indented, input_offset=offset, node=footnote) + return [footnote], blank_finish def citation(self, match): - indented, indent, offset, blankfinish = \ - self.statemachine.getfirstknownindented(match.end()) + indented, indent, offset, blank_finish = \ + self.state_machine.get_first_known_indented(match.end()) label = match.group(1) - name = normname(label) + name = normalize_name(label) citation = nodes.citation('\n'.join(indented)) citation += nodes.label('', label) citation['name'] = name - self.statemachine.memo.document.note_citation(citation) - self.statemachine.memo.document.note_explicit_target(citation, citation) + self.document.note_citation(citation) + self.document.note_explicit_target(citation, citation) if indented: - self.nestedparse(indented, inputoffset=offset, node=citation) - return [citation], blankfinish + self.nested_parse(indented, input_offset=offset, node=citation) + return [citation], blank_finish def hyperlink_target(self, match): pattern = self.explicit.patterns.target namegroup = self.explicit.groups.target.name - lineno = self.statemachine.abslineno() - block, indent, offset, blankfinish = \ - self.statemachine.getfirstknownindented(match.end(), uptoblank=1, - stripindent=0) + lineno = self.state_machine.abs_line_number() + block, indent, offset, blank_finish = \ + self.state_machine.get_first_known_indented( + match.end(), until_blank=1, strip_indent=0) blocktext = match.string[:match.end()] + '\n'.join(block) block = [escape2null(line) for line in block] escaped = block[0] @@ -1357,58 +1403,58 @@ class Body(RSTState): block[0] = (block[0] + ' ')[targetmatch.end()-len(escaped)-1:].strip() if block and block[-1].strip()[-1:] == '_': # possible indirect target reference = ' '.join([line.strip() for line in block]) - refname = self.isreference(reference) + refname = self.is_reference(reference) if refname: target = nodes.target(blocktext, '', refname=refname) - self.addtarget(targetmatch.group(namegroup), '', target) - self.statemachine.memo.document.note_indirect_target(target) - return [target], blankfinish + self.add_target(targetmatch.group(namegroup), '', target) + self.document.note_indirect_target(target) + return [target], blank_finish nodelist = [] reference = ''.join([line.strip() for line in block]) if reference.find(' ') != -1: - warning = self.statemachine.memo.reporter.warning( + warning = self.reporter.warning( 'Hyperlink target at line %s contains whitespace. ' 'Perhaps a footnote was intended?' - % (self.statemachine.abslineno() - len(block) + 1), '', - nodes.literal_block(blocktext, blocktext)) + % (self.state_machine.abs_line_number() - len(block) + 1), + '', nodes.literal_block(blocktext, blocktext)) nodelist.append(warning) else: unescaped = unescape(reference) target = nodes.target(blocktext, '') - self.addtarget(targetmatch.group(namegroup), unescaped, target) + self.add_target(targetmatch.group(namegroup), unescaped, target) nodelist.append(target) - return nodelist, blankfinish + return nodelist, blank_finish - def isreference(self, reference): - match = self.explicit.patterns.reference.match(normname(reference)) + def is_reference(self, reference): + match = self.explicit.patterns.reference.match(normalize_name(reference)) if not match: return None return unescape(match.group(self.explicit.groups.reference.simple) or match.group(self.explicit.groups.reference.phrase)) - def addtarget(self, targetname, refuri, target): + def add_target(self, targetname, refuri, target): if targetname: - name = normname(unescape(targetname)) + name = normalize_name(unescape(targetname)) target['name'] = name if refuri: target['refuri'] = refuri - self.statemachine.memo.document.note_external_target(target) + self.document.note_external_target(target) else: - self.statemachine.memo.document.note_internal_target(target) - self.statemachine.memo.document.note_explicit_target( - target, self.statemachine.node) + self.document.note_internal_target(target) + self.document.note_explicit_target( + target, self.parent) else: # anonymous target if refuri: target['refuri'] = refuri target['anonymous'] = 1 - self.statemachine.memo.document.note_anonymous_target(target) + self.document.note_anonymous_target(target) - def substitutiondef(self, match): + def substitution_def(self, match): pattern = self.explicit.patterns.substitution - lineno = self.statemachine.abslineno() - block, indent, offset, blankfinish = \ - self.statemachine.getfirstknownindented(match.end(), - stripindent=0) + lineno = self.state_machine.abs_line_number() + block, indent, offset, blank_finish = \ + self.state_machine.get_first_known_indented(match.end(), + strip_indent=0) blocktext = (match.string[:match.end()] + '\n'.join(block)) block = [escape2null(line) for line in block] escaped = block[0].rstrip() @@ -1429,65 +1475,66 @@ class Body(RSTState): del block[0] offset += 1 subname = subdefmatch.group(self.explicit.groups.substitution.name) - name = normname(subname) + name = normalize_name(subname) substitutionnode = nodes.substitution_definition( blocktext, name=name, alt=subname) if block: block[0] = block[0].strip() - newabsoffset, blankfinish = self.nestedlistparse( - block, inputoffset=offset, node=substitutionnode, - initialstate='SubstitutionDef', blankfinish=blankfinish) - self.statemachine.previousline( + newabsoffset, blank_finish = self.nested_list_parse( + block, input_offset=offset, node=substitutionnode, + initial_state='SubstitutionDef', blank_finish=blank_finish) + self.state_machine.previous_line( len(block) + offset - newabsoffset - 1) i = 0 for node in substitutionnode[:]: if not (isinstance(node, nodes.Inline) or isinstance(node, nodes.Text)): - self.statemachine.node += substitutionnode[i] + self.parent += substitutionnode[i] del substitutionnode[i] else: i += 1 if len(substitutionnode) == 0: - msg = self.statemachine.memo.reporter.warning( + msg = self.reporter.warning( 'Substitution definition "%s" empty or invalid at line ' - '%s.' % (subname, self.statemachine.abslineno()), '', - nodes.literal_block(blocktext, blocktext)) - self.statemachine.node += msg + '%s.' % (subname, self.state_machine.abs_line_number()), + '', nodes.literal_block(blocktext, blocktext)) + self.parent += msg else: del substitutionnode['alt'] - self.statemachine.memo.document.note_substitution_def( - substitutionnode, self.statemachine.node) - return [substitutionnode], blankfinish + self.document.note_substitution_def( + substitutionnode, self.parent) + return [substitutionnode], blank_finish else: - msg = self.statemachine.memo.reporter.warning( + msg = self.reporter.warning( 'Substitution definition "%s" missing contents at line %s.' - % (subname, self.statemachine.abslineno()), '', + % (subname, self.state_machine.abs_line_number()), '', nodes.literal_block(blocktext, blocktext)) - self.statemachine.node += msg - return [], blankfinish + self.parent += msg + return [], blank_finish def directive(self, match, **attributes): - typename = match.group(1) - directivefunction = directives.directive( - typename, self.statemachine.memo.language) + type_name = match.group(1) + directivefunction = directives.directive(type_name, + self.memo.language) data = match.string[match.end():].strip() if directivefunction: - return directivefunction(match, typename, data, self, - self.statemachine, attributes) + return directivefunction(match, type_name, data, self, + self.state_machine, attributes) else: - return self.unknowndirective(typename, data) + return self.unknown_directive(type_name, data) - def unknowndirective(self, typename, data): - lineno = self.statemachine.abslineno() - indented, indent, offset, blankfinish = \ - self.statemachine.getfirstknownindented(0, stripindent=0) + def unknown_directive(self, type_name, data): + lineno = self.state_machine.abs_line_number() + indented, indent, offset, blank_finish = \ + self.state_machine.get_first_known_indented(0, strip_indent=0) text = '\n'.join(indented) - error = self.statemachine.memo.reporter.error( - 'Unknown directive type "%s" at line %s.' % (typename, lineno), + error = self.reporter.error( + 'Unknown directive type "%s" at line %s.' % (type_name, lineno), '', nodes.literal_block(text, text)) - return [error], blankfinish + return [error], blank_finish - def parse_extension_attributes(self, attribute_spec, datalines, blankfinish): + def parse_extension_attributes(self, attribute_spec, datalines, + blank_finish): """ Parse `datalines` for a field list containing extension attributes matching `attribute_spec`. @@ -1496,37 +1543,38 @@ class Body(RSTState): - `attribute_spec`: a mapping of attribute name to conversion function, which should raise an exception on bad input. - `datalines`: a list of input strings. - - `blankfinish`: + - `blank_finish`: :Return: - Success value, 1 or 0. - An attribute dictionary on success, an error string on failure. - - Updated `blankfinish` flag. + - Updated `blank_finish` flag. """ node = nodes.field_list() - newlineoffset, blankfinish = self.nestedlistparse( - datalines, 0, node, initialstate='FieldList', - blankfinish=blankfinish) - if newlineoffset != len(datalines): # incomplete parse of block - return 0, 'invalid attribute block', blankfinish + newline_offset, blank_finish = self.nested_list_parse( + datalines, 0, node, initial_state='FieldList', + blank_finish=blank_finish) + if newline_offset != len(datalines): # incomplete parse of block + return 0, 'invalid attribute block', blank_finish try: - attributes = utils.extract_extension_attributes(node, attribute_spec) + attributes = utils.extract_extension_attributes(node, + attribute_spec) except KeyError, detail: - return 0, ('unknown attribute: "%s"' % detail), blankfinish + return 0, ('unknown attribute: "%s"' % detail), blank_finish except (ValueError, TypeError), detail: - return 0, ('invalid attribute value:\n%s' % detail), blankfinish + return 0, ('invalid attribute value:\n%s' % detail), blank_finish except utils.ExtensionAttributeError, detail: - return 0, ('invalid attribute data: %s' % detail), blankfinish - return 1, attributes, blankfinish + return 0, ('invalid attribute data: %s' % detail), blank_finish + return 1, attributes, blank_finish def comment(self, match): if not match.string[match.end():].strip() \ - and self.statemachine.nextlineblank(): # an empty comment? + and self.state_machine.is_next_line_blank(): # an empty comment? return [nodes.comment()], 1 # "A tiny but practical wart." - indented, indent, offset, blankfinish = \ - self.statemachine.getfirstknownindented(match.end()) + indented, indent, offset, blank_finish = \ + self.state_machine.get_first_known_indented(match.end()) text = '\n'.join(indented) - return [nodes.comment(text, text)], blankfinish + return [nodes.comment(text, text)], blank_finish explicit.constructs = [ (footnote, @@ -1544,20 +1592,20 @@ class Body(RSTState): ) \] (?:[ ]+|$) # whitespace or end of line - """ % RSTState.inline.simplename, re.VERBOSE)), + """ % Inliner.simplename, re.VERBOSE)), (citation, re.compile(r""" \.\.[ ]+ # explicit markup start \[(%s)\] # citation label (?:[ ]+|$) # whitespace or end of line - """ % RSTState.inline.simplename, re.VERBOSE)), + """ % Inliner.simplename, re.VERBOSE)), (hyperlink_target, re.compile(r""" \.\.[ ]+ # explicit markup start _ # target indicator (?![ ]) # first char. not space """, re.VERBOSE)), - (substitutiondef, + (substitution_def, re.compile(r""" \.\.[ ]+ # explicit markup start \| # substitution indicator @@ -1569,14 +1617,14 @@ class Body(RSTState): (%s) # directive name :: # directive delimiter (?:[ ]+|$) # whitespace or end of line - """ % RSTState.inline.simplename, re.VERBOSE))] + """ % Inliner.simplename, re.VERBOSE))] - def explicit_markup(self, match, context, nextstate): + def explicit_markup(self, match, context, next_state): """Footnotes, hyperlink targets, directives, comments.""" - nodelist, blankfinish = self.explicit_construct(match) - self.statemachine.node += nodelist - self.explicitlist(blankfinish) - return [], nextstate, [] + nodelist, blank_finish = self.explicit_construct(match) + self.parent += nodelist + self.explicit_list(blank_finish) + return [], next_state, [] def explicit_construct(self, match): """Determine which explicit construct this is, parse & return it.""" @@ -1588,80 +1636,81 @@ class Body(RSTState): return method(self, expmatch) except MarkupError, detail: # never reached? errors.append( - self.statemachine.memo.reporter.warning('%s: %s' + self.reporter.warning('%s: %s' % (detail.__class__.__name__, detail))) break - nodelist, blankfinish = self.comment(match) - return nodelist + errors, blankfinish + nodelist, blank_finish = self.comment(match) + return nodelist + errors, blank_finish - def explicitlist(self, blankfinish): + def explicit_list(self, blank_finish): """ Create a nested state machine for a series of explicit markup constructs (including anonymous hyperlink targets). """ - offset = self.statemachine.lineoffset + 1 # next line - newlineoffset, blankfinish = self.nestedlistparse( - self.statemachine.inputlines[offset:], - inputoffset=self.statemachine.abslineoffset() + 1, - node=self.statemachine.node, initialstate='Explicit', - blankfinish=blankfinish) - self.gotoline(newlineoffset) - if not blankfinish: - self.statemachine.node += self.unindent_warning('Explicit markup') - - def anonymous(self, match, context, nextstate): + offset = self.state_machine.line_offset + 1 # next line + newline_offset, blank_finish = self.nested_list_parse( + self.state_machine.input_lines[offset:], + input_offset=self.state_machine.abs_line_offset() + 1, + node=self.parent, initial_state='Explicit', + blank_finish=blank_finish) + self.goto_line(newline_offset) + if not blank_finish: + self.parent += self.unindent_warning('Explicit markup') + + def anonymous(self, match, context, next_state): """Anonymous hyperlink targets.""" - nodelist, blankfinish = self.anonymous_target(match) - self.statemachine.node += nodelist - self.explicitlist(blankfinish) - return [], nextstate, [] + nodelist, blank_finish = self.anonymous_target(match) + self.parent += nodelist + self.explicit_list(blank_finish) + return [], next_state, [] def anonymous_target(self, match): - block, indent, offset, blankfinish \ - = self.statemachine.getfirstknownindented(match.end(), - uptoblank=1) + block, indent, offset, blank_finish \ + = self.state_machine.get_first_known_indented(match.end(), + until_blank=1) blocktext = match.string[:match.end()] + '\n'.join(block) if block and block[-1].strip()[-1:] == '_': # possible indirect target - reference = escape2null(' '.join([line.strip() for line in block])) - refname = self.isreference(reference) + reference = escape2null(' '.join([line.strip() + for line in block])) + refname = self.is_reference(reference) if refname: target = nodes.target(blocktext, '', refname=refname, anonymous=1) - self.statemachine.memo.document.note_anonymous_target(target) - self.statemachine.memo.document.note_indirect_target(target) - return [target], blankfinish + self.document.note_anonymous_target(target) + self.document.note_indirect_target(target) + return [target], blank_finish nodelist = [] reference = escape2null(''.join([line.strip() for line in block])) if reference.find(' ') != -1: - warning = self.statemachine.memo.reporter.warning( - 'Anonymous hyperlink target at line %s contains whitespace. ' - 'Perhaps a footnote was intended?' - % (self.statemachine.abslineno() - len(block) + 1), '', - nodes.literal_block(blocktext, blocktext)) + warning = self.reporter.warning( + 'Anonymous hyperlink target at line %s contains ' + 'whitespace. Perhaps a footnote was intended?' + % (self.state_machine.abs_line_number() - len(block) + 1), + '', nodes.literal_block(blocktext, blocktext)) nodelist.append(warning) else: target = nodes.target(blocktext, '', anonymous=1) if reference: unescaped = unescape(reference) target['refuri'] = unescaped - self.statemachine.memo.document.note_anonymous_target(target) + self.document.note_anonymous_target(target) nodelist.append(target) - return nodelist, blankfinish + return nodelist, blank_finish - def line(self, match, context, nextstate): + def line(self, match, context, next_state): """Section title overline or transition marker.""" - if self.statemachine.matchtitles: + if self.state_machine.match_titles: return [match.string], 'Line', [] else: - blocktext = self.statemachine.line - msg = self.statemachine.memo.reporter.severe( + blocktext = self.state_machine.line + msg = self.reporter.severe( 'Unexpected section title or transition at line %s.' - % self.statemachine.abslineno(), '', + % self.state_machine.abs_line_number(), '', nodes.literal_block(blocktext, blocktext)) - self.statemachine.node += msg - return [], nextstate, [] + self.parent += msg + return [], next_state, [] - def text(self, match, context, nextstate): + def text(self, match, context, next_state): """Titles, definition lists, paragraphs.""" return [match.string], 'Text', [] @@ -1675,38 +1724,40 @@ class RFC2822Body(Body): patterns = Body.patterns.copy() # can't modify the original patterns['rfc2822'] = r'[!-9;-~]+:( +|$)' - initialtransitions = [(name, 'Body') for name in Body.initialtransitions] - initialtransitions.insert(-1, ('rfc2822', 'Body')) # just before 'text' + initial_transitions = [(name, 'Body') + for name in Body.initial_transitions] + initial_transitions.insert(-1, ('rfc2822', 'Body')) # just before 'text' - def rfc2822(self, match, context, nextstate): + def rfc2822(self, match, context, next_state): """RFC2822-style field list item.""" - fieldlist = nodes.field_list() - self.statemachine.node += fieldlist - field, blankfinish = self.rfc2822_field(match) + fieldlist = nodes.field_list(CLASS='rfc2822') + self.parent += fieldlist + field, blank_finish = self.rfc2822_field(match) fieldlist += field - offset = self.statemachine.lineoffset + 1 # next line - newlineoffset, blankfinish = self.nestedlistparse( - self.statemachine.inputlines[offset:], - inputoffset=self.statemachine.abslineoffset() + 1, - node=fieldlist, initialstate='RFC2822List', - blankfinish=blankfinish) - if not blankfinish: - self.statemachine.node += self.unindent_warning( + offset = self.state_machine.line_offset + 1 # next line + newline_offset, blank_finish = self.nested_list_parse( + self.state_machine.input_lines[offset:], + input_offset=self.state_machine.abs_line_offset() + 1, + node=fieldlist, initial_state='RFC2822List', + blank_finish=blank_finish) + if not blank_finish: + self.parent += self.unindent_warning( 'RFC2822-style field list') - self.gotoline(newlineoffset) - return [], nextstate, [] + self.goto_line(newline_offset) + return [], next_state, [] def rfc2822_field(self, match): name = match.string[:match.string.find(':')] - indented, indent, lineoffset, blankfinish = \ - self.statemachine.getfirstknownindented(match.end()) + indented, indent, line_offset, blank_finish = \ + self.state_machine.get_first_known_indented(match.end()) fieldnode = nodes.field() fieldnode += nodes.field_name(name, name) fieldbody = nodes.field_body('\n'.join(indented)) fieldnode += fieldbody if indented: - self.nestedparse(indented, inputoffset=lineoffset, node=fieldbody) - return fieldnode, blankfinish + self.nested_parse(indented, input_offset=line_offset, + node=fieldbody) + return fieldnode, blank_finish class SpecializedBody(Body): @@ -1718,9 +1769,9 @@ class SpecializedBody(Body): subclasses to re-enable. """ - def invalid_input(self, match=None, context=None, nextstate=None): + def invalid_input(self, match=None, context=None, next_state=None): """Not a compound element member. Abort this state machine.""" - self.statemachine.previousline() # back up so parent SM can reassess + self.state_machine.previous_line() # back up so parent SM can reassess raise EOFError indent = invalid_input @@ -1729,7 +1780,7 @@ class SpecializedBody(Body): field_marker = invalid_input option_marker = invalid_input doctest = invalid_input - tabletop = invalid_input + table_top = invalid_input explicit_markup = invalid_input anonymous = invalid_input line = invalid_input @@ -1740,14 +1791,14 @@ class BulletList(SpecializedBody): """Second and subsequent bullet_list list_items.""" - def bullet(self, match, context, nextstate): + def bullet(self, match, context, next_state): """Bullet list item.""" - if match.string[0] != self.statemachine.node['bullet']: + if match.string[0] != self.parent['bullet']: # different bullet: new list self.invalid_input() - listitem, blankfinish = self.list_item(match.end()) - self.statemachine.node += listitem - self.blankfinish = blankfinish + listitem, blank_finish = self.list_item(match.end()) + self.parent += listitem + self.blank_finish = blank_finish return [], 'BulletList', [] @@ -1755,7 +1806,7 @@ class DefinitionList(SpecializedBody): """Second and subsequent definition_list_items.""" - def text(self, match, context, nextstate): + def text(self, match, context, next_state): """Definition lists.""" return [match.string], 'Definition', [] @@ -1764,18 +1815,18 @@ class EnumeratedList(SpecializedBody): """Second and subsequent enumerated_list list_items.""" - def enumerator(self, match, context, nextstate): + def enumerator(self, match, context, next_state): """Enumerated list item.""" format, sequence, text, ordinal = self.parse_enumerator( - match, self.statemachine.node['enumtype']) - if (sequence != self.statemachine.node['enumtype'] or + match, self.parent['enumtype']) + if (sequence != self.parent['enumtype'] or format != self.format or ordinal != self.lastordinal + 1): # different enumeration: new list self.invalid_input() - listitem, blankfinish = self.list_item(match.end()) - self.statemachine.node += listitem - self.blankfinish = blankfinish + listitem, blank_finish = self.list_item(match.end()) + self.parent += listitem + self.blank_finish = blank_finish self.lastordinal = ordinal return [], 'EnumeratedList', [] @@ -1784,11 +1835,11 @@ class FieldList(SpecializedBody): """Second and subsequent field_list fields.""" - def field_marker(self, match, context, nextstate): + def field_marker(self, match, context, next_state): """Field list field.""" - field, blankfinish = self.field(match) - self.statemachine.node += field - self.blankfinish = blankfinish + field, blank_finish = self.field(match) + self.parent += field + self.blank_finish = blank_finish return [], 'FieldList', [] @@ -1796,14 +1847,14 @@ class OptionList(SpecializedBody): """Second and subsequent option_list option_list_items.""" - def option_marker(self, match, context, nextstate): + def option_marker(self, match, context, next_state): """Option list item.""" try: - option_list_item, blankfinish = self.option_list_item(match) + option_list_item, blank_finish = self.option_list_item(match) except MarkupError, detail: self.invalid_input() - self.statemachine.node += option_list_item - self.blankfinish = blankfinish + self.parent += option_list_item + self.blank_finish = blank_finish return [], 'OptionList', [] @@ -1812,13 +1863,13 @@ class RFC2822List(SpecializedBody, RFC2822Body): """Second and subsequent RFC2822-style field_list fields.""" patterns = RFC2822Body.patterns - initialtransitions = RFC2822Body.initialtransitions + initial_transitions = RFC2822Body.initial_transitions - def rfc2822(self, match, context, nextstate): + def rfc2822(self, match, context, next_state): """RFC2822-style field list item.""" - field, blankfinish = self.rfc2822_field(match) - self.statemachine.node += field - self.blankfinish = blankfinish + field, blank_finish = self.rfc2822_field(match) + self.parent += field + self.blank_finish = blank_finish return [], 'RFC2822List', [] blank = SpecializedBody.invalid_input @@ -1828,19 +1879,19 @@ class Explicit(SpecializedBody): """Second and subsequent explicit markup construct.""" - def explicit_markup(self, match, context, nextstate): + def explicit_markup(self, match, context, next_state): """Footnotes, hyperlink targets, directives, comments.""" - nodelist, blankfinish = self.explicit_construct(match) - self.statemachine.node += nodelist - self.blankfinish = blankfinish - return [], nextstate, [] + nodelist, blank_finish = self.explicit_construct(match) + self.parent += nodelist + self.blank_finish = blank_finish + return [], next_state, [] - def anonymous(self, match, context, nextstate): + def anonymous(self, match, context, next_state): """Anonymous hyperlink targets.""" - nodelist, blankfinish = self.anonymous_target(match) - self.statemachine.node += nodelist - self.blankfinish = blankfinish - return [], nextstate, [] + nodelist, blank_finish = self.anonymous_target(match) + self.parent += nodelist + self.blank_finish = blank_finish + return [], next_state, [] class SubstitutionDef(Body): @@ -1850,24 +1901,24 @@ class SubstitutionDef(Body): """ patterns = { - 'embedded_directive': r'(%s)::( +|$)' % RSTState.inline.simplename, + 'embedded_directive': r'(%s)::( +|$)' % Inliner.simplename, 'text': r''} - initialtransitions = ['embedded_directive', 'text'] + initial_transitions = ['embedded_directive', 'text'] - def embedded_directive(self, match, context, nextstate): - if self.statemachine.node.has_key('alt'): - attributes = {'alt': self.statemachine.node['alt']} + def embedded_directive(self, match, context, next_state): + if self.parent.has_key('alt'): + attributes = {'alt': self.parent['alt']} else: attributes = {} - nodelist, blankfinish = self.directive(match, **attributes) - self.statemachine.node += nodelist - if not self.statemachine.ateof(): - self.blankfinish = blankfinish + nodelist, blank_finish = self.directive(match, **attributes) + self.parent += nodelist + if not self.state_machine.at_eof(): + self.blank_finish = blank_finish raise EOFError - def text(self, match, context, nextstate): - if not self.statemachine.ateof(): - self.blankfinish = self.statemachine.nextlineblank() + def text(self, match, context, next_state): + if not self.state_machine.at_eof(): + self.blank_finish = self.state_machine.is_next_line_blank() raise EOFError @@ -1881,123 +1932,123 @@ class Text(RSTState): patterns = {'underline': Body.patterns['line'], 'text': r''} - initialtransitions = [('underline', 'Body'), ('text', 'Body')] + initial_transitions = [('underline', 'Body'), ('text', 'Body')] - def blank(self, match, context, nextstate): + def blank(self, match, context, next_state): """End of paragraph.""" paragraph, literalnext = self.paragraph( - context, self.statemachine.abslineno() - 1) - self.statemachine.node += paragraph + context, self.state_machine.abs_line_number() - 1) + self.parent += paragraph if literalnext: - self.statemachine.node += self.literal_block() + self.parent += self.literal_block() return [], 'Body', [] def eof(self, context): if context: paragraph, literalnext = self.paragraph( - context, self.statemachine.abslineno() - 1) - self.statemachine.node += paragraph + context, self.state_machine.abs_line_number() - 1) + self.parent += paragraph if literalnext: - self.statemachine.node += self.literal_block() + self.parent += self.literal_block() return [] - def indent(self, match, context, nextstate): + def indent(self, match, context, next_state): """Definition list item.""" definitionlist = nodes.definition_list() - definitionlistitem, blankfinish = self.definition_list_item(context) + definitionlistitem, blank_finish = self.definition_list_item(context) definitionlist += definitionlistitem - self.statemachine.node += definitionlist - offset = self.statemachine.lineoffset + 1 # next line - newlineoffset, blankfinish = self.nestedlistparse( - self.statemachine.inputlines[offset:], - inputoffset=self.statemachine.abslineoffset() + 1, - node=definitionlist, initialstate='DefinitionList', - blankfinish=blankfinish, blankfinishstate='Definition') - if not blankfinish: - self.statemachine.node += self.unindent_warning('Definition list') - self.gotoline(newlineoffset) + self.parent += definitionlist + offset = self.state_machine.line_offset + 1 # next line + newline_offset, blank_finish = self.nested_list_parse( + self.state_machine.input_lines[offset:], + input_offset=self.state_machine.abs_line_offset() + 1, + node=definitionlist, initial_state='DefinitionList', + blank_finish=blank_finish, blank_finish_state='Definition') + if not blank_finish: + self.parent += self.unindent_warning('Definition list') + self.goto_line(newline_offset) return [], 'Body', [] - def underline(self, match, context, nextstate): + def underline(self, match, context, next_state): """Section title.""" - lineno = self.statemachine.abslineno() - if not self.statemachine.matchtitles: - blocktext = context[0] + '\n' + self.statemachine.line - msg = self.statemachine.memo.reporter.severe( + 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 at line %s.' % lineno, '', nodes.literal_block(blocktext, blocktext)) - self.statemachine.node += msg - return [], nextstate, [] + self.parent += msg + return [], next_state, [] title = context[0].rstrip() underline = match.string.rstrip() source = title + '\n' + underline if len(title) > len(underline): - blocktext = context[0] + '\n' + self.statemachine.line - msg = self.statemachine.memo.reporter.info( + blocktext = context[0] + '\n' + self.state_machine.line + msg = self.reporter.info( 'Title underline too short at line %s.' % lineno, '', nodes.literal_block(blocktext, blocktext)) - self.statemachine.node += msg + self.parent += msg style = underline[0] context[:] = [] self.section(title, source, style, lineno - 1) - return [], nextstate, [] + return [], next_state, [] - def text(self, match, context, nextstate): + def text(self, match, context, next_state): """Paragraph.""" - startline = self.statemachine.abslineno() - 1 + startline = self.state_machine.abs_line_number() - 1 msg = None try: - block = self.statemachine.getunindented() + block = self.state_machine.get_text_block(flush_left=1) except statemachine.UnexpectedIndentationError, instance: block, lineno = instance.args - msg = self.statemachine.memo.reporter.error( + msg = self.reporter.error( 'Unexpected indentation at line %s.' % lineno) lines = context + block paragraph, literalnext = self.paragraph(lines, startline) - self.statemachine.node += paragraph - self.statemachine.node += msg + self.parent += paragraph + self.parent += msg if literalnext: try: - self.statemachine.nextline() + self.state_machine.next_line() except IndexError: pass - self.statemachine.node += self.literal_block() - return [], nextstate, [] + self.parent += self.literal_block() + return [], next_state, [] def literal_block(self): """Return a list of nodes.""" - indented, indent, offset, blankfinish = \ - self.statemachine.getindented() + indented, indent, offset, blank_finish = \ + self.state_machine.get_indented() nodelist = [] while indented and not indented[-1].strip(): indented.pop() if indented: data = '\n'.join(indented) nodelist.append(nodes.literal_block(data, data)) - if not blankfinish: + if not blank_finish: nodelist.append(self.unindent_warning('Literal block')) else: - nodelist.append(self.statemachine.memo.reporter.warning( + nodelist.append(self.reporter.warning( 'Literal block expected at line %s; none found.' - % self.statemachine.abslineno())) + % self.state_machine.abs_line_number())) return nodelist def definition_list_item(self, termline): - indented, indent, lineoffset, blankfinish = \ - self.statemachine.getindented() + indented, indent, line_offset, blank_finish = \ + self.state_machine.get_indented() definitionlistitem = nodes.definition_list_item('\n'.join(termline + indented)) - termlist, messages = self.term(termline, - self.statemachine.abslineno() - 1) + termlist, messages = self.term( + termline, self.state_machine.abs_line_number() - 1) definitionlistitem += termlist definition = nodes.definition('', *messages) definitionlistitem += definition if termline[0][-2:] == '::': - definition += self.statemachine.memo.reporter.info( + definition += self.reporter.info( 'Blank line missing before literal block? Interpreted as a ' - 'definition list item. At line %s.' % (lineoffset + 1)) - self.nestedparse(indented, inputoffset=lineoffset, node=definition) - return definitionlistitem, blankfinish + 'definition list item. At line %s.' % (line_offset + 1)) + self.nested_parse(indented, input_offset=line_offset, node=definition) + return definitionlistitem, blank_finish def term(self, lines, lineno): """Return a definition_list's term and optional classifier.""" @@ -2028,7 +2079,7 @@ class SpecializedText(Text): """Incomplete construct.""" return [] - def invalid_input(self, match=None, context=None, nextstate=None): + def invalid_input(self, match=None, context=None, next_state=None): """Not a compound element member. Abort this state machine.""" raise EOFError @@ -2044,14 +2095,14 @@ class Definition(SpecializedText): def eof(self, context): """Not a definition.""" - self.statemachine.previousline(2) # back up so parent SM can reassess + self.state_machine.previous_line(2) # so parent SM can reassess return [] - def indent(self, match, context, nextstate): + def indent(self, match, context, next_state): """Definition list item.""" - definitionlistitem, blankfinish = self.definition_list_item(context) - self.statemachine.node += definitionlistitem - self.blankfinish = blankfinish + definitionlistitem, blank_finish = self.definition_list_item(context) + self.parent += definitionlistitem + self.blank_finish = blank_finish return [], 'DefinitionList', [] @@ -2066,67 +2117,67 @@ class Line(SpecializedText): """Transition marker at end of section or document.""" if self.eofcheck: # ignore EOFError with sections transition = nodes.transition(context[0]) - self.statemachine.node += transition - msg = self.statemachine.memo.reporter.error( + self.parent += transition + msg = self.reporter.error( 'Document or section may not end with a transition ' - '(line %s).' % (self.statemachine.abslineno() - 1)) - self.statemachine.node += msg + '(line %s).' % (self.state_machine.abs_line_number() - 1)) + self.parent += msg self.eofcheck = 1 return [] - def blank(self, match, context, nextstate): + def blank(self, match, context, next_state): """Transition marker.""" transition = nodes.transition(context[0]) - if len(self.statemachine.node) == 0: - msg = self.statemachine.memo.reporter.error( + if len(self.parent) == 0: + msg = self.reporter.error( 'Document or section may not begin with a transition ' - '(line %s).' % (self.statemachine.abslineno() - 1)) - self.statemachine.node += msg - elif isinstance(self.statemachine.node[-1], nodes.transition): - msg = self.statemachine.memo.reporter.error( + '(line %s).' % (self.state_machine.abs_line_number() - 1)) + self.parent += msg + elif isinstance(self.parent[-1], nodes.transition): + msg = self.reporter.error( 'At least one body element must separate transitions; ' 'adjacent transitions at line %s.' - % (self.statemachine.abslineno() - 1)) - self.statemachine.node += msg - self.statemachine.node += transition + % (self.state_machine.abs_line_number() - 1)) + self.parent += msg + self.parent += transition return [], 'Body', [] - def text(self, match, context, nextstate): + def text(self, match, context, next_state): """Potential over- & underlined title.""" - lineno = self.statemachine.abslineno() - 1 + lineno = self.state_machine.abs_line_number() - 1 overline = context[0] title = match.string underline = '' try: - underline = self.statemachine.nextline() + underline = self.state_machine.next_line() except IndexError: blocktext = overline + '\n' + title - msg = self.statemachine.memo.reporter.severe( + msg = self.reporter.severe( 'Incomplete section title at line %s.' % lineno, '', nodes.literal_block(blocktext, blocktext)) - self.statemachine.node += msg + self.parent += msg return [], 'Body', [] source = '%s\n%s\n%s' % (overline, title, underline) overline = overline.rstrip() underline = underline.rstrip() if not self.transitions['underline'][0].match(underline): - msg = self.statemachine.memo.reporter.severe( + msg = self.reporter.severe( 'Missing underline for overline at line %s.' % lineno, '', nodes.literal_block(source, source)) - self.statemachine.node += msg + self.parent += msg return [], 'Body', [] elif overline != underline: - msg = self.statemachine.memo.reporter.severe( - 'Title overline & underline mismatch at ' 'line %s.' % lineno, - '', nodes.literal_block(source, source)) - self.statemachine.node += msg + msg = self.reporter.severe( + 'Title overline & underline mismatch at ' 'line %s.' + % lineno, '', nodes.literal_block(source, source)) + self.parent += msg return [], 'Body', [] title = title.rstrip() if len(title) > len(overline): - msg = self.statemachine.memo.reporter.info( + msg = self.reporter.info( 'Title overline too short at line %s.'% lineno, '', nodes.literal_block(source, source)) - self.statemachine.node += msg + self.parent += msg style = (overline[0], underline[0]) self.eofcheck = 0 # @@@ not sure this is correct self.section(title.lstrip(), source, style, lineno + 1) @@ -2135,19 +2186,19 @@ class Line(SpecializedText): indent = text # indented title - def underline(self, match=None, context=None, nextstate=None): - blocktext = context[0] + '\n' + self.statemachine.line - msg = self.statemachine.memo.reporter.error( + def underline(self, match=None, context=None, next_state=None): + blocktext = context[0] + '\n' + self.state_machine.line + msg = self.reporter.error( 'Invalid section title or transition marker at line %s.' - % (self.statemachine.abslineno() - 1), '', + % (self.state_machine.abs_line_number() - 1), '', nodes.literal_block(blocktext, blocktext)) - self.statemachine.node += msg + self.parent += msg return [], 'Body', [] -stateclasses = [Body, BulletList, DefinitionList, EnumeratedList, FieldList, - OptionList, Explicit, Text, Definition, Line, SubstitutionDef, - RFC2822Body, RFC2822List] +state_classes = (Body, BulletList, DefinitionList, EnumeratedList, FieldList, + OptionList, Explicit, Text, Definition, Line, + SubstitutionDef, RFC2822Body, RFC2822List) """Standard set of State classes used to start `RSTStateMachine`.""" @@ -2164,9 +2215,9 @@ def escape2null(text): parts.append('\x00' + text[found+1:found+2]) start = found + 2 # skip character after escape -def unescape(text, restorebackslashes=0): +def unescape(text, restore_backslashes=0): """Return a string with nulls removed or restored to backslashes.""" - if restorebackslashes: - return text.translate(RSTState.inline.null2backslash) + if restore_backslashes: + return text.translate(Inliner.null2backslash) else: - return text.translate(RSTState.inline.identity, '\x00') + return text.translate(Inliner.identity, '\x00') -- cgit v1.2.1 From 9f927b22539072acd91336c84dbd2e120bfe6d28 Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 5 May 2002 15:27:34 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@79 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/en.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index 2b1c52649..370c34d12 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -24,15 +24,18 @@ directives = { 'note': 'note', 'tip': 'tip', 'warning': 'warning', + 'questions': 'questions', + 'qa': 'questions', + 'faq': 'questions', + 'meta': 'meta', + #'imagemap': 'imagemap', 'image': 'image', 'figure': 'figure', + #'raw': 'raw', 'contents': 'contents', - 'footnotes': 'footnotes', - 'citations': 'citations', - 'topic': 'topic', - 'meta': 'meta', - 'imagemap': 'imagemap', - 'raw': 'raw', + #'footnotes': 'footnotes', + #'citations': 'citations', + #'topic': 'topic', 'restructuredtext-test-directive': 'restructuredtext-test-directive'} """English name to registered (in directives/__init__.py) directive name mapping.""" -- cgit v1.2.1 From f6d1d682215cee2501c938cf8389d720ef6118df Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 5 May 2002 15:59:03 +0000 Subject: refactored; improved compound names git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@95 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/__init__.py b/docutils/parsers/rst/languages/__init__.py index ee36d1148..07b44ea86 100644 --- a/docutils/parsers/rst/languages/__init__.py +++ b/docutils/parsers/rst/languages/__init__.py @@ -15,9 +15,9 @@ __docformat__ = 'reStructuredText' _languages = {} -def getlanguage(languagecode): - if _languages.has_key(languagecode): - return _languages[languagecode] - module = __import__(languagecode, globals(), locals()) - _languages[languagecode] = module +def getlanguage(language_code): + if _languages.has_key(language_code): + return _languages[language_code] + module = __import__(language_code, globals(), locals()) + _languages[language_code] = module return module -- cgit v1.2.1 From 5acb5943d2383d82e4e180a49905f6d7f7eb7337 Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 7 May 2002 04:18:13 +0000 Subject: - Fixed bug reporting (line #) when no blank line. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@107 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index d2a133198..434888417 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -141,7 +141,7 @@ class RSTStateMachine(StateMachineWS): StateMachine, and return the resulting document. """ - self.language = languages.getlanguage(document.language_code) + self.language = languages.get_language(document.language_code) self.match_titles = match_titles if inliner is None: inliner = Inliner() @@ -947,9 +947,9 @@ class Body(RSTState): input_offset=self.state_machine.abs_line_offset() + 1, node=bulletlist, initial_state='BulletList', blank_finish=blank_finish) + self.goto_line(newline_offset) if not blank_finish: self.parent += self.unindent_warning('Bullet list') - self.goto_line(newline_offset) return [], next_state, [] def list_item(self, indent): @@ -1000,9 +1000,9 @@ class Body(RSTState): node=enumlist, initial_state='EnumeratedList', blank_finish=blank_finish, extra_settings={'lastordinal': ordinal, 'format': format}) + self.goto_line(newline_offset) if not blank_finish: self.parent += self.unindent_warning('Enumerated list') - self.goto_line(newline_offset) return [], next_state, [] def parse_enumerator(self, match, expected_sequence=None): @@ -1067,9 +1067,9 @@ class Body(RSTState): input_offset=self.state_machine.abs_line_offset() + 1, node=fieldlist, initial_state='FieldList', blank_finish=blank_finish) + self.goto_line(newline_offset) if not blank_finish: self.parent += self.unindent_warning('Field list') - self.goto_line(newline_offset) return [], next_state, [] def field(self, match): @@ -1119,9 +1119,9 @@ class Body(RSTState): input_offset=self.state_machine.abs_line_offset() + 1, node=optionlist, initial_state='OptionList', blank_finish=blank_finish) + self.goto_line(newline_offset) if not blank_finish: self.parent += self.unindent_warning('Option list') - self.goto_line(newline_offset) return [], next_state, [] def option_list_item(self, match): @@ -1740,10 +1740,10 @@ class RFC2822Body(Body): input_offset=self.state_machine.abs_line_offset() + 1, node=fieldlist, initial_state='RFC2822List', blank_finish=blank_finish) + self.goto_line(newline_offset) if not blank_finish: self.parent += self.unindent_warning( 'RFC2822-style field list') - self.goto_line(newline_offset) return [], next_state, [] def rfc2822_field(self, match): @@ -1964,9 +1964,9 @@ class Text(RSTState): input_offset=self.state_machine.abs_line_offset() + 1, node=definitionlist, initial_state='DefinitionList', blank_finish=blank_finish, blank_finish_state='Definition') + self.goto_line(newline_offset) if not blank_finish: self.parent += self.unindent_warning('Definition list') - self.goto_line(newline_offset) return [], 'Body', [] def underline(self, match, context, next_state): -- cgit v1.2.1 From e5744d83bfa217b861297a76840492691f1896d2 Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 7 May 2002 04:22:10 +0000 Subject: name improvements git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@109 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/html.py | 2 +- docutils/parsers/rst/languages/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/html.py b/docutils/parsers/rst/directives/html.py index 262a124c8..d21ff0505 100644 --- a/docutils/parsers/rst/directives/html.py +++ b/docutils/parsers/rst/directives/html.py @@ -39,7 +39,7 @@ def meta(match, type_name, data, state, state_machine, attributes): msg = state_machine.reporter.error('Empty meta directive at line %s.' % state_machine.abs_line_number()) node += msg - return node.getchildren(), blank_finish + return node.get_children(), blank_finish def imagemap(match, type_name, data, state, state_machine, attributes): return [], 0 diff --git a/docutils/parsers/rst/languages/__init__.py b/docutils/parsers/rst/languages/__init__.py index 07b44ea86..4a5441e9e 100644 --- a/docutils/parsers/rst/languages/__init__.py +++ b/docutils/parsers/rst/languages/__init__.py @@ -15,7 +15,7 @@ __docformat__ = 'reStructuredText' _languages = {} -def getlanguage(language_code): +def get_language(language_code): if _languages.has_key(language_code): return _languages[language_code] module = __import__(language_code, globals(), locals()) -- cgit v1.2.1 From 9c4cc2885cf24d4bf4c5edb3d968ecb3dae2ef0d Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 30 May 2002 02:15:20 +0000 Subject: - Added ``-/:`` characters to inline markup's start string prefix, ``/`` to end string suffix. - Added support for an option values object which carries default settings and overrides (from command-line options and library use). - Cleaned up imports: no more relative package imports or comma-separated lists of top-level modules. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@153 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 434888417..3ee0e0534 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -12,6 +12,7 @@ the reStructuredText parser. It defines the following: - `RSTStateMachine`: reStructuredText parser's entry point. - `NestedStateMachine`: recursive StateMachine. - `RSTState`: reStructuredText State superclass. + - `Inliner`: For parsing inline markup. - `Body`: Generic classifier of the first line of a block. - `SpecializedBody`: Superclass for compound element members. - `BulletList`: Second and subsequent bullet_list list_items @@ -102,13 +103,15 @@ Parsing proceeds as follows: __docformat__ = 'reStructuredText' -import sys, re, string -from docutils import nodes, statemachine, utils, roman, urischemes, \ - ApplicationError, DataError +import sys +import re +import string +from docutils import nodes, statemachine, utils, roman, urischemes +from docutils import ApplicationError, DataError from docutils.statemachine import StateMachineWS, StateWS from docutils.utils import normalize_name -import directives, languages -from tableparser import TableParser, TableMarkupError +from docutils.parsers.rst import directives, languages +from docutils.parsers.rst.tableparser import TableParser, TableMarkupError class MarkupError(DataError): pass @@ -141,7 +144,7 @@ class RSTStateMachine(StateMachineWS): StateMachine, and return the resulting document. """ - self.language = languages.get_language(document.language_code) + self.language = languages.get_language(document.options.language_code) self.match_titles = match_titles if inliner is None: inliner = Inliner() @@ -431,9 +434,9 @@ class Inliner: openers = '\'"([{<' closers = '\'")]}>' - start_string_prefix = (r'(?:(?<=^)|(?<=[ \n%s]))' + start_string_prefix = (r'(?:(?<=^)|(?<=[-/: \n%s]))' % re.escape(openers)) - end_string_suffix = (r'(?:(?=$)|(?=[- \n.,:;!?%s]))' + end_string_suffix = (r'(?:(?=$)|(?=[-/:.,;!? \n%s]))' % re.escape(closers)) non_whitespace_before = r'(? Date: Thu, 30 May 2002 02:30:40 +0000 Subject: Cleaned up imports git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@160 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/__init__.py b/docutils/parsers/rst/__init__.py index 506a9e9fb..66b594841 100644 --- a/docutils/parsers/rst/__init__.py +++ b/docutils/parsers/rst/__init__.py @@ -48,7 +48,7 @@ __docformat__ = 'reStructuredText' import docutils.parsers import docutils.statemachine -import states +from docutils.parsers.rst import states class Parser(docutils.parsers.Parser): -- cgit v1.2.1 From 279a5cfc2c066bba8de6a9035c077f43710d849d Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 27 Jun 2002 01:20:25 +0000 Subject: Updated & cleaned up (a bit). git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@208 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 3ee0e0534..543bc1108 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1361,8 +1361,9 @@ class Body(RSTState): footnote['name'] = name self.document.note_footnote(footnote) if name: - self.document.note_explicit_target(footnote, - footnote) + self.document.note_explicit_target(footnote, footnote) + else: + self.document.set_id(footnote) if indented: self.nested_parse(indented, input_offset=offset, node=footnote) return [footnote], blank_finish @@ -1444,8 +1445,7 @@ class Body(RSTState): self.document.note_external_target(target) else: self.document.note_internal_target(target) - self.document.note_explicit_target( - target, self.parent) + self.document.note_explicit_target(target, self.parent) else: # anonymous target if refuri: target['refuri'] = refuri -- cgit v1.2.1 From eca63d0c7af69af08c0acc8e54b1d8e9fc97b88d Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 28 Jun 2002 04:19:02 +0000 Subject: - Fixed bug with literal blocks. - Added support for input and output encodings and for internal Unicode support. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@221 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 543bc1108..aff499625 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -353,7 +353,7 @@ class RSTState(StateWS): if data[-2:] == '::': if len(data) == 2: return [], 1 - elif data[-3] == ' ': + elif data[-3] in ' \n': text = data[:-3].rstrip() else: text = data[:-1] @@ -445,8 +445,6 @@ class Inliner: uric = r"""[-_.!~*'()[\];/:@&=+$,%a-zA-Z0-9]""" urilast = r"""[_~/\]a-zA-Z0-9]""" emailc = r"""[-_!~*'{|}/#?^`&=+$%a-zA-Z0-9]""" - identity = string.maketrans('', '') - null2backslash = string.maketrans('\x00', '\\') patterns = Stuff( initial=re.compile( r""" @@ -970,8 +968,8 @@ class Body(RSTState): if ordinal is None: msg = self.reporter.error( ('Enumerated list start value invalid at line %s: ' - '%r (sequence %r)' % (self.state_machine.abs_line_number(), - text, sequence))) + '"%s" (sequence %r)' + % (self.state_machine.abs_line_number(), text, sequence))) self.parent += msg indented, line_offset, blank_finish = \ self.state_machine.get_known_indented(match.end()) @@ -984,8 +982,8 @@ class Body(RSTState): if ordinal != 1: msg = self.reporter.info( ('Enumerated list start value not ordinal-1 at line %s: ' - '%r (ordinal %s)' % (self.state_machine.abs_line_number(), - text, ordinal))) + '"%s" (ordinal %s)' + % (self.state_machine.abs_line_number(), text, ordinal))) self.parent += msg enumlist = nodes.enumerated_list() self.parent += enumlist @@ -1167,8 +1165,8 @@ class Body(RSTState): optlist.append(option) else: raise MarkupError('wrong numer of option tokens (=%s), ' - 'should be 1 or 2: %r' % (len(tokens), - optionstring)) + 'should be 1 or 2: "%s"' % (len(tokens), + optionstring)) return optlist def doctest(self, match, context, next_state): @@ -2221,6 +2219,6 @@ def escape2null(text): def unescape(text, restore_backslashes=0): """Return a string with nulls removed or restored to backslashes.""" if restore_backslashes: - return text.translate(Inliner.null2backslash) + return text.replace('\x00', '\\') else: - return text.translate(Inliner.identity, '\x00') + return ''.join(text.split('\x00')) -- cgit v1.2.1 From c06d0f016cf4f539db28a4ea6142855cc7bb92aa Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 29 Jun 2002 23:07:42 +0000 Subject: Applied patch from Simon Budig, simplifying regexps by with symbolic names. Also, Inliner.groups and Body.explicit.groups have been removed. The patch pointed out a bug in interpreted text parsing code, to be resolved. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@232 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 198 ++++++++++++++++++----------------------- 1 file changed, 89 insertions(+), 109 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index aff499625..ffce6171b 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -402,10 +402,6 @@ class Inliner: self.parent = parent pattern = self.patterns.initial dispatch = self.dispatch - start = self.groups.initial.start - 1 - backquote = self.groups.initial.backquote - 1 - refend = self.groups.initial.refend - 1 - fnend = self.groups.initial.fnend - 1 remaining = escape2null(text) processed = [] unprocessed = [] @@ -413,11 +409,11 @@ class Inliner: while remaining: match = pattern.search(remaining) if match: - groups = match.groups() - before, inlines, remaining, sysmessages = \ - dispatch[groups[start] or groups[backquote] - or groups[refend] - or groups[fnend]](self, match, lineno) + groupdict = match.groupdict() + method = dispatch[groupdict["start"] or groupdict["backquote"] + or groupdict["refend"] or groupdict["fnend"]] + before, inlines, remaining, sysmessages = method(self, match, + lineno) unprocessed.append(before) messages += sysmessages if inlines: @@ -434,14 +430,12 @@ class Inliner: openers = '\'"([{<' closers = '\'")]}>' - start_string_prefix = (r'(?:(?<=^)|(?<=[-/: \n%s]))' - % re.escape(openers)) - end_string_suffix = (r'(?:(?=$)|(?=[-/:.,;!? \n%s]))' - % re.escape(closers)) + start_string_prefix = (r'((?<=^)|(?<=[-/: \n%s]))' % re.escape(openers)) + end_string_suffix = (r'((?=$)|(?=[-/:.,;!? \n%s]))' % re.escape(closers)) non_whitespace_before = r'(? # start-strings only: \*\* # strong | \* # emphasis @@ -464,27 +458,27 @@ class Inliner: ) %s # no whitespace after | # *OR* - ( # whole constructs (group 3): - (%s) # reference name (4) - (__?) # end-string (5) + (?P # whole constructs: + (?P%s) # reference name + (?P__?) # end-string | \[ # footnote_reference or # citation_reference start - ( # label (group 6): + (?P # label: [0-9]+ # manually numbered | # *OR* - \#(?:%s)? # auto-numbered (w/ label?) + \#(%s)? # auto-numbered (w/ label?) | # *OR* \* # auto-symbol | # *OR* - (%s) # citation reference (group 7) + (?P%s) # citation reference ) - (\]_) # end-string (group 8) + (?P\]_) # end-string ) %s # end-string suffix | # *OR* - ((?::%s:)?) # optional role (group 9) - ( # start-string (group 10) + (?P(:%s:)?) # optional role + (?P # start-string ` # interpreted text # or phrase reference (?!`) # but not literal @@ -505,9 +499,9 @@ class Inliner: strong=re.compile(non_whitespace_escape_before + r'(\*\*)' + end_string_suffix), interpreted_or_phrase_ref=re.compile( - '%s(`(:%s:|__?)?)%s' % (non_whitespace_escape_before, - simplename, - end_string_suffix)), + '%s(`(?P:%s:|__?)?)%s' % (non_whitespace_escape_before, + simplename, + end_string_suffix)), literal=re.compile(non_whitespace_before + '(``)' + end_string_suffix), target=re.compile(non_whitespace_escape_before @@ -518,33 +512,33 @@ class Inliner: uri=re.compile( r""" %s # start-string prefix - ( - ( # absolute URI (group 2) - ( # scheme (http, ftp, mailto) - [a-zA-Z][a-zA-Z0-9.+-]* # (group 3) + (?P + (?P # absolute URI + (?P # scheme (http, ftp, mailto) + [a-zA-Z][a-zA-Z0-9.+-]* ) : - (?: - (?: # either: - (?://?)? # hierarchical URI + ( + ( # either: + (//?)? # hierarchical URI %s* # URI characters %s # final URI char ) - (?: # optional query + ( # optional query \?%s* # URI characters %s # final URI char )? - (?: # optional fragment + ( # optional fragment \#%s* # URI characters %s # final URI char )? ) ) | # *OR* - ( # email address (group 4) - %s+(?:\.%s+)* # name + (?P # email address + %s+(\.%s+)* # name @ # at - %s+(?:\.%s*)* # host + %s+(\.%s*)* # host %s # final URI char ) ) @@ -553,11 +547,6 @@ class Inliner: uric, urilast, emailc, emailc, emailc, emailc, urilast, end_string_suffix,), re.VERBOSE)) - groups = Stuff(initial=Stuff(start=2, whole=3, refname=4, refend=5, - footnotelabel=6, citationlabel=7, - fnend=8, role=9, backquote=10), - interpreted_or_phrase_ref=Stuff(suffix=2), - uri=Stuff(whole=1, absolute=2, scheme=3, email=4)) def quoted_start(self, match): """Return 1 if inline markup start-string is 'quoted', 0 if not.""" @@ -581,8 +570,8 @@ class Inliner: def inline_obj(self, match, lineno, pattern, nodeclass, restore_backslashes=0): string = match.string - matchstart = match.start(self.groups.initial.start) - matchend = match.end(self.groups.initial.start) + matchstart = match.start('start') + matchend = match.end('start') if self.quoted_start(match): return (string[:matchend], [], string[matchend:], [], '') endmatch = pattern.search(string[matchend:]) @@ -621,13 +610,11 @@ class Inliner: def interpreted_or_phrase_ref(self, match, lineno): pattern = self.patterns.interpreted_or_phrase_ref - rolegroup = self.groups.initial.role - backquote = self.groups.initial.backquote string = match.string - matchstart = match.start(backquote) - matchend = match.end(backquote) - rolestart = match.start(rolegroup) - role = match.group(rolegroup) + matchstart = match.start('backquote') + matchend = match.end('backquote') + rolestart = match.start('role') + role = match.group('role') position = '' if role: role = role[1:-1] @@ -680,13 +667,12 @@ class Inliner: def interpreted(self, before, after, endmatch, role, position, lineno, escaped, rawsource, text): - suffix = self.groups.interpreted_or_phrase_ref.suffix - if endmatch.group(suffix): + if endmatch.group('suffix'): if role: msg = self.reporter.warning('Multiple roles in interpreted ' 'text at line %s.' % lineno) return (before + rawsource, [], after, [msg]) - role = endmatch.group(suffix)[1:-1] + role = endmatch.group('suffix')[1:-1] position = 'suffix' if role: atts = {'role': role, 'position': position} @@ -743,9 +729,9 @@ class Inliner: Handles `nodes.footnote_reference` and `nodes.citation_reference` elements. """ - label = match.group(self.groups.initial.footnotelabel) + label = match.group('footnotelabel') refname = normalize_name(label) - if match.group(self.groups.initial.citationlabel): + if match.group('citationlabel'): refnode = nodes.citation_reference('[%s]_' % label, refname=refname) refnode += nodes.Text(label) @@ -767,16 +753,15 @@ class Inliner: refnode['refname'] = refname self.document.note_footnote_ref(refnode) string = match.string - matchstart = match.start(self.groups.initial.whole) - matchend = match.end(self.groups.initial.whole) + matchstart = match.start('whole') + matchend = match.end('whole') return (string[:matchstart], [refnode], string[matchend:], []) def reference(self, match, lineno, anonymous=None): - referencename = match.group(self.groups.initial.refname) + referencename = match.group('refname') refname = normalize_name(referencename) - referencenode = nodes.reference( - referencename + match.group(self.groups.initial.refend), - referencename) + referencenode = nodes.reference(referencename + match.group('refend'), + referencename) if anonymous: referencenode['anonymous'] = 1 self.document.note_anonymous_ref(referencenode) @@ -784,22 +769,21 @@ class Inliner: referencenode['refname'] = refname self.document.note_refname(referencenode) string = match.string - matchstart = match.start(self.groups.initial.whole) - matchend = match.end(self.groups.initial.whole) + matchstart = match.start('whole') + matchend = match.end('whole') return (string[:matchstart], [referencenode], string[matchend:], []) def anonymous_reference(self, match, lineno): return self.reference(match, lineno, anonymous=1) def standalone_uri(self, match, lineno): - scheme = self.groups.uri.scheme - if not match.group(scheme) or urischemes.schemes.has_key( - match.group(scheme).lower()): - if match.group(self.groups.uri.email): + if not match.group('scheme') or urischemes.schemes.has_key( + match.group('scheme').lower()): + if match.group('email'): addscheme = 'mailto:' else: addscheme = '' - text = match.group(self.groups.uri.whole) + text = match.group('whole') unescaped = unescape(text, 0) return [nodes.reference(unescape(text, 1), unescaped, refuri=addscheme + unescaped)] @@ -1289,54 +1273,52 @@ class Body(RSTState): explicit.patterns = Stuff( target=re.compile(r""" - (?: - _ # anonymous target - | # *OR* - (`?) # optional open quote - (?![ `]) # first char. not space or backquote - ( # reference name + ( + _ # anonymous target + | # *OR* + (?P`?) # optional open quote + (?![ `]) # first char. not space or + # backquote + (?P # reference name .+? ) - %s # not whitespace or escape - \1 # close quote if open quote used + %s # not whitespace or escape + (?P=quote) # close quote if open quote used ) - %s # not whitespace or escape - : # end of reference name - (?:[ ]+|$) # followed by whitespace + %s # not whitespace or escape + : # end of reference name + ([ ]+|$) # followed by whitespace """ % (Inliner.non_whitespace_escape_before, Inliner.non_whitespace_escape_before), re.VERBOSE), reference=re.compile(r""" - (?: - (%s)_ # simple reference name - | # *OR* - ` # open backquote - (?![ ]) # not space - (.+?) # hyperlink phrase - %s # not whitespace or escape - `_ # close backquote, reference mark + ( + (?P%s)_ # simple reference name + | # *OR* + ` # open backquote + (?![ ]) # not space + (?P.+?) # hyperlink phrase + %s # not whitespace or escape + `_ # close backquote, + # reference mark ) - $ # end of string + $ # end of string """ % (Inliner.simplename, Inliner.non_whitespace_escape_before,), re.VERBOSE), substitution=re.compile(r""" - (?: - (?![ ]) # first char. not space - (.+?) # substitution text - %s # not whitespace or escape - \| # close delimiter + ( + (?![ ]) # first char. not space + (?P.+?) # substitution text + %s # not whitespace or escape + \| # close delimiter ) - (?:[ ]+|$) # followed by whitespace + ([ ]+|$) # followed by whitespace """ % Inliner.non_whitespace_escape_before, re.VERBOSE),) - explicit.groups = Stuff( - target=Stuff(quote=1, name=2), - reference=Stuff(simple=1, phrase=2), - substitution=Stuff(name=1)) def footnote(self, match): indented, indent, offset, blank_finish = \ @@ -1382,7 +1364,6 @@ class Body(RSTState): def hyperlink_target(self, match): pattern = self.explicit.patterns.target - namegroup = self.explicit.groups.target.name lineno = self.state_machine.abs_line_number() block, indent, offset, blank_finish = \ self.state_machine.get_first_known_indented( @@ -1408,7 +1389,7 @@ class Body(RSTState): refname = self.is_reference(reference) if refname: target = nodes.target(blocktext, '', refname=refname) - self.add_target(targetmatch.group(namegroup), '', target) + self.add_target(targetmatch.group('name'), '', target) self.document.note_indirect_target(target) return [target], blank_finish nodelist = [] @@ -1423,7 +1404,7 @@ class Body(RSTState): else: unescaped = unescape(reference) target = nodes.target(blocktext, '') - self.add_target(targetmatch.group(namegroup), unescaped, target) + self.add_target(targetmatch.group('name'), unescaped, target) nodelist.append(target) return nodelist, blank_finish @@ -1431,8 +1412,7 @@ class Body(RSTState): match = self.explicit.patterns.reference.match(normalize_name(reference)) if not match: return None - return unescape(match.group(self.explicit.groups.reference.simple) - or match.group(self.explicit.groups.reference.phrase)) + return unescape(match.group('simple') or match.group('phrase')) def add_target(self, targetname, refuri, target): if targetname: @@ -1475,7 +1455,7 @@ class Body(RSTState): if not block[0]: del block[0] offset += 1 - subname = subdefmatch.group(self.explicit.groups.substitution.name) + subname = subdefmatch.group('name') name = normalize_name(subname) substitutionnode = nodes.substitution_definition( blocktext, name=name, alt=subname) @@ -1592,13 +1572,13 @@ class Body(RSTState): \* # auto-symbol footnote ) \] - (?:[ ]+|$) # whitespace or end of line + ([ ]+|$) # whitespace or end of line """ % Inliner.simplename, re.VERBOSE)), (citation, re.compile(r""" \.\.[ ]+ # explicit markup start \[(%s)\] # citation label - (?:[ ]+|$) # whitespace or end of line + ([ ]+|$) # whitespace or end of line """ % Inliner.simplename, re.VERBOSE)), (hyperlink_target, re.compile(r""" @@ -1617,7 +1597,7 @@ class Body(RSTState): \.\.[ ]+ # explicit markup start (%s) # directive name :: # directive delimiter - (?:[ ]+|$) # whitespace or end of line + ([ ]+|$) # whitespace or end of line """ % Inliner.simplename, re.VERBOSE))] def explicit_markup(self, match, context, next_state): -- cgit v1.2.1 From 606baf1b20ec93778e127d90c11d60321ea2ae4e Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 4 Jul 2002 01:21:21 +0000 Subject: - Converted regexps from ``'%s' % var`` to ``'%(var)s' % locals()``. - Fixed a bug in ``Inliner.interpreted_or_phrase_ref()``. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@240 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 192 ++++++++++++++++++++--------------------- 1 file changed, 93 insertions(+), 99 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index ffce6171b..f3be937d6 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -400,18 +400,18 @@ class Inliner: self.reporter = memo.reporter self.document = memo.document self.parent = parent - pattern = self.patterns.initial + pattern_search = self.patterns.initial.search dispatch = self.dispatch remaining = escape2null(text) processed = [] unprocessed = [] messages = [] while remaining: - match = pattern.search(remaining) + match = pattern_search(remaining) if match: - groupdict = match.groupdict() - method = dispatch[groupdict["start"] or groupdict["backquote"] - or groupdict["refend"] or groupdict["fnend"]] + groups = match.groupdict() + method = dispatch[groups['start'] or groups['backquote'] + or groups['refend'] or groups['fnend']] before, inlines, remaining, sysmessages = method(self, match, lineno) unprocessed.append(before) @@ -437,12 +437,12 @@ class Inliner: non_whitespace_after = r'(?![ \n])' simplename = r'[a-zA-Z0-9]([-_.a-zA-Z0-9]*[a-zA-Z0-9])?' uric = r"""[-_.!~*'()[\];/:@&=+$,%a-zA-Z0-9]""" - urilast = r"""[_~/\]a-zA-Z0-9]""" + urilast = r"""[_~/\]a-zA-Z0-9]""" # no punctuation emailc = r"""[-_!~*'{|}/#?^`&=+$%a-zA-Z0-9]""" patterns = Stuff( initial=re.compile( r""" - %s # start-string prefix + %(start_string_prefix)s ( (?P # start-strings only: \*\* # strong @@ -456,52 +456,53 @@ class Inliner: | \| # substitution_reference start ) - %s # no whitespace after + %(non_whitespace_after)s | # *OR* (?P # whole constructs: - (?P%s) # reference name - (?P__?) # end-string + (?P%(simplename)s) # reference name + (?P__?) # end-string | \[ # footnote_reference or # citation_reference start (?P # label: [0-9]+ # manually numbered | # *OR* - \#(%s)? # auto-numbered (w/ label?) + \#(%(simplename)s)? # auto-numbered (w/ label?) | # *OR* \* # auto-symbol | # *OR* - (?P%s) # citation reference + (?P + %(simplename)s) # citation reference ) (?P\]_) # end-string ) - %s # end-string suffix + %(end_string_suffix)s | # *OR* - (?P(:%s:)?) # optional role + (?P(:%(simplename)s:)?) # optional role (?P # start-string ` # interpreted text # or phrase reference (?!`) # but not literal ) - %s # no whitespace after + %(non_whitespace_after)s # no whitespace after ) - """ % (start_string_prefix, - non_whitespace_after, - simplename, - simplename, - simplename, - end_string_suffix, - simplename, - non_whitespace_after,), - re.VERBOSE), + """ % locals(), re.VERBOSE), emphasis=re.compile(non_whitespace_escape_before + r'(\*)' + end_string_suffix), strong=re.compile(non_whitespace_escape_before + r'(\*\*)' + end_string_suffix), interpreted_or_phrase_ref=re.compile( - '%s(`(?P:%s:|__?)?)%s' % (non_whitespace_escape_before, - simplename, - end_string_suffix)), + r""" + %(non_whitespace_escape_before)s + ( + ` + (?P + (?P:%(simplename)s:)? + (?P__?)? + ) + ) + %(end_string_suffix)s + """ % locals(), re.VERBOSE), literal=re.compile(non_whitespace_before + '(``)' + end_string_suffix), target=re.compile(non_whitespace_escape_before @@ -511,7 +512,7 @@ class Inliner: + end_string_suffix), uri=re.compile( r""" - %s # start-string prefix + %(start_string_prefix)s (?P (?P # absolute URI (?P # scheme (http, ftp, mailto) @@ -521,32 +522,29 @@ class Inliner: ( ( # either: (//?)? # hierarchical URI - %s* # URI characters - %s # final URI char + %(uric)s* # URI characters + %(urilast)s # final URI char ) ( # optional query - \?%s* # URI characters - %s # final URI char + \?%(uric)s* + %(urilast)s )? ( # optional fragment - \#%s* # URI characters - %s # final URI char + \#%(uric)s* + %(urilast)s )? ) ) | # *OR* (?P # email address - %s+(\.%s+)* # name - @ # at - %s+(\.%s*)* # host - %s # final URI char + %(emailc)s+(\.%(emailc)s+)* # name + @ # at + %(emailc)s+(\.%(emailc)s*)* # host + %(urilast)s # final URI char ) ) - %s # end-string suffix - """ % (start_string_prefix, uric, urilast, uric, urilast, - uric, urilast, emailc, emailc, emailc, emailc, urilast, - end_string_suffix,), - re.VERBOSE)) + %(end_string_suffix)s + """ % locals(), re.VERBOSE)) def quoted_start(self, match): """Return 1 if inline markup start-string is 'quoted', 0 if not.""" @@ -567,22 +565,21 @@ class Inliner: pass return 0 - def inline_obj(self, match, lineno, pattern, nodeclass, + def inline_obj(self, match, lineno, end_pattern, nodeclass, restore_backslashes=0): string = match.string matchstart = match.start('start') matchend = match.end('start') if self.quoted_start(match): return (string[:matchend], [], string[matchend:], [], '') - endmatch = pattern.search(string[matchend:]) + endmatch = end_pattern.search(string[matchend:]) if endmatch and endmatch.start(1): # 1 or more chars text = unescape(endmatch.string[:endmatch.start(1)], restore_backslashes) - rawsource = unescape(string[matchstart:matchend+endmatch.end(1)], - 1) + textend = matchend + endmatch.end(1) + rawsource = unescape(string[matchstart:textend], 1) return (string[:matchstart], [nodeclass(rawsource, text)], - string[matchend:][endmatch.end(1):], [], - endmatch.group(1)) + string[textend:], [], endmatch.group(1)) msg = self.reporter.warning( 'Inline %s start-string without end-string ' 'at line %s.' % (nodeclass.__name__, lineno)) @@ -609,7 +606,7 @@ class Inliner: return before, inlines, remaining, sysmessages def interpreted_or_phrase_ref(self, match, lineno): - pattern = self.patterns.interpreted_or_phrase_ref + end_pattern = self.patterns.interpreted_or_phrase_ref string = match.string matchstart = match.start('backquote') matchend = match.end('backquote') @@ -621,40 +618,44 @@ class Inliner: position = 'prefix' elif self.quoted_start(match): return (string[:matchend], [], string[matchend:], []) - endmatch = pattern.search(string[matchend:]) + endmatch = end_pattern.search(string[matchend:]) if endmatch and endmatch.start(1): # 1 or more chars + textend = matchend + endmatch.end() + if endmatch.group('role'): + if role: + msg = self.reporter.warning( + 'Multiple roles in interpreted text at line %s (both ' + 'prefix and suffix present; only one allowed).' + % lineno) + text = unescape(string[rolestart:textend], 1) + prb = self.problematic(text, text, msg) + return string[:rolestart], [prb], string[textend:], [msg] + role = endmatch.group('suffix')[1:-1] + position = 'suffix' escaped = endmatch.string[:endmatch.start(1)] text = unescape(escaped, 0) - rawsource = unescape( - string[match.start():matchend+endmatch.end()], 1) + rawsource = unescape(string[matchstart:textend], 1) if rawsource[-1:] == '_': if role: msg = self.reporter.warning( - 'Mismatch: inline interpreted text start-string and' - ' role with phrase-reference end-string at line %s.' - % lineno) - text = unescape(string[matchstart:matchend], 1) - rawsource = unescape(string[matchstart:matchend], 1) - prb = self.problematic(text, rawsource, msg) - return (string[:matchstart], [prb], string[matchend:], - [msg]) - return self.phrase_ref( - string[:matchstart], string[matchend:][endmatch.end():], - text, rawsource) + 'Mismatch: both interpreted text role %s and ' + 'reference suffix at line %s.' % (position, lineno)) + text = unescape(string[rolestart:textend], 1) + prb = self.problematic(text, text, msg) + return string[:rolestart], [prb], string[textend:], [msg] + return self.phrase_ref(string[:matchstart], string[textend:], + rawsource, text) else: - return self.interpreted( - string[:rolestart], string[matchend:][endmatch.end():], - endmatch, role, position, lineno, - escaped, rawsource, text) + return self.interpreted(string[:rolestart], string[textend:], + rawsource, text, role, position) msg = self.reporter.warning( 'Inline interpreted text or phrase reference start-string ' 'without end-string at line %s.' % lineno) text = unescape(string[matchstart:matchend], 1) - rawsource = unescape(string[matchstart:matchend], 1) - prb = self.problematic(text, rawsource, msg) + prb = self.problematic(text, text, msg) return string[:matchstart], [prb], string[matchend:], [msg] - def phrase_ref(self, before, after, text, rawsource): + def phrase_ref(self, before, after, rawsource, text): refname = normalize_name(text) reference = nodes.reference(rawsource, text) if rawsource[-2:] == '__': @@ -665,15 +666,7 @@ class Inliner: self.document.note_refname(reference) return before, [reference], after, [] - def interpreted(self, before, after, endmatch, role, position, lineno, - escaped, rawsource, text): - if endmatch.group('suffix'): - if role: - msg = self.reporter.warning('Multiple roles in interpreted ' - 'text at line %s.' % lineno) - return (before + rawsource, [], after, [msg]) - role = endmatch.group('suffix')[1:-1] - position = 'suffix' + def interpreted(self, before, after, rawsource, text, role, position): if role: atts = {'role': role, 'position': position} else: @@ -797,7 +790,8 @@ class Inliner: """ Check each of the patterns in `self.implicit` for a match, and dispatch to the stored method for the pattern. Recursively check the - text before and after the match. + text before and after the match. Return a list of `nodes.Text` and + inline element nodes. """ if not text: return [] @@ -805,13 +799,20 @@ class Inliner: match = pattern.search(text) if match: try: - return (self.implicit_inline(text[:match.start()], lineno) + return (self.text(text[:match.start()]) + dispatch(self, match, lineno) + self.implicit_inline(text[match.end():], lineno)) except MarkupMismatch: pass return [nodes.Text(unescape(text))] + def text(self, text): + """Return a list containing one `nodes.Text` node or nothing.""" + if not text: + return [] + return [nodes.Text(unescape(text))] + + dispatch = {'*': emphasis, '**': strong, '`': interpreted_or_phrase_ref, @@ -1282,43 +1283,35 @@ class Body(RSTState): (?P # reference name .+? ) - %s # not whitespace or escape + %(non_whitespace_escape_before)s (?P=quote) # close quote if open quote used ) - %s # not whitespace or escape + %(non_whitespace_escape_before)s : # end of reference name ([ ]+|$) # followed by whitespace - """ - % (Inliner.non_whitespace_escape_before, - Inliner.non_whitespace_escape_before), - re.VERBOSE), + """ % vars(Inliner), re.VERBOSE), reference=re.compile(r""" ( - (?P%s)_ # simple reference name + (?P%(simplename)s)_ | # *OR* ` # open backquote (?![ ]) # not space (?P.+?) # hyperlink phrase - %s # not whitespace or escape + %(non_whitespace_escape_before)s `_ # close backquote, # reference mark ) $ # end of string - """ % - (Inliner.simplename, - Inliner.non_whitespace_escape_before,), - re.VERBOSE), + """ % vars(Inliner), re.VERBOSE), substitution=re.compile(r""" ( (?![ ]) # first char. not space (?P.+?) # substitution text - %s # not whitespace or escape + %(non_whitespace_escape_before)s \| # close delimiter ) ([ ]+|$) # followed by whitespace - """ % - Inliner.non_whitespace_escape_before, - re.VERBOSE),) + """ % vars(Inliner), re.VERBOSE),) def footnote(self, match): indented, indent, offset, blank_finish = \ @@ -1409,7 +1402,8 @@ class Body(RSTState): return nodelist, blank_finish def is_reference(self, reference): - match = self.explicit.patterns.reference.match(normalize_name(reference)) + match = self.explicit.patterns.reference.match( + normalize_name(reference)) if not match: return None return unescape(match.group('simple') or match.group('phrase')) -- cgit v1.2.1 From e521880b4a16e6500b171d673e1c6ef50d92e7e2 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 11 Jul 2002 01:49:35 +0000 Subject: - Allowed non-ASCII in "simple names" (directive names, field names, references, etc.). git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@262 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index f3be937d6..12174c5de 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -435,7 +435,7 @@ class Inliner: non_whitespace_before = r'(? Date: Sat, 13 Jul 2002 03:05:45 +0000 Subject: - Converted ``Inliner.patterns.initial`` to be dynamically built from parts with ``build_regexp()`` function. - Changed ``Inliner.inline_target`` to ``.inline_internal_target``. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@275 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 103 +++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 50 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 12174c5de..6c26b779b 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -105,7 +105,7 @@ __docformat__ = 'reStructuredText' import sys import re -import string +from types import TupleType from docutils import nodes, statemachine, utils, roman, urischemes from docutils import ApplicationError, DataError from docutils.statemachine import StateMachineWS, StateWS @@ -377,6 +377,29 @@ class RSTState(StateWS): % (node_name, self.state_machine.abs_line_number() + 1))) +def build_regexp(definition, compile=1): + """ + Build, compile and return a regular expression based on `definition`. + + :Parameter: `definition`: a 4-tuple (group name, prefix, suffix, parts), + where "parts" is a list of regular expressions and/or regular + expression definitions to be joined into an or-group. + """ + name, prefix, suffix, parts = definition + part_strings = [] + for part in parts: + if type(part) is TupleType: + part_strings.append(build_regexp(part, None)) + else: + part_strings.append(part) + or_group = '|'.join(part_strings) + regexp = '%(prefix)s(?P<%(name)s>%(or_group)s)%(suffix)s' % locals() + if compile: + return re.compile(regexp, re.UNICODE) + else: + return regexp + + class Inliner: """ @@ -439,54 +462,34 @@ class Inliner: uric = r"""[-_.!~*'()[\];/:@&=+$,%a-zA-Z0-9]""" urilast = r"""[_~/\]a-zA-Z0-9]""" # no punctuation emailc = r"""[-_!~*'{|}/#?^`&=+$%a-zA-Z0-9]""" + parts = ('initial_inline', start_string_prefix, '', + [('start', '', non_whitespace_after, # simple start-strings + [r'\*\*', # strong + r'\*(?!\*)', # emphasis but not strong + r'``', # literal + r'_`', # inline internal target + r'\|'] # substitution reference + ), + ('whole', '', end_string_suffix, # whole constructs + [# reference name & end-string + r'(?P%s)(?P__?)' % simplename, + ('footnotelabel', r'\[', r'(?P\]_)', + [r'[0-9]+', # manually numbered + r'\#(%s)?' % simplename, # auto-numbered (w/ label?) + r'\*', # auto-symbol + r'(?P%s)' % simplename] # citation reference + ) + ] + ), + ('backquote', # interpreted text or phrase reference + '(?P(:%s:)?)' % simplename, # optional role + non_whitespace_after, + ['`(?!`)'] # but not literal + ) + ] + ) patterns = Stuff( - initial=re.compile( - r""" - %(start_string_prefix)s - ( - (?P # start-strings only: - \*\* # strong - | - \* # emphasis - (?!\*) # but not strong - | - `` # literal - | - _` # inline hyperlink target - | - \| # substitution_reference start - ) - %(non_whitespace_after)s - | # *OR* - (?P # whole constructs: - (?P%(simplename)s) # reference name - (?P__?) # end-string - | - \[ # footnote_reference or - # citation_reference start - (?P # label: - [0-9]+ # manually numbered - | # *OR* - \#(%(simplename)s)? # auto-numbered (w/ label?) - | # *OR* - \* # auto-symbol - | # *OR* - (?P - %(simplename)s) # citation reference - ) - (?P\]_) # end-string - ) - %(end_string_suffix)s - | # *OR* - (?P(:%(simplename)s:)?) # optional role - (?P # start-string - ` # interpreted text - # or phrase reference - (?!`) # but not literal - ) - %(non_whitespace_after)s # no whitespace after - ) - """ % locals(), re.VERBOSE | re.UNICODE), + initial=build_regexp(parts), emphasis=re.compile(non_whitespace_escape_before + r'(\*)' + end_string_suffix), strong=re.compile(non_whitespace_escape_before @@ -679,7 +682,7 @@ class Inliner: restore_backslashes=1) return before, inlines, remaining, sysmessages - def inline_target(self, match, lineno): + def inline_internal_target(self, match, lineno): before, inlines, remaining, sysmessages, endstring = self.inline_obj( match, lineno, self.patterns.target, nodes.target) if inlines and isinstance(inlines[0], nodes.target): @@ -817,7 +820,7 @@ class Inliner: '**': strong, '`': interpreted_or_phrase_ref, '``': literal, - '_`': inline_target, + '_`': inline_internal_target, ']_': footnote_reference, '|': substitution_reference, '_': reference, -- cgit v1.2.1 From c21a148798856797bbf693ff1f5c8ba9c604cce1 Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 14 Jul 2002 02:45:41 +0000 Subject: Undid a mistake. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@278 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 6c26b779b..9b4114b80 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -802,18 +802,14 @@ class Inliner: match = pattern.search(text) if match: try: - return (self.text(text[:match.start()]) + # Must recurse on strings before *and* after the match; + # there may be multiple patterns. + return (self.implicit_inline(text[:match.start()], lineno) + dispatch(self, match, lineno) + self.implicit_inline(text[match.end():], lineno)) except MarkupMismatch: pass return [nodes.Text(unescape(text))] - - def text(self, text): - """Return a list containing one `nodes.Text` node or nothing.""" - if not text: - return [] - return [nodes.Text(unescape(text))] dispatch = {'*': emphasis, -- cgit v1.2.1 From 6b456ac082f235f368eaa37e4b4905222a76028d Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 18 Jul 2002 00:52:40 +0000 Subject: - Updated docstrings. - Changed "table" to "grid_table"; added "simple_table" support. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@300 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 161 ++++++++++++++++++++++++++++++----------- 1 file changed, 119 insertions(+), 42 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 9b4114b80..04a9ea605 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -44,11 +44,11 @@ the reStructuredText parser. It defines the following: Parser Overview =============== -The reStructuredText parser is implemented as a state machine, examining its -input one line at a time. To understand how the parser works, please first -become familiar with the `docutils.statemachine` module. In the description -below, references are made to classes defined in this module; please see the -individual classes for details. +The reStructuredText parser is implemented as a recursive state machine, +examining its input one line at a time. To understand how the parser works, +please first become familiar with the `docutils.statemachine` module. In the +description below, references are made to classes defined in this module; +please see the individual classes for details. Parsing proceeds as follows: @@ -60,26 +60,27 @@ Parsing proceeds as follows: 2. The method associated with the matched transition pattern is called. A. Some transition methods are self-contained, appending elements to the - document tree ('doctest' parses a doctest block). The parser's current - line index is advanced to the end of the element, and parsing continues - with step 1. + document tree (`Body.doctest` parses a doctest block). The parser's + current line index is advanced to the end of the element, and parsing + continues with step 1. - B. Others trigger the creation of a nested state machine, whose job is to - parse a compound construct ('indent' does a block quote, 'bullet' does a - bullet list, 'overline' does a section [first checking for a valid - section header]). + B. Other transition methods trigger the creation of a nested state machine, + whose job is to parse a compound construct ('indent' does a block quote, + 'bullet' does a bullet list, 'overline' does a section [first checking + for a valid section header], etc.). - - In the case of lists and explicit markup, a new state machine is - created and run to parse the first item. + - In the case of lists and explicit markup, a one-off state machine is + created and run to parse contents of the first item. - A new state machine is created and its initial state is set to the appropriate specialized state (`BulletList` in the case of the - 'bullet' transition). This state machine is run to parse the compound - element (or series of explicit markup elements), and returns as soon - as a non-member element is encountered. For example, the `BulletList` - state machine aborts as soon as it encounters an element which is not - a list item of that bullet list. The optional omission of - inter-element blank lines is handled by the nested state machine. + 'bullet' transition; see `SpecializedBody` for more detail). This + state machine is run to parse the compound element (or series of + explicit markup elements), and returns as soon as a non-member element + is encountered. For example, the `BulletList` state machine ends as + soon as it encounters an element which is not a list item of that + bullet list. The optional omission of inter-element blank lines is + enabled by this nested state machine. - The current line index is advanced to the end of the elements parsed, and parsing continues with step 1. @@ -110,8 +111,7 @@ from docutils import nodes, statemachine, utils, roman, urischemes from docutils import ApplicationError, DataError from docutils.statemachine import StateMachineWS, StateWS from docutils.utils import normalize_name -from docutils.parsers.rst import directives, languages -from docutils.parsers.rst.tableparser import TableParser, TableMarkupError +from docutils.parsers.rst import directives, languages, tableparser class MarkupError(DataError): pass @@ -858,10 +858,14 @@ class Body(RSTState): enum.sequenceregexps[sequence] = re.compile( enum.sequencepats[sequence] + '$') - table_top_pat = re.compile(r'\+-[-+]+-\+ *$') - """Matches the top (& bottom) of a table).""" + grid_table_top_pat = re.compile(r'\+-[-+]+-\+ *$') + """Matches the top (& bottom) of a full table).""" - tableparser = TableParser() + simple_table_top_pat = re.compile('=+( +=+)+ *$') + """Matches the top of a simple table.""" + + simple_table_border_pat = re.compile('=+[ =]*$') + """Matches the bottom & header bottom of a simple table.""" pats = {} """Fragments of patterns used by transitions.""" @@ -888,7 +892,8 @@ class Body(RSTState): 'field_marker': r':[^: ]([^:]*[^: ])?:( +|$)', 'option_marker': r'%(option)s(, %(option)s)*( +| ?$)' % pats, 'doctest': r'>>>( +|$)', - 'table_top': table_top_pat, + 'grid_table_top': grid_table_top_pat, + 'simple_table_top': simple_table_top_pat, 'explicit_markup': r'\.\.( +|$)', 'anonymous': r'__( +|$)', 'line': r'(%(nonalphanum7bit)s)\1\1\1+ *$' % pats, @@ -899,7 +904,8 @@ class Body(RSTState): 'field_marker', 'option_marker', 'doctest', - 'table_top', + 'grid_table_top', + 'simple_table_top', 'explicit_markup', 'anonymous', 'line', @@ -1159,9 +1165,22 @@ class Body(RSTState): self.parent += nodes.doctest_block(data, data) return [], next_state, [] - def table_top(self, match, context, next_state): - """Top border of a table.""" - nodelist, blank_finish = self.table() + def grid_table_top(self, match, context, next_state): + """Top border of a full table.""" + return self.table_top(match, context, next_state, + self.isolate_grid_table, + tableparser.GridTableParser) + + def simple_table_top(self, match, context, next_state): + """Top border of a simple table.""" + return self.table_top(match, context, next_state, + self.isolate_simple_table, + tableparser.SimpleTableParser) + + def table_top(self, match, context, next_state, + isolate_function, parser_class): + """Top border of a generic table.""" + nodelist, blank_finish = self.table(isolate_function, parser_class) self.parent += nodelist if not blank_finish: msg = self.reporter.warning( @@ -1170,23 +1189,24 @@ class Body(RSTState): self.parent += msg return [], next_state, [] - def table(self): + def table(self, isolate_function, parser_class): """Parse a table.""" - block, messages, blank_finish = self.isolate_table() + block, messages, blank_finish = isolate_function() if block: try: - tabledata = self.tableparser.parse(block) + parser = parser_class() + tabledata = parser.parse(block) tableline = (self.state_machine.abs_line_number() - len(block) + 1) table = self.build_table(tabledata, tableline) nodelist = [table] + messages - except TableMarkupError, detail: + except tableparser.TableMarkupError, detail: nodelist = self.malformed_table(block, str(detail)) + messages else: nodelist = messages return nodelist, blank_finish - def isolate_table(self): + def isolate_grid_table(self): messages = [] blank_finish = 1 try: @@ -1204,11 +1224,11 @@ class Body(RSTState): self.state_machine.previous_line(len(block) - i) del block[i:] break - if not self.table_top_pat.match(block[-1]): # find bottom + if not self.grid_table_top_pat.match(block[-1]): # find bottom blank_finish = 0 # from second-last to third line of table: for i in range(len(block) - 2, 1, -1): - if self.table_top_pat.match(block[i]): + if self.grid_table_top_pat.match(block[i]): self.state_machine.previous_line(len(block) - i + 1) del block[i+1:] break @@ -1221,6 +1241,47 @@ class Body(RSTState): return [], messages, blank_finish return block, messages, blank_finish + def isolate_simple_table(self): + start = self.state_machine.line_offset + lines = self.state_machine.input_lines + limit = len(lines) - 1 + toplen = len(lines[start].strip()) + pattern_match = self.simple_table_border_pat.match + found = 0 + found_at = None + i = start + 1 + while i <= limit: + line = lines[i] + match = pattern_match(line) + if match: + if len(line.strip()) != toplen: + self.state_machine.next_line(i - start) + messages = self.malformed_table( + lines[start:i+1], 'Bottom/header table border does ' + 'not match top border.') + return [], messages, i == limit or not lines[i+1].strip() + found += 1 + found_at = i + if found == 2 or i == limit or not lines[i+1].strip(): + end = i + break + i += 1 + else: # reached end of input_lines + if found: + extra = ' or no blank line after table bottom' + self.state_machine.next_line(found_at - start) + block = lines[start:found_at+1] + else: + extra = '' + self.state_machine.next_line(i - start - 1) + block = lines[start:] + messages = self.malformed_table( + block, 'No bottom table border found%s.' % extra) + return [], messages, not extra + self.state_machine.next_line(end - start) + block = lines[start:end+1] + return block, [], end == limit or not lines[end+1].strip() + def malformed_table(self, block, detail=''): data = '\n'.join(block) message = 'Malformed table at line %s; formatting as a ' \ @@ -1738,10 +1799,25 @@ class RFC2822Body(Body): class SpecializedBody(Body): """ - Superclass for second and subsequent compound element members. - - All transition methods are disabled. Override individual methods in - subclasses to re-enable. + Superclass for second and subsequent compound element members. Compound + elements are lists and list-like constructs. + + All transition methods are disabled (redefined as `invalid_input`). + Override individual methods in subclasses to re-enable. + + For example, once an initial bullet list item, say, is recognized, the + `BulletList` subclass takes over, with a "bullet_list" node as its + container. Upon encountering the initial bullet list item, `Body.bullet` + calls its ``self.nested_list_parse`` (`RSTState.nested_list_parse`), which + starts up a nested parsing session with `BulletList` as the initial state. + Only the ``bullet`` transition method is enabled in `BulletList`; as long + as only bullet list items are encountered, they are parsed and inserted + into the container. The first construct which is *not* a bullet list item + triggers the `invalid_input` method, which ends the nested parse and + closes the container. `BulletList` needs to recognize input that is + invalid in the context of a bullet list, which means everything *other + than* bullet list items, so it inherits the transition list created in + `Body`. """ def invalid_input(self, match=None, context=None, next_state=None): @@ -1755,7 +1831,8 @@ class SpecializedBody(Body): field_marker = invalid_input option_marker = invalid_input doctest = invalid_input - table_top = invalid_input + grid_table_top = invalid_input + simple_table_top = invalid_input explicit_markup = invalid_input anonymous = invalid_input line = invalid_input -- cgit v1.2.1 From 80dbe0f7f7d7ddc5d9850562e76912c93a7c2261 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 18 Jul 2002 00:53:21 +0000 Subject: - Changed ``TableParser`` to ``GridTableParser``. - Added ``SimpleTableParser``. - Refactored naming. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@301 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/tableparser.py | 345 ++++++++++++++++++++++++++++-------- 1 file changed, 272 insertions(+), 73 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/tableparser.py b/docutils/parsers/rst/tableparser.py index 3f7575040..51beb6b97 100644 --- a/docutils/parsers/rst/tableparser.py +++ b/docutils/parsers/rst/tableparser.py @@ -5,20 +5,25 @@ :Date: $Date$ :Copyright: This module has been placed in the public domain. -This module defines the `TableParser` class, which parses a plaintext-graphic -table and produces a well-formed data structure suitable for building a CALS -table. +This module defines table parser classes,which parse plaintext-graphic tables +and produce a well-formed data structure suitable for building a CALS table. + +:Classes: + - `GridTableParser`: Parse fully-formed tables represented with a grid. + - `SimpleTableParser`: Parse simple tables, delimited by top & bottom + borders. :Exception class: `TableMarkupError` :Function: - `update_dictoflists()`: Merge two dictionaries containing list values. + `update_dict_of_lists()`: Merge two dictionaries containing list values. """ __docformat__ = 'reStructuredText' import re +import sys from docutils import DataError @@ -28,9 +33,53 @@ class TableMarkupError(DataError): pass class TableParser: """ - Parse a plaintext graphic table using `parse()`. + Abstract superclass for the common parts of the syntax-specific parsers. + """ - Here's an example of a plaintext graphic table:: + head_body_separator_pat = None + """Matches the row separator between head rows and body rows.""" + + def parse(self, block): + """ + Analyze the text `block` and return a table data structure. + + Given a plaintext-graphic table in `block` (list of lines of text; no + whitespace padding), parse the table, construct and return the data + necessary to construct a CALS table or equivalent. + + Raise `TableMarkupError` if there is any problem with the markup. + """ + self.setup(block) + self.find_head_body_sep() + self.parse_table() + structure = self.structure_from_cells() + return structure + + def find_head_body_sep(self): + """Look for a head/body row separator line; store the line index.""" + for i in range(len(self.block)): + line = self.block[i] + if self.head_body_separator_pat.match(line): + if self.head_body_sep: + raise TableMarkupError( + 'Multiple head/body row separators in table (at line ' + 'offset %s and %s); only one allowed.' + % (self.head_body_sep, i)) + else: + self.head_body_sep = i + self.block[i] = line.replace('=', '-') + if self.head_body_sep == 0 or self.head_body_sep == (len(self.block) + - 1): + raise TableMarkupError('The head/body row separator may not be ' + 'the first or last line of the table.') + + +class GridTableParser(TableParser): + + """ + Parse a grid table using `parse()`. + + Here's an example of a grid table:: +------------------------+------------+----------+----------+ | Header row, column 1 | Header 2 | Header 3 | Header 4 | @@ -79,54 +128,19 @@ class TableParser: and the cell contents, a list of lines of text. """ - headbodyseparatorpat = re.compile(r'\+=[=+]+=\+$') - """Matches the row separator between head rows and body rows.""" - - def parse(self, block): - """ - Analyze the text `block` and return a table data structure. - - Given a plaintext-graphic table in `block` (list of lines of text; no - whitespace padding), parse the table, construct and return the data - necessary to construct a CALS table or equivalent. - - Raise `TableMarkupError` if there is any problem with the markup. - """ - self.setup(block) - self.findheadbodysep() - self.parsegrid() - structure = self.structurefromcells() - return structure + head_body_separator_pat = re.compile(r'\+=[=+]+=\+ *$') def setup(self, block): self.block = block[:] # make a copy; it may be modified self.bottom = len(block) - 1 self.right = len(block[0]) - 1 - self.headbodysep = None + self.head_body_sep = None self.done = [-1] * len(block[0]) self.cells = [] self.rowseps = {0: [0]} self.colseps = {0: [0]} - def findheadbodysep(self): - """Look for a head/body row separator line; store the line index.""" - for i in range(len(self.block)): - line = self.block[i] - if self.headbodyseparatorpat.match(line): - if self.headbodysep: - raise TableMarkupError, ( - 'Multiple head/body row separators in table (at line ' - 'offset %s and %s); only one allowed.' - % (self.headbodysep, i)) - else: - self.headbodysep = i - self.block[i] = line.replace('=', '-') - if self.headbodysep == 0 or self.headbodysep == len(self.block) - 1: - raise TableMarkupError, ( - 'The head/body row separator may not be the first or last ' - 'line of the table.' % (self.headbodysep, i)) - - def parsegrid(self): + def parse_table(self): """ Start with a queue of upper-left corners, containing the upper-left corner of the table itself. Trace out one rectangular cell, remember @@ -144,21 +158,21 @@ class TableParser: if top == self.bottom or left == self.right \ or top <= self.done[left]: continue - result = self.scancell(top, left) + result = self.scan_cell(top, left) if not result: continue bottom, right, rowseps, colseps = result - update_dictoflists(self.rowseps, rowseps) - update_dictoflists(self.colseps, colseps) - self.markdone(top, left, bottom, right) - cellblock = self.getcellblock(top, left, bottom, right) + update_dict_of_lists(self.rowseps, rowseps) + update_dict_of_lists(self.colseps, colseps) + self.mark_done(top, left, bottom, right) + cellblock = self.get_cell_block(top, left, bottom, right) self.cells.append((top, left, bottom, right, cellblock)) corners.extend([(top, right), (bottom, left)]) corners.sort() - if not self.checkparsecomplete(): - raise TableMarkupError, 'Malformed table; parse incomplete.' + if not self.check_parse_complete(): + raise TableMarkupError('Malformed table; parse incomplete.') - def markdone(self, top, left, bottom, right): + def mark_done(self, top, left, bottom, right): """For keeping track of how much of each text column has been seen.""" before = top - 1 after = bottom - 1 @@ -166,7 +180,7 @@ class TableParser: assert self.done[col] == before self.done[col] = after - def checkparsecomplete(self): + def check_parse_complete(self): """Each text column should have been completely seen.""" last = self.bottom - 1 for col in range(self.right): @@ -174,7 +188,7 @@ class TableParser: return None return 1 - def getcellblock(self, top, left, bottom, right): + def get_cell_block(self, top, left, bottom, right): """Given the corners, extract the text of a cell.""" cellblock = [] margin = right @@ -182,18 +196,18 @@ class TableParser: line = self.block[lineno][left + 1 : right].rstrip() cellblock.append(line) if line: - margin = margin and min(margin, len(line) - len(line.lstrip())) + margin = min(margin, len(line) - len(line.lstrip())) if 0 < margin < right: cellblock = [line[margin:] for line in cellblock] return cellblock - def scancell(self, top, left): + def scan_cell(self, top, left): """Starting at the top-left corner, start tracing out a cell.""" assert self.block[top][left] == '+' - result = self.scanright(top, left) + result = self.scan_right(top, left) return result - def scanright(self, top, left): + def scan_right(self, top, left): """ Look for the top-right corner of the cell, and make note of all column boundaries ('+'). @@ -203,16 +217,16 @@ class TableParser: for i in range(left + 1, self.right + 1): if line[i] == '+': colseps[i] = [top] - result = self.scandown(top, left, i) + result = self.scan_down(top, left, i) if result: bottom, rowseps, newcolseps = result - update_dictoflists(colseps, newcolseps) + update_dict_of_lists(colseps, newcolseps) return bottom, i, rowseps, colseps elif line[i] != '-': return None return None - def scandown(self, top, left, right): + def scan_down(self, top, left, right): """ Look for the bottom-right corner of the cell, making note of all row boundaries. @@ -221,16 +235,16 @@ class TableParser: for i in range(top + 1, self.bottom + 1): if self.block[i][right] == '+': rowseps[i] = [right] - result = self.scanleft(top, left, i, right) + result = self.scan_left(top, left, i, right) if result: newrowseps, colseps = result - update_dictoflists(rowseps, newrowseps) + update_dict_of_lists(rowseps, newrowseps) return i, rowseps, colseps elif self.block[i][right] != '|': return None return None - def scanleft(self, top, left, bottom, right): + def scan_left(self, top, left, bottom, right): """ Noting column boundaries, look for the bottom-left corner of the cell. It must line up with the starting point. @@ -244,14 +258,16 @@ class TableParser: return None if line[left] != '+': return None - result = self.scanup(top, left, bottom, right) + result = self.scan_up(top, left, bottom, right) if result is not None: rowseps = result return rowseps, colseps return None - def scanup(self, top, left, bottom, right): - """Noting row boundaries, see if we can return to the starting point.""" + def scan_up(self, top, left, bottom, right): + """ + Noting row boundaries, see if we can return to the starting point. + """ rowseps = {} for i in range(bottom - 1, top, -1): if self.block[i][left] == '+': @@ -260,9 +276,9 @@ class TableParser: return None return rowseps - def structurefromcells(self): + def structure_from_cells(self): """ - From the data colledted by `scancell()`, convert to the final data + From the data colledted by `scan_cell()`, convert to the final data structure. """ rowseps = self.rowseps.keys() # list of row boundaries @@ -274,7 +290,7 @@ class TableParser: colseps.sort() colindex = {} for i in range(len(colseps)): - colindex[colseps[i]] = i # column boundary -> col number mapping + colindex[colseps[i]] = i # column boundary -> col number map colspecs = [(colseps[i] - colseps[i - 1] - 1) for i in range(1, len(colseps))] # list of column widths # prepare an empty table with the correct number of rows & columns @@ -294,8 +310,8 @@ class TableParser: # write the cell into the table rows[rownum][colnum] = (morerows, morecols, top + 1, block) assert remaining == 0, 'Unused cells remaining.' - if self.headbodysep: # separate head rows from body rows - numheadrows = rowindex[self.headbodysep] + if self.head_body_sep: # separate head rows from body rows + numheadrows = rowindex[self.head_body_sep] headrows = rows[:numheadrows] bodyrows = rows[numheadrows:] else: @@ -304,7 +320,190 @@ class TableParser: return (colspecs, headrows, bodyrows) -def update_dictoflists(master, newdata): +class SimpleTableParser(TableParser): + + """ + Parse a simple table using `parse()`. + + Here's an example of a simple table:: + + ===== ===== + col 1 col 2 + ===== ===== + 1 Second column of row 1. + 2 Second column of row 2. + Second line of paragraph. + 3 - Second column of row 3. + + - Second item in bullet + list (row 3, column 2). + 4 is a span + ------------ + 5 + ===== ===== + + Top and bottom borders use '=', column span underlines use '-', column + separation is indicated with spaces. + + Passing the above table to the `parse()` method will result in the + following data structure, whose interpretation is the same as for + `GridTableParser`:: + + ([5, 25], + [[(0, 0, 1, ['col 1']), + (0, 0, 1, ['col 2'])]], + [[(0, 0, 3, ['1']), + (0, 0, 3, ['Second column of row 1.'])], + [(0, 0, 4, ['2']), + (0, 0, 4, ['Second column of row 2.', + 'Second line of paragraph.'])], + [(0, 0, 6, ['3']), + (0, 0, 6, ['- Second column of row 3.', + '', + '- Second item in bullet', + ' list (row 3, column 2).'])], + [(0, 1, 10, ['4 is a span'])], + [(0, 0, 12, ['5']), + (0, 0, 12, [''])]]) + """ + + head_body_separator_pat = re.compile('=[ =]*$') + span_pat = re.compile('-[ -]*$') + + def setup(self, block): + self.block = block[:] # make a copy; it will be modified + # Convert top & bottom borders to column span underlines: + self.block[0] = self.block[0].replace('=', '-') + self.block[-1] = self.block[-1].replace('=', '-') + self.head_body_sep = None + self.columns = [] + self.table = [] + self.done = [-1] * len(block[0]) + self.rowseps = {0: [0]} + self.colseps = {0: [0]} + + def parse_table(self): + """ + First determine the column boundaries from the top border, then + process rows. Each row may consist of multiple lines; accumulate + lines until a row is complete. Call `self.parse_row` to finish the + job. + """ + # Top border must fully describe all table columns. + self.columns = self.parse_columns(self.block[0]) + firststart, firstend = self.columns[0] + block = self.block[1:] + offset = 0 + # Container for accumulating text lines until a row is complete: + rowlines = [] + while block: + line = block.pop(0) + offset += 1 + if self.span_pat.match(line): + # Column span underline or border; row is complete. + self.parse_row(rowlines, line) + rowlines = [] + elif line[firststart:firstend].strip(): + # First column not blank, therefore it's a new row. + if rowlines: + self.parse_row(rowlines) + rowlines = [(line, offset)] + else: + # Accumulate lines of incomplete row. + rowlines.append((line, offset)) + + def parse_columns(self, line): + """ + Given a column span underline, return a list of (begin, end) pairs. + """ + cols = [] + end = 0 + while 1: + begin = line.find('-', end) + end = line.find(' ', begin) + if begin < 0: + break + if end < 0: + end = len(line) + cols.append((begin, end)) + return cols + + def init_row(self, colspec, offset): + i = 0 + cells = [] + for start, end in colspec: + morecols = 0 + try: + assert start == self.columns[i][0] + while end != self.columns[i][1]: + i += 1 + morecols += 1 + except (AssertionError, IndexError): + raise TableMarkupError('Column span alignment problem at ' + 'line offset %s.' % offset) + cells.append((0, morecols, offset, [])) + i += 1 + return cells + + def parse_row(self, lines, spanline=None): + """ + Given the text `lines` of a row, parse it and append to `self.table`. + + The row is parsed according to the current column spec (either + `spanline` if provided or `self.columns`). For each column, extract + text from each line, and check for text in column margins. Finally, + adjust for insigificant whitespace. + """ + if spanline: + columns = self.parse_columns(spanline) + else: + columns = self.columns[:] + row = self.init_row(columns, lines[0][1]) + # "Infinite" value for a dummy last column's beginning, used to + # check for text overflow: + columns.append((sys.maxint, None)) + lastcol = len(columns) - 2 + for i in range(len(columns) - 1): + start, end = columns[i] + nextstart = columns[i+1][0] + block = [] + margin = sys.maxint + for line, offset in lines: + if i == lastcol and line[end:].strip(): + text = line[start:].rstrip() + columns[lastcol] = (start, start + len(text)) + self.adjust_last_column(start + len(text)) + elif line[end:nextstart].strip(): + raise TableMarkupError('Text in column margin at line ' + 'offset %s.' % offset) + else: + text = line[start:end].rstrip() + block.append(text) + if text: + margin = min(margin, len(text) - len(text.lstrip())) + if 0 < margin < sys.maxint: + block = [line[margin:] for line in block] + row[i][3].extend(block) + self.table.append(row) + + def adjust_last_column(self, new_end): + start, end = self.columns[-1] + if new_end > end: + self.columns[-1] = (start, new_end) + + def structure_from_cells(self): + colspecs = [end - start for start, end in self.columns] + first_body_row = 0 + if self.head_body_sep: + for i in range(len(self.table)): + if self.table[i][0][2] > self.head_body_sep: + first_body_row = i + break + return (colspecs, self.table[:first_body_row], + self.table[first_body_row:]) + + +def update_dict_of_lists(master, newdata): """ Extend the list values of `master` with those from `newdata`. -- cgit v1.2.1 From 442077e5397b31c810e7c730b95150e8dc226c0a Mon Sep 17 00:00:00 2001 From: chodorowski Date: Sat, 20 Jul 2002 13:14:12 +0000 Subject: Swedish language mappings. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@341 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/sv.py | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 docutils/parsers/rst/languages/sv.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py new file mode 100644 index 000000000..ad2454cb9 --- /dev/null +++ b/docutils/parsers/rst/languages/sv.py @@ -0,0 +1,39 @@ +#! /usr/bin/env python + +""" +:Author: Adam Chodorowski +:Contact: chodorowski@users.sourceforge.net +:Revision: $Revision$ +:Date: $Date$ +:Copyright: This module has been placed in the public domain. + +Swedish language mappings for language-dependent features of reStructuredText. +""" + +__docformat__ = 'reStructuredText' + + +directives = { + 'observera': 'attention', + 'varning': 'caution', + 'fara': 'danger', + 'fel': 'error', + 'vägledning': 'hint', + 'viktigt': 'important', + 'notera': 'note', + 'tips': 'tip', + 'varning': 'warning', + 'frågor': 'questions', + 'frågor-och-svar': 'questions', # NOTE: A bit long, but recommended by + 'vanliga-frågor': 'questions', # NOTE: http://www.nada.kth.se/dataterm/ + 'meta': 'meta', + #'bildkarta': 'imagemap', # FIXME: Translation might be to literal. + 'bild': 'image', + 'figur': 'figure', + #'rå': 'raw', # FIXME: Translation might be to literal. + 'innehåll': 'contents', + #'fotnoter': 'footnotes', + #'citeringar': 'citations', + #'ämne': 'topic', + 'restructuredtext-test-directive': 'restructuredtext-test-directive'} +"""Swedish name to registered (in directives/__init__.py) directive name mapping.""" -- cgit v1.2.1 From cc938c6242269ac94acbba52e0938c9d83e5d5db Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 20 Jul 2002 14:09:32 +0000 Subject: Ignore generated files. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@342 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/.cvsignore | 1 + docutils/parsers/rst/.cvsignore | 1 + docutils/parsers/rst/directives/.cvsignore | 1 + docutils/parsers/rst/languages/.cvsignore | 1 + 4 files changed, 4 insertions(+) create mode 100644 docutils/parsers/.cvsignore create mode 100644 docutils/parsers/rst/.cvsignore create mode 100644 docutils/parsers/rst/directives/.cvsignore create mode 100644 docutils/parsers/rst/languages/.cvsignore (limited to 'docutils/parsers') diff --git a/docutils/parsers/.cvsignore b/docutils/parsers/.cvsignore new file mode 100644 index 000000000..0d20b6487 --- /dev/null +++ b/docutils/parsers/.cvsignore @@ -0,0 +1 @@ +*.pyc diff --git a/docutils/parsers/rst/.cvsignore b/docutils/parsers/rst/.cvsignore new file mode 100644 index 000000000..0d20b6487 --- /dev/null +++ b/docutils/parsers/rst/.cvsignore @@ -0,0 +1 @@ +*.pyc diff --git a/docutils/parsers/rst/directives/.cvsignore b/docutils/parsers/rst/directives/.cvsignore new file mode 100644 index 000000000..0d20b6487 --- /dev/null +++ b/docutils/parsers/rst/directives/.cvsignore @@ -0,0 +1 @@ +*.pyc diff --git a/docutils/parsers/rst/languages/.cvsignore b/docutils/parsers/rst/languages/.cvsignore new file mode 100644 index 000000000..0d20b6487 --- /dev/null +++ b/docutils/parsers/rst/languages/.cvsignore @@ -0,0 +1 @@ +*.pyc -- cgit v1.2.1 From 8580b0585c3d927f38e4c38098e9c7e982e2ba81 Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 23 Jul 2002 02:33:29 +0000 Subject: Added "en" (English) as a fallback language for directive names. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@347 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 89d273651..484714588 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -31,6 +31,8 @@ Where: __docformat__ = 'reStructuredText' +from docutils.parsers.rst.languages import en as _fallback_language_module + _directive_registry = { 'attention': ('admonitions', 'attention'), @@ -63,15 +65,24 @@ _modules = {} _directives = {} """Cache of imported directive functions.""" -def directive(directivename, languagemodule): +def directive(directive_name, language_module): """ Locate and return a directive function from its language-dependent name. + If not found in the current language, check English. """ - normname = directivename.lower() + normname = directive_name.lower() if _directives.has_key(normname): return _directives[normname] try: - canonicalname = languagemodule.directives[normname] + canonicalname = language_module.directives[normname] + except KeyError: + try: + # Try English as a fallback: + canonicalname = _fallback_language_module.directives[normname] + except KeyError: + # The canonical name should be an English name, but just in case: + canonicalname = normname + try: modulename, functionname = _directive_registry[canonicalname] except KeyError: return None -- cgit v1.2.1 From c838df7b5cd17daa4545f03e097791ae34679eb1 Mon Sep 17 00:00:00 2001 From: chodorowski Date: Tue, 23 Jul 2002 03:04:00 +0000 Subject: Escaped all swedish characters and changed all strings to be unicode strings (for consistency). git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@352 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/sv.py | 44 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index ad2454cb9..07e16a36c 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -14,26 +14,26 @@ __docformat__ = 'reStructuredText' directives = { - 'observera': 'attention', - 'varning': 'caution', - 'fara': 'danger', - 'fel': 'error', - 'vägledning': 'hint', - 'viktigt': 'important', - 'notera': 'note', - 'tips': 'tip', - 'varning': 'warning', - 'frågor': 'questions', - 'frågor-och-svar': 'questions', # NOTE: A bit long, but recommended by - 'vanliga-frågor': 'questions', # NOTE: http://www.nada.kth.se/dataterm/ - 'meta': 'meta', - #'bildkarta': 'imagemap', # FIXME: Translation might be to literal. - 'bild': 'image', - 'figur': 'figure', - #'rå': 'raw', # FIXME: Translation might be to literal. - 'innehåll': 'contents', - #'fotnoter': 'footnotes', - #'citeringar': 'citations', - #'ämne': 'topic', - 'restructuredtext-test-directive': 'restructuredtext-test-directive'} + u'observera': 'attention', + u'varning': 'caution', + u'fara': 'danger', + u'fel': 'error', + u'v\u00e4gledning': 'hint', + u'viktigt': 'important', + u'notera': 'note', + u'tips': 'tip', + u'varning': 'warning', + u'fr\u00e5gor': 'questions', + u'fr\u00e5gor-och-svar': 'questions', # NOTE: A bit long, but recommended by + u'vanliga-fr\u00e5gor': 'questions', # NOTE: http://www.nada.kth.se/dataterm/ + u'meta': 'meta', + # u'bildkarta': 'imagemap', # FIXME: Translation might be to literal. + u'bild': 'image', + u'figur': 'figure', + # u'r\u00e5': 'raw', # FIXME: Translation might be to literal. + u'innehåll': 'contents', + # u'fotnoter': 'footnotes', + # u'citeringar': 'citations', + # u'\u00e4mne': 'topic', + u'restructuredtext-test-directive': 'restructuredtext-test-directive' } """Swedish name to registered (in directives/__init__.py) directive name mapping.""" -- cgit v1.2.1 From 09d88c2d27d9781fd35f1cec44633cf4acd7d9ba Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 24 Jul 2002 01:36:58 +0000 Subject: In case language_module is None. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@355 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 484714588..74ff8830a 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -75,7 +75,7 @@ def directive(directive_name, language_module): return _directives[normname] try: canonicalname = language_module.directives[normname] - except KeyError: + except (KeyError, AttributeError): try: # Try English as a fallback: canonicalname = _fallback_language_module.directives[normname] -- cgit v1.2.1 From 9c1f254c9a15569eecdb31276a51628881f6a06f Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 24 Jul 2002 01:37:44 +0000 Subject: Added "backlinks" attribute. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@356 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/parts.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py index 7b3d63697..d3bba86c5 100644 --- a/docutils/parsers/rst/directives/parts.py +++ b/docutils/parsers/rst/directives/parts.py @@ -19,8 +19,23 @@ from docutils.transforms import parts def unchanged(arg): return arg # unchanged! +def backlinks(arg): + try: + value = arg.lower().strip() + except AttributeError: + raise TypeError('must supply an argument; choose from "top", ' + '"entry", or "none"') + if value == 'none': + return None + elif value == 'top' or arg == 'entry': + return value + else: + raise ValueError( + '"%s" unknown; choose from "top", "entry", or "none"' % arg) + contents_attribute_spec = {'depth': int, 'local': unchanged, + 'backlinks': backlinks, 'qa': unchanged} def contents(match, type_name, data, state, state_machine, attributes): -- cgit v1.2.1 From 54a26a7452be9b2e0f5f0404d383e244fec5376a Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 24 Jul 2002 01:39:23 +0000 Subject: Changed format of directve attribute error.. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@357 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 04a9ea605..cfb934e9d 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1598,7 +1598,7 @@ class Body(RSTState): except KeyError, detail: return 0, ('unknown attribute: "%s"' % detail), blank_finish except (ValueError, TypeError), detail: - return 0, ('invalid attribute value:\n%s' % detail), blank_finish + return 0, ('invalid attribute value: %s' % detail), blank_finish except utils.ExtensionAttributeError, detail: return 0, ('invalid attribute data: %s' % detail), blank_finish return 1, attributes, blank_finish -- cgit v1.2.1 From 659ceac33a3aa10d234d7eaf8e4f4adc2778df99 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 25 Jul 2002 01:49:17 +0000 Subject: one last 8-bit char; cleanup git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@368 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/sv.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index 07e16a36c..2d45a5222 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -24,16 +24,18 @@ directives = { u'tips': 'tip', u'varning': 'warning', u'fr\u00e5gor': 'questions', - u'fr\u00e5gor-och-svar': 'questions', # NOTE: A bit long, but recommended by - u'vanliga-fr\u00e5gor': 'questions', # NOTE: http://www.nada.kth.se/dataterm/ + # NOTE: A bit long, but recommended by http://www.nada.kth.se/dataterm/: + u'fr\u00e5gor-och-svar': 'questions', + u'vanliga-fr\u00e5gor': 'questions', u'meta': 'meta', - # u'bildkarta': 'imagemap', # FIXME: Translation might be to literal. + # u'bildkarta': 'imagemap', # FIXME: Translation might be too literal. u'bild': 'image', u'figur': 'figure', - # u'r\u00e5': 'raw', # FIXME: Translation might be to literal. - u'innehåll': 'contents', + # u'r\u00e5': 'raw', # FIXME: Translation might be too literal. + u'inneh\u00e5ll': 'contents', # u'fotnoter': 'footnotes', # u'citeringar': 'citations', # u'\u00e4mne': 'topic', u'restructuredtext-test-directive': 'restructuredtext-test-directive' } -"""Swedish name to registered (in directives/__init__.py) directive name mapping.""" +"""Swedish name to registered (in directives/__init__.py) directive name +mapping.""" -- cgit v1.2.1 From 8d07f5fac59043b0af54a372a3ffbc4ed10f6cf3 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 25 Jul 2002 01:49:57 +0000 Subject: Simple tables bug fix. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@369 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/tableparser.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/tableparser.py b/docutils/parsers/rst/tableparser.py index 51beb6b97..d304445c8 100644 --- a/docutils/parsers/rst/tableparser.py +++ b/docutils/parsers/rst/tableparser.py @@ -426,6 +426,9 @@ class SimpleTableParser(TableParser): if end < 0: end = len(line) cols.append((begin, end)) + if self.columns: + # Allow for an unbounded rightmost column: + cols[-1] = (cols[-1][0], self.columns[-1][1]) return cols def init_row(self, colspec, offset): -- cgit v1.2.1 From 6e9d13e192d14bb626255e5a06dbcfed07122564 Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 4 Aug 2002 21:08:35 +0000 Subject: docstring update git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@455 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 74ff8830a..025405029 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -27,6 +27,12 @@ Where: element the directive produces. Currently, only an "alt" attribute is passed by substitution definitions (value: the substitution name), which may by used by an embedded image directive. + +Directive functions return a tuple of two values: + +- a list of nodes which will be inserted into the document tree at the point + where the directive was encountered (can be an empty list), and +- a boolean: true iff the directive block finished at a blank line. """ __docformat__ = 'reStructuredText' -- cgit v1.2.1 From 66dca2559e93fca4d221305e15099438b00ddc5a Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 7 Aug 2002 01:06:41 +0000 Subject: Added to project. Contains the "topic" directive. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@463 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/body.py | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 docutils/parsers/rst/directives/body.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py new file mode 100644 index 000000000..3cdc1d382 --- /dev/null +++ b/docutils/parsers/rst/directives/body.py @@ -0,0 +1,47 @@ +#! /usr/bin/env python + +""" +:Author: David Goodger +:Contact: goodger@users.sourceforge.net +:Revision: $Revision$ +:Date: $Date$ +:Copyright: This module has been placed in the public domain. + +Directives for additional body elements. +""" + +__docformat__ = 'reStructuredText' + +from docutils import nodes + + +def topic(match, type_name, data, state, state_machine, attributes): + lineno = state_machine.abs_line_number() + initial_offset = state_machine.line_offset + indented, indent, line_offset, blank_finish \ + = state_machine.get_first_known_indented(match.end()) + blocktext = '\n'.join(state_machine.input_lines[ + initial_offset : line_offset + len(indented)]) + if not state_machine.match_titles: + error = state_machine.reporter.error( + 'Topics may not be nested within body elements (line %s).' + % lineno, '', nodes.literal_block(blocktext, blocktext)) + return [error], blank_finish + if not indented: + return [], blank_finish + title_text = indented.pop(0) + textnodes, messages = state.inline_text(title_text, lineno) + title = nodes.title(title_text, '', *textnodes) + if indented: + if indented[0].strip(): + warning = state_machine.reporter.warning( + 'The second line of a topic block must be blank (line %s).' + % (lineno + 1 + line_offset - initial_offset), '') + messages.append(warning) + text = '\n'.join(indented) + else: + text = '' + topic_node = nodes.topic(text, title, *messages) + if text: + state.nested_parse(indented, line_offset, topic_node) + return [topic_node], blank_finish -- cgit v1.2.1 From 1981123ec5a63f9d98ee3b8d8433e7d1cab3b021 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 7 Aug 2002 01:25:26 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@474 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 4 ++-- docutils/parsers/rst/languages/en.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 025405029..ada409a79 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -50,13 +50,13 @@ _directive_registry = { 'tip': ('admonitions', 'tip'), 'hint': ('admonitions', 'hint'), 'warning': ('admonitions', 'warning'), - 'questions': ('body', 'question_list'), + 'topic': ('body', 'topic'), + #'questions': ('body', 'question_list'), 'image': ('images', 'image'), 'figure': ('images', 'figure'), 'contents': ('parts', 'contents'), #'footnotes': ('parts', 'footnotes'), #'citations': ('parts', 'citations'), - #'topic': ('parts', 'topic'), 'meta': ('html', 'meta'), #'imagemap': ('html', 'imagemap'), #'raw': ('misc', 'raw'), diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index 370c34d12..0ccba3952 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -24,9 +24,10 @@ directives = { 'note': 'note', 'tip': 'tip', 'warning': 'warning', - 'questions': 'questions', - 'qa': 'questions', - 'faq': 'questions', + 'topic': 'topic', + #'questions': 'questions', + #'qa': 'questions', + #'faq': 'questions', 'meta': 'meta', #'imagemap': 'imagemap', 'image': 'image', @@ -35,7 +36,6 @@ directives = { 'contents': 'contents', #'footnotes': 'footnotes', #'citations': 'citations', - #'topic': 'topic', 'restructuredtext-test-directive': 'restructuredtext-test-directive'} """English name to registered (in directives/__init__.py) directive name mapping.""" -- cgit v1.2.1 From 4b4b1b9a3615ba979d6c5b933e34a14d30dcf3c2 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 8 Aug 2002 00:25:37 +0000 Subject: Changed "title under/overline too short" system messages from INFO to WARNING, and fixed its insertion location. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@480 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index cfb934e9d..e59102801 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -270,10 +270,10 @@ class RSTState(StateWS): state_machine.unlink() return state_machine.abs_line_offset(), blank_finish - def section(self, title, source, style, lineno): + def section(self, title, source, style, lineno, messages): """Check for a valid subsection and create one if it checks out.""" if self.check_subsection(source, style, lineno): - self.new_subsection(title, lineno) + self.new_subsection(title, lineno, messages) def check_subsection(self, source, style, lineno): """ @@ -320,19 +320,20 @@ class RSTState(StateWS): % lineno, '', literalblock) return error - def new_subsection(self, title, lineno): + def new_subsection(self, title, lineno, messages): """Append new subsection to document tree. On return, check level.""" memo = self.memo mylevel = memo.section_level memo.section_level += 1 sectionnode = nodes.section() self.parent += sectionnode - textnodes, messages = self.inline_text(title, lineno) + textnodes, title_messages = self.inline_text(title, lineno) titlenode = nodes.title(title, '', *textnodes) name = normalize_name(titlenode.astext()) sectionnode['name'] = name sectionnode += titlenode sectionnode += messages + sectionnode += title_messages self.document.note_implicit_target(sectionnode, sectionnode) offset = self.state_machine.line_offset + 1 absoffset = self.state_machine.abs_line_offset() + 1 @@ -2035,15 +2036,16 @@ class Text(RSTState): title = context[0].rstrip() underline = match.string.rstrip() source = title + '\n' + underline + messages = [] if len(title) > len(underline): blocktext = context[0] + '\n' + self.state_machine.line - msg = self.reporter.info( + msg = self.reporter.warning( 'Title underline too short at line %s.' % lineno, '', nodes.literal_block(blocktext, blocktext)) - self.parent += msg + messages.append(msg) style = underline[0] context[:] = [] - self.section(title, source, style, lineno - 1) + self.section(title, source, style, lineno - 1, messages) return [], next_state, [] def text(self, match, context, next_state): @@ -2226,14 +2228,15 @@ class Line(SpecializedText): self.parent += msg return [], 'Body', [] title = title.rstrip() + messages = [] if len(title) > len(overline): - msg = self.reporter.info( + msg = self.reporter.warning( 'Title overline too short at line %s.'% lineno, '', nodes.literal_block(source, source)) - self.parent += msg + messages.append(msg) style = (overline[0], underline[0]) self.eofcheck = 0 # @@@ not sure this is correct - self.section(title.lstrip(), source, style, lineno + 1) + self.section(title.lstrip(), source, style, lineno + 1, messages) self.eofcheck = 1 return [], 'Body', [] -- cgit v1.2.1 From 403cb20d5dc1c872855031ed1ea90dc2fa948281 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 10 Aug 2002 02:31:33 +0000 Subject: docstrings git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@493 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index e59102801..fec37d1c9 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -27,7 +27,7 @@ the reStructuredText parser. It defines the following: - `SpecializedText`: Superclass for continuation lines of Text-variants. - `Definition`: Second line of potential definition_list_item. - `Line`: Second line of overlined section title or transition marker. - - `Stuff`: An auxilliary collection class. + - `Stuff`: An auxiliary collection class. :Exception classes: - `MarkupError` -- cgit v1.2.1 From 940de581fe90267e7d5b9b1acbfa878db8e7961c Mon Sep 17 00:00:00 2001 From: yole Date: Sun, 11 Aug 2002 19:41:37 +0000 Subject: Second version of the .. sectnum:: directive implementation. Also, the really working fix of the empty path problem in package_unittest.py. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@500 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 1 + docutils/parsers/rst/directives/parts.py | 35 ++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index ada409a79..0a9721c9f 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -55,6 +55,7 @@ _directive_registry = { 'image': ('images', 'image'), 'figure': ('images', 'figure'), 'contents': ('parts', 'contents'), + 'sectnum': ('parts', 'sectnum'), #'footnotes': ('parts', 'footnotes'), #'citations': ('parts', 'citations'), 'meta': ('html', 'meta'), diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py index d3bba86c5..aefea341d 100644 --- a/docutils/parsers/rst/directives/parts.py +++ b/docutils/parsers/rst/directives/parts.py @@ -1,7 +1,7 @@ #! /usr/bin/env python """ -:Author: David Goodger +:Author: David Goodger, Dmitry Jemerov :Contact: goodger@users.sourceforge.net :Revision: $Revision$ :Date: $Date$ @@ -75,3 +75,36 @@ def contents(match, type_name, data, state, state_machine, attributes): return [error] + messages, blank_finish state_machine.document.note_pending(pending) return [pending] + messages, blank_finish + +sectnum_attribute_spec = {'depth': int} + +def sectnum(match, type_name, data, state, state_machine, attributes): + """ + Parse the `.. sectnum::` directive. + + The following attributes are supported: + + - :depth: + + The attributes can be specified in the lines following the directive, + or it is possible to specify one attribute in the same line as the + directive itself. + """ + lineno = state_machine.abs_line_number() + line_offset = state_machine.line_offset + datablock, indent, offset, blank_finish = \ + state_machine.get_first_known_indented(match.end(), until_blank=1) + + pending = nodes.pending(parts.SectNum, 'last reader', {}) + success, data, blank_finish = state.parse_extension_attributes( + sectnum_attribute_spec, datablock, blank_finish) + if success: # data is a dict of attributes + pending.details.update(data) + else: # data is an error string + error = state_machine.reporter.error( + 'Error in "%s" directive attributes at line %s:\n%s.' + % (match.group(1), lineno, data), '') + return [error], blank_finish + + state_machine.document.note_pending(pending) + return [pending], blank_finish -- cgit v1.2.1 From 7a7a49ec21fec9c14621992cbfcee53337a424f4 Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 13 Aug 2002 00:53:05 +0000 Subject: Changed the "Contents" transform's order. Docstrings. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@504 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/parts.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py index aefea341d..eeff6fc29 100644 --- a/docutils/parsers/rst/directives/parts.py +++ b/docutils/parsers/rst/directives/parts.py @@ -39,6 +39,7 @@ contents_attribute_spec = {'depth': int, 'qa': unchanged} def contents(match, type_name, data, state, state_machine, attributes): + """Table of contents.""" lineno = state_machine.abs_line_number() line_offset = state_machine.line_offset datablock, indent, offset, blank_finish = \ @@ -60,7 +61,7 @@ def contents(match, type_name, data, state, state_machine, attributes): else: messages = [] title = None - pending = nodes.pending(parts.Contents, 'last reader', {'title': title}, + pending = nodes.pending(parts.Contents, 'first writer', {'title': title}, blocktext) if attlines: success, data, blank_finish = state.parse_extension_attributes( @@ -79,22 +80,11 @@ def contents(match, type_name, data, state, state_machine, attributes): sectnum_attribute_spec = {'depth': int} def sectnum(match, type_name, data, state, state_machine, attributes): - """ - Parse the `.. sectnum::` directive. - - The following attributes are supported: - - - :depth: - - The attributes can be specified in the lines following the directive, - or it is possible to specify one attribute in the same line as the - directive itself. - """ + """Automatic section numbering.""" lineno = state_machine.abs_line_number() line_offset = state_machine.line_offset datablock, indent, offset, blank_finish = \ state_machine.get_first_known_indented(match.end(), until_blank=1) - pending = nodes.pending(parts.SectNum, 'last reader', {}) success, data, blank_finish = state.parse_extension_attributes( sectnum_attribute_spec, datablock, blank_finish) @@ -105,6 +95,5 @@ def sectnum(match, type_name, data, state, state_machine, attributes): 'Error in "%s" directive attributes at line %s:\n%s.' % (match.group(1), lineno, data), '') return [error], blank_finish - state_machine.document.note_pending(pending) return [pending], blank_finish -- cgit v1.2.1 From 3cfa7ce4f723086105232c55166fec4b7bc935bc Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 13 Aug 2002 00:53:40 +0000 Subject: Added "sectnum" directive. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@505 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/en.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index 0ccba3952..3e95e1972 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -34,6 +34,8 @@ directives = { 'figure': 'figure', #'raw': 'raw', 'contents': 'contents', + 'sectnum': 'sectnum', + 'section-numbering': 'sectnum', #'footnotes': 'footnotes', #'citations': 'citations', 'restructuredtext-test-directive': 'restructuredtext-test-directive'} -- cgit v1.2.1 From 9d58b7001284d065e4d04254c1ac50d097858dc9 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 14 Aug 2002 02:39:34 +0000 Subject: Added to project. Contains the "target-notes" directive. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@518 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/references.py | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 docutils/parsers/rst/directives/references.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/references.py b/docutils/parsers/rst/directives/references.py new file mode 100644 index 000000000..98f06f778 --- /dev/null +++ b/docutils/parsers/rst/directives/references.py @@ -0,0 +1,29 @@ +#! /usr/bin/env python + +""" +:Author: David Goodger, Dmitry Jemerov +:Contact: goodger@users.sourceforge.net +:Revision: $Revision$ +:Date: $Date$ +:Copyright: This module has been placed in the public domain. + +Directives for references and targets. +""" + +__docformat__ = 'reStructuredText' + +from docutils import nodes +from docutils.transforms import references + + +def target_notes(match, type_name, data, state, state_machine, attributes): + """Target footnote generation.""" + pending = nodes.pending(references.TargetNotes, 'first reader', {}) + state_machine.document.note_pending(pending) + nodelist = [pending] + if data: + warning = state_machine.reporter.warning( + 'The "%s" directive takes no data; "%s" ignored (at line %s).' + % (match.group(1), data, state_machine.abs_line_number())) + nodelist.append(warning) + return nodelist, state_machine.is_next_line_blank() -- cgit v1.2.1 From 096e020774b4f3681762f86fb2baeff90957feb5 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 14 Aug 2002 02:45:02 +0000 Subject: Added the "target-notes" directive. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@523 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 1 + docutils/parsers/rst/languages/en.py | 1 + 2 files changed, 2 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 0a9721c9f..03ebf262d 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -58,6 +58,7 @@ _directive_registry = { 'sectnum': ('parts', 'sectnum'), #'footnotes': ('parts', 'footnotes'), #'citations': ('parts', 'citations'), + 'target-notes': ('references', 'target_notes'), 'meta': ('html', 'meta'), #'imagemap': ('html', 'imagemap'), #'raw': ('misc', 'raw'), diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index 3e95e1972..8c198ccef 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -36,6 +36,7 @@ directives = { 'contents': 'contents', 'sectnum': 'sectnum', 'section-numbering': 'sectnum', + 'target-notes': 'target-notes', #'footnotes': 'footnotes', #'citations': 'citations', 'restructuredtext-test-directive': 'restructuredtext-test-directive'} -- cgit v1.2.1 From 0e0945034dac85d840bcf15384b533a41ece4d49 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 16 Aug 2002 00:32:36 +0000 Subject: Added the "line-block" and "parsed-literal" directives. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@537 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 2 ++ docutils/parsers/rst/directives/body.py | 36 +++++++++++++++++++++++++++++ docutils/parsers/rst/languages/en.py | 2 ++ 3 files changed, 40 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 03ebf262d..d6345562a 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -51,6 +51,8 @@ _directive_registry = { 'hint': ('admonitions', 'hint'), 'warning': ('admonitions', 'warning'), 'topic': ('body', 'topic'), + 'line-block': ('body', 'line_block'), + 'parsed-literal': ('body', 'parsed_literal'), #'questions': ('body', 'question_list'), 'image': ('images', 'image'), 'figure': ('images', 'figure'), diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index 3cdc1d382..98f04d237 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -12,6 +12,8 @@ Directives for additional body elements. __docformat__ = 'reStructuredText' + +import sys from docutils import nodes @@ -45,3 +47,37 @@ def topic(match, type_name, data, state, state_machine, attributes): if text: state.nested_parse(indented, line_offset, topic_node) return [topic_node], blank_finish + + +def parsed_literal(match, type_name, data, state, state_machine, attributes): + lineno = state_machine.abs_line_number() + initial_offset = state_machine.line_offset + indented, indent, line_offset, blank_finish \ + = state_machine.get_first_known_indented(match.end()) + while indented and not indented[-1].strip(): + indented.pop() + blocktext = '\n'.join(state_machine.input_lines[ + initial_offset : line_offset + len(indented)]) + if not indented: + return [], blank_finish + text = '\n'.join(indented) + textnodes, messages = state.inline_text(text, lineno) + literal = nodes.literal_block(text, '', *textnodes) + return [literal] + messages, blank_finish + + +def line_block(match, type_name, data, state, state_machine, attributes): + lineno = state_machine.abs_line_number() + initial_offset = state_machine.line_offset + indented, indent, line_offset, blank_finish \ + = state_machine.get_first_known_indented(match.end()) + while indented and not indented[-1].strip(): + indented.pop() + blocktext = '\n'.join(state_machine.input_lines[ + initial_offset : line_offset + len(indented)]) + if not indented: + return [], blank_finish + text = '\n'.join(indented) + textnodes, messages = state.inline_text(text, lineno) + line_block_node = nodes.line_block(text, '', *textnodes) + return [line_block_node] + messages, blank_finish diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index 8c198ccef..34c4c101a 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -25,6 +25,8 @@ directives = { 'tip': 'tip', 'warning': 'warning', 'topic': 'topic', + 'line-block': 'line-block', + 'parsed-literal': 'parsed-literal', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', -- cgit v1.2.1 From a7cbc5c1f096f980f20efceb9ca8dd3b7cff1ee0 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 16 Aug 2002 00:34:32 +0000 Subject: Fixed enumerated list item parsing to allow paragraphs & section titles to begin with enumerators. Plus some cleanup. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@538 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 102 +++++++++++++++++++++++++++++------------ 1 file changed, 73 insertions(+), 29 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index fec37d1c9..eb545a1f2 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -957,20 +957,8 @@ class Body(RSTState): def enumerator(self, match, context, next_state): """Enumerated List Item""" format, sequence, text, ordinal = self.parse_enumerator(match) - if ordinal is None: - msg = self.reporter.error( - ('Enumerated list start value invalid at line %s: ' - '"%s" (sequence %r)' - % (self.state_machine.abs_line_number(), text, sequence))) - self.parent += msg - indented, line_offset, blank_finish = \ - self.state_machine.get_known_indented(match.end()) - bq = self.block_quote(indented, line_offset) - self.parent += bq - if not blank_finish: - self.parent += self.unindent_warning( - 'Enumerated list') - return [], next_state, [] + if not self.is_enumerated_list_item(ordinal, sequence, format): + raise statemachine.TransitionCorrection('text') if ordinal != 1: msg = self.reporter.info( ('Enumerated list start value not ordinal-1 at line %s: ' @@ -1022,7 +1010,7 @@ class Body(RSTState): if groupdict[format]: # was this the format matched? break # yes; keep `format` else: # shouldn't happen - raise ParserError, 'enumerator format not matched' + raise ParserError('enumerator format not matched') text = groupdict[format][self.enum.formatinfo[format].start :self.enum.formatinfo[format].end] if expected_sequence: @@ -1030,24 +1018,81 @@ class Body(RSTState): if self.enum.sequenceregexps[expected_sequence].match(text): sequence = expected_sequence except KeyError: # shouldn't happen - raise ParserError, 'unknown sequence: %s' % sequence - else: - if text == 'i': - sequence = 'lowerroman' - elif text == 'I': - sequence = 'upperroman' + raise ParserError('unknown enumerator sequence: %s' + % sequence) + elif text == 'i': + sequence = 'lowerroman' + elif text == 'I': + sequence = 'upperroman' if not sequence: for sequence in self.enum.sequences: if self.enum.sequenceregexps[sequence].match(text): break else: # shouldn't happen - raise ParserError, 'enumerator sequence not matched' + raise ParserError('enumerator sequence not matched') try: ordinal = self.enum.converters[sequence](text) except roman.InvalidRomanNumeralError: ordinal = None return format, sequence, text, ordinal + def is_enumerated_list_item(self, ordinal, sequence, format): + """ + Check validity based on the ordinal value and the second line. + + Return true iff the ordinal is valid and the second line is blank, + indented, or starts with the next enumerator. + """ + if ordinal is None: + return None + try: + next_line = self.state_machine.next_line() + except IndexError: # end of input lines + self.state_machine.previous_line() + return 1 + else: + self.state_machine.previous_line() + if not next_line[:1].strip(): # blank or indented + return 1 + next_enumerator = self.make_enumerator(ordinal + 1, sequence, format) + try: + if next_line.startswith(next_enumerator): + return 1 + except TypeError: + pass + return None + + def make_enumerator(self, ordinal, sequence, format): + """ + Construct and return an enumerated list item marker. + + Return ``None`` for invalid (out of range) ordinals. + """ + if sequence == 'arabic': + enumerator = str(ordinal) + else: + if sequence.endswith('alpha'): + if ordinal > 26: + return None + enumerator = chr(ordinal + ord('a') - 1) + elif sequence.endswith('roman'): + try: + enumerator = roman.toRoman(ordinal) + except roman.RomanError: + return None + else: # shouldn't happen + raise ParserError('unknown enumerator sequence: "%s"' + % sequence) + if sequence.startswith('lower'): + enumerator = enumerator.lower() + elif sequence.startswith('upper'): + enumerator = enumerator.upper() + else: # shouldn't happen + raise ParserError('unknown enumerator sequence: "%s"' + % sequence) + formatinfo = self.enum.formatinfo[format] + return formatinfo.prefix + enumerator + formatinfo.suffix + ' ' + def field_marker(self, match, context, next_state): """Field list item.""" fieldlist = nodes.field_list() @@ -1874,7 +1919,8 @@ class EnumeratedList(SpecializedBody): match, self.parent['enumtype']) if (sequence != self.parent['enumtype'] or format != self.format or - ordinal != self.lastordinal + 1): + ordinal != (self.lastordinal + 1) or + not self.is_enumerated_list_item(ordinal, sequence, format)): # different enumeration: new list self.invalid_input() listitem, blank_finish = self.list_item(match.end()) @@ -1999,11 +2045,7 @@ class Text(RSTState): def eof(self, context): if context: - paragraph, literalnext = self.paragraph( - context, self.state_machine.abs_line_number() - 1) - self.parent += paragraph - if literalnext: - self.parent += self.literal_block() + self.blank(None, context, None) return [] def indent(self, match, context, next_state): @@ -2163,7 +2205,9 @@ class Definition(SpecializedText): class Line(SpecializedText): - """Second line of over- & underlined section title or transition marker.""" + """ + Second line of over- & underlined section title or transition marker. + """ eofcheck = 1 # @@@ ??? """Set to 0 while parsing sections, so that we don't catch the EOF.""" -- cgit v1.2.1 From 09f7c959981a2e5f51ab2c28b1388cb4d91c2bff Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 16 Aug 2002 01:49:44 +0000 Subject: simplified git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@547 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/body.py | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index 98f04d237..d60bb98e9 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -49,35 +49,22 @@ def topic(match, type_name, data, state, state_machine, attributes): return [topic_node], blank_finish -def parsed_literal(match, type_name, data, state, state_machine, attributes): +def parsed_literal(match, type_name, data, state, state_machine, attributes, + node_class=nodes.literal_block): lineno = state_machine.abs_line_number() initial_offset = state_machine.line_offset indented, indent, line_offset, blank_finish \ = state_machine.get_first_known_indented(match.end()) while indented and not indented[-1].strip(): indented.pop() - blocktext = '\n'.join(state_machine.input_lines[ - initial_offset : line_offset + len(indented)]) if not indented: return [], blank_finish text = '\n'.join(indented) textnodes, messages = state.inline_text(text, lineno) - literal = nodes.literal_block(text, '', *textnodes) - return [literal] + messages, blank_finish + node = node_class(text, '', *textnodes) + return [node] + messages, blank_finish def line_block(match, type_name, data, state, state_machine, attributes): - lineno = state_machine.abs_line_number() - initial_offset = state_machine.line_offset - indented, indent, line_offset, blank_finish \ - = state_machine.get_first_known_indented(match.end()) - while indented and not indented[-1].strip(): - indented.pop() - blocktext = '\n'.join(state_machine.input_lines[ - initial_offset : line_offset + len(indented)]) - if not indented: - return [], blank_finish - text = '\n'.join(indented) - textnodes, messages = state.inline_text(text, lineno) - line_block_node = nodes.line_block(text, '', *textnodes) - return [line_block_node] + messages, blank_finish + return parsed_literal(match, type_name, data, state, state_machine, + attributes, node_class=nodes.line_block) -- cgit v1.2.1 From f0b8b4564b132e5d6622d98c56b93deeabffc1cc Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 17 Aug 2002 01:22:29 +0000 Subject: Simplified and improved the "line-block" and "parsed-literal" code. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@548 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/body.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index d60bb98e9..ad603dae6 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -49,22 +49,24 @@ def topic(match, type_name, data, state, state_machine, attributes): return [topic_node], blank_finish -def parsed_literal(match, type_name, data, state, state_machine, attributes, - node_class=nodes.literal_block): +def line_block(match, type_name, data, state, state_machine, attributes, + node_class=nodes.line_block): lineno = state_machine.abs_line_number() - initial_offset = state_machine.line_offset indented, indent, line_offset, blank_finish \ = state_machine.get_first_known_indented(match.end()) while indented and not indented[-1].strip(): indented.pop() if not indented: - return [], blank_finish + warning = state_machine.reporter.warning( + 'Text block expected for the "%s" directive after line %s; none ' + 'found.' % (type_name, lineno)) + return [warning], blank_finish text = '\n'.join(indented) textnodes, messages = state.inline_text(text, lineno) node = node_class(text, '', *textnodes) return [node] + messages, blank_finish -def line_block(match, type_name, data, state, state_machine, attributes): - return parsed_literal(match, type_name, data, state, state_machine, - attributes, node_class=nodes.line_block) +def parsed_literal(match, type_name, data, state, state_machine, attributes): + return line_block(match, type_name, data, state, state_machine, + attributes, node_class=nodes.literal_block) -- cgit v1.2.1 From b24a391ecebe5f31ba0129fdecf2aadbef595f5b Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 17 Aug 2002 01:31:15 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@553 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index d6345562a..002270bc6 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -24,9 +24,9 @@ Where: - ``state_machine`` is the state machine which controls the state which called the directive function. - ``attributes`` is a dictionary of extra attributes which may be added to the - element the directive produces. Currently, only an "alt" attribute is passed - by substitution definitions (value: the substitution name), which may by - used by an embedded image directive. + element the directive produces. Currently, only an "alt" attribute is + passed by substitution definitions (value: the substitution name), which may + be used by an embedded image directive. Directive functions return a tuple of two values: -- cgit v1.2.1 From 13ed20d392cc6c5e727344dad0c3aca8cea125f1 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 21 Aug 2002 03:00:07 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@572 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/__init__.py b/docutils/parsers/rst/__init__.py index 66b594841..7894d8869 100644 --- a/docutils/parsers/rst/__init__.py +++ b/docutils/parsers/rst/__init__.py @@ -26,7 +26,7 @@ Usage 3. Create a new empty `docutils.nodes.document` tree:: - document = docutils.utils.new_document() + document = docutils.utils.new_document(source) See `docutils.utils.new_document()` for parameter details. -- cgit v1.2.1 From 236ccf11c2d82f9003ebcab79785981dfaf653d6 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 24 Aug 2002 14:09:15 +0000 Subject: Added literal block to system_message ("sectnum" directive). git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@593 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/parts.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py index eeff6fc29..8c36b3cc7 100644 --- a/docutils/parsers/rst/directives/parts.py +++ b/docutils/parsers/rst/directives/parts.py @@ -91,9 +91,12 @@ def sectnum(match, type_name, data, state, state_machine, attributes): if success: # data is a dict of attributes pending.details.update(data) else: # data is an error string + blocktext = '\n'.join(state_machine.input_lines[ + line_offset : line_offset + len(datablock) + 1]) error = state_machine.reporter.error( 'Error in "%s" directive attributes at line %s:\n%s.' - % (match.group(1), lineno, data), '') + % (match.group(1), lineno, data), '', + nodes.literal_block(blocktext, blocktext)) return [error], blank_finish state_machine.document.note_pending(pending) return [pending], blank_finish -- cgit v1.2.1 From f14be8cb9b05636ef65e921923ecd74a7cd8304d Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 27 Aug 2002 00:40:51 +0000 Subject: Changed "attribute" to "option" for directives/extensions. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@597 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 7 ++--- docutils/parsers/rst/directives/admonitions.py | 2 +- docutils/parsers/rst/directives/body.py | 9 ++++--- docutils/parsers/rst/directives/html.py | 4 +-- docutils/parsers/rst/directives/images.py | 32 +++++++++++------------ docutils/parsers/rst/directives/misc.py | 4 +-- docutils/parsers/rst/directives/parts.py | 30 ++++++++++----------- docutils/parsers/rst/directives/references.py | 3 ++- docutils/parsers/rst/states.py | 36 ++++++++++++-------------- 9 files changed, 64 insertions(+), 63 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 002270bc6..419350110 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -11,7 +11,8 @@ This package contains directive implementation modules. The interface for directive functions is as follows:: - def directivefn(match, type_name, data, state, state_machine, attributes) + def directivefn(match, type_name, data, state, state_machine, + option_presets): Where: @@ -23,8 +24,8 @@ Where: - ``state`` is the state which called the directive function. - ``state_machine`` is the state machine which controls the state which called the directive function. -- ``attributes`` is a dictionary of extra attributes which may be added to the - element the directive produces. Currently, only an "alt" attribute is +- ``option_presets`` is a dictionary of preset options which may be added to + the element the directive produces. Currently, only an "alt" option is passed by substitution definitions (value: the substitution name), which may be used by an embedded image directive. diff --git a/docutils/parsers/rst/directives/admonitions.py b/docutils/parsers/rst/directives/admonitions.py index 9e6b0ebf7..e1506610f 100644 --- a/docutils/parsers/rst/directives/admonitions.py +++ b/docutils/parsers/rst/directives/admonitions.py @@ -18,7 +18,7 @@ from docutils import nodes def admonition(node_class, match, type_name, data, state, state_machine, - attributes): + option_presets): indented, indent, line_offset, blank_finish \ = state_machine.get_first_known_indented(match.end()) text = '\n'.join(indented) diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index ad603dae6..9ba25844e 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -17,7 +17,7 @@ import sys from docutils import nodes -def topic(match, type_name, data, state, state_machine, attributes): +def topic(match, type_name, data, state, state_machine, option_presets): lineno = state_machine.abs_line_number() initial_offset = state_machine.line_offset indented, indent, line_offset, blank_finish \ @@ -49,7 +49,7 @@ def topic(match, type_name, data, state, state_machine, attributes): return [topic_node], blank_finish -def line_block(match, type_name, data, state, state_machine, attributes, +def line_block(match, type_name, data, state, state_machine, option_presets, node_class=nodes.line_block): lineno = state_machine.abs_line_number() indented, indent, line_offset, blank_finish \ @@ -67,6 +67,7 @@ def line_block(match, type_name, data, state, state_machine, attributes, return [node] + messages, blank_finish -def parsed_literal(match, type_name, data, state, state_machine, attributes): +def parsed_literal(match, type_name, data, state, state_machine, + option_presets): return line_block(match, type_name, data, state, state_machine, - attributes, node_class=nodes.literal_block) + option_presets, node_class=nodes.literal_block) diff --git a/docutils/parsers/rst/directives/html.py b/docutils/parsers/rst/directives/html.py index d21ff0505..e7315bd76 100644 --- a/docutils/parsers/rst/directives/html.py +++ b/docutils/parsers/rst/directives/html.py @@ -18,7 +18,7 @@ from docutils.parsers.rst import states from docutils.transforms import components -def meta(match, type_name, data, state, state_machine, attributes): +def meta(match, type_name, data, state, state_machine, option_presets): line_offset = state_machine.line_offset block, indent, offset, blank_finish = \ state_machine.get_first_known_indented(match.end(), until_blank=1) @@ -41,7 +41,7 @@ def meta(match, type_name, data, state, state_machine, attributes): node += msg return node.get_children(), blank_finish -def imagemap(match, type_name, data, state, state_machine, attributes): +def imagemap(match, type_name, data, state, state_machine, option_presets): return [], 0 diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index 76e5d6f47..94599b933 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -20,12 +20,12 @@ from docutils import nodes, utils def unchanged(arg): return arg # unchanged! -image_attribute_spec = {'alt': unchanged, - 'height': int, - 'width': int, - 'scale': int} +image_option_spec = {'alt': unchanged, + 'height': int, + 'width': int, + 'scale': int} -def image(match, type_name, data, state, state_machine, attributes): +def image(match, type_name, data, state, state_machine, option_presets): lineno = state_machine.abs_line_number() line_offset = state_machine.line_offset datablock, indent, offset, blank_finish = \ @@ -52,28 +52,28 @@ def image(match, type_name, data, state, state_machine, attributes): nodes.literal_block(blocktext, blocktext)) return [error], blank_finish if attlines: - success, data, blank_finish = state.parse_extension_attributes( - image_attribute_spec, attlines, blank_finish) - if success: # data is a dict of attributes - attributes.update(data) + success, data, blank_finish = state.parse_extension_options( + image_option_spec, attlines, blank_finish) + if success: # data is a dict of options + option_presets.update(data) else: # data is an error string error = state_machine.reporter.error( - 'Error in "%s" directive attributes at line %s:\n%s.' + 'Error in "%s" directive options at line %s:\n%s.' % (match.group(1), lineno, data), '', nodes.literal_block(blocktext, blocktext)) return [error], blank_finish - attributes['uri'] = reference - imagenode = nodes.image(blocktext, **attributes) + option_presets['uri'] = reference + imagenode = nodes.image(blocktext, **option_presets) return [imagenode], blank_finish -def figure(match, type_name, data, state, state_machine, attributes): +def figure(match, type_name, data, state, state_machine, option_presets): line_offset = state_machine.line_offset (imagenode,), blank_finish = image(match, type_name, data, state, - state_machine, attributes) + state_machine, option_presets) indented, indent, offset, blank_finish \ = state_machine.get_first_known_indented(sys.maxint) - blocktext = '\n'.join(state_machine.input_lines[line_offset: - state_machine.line_offset+1]) + blocktext = '\n'.join(state_machine.input_lines[ + line_offset : state_machine.line_offset + 1]) if isinstance(imagenode, nodes.system_message): if indented: imagenode[-1] = nodes.literal_block(blocktext, blocktext) diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 3a23f9226..ee0a56b99 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -16,11 +16,11 @@ __docformat__ = 'reStructuredText' from docutils import nodes -def raw(match, type_name, data, state, state_machine, attributes): +def raw(match, type_name, data, state, state_machine, option_presets): return [], 1 def directive_test_function(match, type_name, data, state, state_machine, - attributes): + option_presets): try: state_machine.next_line() indented, indent, offset, blank_finish = state_machine.get_indented() diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py index 8c36b3cc7..a5a5c70f7 100644 --- a/docutils/parsers/rst/directives/parts.py +++ b/docutils/parsers/rst/directives/parts.py @@ -33,12 +33,12 @@ def backlinks(arg): raise ValueError( '"%s" unknown; choose from "top", "entry", or "none"' % arg) -contents_attribute_spec = {'depth': int, - 'local': unchanged, - 'backlinks': backlinks, - 'qa': unchanged} +contents_option_spec = {'depth': int, + 'local': unchanged, + 'backlinks': backlinks} + #'qa': unchanged} -def contents(match, type_name, data, state, state_machine, attributes): +def contents(match, type_name, data, state, state_machine, option_presets): """Table of contents.""" lineno = state_machine.abs_line_number() line_offset = state_machine.line_offset @@ -64,37 +64,37 @@ def contents(match, type_name, data, state, state_machine, attributes): pending = nodes.pending(parts.Contents, 'first writer', {'title': title}, blocktext) if attlines: - success, data, blank_finish = state.parse_extension_attributes( - contents_attribute_spec, attlines, blank_finish) - if success: # data is a dict of attributes + success, data, blank_finish = state.parse_extension_options( + contents_option_spec, attlines, blank_finish) + if success: # data is a dict of options pending.details.update(data) else: # data is an error string error = state_machine.reporter.error( - 'Error in "%s" directive attributes at line %s:\n%s.' + 'Error in "%s" directive options at line %s:\n%s.' % (match.group(1), lineno, data), '', nodes.literal_block(blocktext, blocktext)) return [error] + messages, blank_finish state_machine.document.note_pending(pending) return [pending] + messages, blank_finish -sectnum_attribute_spec = {'depth': int} +sectnum_option_spec = {'depth': int} -def sectnum(match, type_name, data, state, state_machine, attributes): +def sectnum(match, type_name, data, state, state_machine, option_presets): """Automatic section numbering.""" lineno = state_machine.abs_line_number() line_offset = state_machine.line_offset datablock, indent, offset, blank_finish = \ state_machine.get_first_known_indented(match.end(), until_blank=1) pending = nodes.pending(parts.SectNum, 'last reader', {}) - success, data, blank_finish = state.parse_extension_attributes( - sectnum_attribute_spec, datablock, blank_finish) - if success: # data is a dict of attributes + success, data, blank_finish = state.parse_extension_options( + sectnum_option_spec, datablock, blank_finish) + if success: # data is a dict of options pending.details.update(data) else: # data is an error string blocktext = '\n'.join(state_machine.input_lines[ line_offset : line_offset + len(datablock) + 1]) error = state_machine.reporter.error( - 'Error in "%s" directive attributes at line %s:\n%s.' + 'Error in "%s" directive options at line %s:\n%s.' % (match.group(1), lineno, data), '', nodes.literal_block(blocktext, blocktext)) return [error], blank_finish diff --git a/docutils/parsers/rst/directives/references.py b/docutils/parsers/rst/directives/references.py index 98f06f778..12416d5cb 100644 --- a/docutils/parsers/rst/directives/references.py +++ b/docutils/parsers/rst/directives/references.py @@ -16,7 +16,8 @@ from docutils import nodes from docutils.transforms import references -def target_notes(match, type_name, data, state, state_machine, attributes): +def target_notes(match, type_name, data, state, state_machine, + option_presets): """Target footnote generation.""" pending = nodes.pending(references.TargetNotes, 'first reader', {}) state_machine.document.note_pending(pending) diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index eb545a1f2..ed56875cd 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1594,14 +1594,14 @@ class Body(RSTState): self.parent += msg return [], blank_finish - def directive(self, match, **attributes): + def directive(self, match, **option_presets): type_name = match.group(1) directivefunction = directives.directive(type_name, self.memo.language) data = match.string[match.end():].strip() if directivefunction: return directivefunction(match, type_name, data, self, - self.state_machine, attributes) + self.state_machine, option_presets) else: return self.unknown_directive(type_name, data) @@ -1615,21 +1615,20 @@ class Body(RSTState): '', nodes.literal_block(text, text)) return [error], blank_finish - def parse_extension_attributes(self, attribute_spec, datalines, - blank_finish): + def parse_extension_options(self, option_spec, datalines, blank_finish): """ - Parse `datalines` for a field list containing extension attributes - matching `attribute_spec`. + Parse `datalines` for a field list containing extension options + matching `option_spec`. :Parameters: - - `attribute_spec`: a mapping of attribute name to conversion + - `option_spec`: a mapping of option name to conversion function, which should raise an exception on bad input. - `datalines`: a list of input strings. - `blank_finish`: :Return: - Success value, 1 or 0. - - An attribute dictionary on success, an error string on failure. + - An option dictionary on success, an error string on failure. - Updated `blank_finish` flag. """ node = nodes.field_list() @@ -1637,17 +1636,16 @@ class Body(RSTState): datalines, 0, node, initial_state='FieldList', blank_finish=blank_finish) if newline_offset != len(datalines): # incomplete parse of block - return 0, 'invalid attribute block', blank_finish + return 0, 'invalid option block', blank_finish try: - attributes = utils.extract_extension_attributes(node, - attribute_spec) + options = utils.extract_extension_options(node, option_spec) except KeyError, detail: - return 0, ('unknown attribute: "%s"' % detail), blank_finish + return 0, ('unknown option: "%s"' % detail), blank_finish except (ValueError, TypeError), detail: - return 0, ('invalid attribute value: %s' % detail), blank_finish - except utils.ExtensionAttributeError, detail: - return 0, ('invalid attribute data: %s' % detail), blank_finish - return 1, attributes, blank_finish + return 0, ('invalid option value: %s' % detail), blank_finish + except utils.ExtensionOptionError, detail: + return 0, ('invalid option data: %s' % detail), blank_finish + return 1, options, blank_finish def comment(self, match): if not match.string[match.end():].strip() \ @@ -2007,10 +2005,10 @@ class SubstitutionDef(Body): def embedded_directive(self, match, context, next_state): if self.parent.has_key('alt'): - attributes = {'alt': self.parent['alt']} + option_presets = {'alt': self.parent['alt']} else: - attributes = {} - nodelist, blank_finish = self.directive(match, **attributes) + option_presets = {} + nodelist, blank_finish = self.directive(match, **option_presets) self.parent += nodelist if not self.state_machine.at_eof(): self.blank_finish = blank_finish -- cgit v1.2.1 From a024b2b067ec8a092d783c9baed4b43dd5898d56 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 4 Sep 2002 01:33:22 +0000 Subject: Converted system messages to use the new "line" attribute. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@622 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/body.py | 16 +-- docutils/parsers/rst/directives/html.py | 22 ++-- docutils/parsers/rst/directives/images.py | 17 +-- docutils/parsers/rst/directives/misc.py | 6 +- docutils/parsers/rst/directives/parts.py | 12 +- docutils/parsers/rst/directives/references.py | 4 +- docutils/parsers/rst/states.py | 168 +++++++++++++------------- 7 files changed, 123 insertions(+), 122 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index 9ba25844e..7d74e7a2b 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -23,11 +23,11 @@ def topic(match, type_name, data, state, state_machine, option_presets): indented, indent, line_offset, blank_finish \ = state_machine.get_first_known_indented(match.end()) blocktext = '\n'.join(state_machine.input_lines[ - initial_offset : line_offset + len(indented)]) + initial_offset : line_offset + len(indented) - 1]) if not state_machine.match_titles: error = state_machine.reporter.error( - 'Topics may not be nested within body elements (line %s).' - % lineno, '', nodes.literal_block(blocktext, blocktext)) + 'Topics may not be nested within body elements.', '', + nodes.literal_block(blocktext, blocktext), line=lineno) return [error], blank_finish if not indented: return [], blank_finish @@ -37,15 +37,15 @@ def topic(match, type_name, data, state, state_machine, option_presets): if indented: if indented[0].strip(): warning = state_machine.reporter.warning( - 'The second line of a topic block must be blank (line %s).' - % (lineno + 1 + line_offset - initial_offset), '') + 'The second line of a topic block must be blank.', + line=lineno + 1 + line_offset - initial_offset) messages.append(warning) text = '\n'.join(indented) else: text = '' topic_node = nodes.topic(text, title, *messages) if text: - state.nested_parse(indented, line_offset, topic_node) + state.nested_parse(indented, line_offset + 1, topic_node) return [topic_node], blank_finish @@ -58,8 +58,8 @@ def line_block(match, type_name, data, state, state_machine, option_presets, indented.pop() if not indented: warning = state_machine.reporter.warning( - 'Text block expected for the "%s" directive after line %s; none ' - 'found.' % (type_name, lineno)) + 'Text block expected for the "%s" directive; none found.' + % type_name, line=lineno) return [warning], blank_finish text = '\n'.join(indented) textnodes, messages = state.inline_text(text, lineno) diff --git a/docutils/parsers/rst/directives/html.py b/docutils/parsers/rst/directives/html.py index e7315bd76..0e7527592 100644 --- a/docutils/parsers/rst/directives/html.py +++ b/docutils/parsers/rst/directives/html.py @@ -31,13 +31,13 @@ def meta(match, type_name, data, state, state_machine, option_presets): blocktext = '\n'.join(state_machine.input_lines[ line_offset : state_machine.line_offset+1]) msg = state_machine.reporter.error( - 'Invalid meta directive at line %s.' - % state_machine.abs_line_number(), '', - nodes.literal_block(blocktext, blocktext)) + 'Invalid meta directive.', '', + nodes.literal_block(blocktext, blocktext), + line=state_machine.abs_line_number()) node += msg else: - msg = state_machine.reporter.error('Empty meta directive at line %s.' - % state_machine.abs_line_number()) + msg = state_machine.reporter.error( + 'Empty meta directive.', line=state_machine.abs_line_number()) node += msg return node.get_children(), blank_finish @@ -68,9 +68,9 @@ class MetaBody(states.SpecializedBody): if not indented: line = self.state_machine.line msg = self.reporter.info( - 'No content for meta tag "%s" at line %s.' - % (name, self.state_machine.abs_line_number()), - '', nodes.literal_block(line, line)) + 'No content for meta tag "%s".' % name, '', + nodes.literal_block(line, line), + line=self.state_machine.abs_line_number()) return msg, blank_finish try: attname, val = utils.extract_name_value(name)[0] @@ -84,9 +84,9 @@ class MetaBody(states.SpecializedBody): except utils.NameValueError, detail: line = self.state_machine.line msg = self.reporter.error( - 'Error parsing meta tag attribute "%s" at line %s: %s.' - % (arg, self.state_machine.abs_line_number(), detail), - '', nodes.literal_block(line, line)) + 'Error parsing meta tag attribute "%s": %s.' + % (arg, detail), '', nodes.literal_block(line, line), + line=self.state_machine.abs_line_number()) return msg, blank_finish self.document.note_pending(pending) return pending, blank_finish diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index 94599b933..e63105a12 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -41,15 +41,15 @@ def image(match, type_name, data, state, state_machine, option_presets): attlines = [] if not datablock: error = state_machine.reporter.error( - 'Missing image URI argument at line %s.' % lineno, '', - nodes.literal_block(blocktext, blocktext)) + 'Missing image URI argument.', '', + nodes.literal_block(blocktext, blocktext), line=lineno) return [error], blank_finish attoffset = line_offset + i reference = ''.join([line.strip() for line in datablock]) if reference.find(' ') != -1: error = state_machine.reporter.error( - 'Image URI at line %s contains whitespace.' % lineno, '', - nodes.literal_block(blocktext, blocktext)) + 'Image URI contains whitespace.', '', + nodes.literal_block(blocktext, blocktext), line=lineno) return [error], blank_finish if attlines: success, data, blank_finish = state.parse_extension_options( @@ -58,15 +58,16 @@ def image(match, type_name, data, state, state_machine, option_presets): option_presets.update(data) else: # data is an error string error = state_machine.reporter.error( - 'Error in "%s" directive options at line %s:\n%s.' - % (match.group(1), lineno, data), '', - nodes.literal_block(blocktext, blocktext)) + 'Error in "%s" directive options:\n%s.' + % (match.group(1), data), '', + nodes.literal_block(blocktext, blocktext), line=lineno) return [error], blank_finish option_presets['uri'] = reference imagenode = nodes.image(blocktext, **option_presets) return [imagenode], blank_finish def figure(match, type_name, data, state, state_machine, option_presets): + lineno = state_machine.abs_line_number() line_offset = state_machine.line_offset (imagenode,), blank_finish = image(match, type_name, data, state, state_machine, option_presets) @@ -90,7 +91,7 @@ def figure(match, type_name, data, state, state_machine, option_presets): elif not (isinstance(firstnode, nodes.comment) and len(firstnode) == 0): error = state_machine.reporter.error( 'Figure caption must be a paragraph or empty comment.', '', - nodes.literal_block(blocktext, blocktext)) + nodes.literal_block(blocktext, blocktext), line=lineno) return [figurenode, error], blank_finish if len(node) > 1: figurenode += nodes.legend('', *node[1:]) diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index ee0a56b99..663325ead 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -21,6 +21,7 @@ def raw(match, type_name, data, state, state_machine, option_presets): def directive_test_function(match, type_name, data, state, state_machine, option_presets): + lineno = state_machine.abs_line_number() try: state_machine.next_line() indented, indent, offset, blank_finish = state_machine.get_indented() @@ -31,9 +32,10 @@ def directive_test_function(match, type_name, data, state, state_machine, if text: info = state_machine.reporter.info( 'Directive processed. Type="%s", data="%s", directive block:' - % (type_name, data), '', nodes.literal_block(text, text)) + % (type_name, data), '', nodes.literal_block(text, text), + line=lineno) else: info = state_machine.reporter.info( 'Directive processed. Type="%s", data="%s", directive block: ' - 'None' % (type_name, data)) + 'None' % (type_name, data), line=lineno) return [info], blank_finish diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py index a5a5c70f7..bb7527d05 100644 --- a/docutils/parsers/rst/directives/parts.py +++ b/docutils/parsers/rst/directives/parts.py @@ -70,9 +70,9 @@ def contents(match, type_name, data, state, state_machine, option_presets): pending.details.update(data) else: # data is an error string error = state_machine.reporter.error( - 'Error in "%s" directive options at line %s:\n%s.' - % (match.group(1), lineno, data), '', - nodes.literal_block(blocktext, blocktext)) + 'Error in "%s" directive options:\n%s.' + % (match.group(1), data), '', + nodes.literal_block(blocktext, blocktext), line=lineno) return [error] + messages, blank_finish state_machine.document.note_pending(pending) return [pending] + messages, blank_finish @@ -94,9 +94,9 @@ def sectnum(match, type_name, data, state, state_machine, option_presets): blocktext = '\n'.join(state_machine.input_lines[ line_offset : line_offset + len(datablock) + 1]) error = state_machine.reporter.error( - 'Error in "%s" directive options at line %s:\n%s.' - % (match.group(1), lineno, data), '', - nodes.literal_block(blocktext, blocktext)) + 'Error in "%s" directive options:\n%s.' + % (match.group(1), data), '', + nodes.literal_block(blocktext, blocktext), line=lineno) return [error], blank_finish state_machine.document.note_pending(pending) return [pending], blank_finish diff --git a/docutils/parsers/rst/directives/references.py b/docutils/parsers/rst/directives/references.py index 12416d5cb..0a8b2afd0 100644 --- a/docutils/parsers/rst/directives/references.py +++ b/docutils/parsers/rst/directives/references.py @@ -24,7 +24,7 @@ def target_notes(match, type_name, data, state, state_machine, nodelist = [pending] if data: warning = state_machine.reporter.warning( - 'The "%s" directive takes no data; "%s" ignored (at line %s).' - % (match.group(1), data, state_machine.abs_line_number())) + 'The "%s" directive takes no data; "%s" ignored.' + % (match.group(1), data), line=state_machine.abs_line_number()) nodelist.append(warning) return nodelist, state_machine.is_next_line_blank() diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index ed56875cd..88d4f3562 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -316,8 +316,8 @@ class RSTState(StateWS): def title_inconsistent(self, sourcetext, lineno): literalblock = nodes.literal_block('', sourcetext) - error = self.reporter.severe('Title level inconsistent at line %s:' - % lineno, '', literalblock) + error = self.reporter.severe('Title level inconsistent:', '', + literalblock, line=lineno) return error def new_subsection(self, title, lineno, messages): @@ -374,8 +374,8 @@ class RSTState(StateWS): def unindent_warning(self, node_name): return self.reporter.warning( - ('%s ends without a blank line; unexpected unindent at line %s.' - % (node_name, self.state_machine.abs_line_number() + 1))) + '%s ends without a blank line; unexpected unindent.' % node_name, + line=(self.state_machine.abs_line_number() + 1)) def build_regexp(definition, compile=1): @@ -585,8 +585,8 @@ class Inliner: return (string[:matchstart], [nodeclass(rawsource, text)], string[textend:], [], endmatch.group(1)) msg = self.reporter.warning( - 'Inline %s start-string without end-string ' - 'at line %s.' % (nodeclass.__name__, lineno)) + 'Inline %s start-string without end-string.' + % nodeclass.__name__, line=lineno) text = unescape(string[matchstart:matchend], 1) rawsource = unescape(string[matchstart:matchend], 1) prb = self.problematic(text, rawsource, msg) @@ -628,9 +628,9 @@ class Inliner: if endmatch.group('role'): if role: msg = self.reporter.warning( - 'Multiple roles in interpreted text at line %s (both ' - 'prefix and suffix present; only one allowed).' - % lineno) + 'Multiple roles in interpreted text (both ' + 'prefix and suffix present; only one allowed).', + line=lineno) text = unescape(string[rolestart:textend], 1) prb = self.problematic(text, text, msg) return string[:rolestart], [prb], string[textend:], [msg] @@ -643,7 +643,7 @@ class Inliner: if role: msg = self.reporter.warning( 'Mismatch: both interpreted text role %s and ' - 'reference suffix at line %s.' % (position, lineno)) + 'reference suffix.' % position, line=lineno) text = unescape(string[rolestart:textend], 1) prb = self.problematic(text, text, msg) return string[:rolestart], [prb], string[textend:], [msg] @@ -654,7 +654,7 @@ class Inliner: rawsource, text, role, position) msg = self.reporter.warning( 'Inline interpreted text or phrase reference start-string ' - 'without end-string at line %s.' % lineno) + 'without end-string.', line=lineno) text = unescape(string[matchstart:matchend], 1) prb = self.problematic(text, text, msg) return string[:matchstart], [prb], string[matchend:], [msg] @@ -961,9 +961,8 @@ class Body(RSTState): raise statemachine.TransitionCorrection('text') if ordinal != 1: msg = self.reporter.info( - ('Enumerated list start value not ordinal-1 at line %s: ' - '"%s" (ordinal %s)' - % (self.state_machine.abs_line_number(), text, ordinal))) + 'Enumerated list start value not ordinal-1: "%s" (ordinal %s)' + % (text, ordinal), line=self.state_machine.abs_line_number()) self.parent += msg enumlist = nodes.enumerated_list() self.parent += enumlist @@ -1137,10 +1136,10 @@ class Body(RSTState): optionlist = nodes.option_list() try: listitem, blank_finish = self.option_list_item(match) - except MarkupError, detail: # shouldn't happen; won't match pattern + except MarkupError, (message, lineno): + # This shouldn't happen; pattern won't match. msg = self.reporter.error( - ('Invalid option list marker at line %s: %s' - % (self.state_machine.abs_line_number(), detail))) + 'Invalid option list marker: %s' % message, line=lineno) self.parent += msg indented, indent, line_offset, blank_finish = \ self.state_machine.get_first_known_indented(match.end()) @@ -1201,9 +1200,10 @@ class Body(RSTState): delimiter=delimiter) optlist.append(option) else: - raise MarkupError('wrong numer of option tokens (=%s), ' - 'should be 1 or 2: "%s"' % (len(tokens), - optionstring)) + raise MarkupError( + 'wrong numer of option tokens (=%s), should be 1 or 2: ' + '"%s"' % (len(tokens), optionstring), + self.state_machine.abs_line_number() + 1) return optlist def doctest(self, match, context, next_state): @@ -1230,8 +1230,8 @@ class Body(RSTState): self.parent += nodelist if not blank_finish: msg = self.reporter.warning( - 'Blank line required after table at line %s.' - % (self.state_machine.abs_line_number() + 1)) + 'Blank line required after table.', + line=self.state_machine.abs_line_number() + 1) self.parent += msg return [], next_state, [] @@ -1259,8 +1259,8 @@ class Body(RSTState): block = self.state_machine.get_text_block(flush_left=1) except statemachine.UnexpectedIndentationError, instance: block, lineno = instance.args - messages.append(self.reporter.error( - 'Unexpected indentation at line %s.' % lineno)) + messages.append(self.reporter.error('Unexpected indentation.', + line=lineno)) blank_finish = 0 width = len(block[0].strip()) for i in range(len(block)): @@ -1330,14 +1330,14 @@ class Body(RSTState): def malformed_table(self, block, detail=''): data = '\n'.join(block) - message = 'Malformed table at line %s; formatting as a ' \ - 'literal block.' % (self.state_machine.abs_line_number() - - len(block) + 1) + message = 'Malformed table.' + lineno = self.state_machine.abs_line_number() - len(block) + 1 if detail: message += '\n' + detail - nodelist = [self.reporter.error(message), - nodes.literal_block(data, data)] - return nodelist + error = self.reporter.error(message, '', + nodes.literal_block(data, data), + line=lineno) + return [error] def build_table(self, tabledata, tableline): colspecs, headrows, bodyrows = tabledata @@ -1479,9 +1479,8 @@ class Body(RSTState): blockindex += 1 try: escaped += block[blockindex] - except (IndexError, MarkupError): - raise MarkupError('malformed hyperlink target at line %s.' - % lineno) + except IndexError: + raise MarkupError('malformed hyperlink target.', lineno) del block[:blockindex] block[0] = (block[0] + ' ')[targetmatch.end()-len(escaped)-1:].strip() if block and block[-1].strip()[-1:] == '_': # possible indirect target @@ -1496,10 +1495,9 @@ class Body(RSTState): reference = ''.join([line.strip() for line in block]) if reference.find(' ') != -1: warning = self.reporter.warning( - 'Hyperlink target at line %s contains whitespace. ' - 'Perhaps a footnote was intended?' - % (self.state_machine.abs_line_number() - len(block) + 1), - '', nodes.literal_block(blocktext, blocktext)) + 'Hyperlink target contains whitespace. Perhaps a footnote ' + 'was intended?', '', + nodes.literal_block(blocktext, blocktext), line=lineno) nodelist.append(warning) else: unescaped = unescape(reference) @@ -1548,9 +1546,9 @@ class Body(RSTState): blockindex += 1 try: escaped = escaped + ' ' + block[blockindex].strip() - except (IndexError, MarkupError): - raise MarkupError('malformed substitution definition ' - 'at line %s.' % lineno) + except IndexError: + raise MarkupError('malformed substitution definition.', + lineno) del block[:blockindex] # strip out the substitution marker block[0] = (block[0] + ' ')[subdefmatch.end()-len(escaped)-1:].strip() if not block[0]: @@ -1577,9 +1575,9 @@ class Body(RSTState): i += 1 if len(substitutionnode) == 0: msg = self.reporter.warning( - 'Substitution definition "%s" empty or invalid at line ' - '%s.' % (subname, self.state_machine.abs_line_number()), - '', nodes.literal_block(blocktext, blocktext)) + 'Substitution definition "%s" empty or invalid.' + % subname, '', + nodes.literal_block(blocktext, blocktext), line=lineno) self.parent += msg else: del substitutionnode['alt'] @@ -1588,9 +1586,8 @@ class Body(RSTState): return [substitutionnode], blank_finish else: msg = self.reporter.warning( - 'Substitution definition "%s" missing contents at line %s.' - % (subname, self.state_machine.abs_line_number()), '', - nodes.literal_block(blocktext, blocktext)) + 'Substitution definition "%s" missing contents.' % subname, + '', nodes.literal_block(blocktext, blocktext), line=lineno) self.parent += msg return [], blank_finish @@ -1611,8 +1608,8 @@ class Body(RSTState): self.state_machine.get_first_known_indented(0, strip_indent=0) text = '\n'.join(indented) error = self.reporter.error( - 'Unknown directive type "%s" at line %s.' % (type_name, lineno), - '', nodes.literal_block(text, text)) + 'Unknown directive type "%s".' % type_name, '', + nodes.literal_block(text, text), line=lineno) return [error], blank_finish def parse_extension_options(self, option_spec, datalines, blank_finish): @@ -1714,10 +1711,11 @@ class Body(RSTState): if expmatch: try: return method(self, expmatch) - except MarkupError, detail: # never reached? + except MarkupError, (message, lineno): # never reached? errors.append( - self.reporter.warning('%s: %s' - % (detail.__class__.__name__, detail))) + self.reporter.warning( + '%s: %s' % (detail.__class__.__name__, message), + line=lineno)) break nodelist, blank_finish = self.comment(match) return nodelist + errors, blank_finish @@ -1762,11 +1760,12 @@ class Body(RSTState): nodelist = [] reference = escape2null(''.join([line.strip() for line in block])) if reference.find(' ') != -1: + lineno = self.state_machine.abs_line_number() - len(block) + 1 warning = self.reporter.warning( - 'Anonymous hyperlink target at line %s contains ' - 'whitespace. Perhaps a footnote was intended?' - % (self.state_machine.abs_line_number() - len(block) + 1), - '', nodes.literal_block(blocktext, blocktext)) + 'Anonymous hyperlink target contains whitespace. Perhaps a ' + 'footnote was intended?', '', + nodes.literal_block(blocktext, blocktext), + line=lineno) nodelist.append(warning) else: target = nodes.target(blocktext, '', anonymous=1) @@ -1784,9 +1783,9 @@ class Body(RSTState): else: blocktext = self.state_machine.line msg = self.reporter.severe( - 'Unexpected section title or transition at line %s.' - % self.state_machine.abs_line_number(), '', - nodes.literal_block(blocktext, blocktext)) + 'Unexpected section title or transition.', '', + nodes.literal_block(blocktext, blocktext), + line=self.state_machine.abs_line_number()) self.parent += msg return [], next_state, [] @@ -1948,7 +1947,7 @@ class OptionList(SpecializedBody): """Option list item.""" try: option_list_item, blank_finish = self.option_list_item(match) - except MarkupError, detail: + except MarkupError, (message, lineno): self.invalid_input() self.parent += option_list_item self.blank_finish = blank_finish @@ -2069,8 +2068,8 @@ class Text(RSTState): if not self.state_machine.match_titles: blocktext = context[0] + '\n' + self.state_machine.line msg = self.reporter.severe( - 'Unexpected section title at line %s.' % lineno, '', - nodes.literal_block(blocktext, blocktext)) + 'Unexpected section title.', '', + nodes.literal_block(blocktext, blocktext), line=lineno) self.parent += msg return [], next_state, [] title = context[0].rstrip() @@ -2080,8 +2079,8 @@ class Text(RSTState): if len(title) > len(underline): blocktext = context[0] + '\n' + self.state_machine.line msg = self.reporter.warning( - 'Title underline too short at line %s.' % lineno, '', - nodes.literal_block(blocktext, blocktext)) + 'Title underline too short.', '', + nodes.literal_block(blocktext, blocktext), line=lineno) messages.append(msg) style = underline[0] context[:] = [] @@ -2096,8 +2095,7 @@ class Text(RSTState): block = self.state_machine.get_text_block(flush_left=1) except statemachine.UnexpectedIndentationError, instance: block, lineno = instance.args - msg = self.reporter.error( - 'Unexpected indentation at line %s.' % lineno) + msg = self.reporter.error('Unexpected indentation.', line=lineno) lines = context + block paragraph, literalnext = self.paragraph(lines, startline) self.parent += paragraph @@ -2124,8 +2122,8 @@ class Text(RSTState): nodelist.append(self.unindent_warning('Literal block')) else: nodelist.append(self.reporter.warning( - 'Literal block expected at line %s; none found.' - % self.state_machine.abs_line_number())) + 'Literal block expected; none found.', + line=self.state_machine.abs_line_number())) return nodelist def definition_list_item(self, termline): @@ -2141,7 +2139,7 @@ class Text(RSTState): if termline[0][-2:] == '::': definition += self.reporter.info( 'Blank line missing before literal block? Interpreted as a ' - 'definition list item. At line %s.' % (line_offset + 1)) + 'definition list item.', line=line_offset + 1) self.nested_parse(indented, input_offset=line_offset, node=definition) return definitionlistitem, blank_finish @@ -2216,8 +2214,8 @@ class Line(SpecializedText): transition = nodes.transition(context[0]) self.parent += transition msg = self.reporter.error( - 'Document or section may not end with a transition ' - '(line %s).' % (self.state_machine.abs_line_number() - 1)) + 'Document or section may not end with a transition.', + line=self.state_machine.abs_line_number() - 1) self.parent += msg self.eofcheck = 1 return [] @@ -2227,14 +2225,14 @@ class Line(SpecializedText): transition = nodes.transition(context[0]) if len(self.parent) == 0: msg = self.reporter.error( - 'Document or section may not begin with a transition ' - '(line %s).' % (self.state_machine.abs_line_number() - 1)) + 'Document or section may not begin with a transition.', + line=self.state_machine.abs_line_number() - 1) self.parent += msg elif isinstance(self.parent[-1], nodes.transition): msg = self.reporter.error( 'At least one body element must separate transitions; ' - 'adjacent transitions at line %s.' - % (self.state_machine.abs_line_number() - 1)) + 'adjacent transitions not allowed.', + line=self.state_machine.abs_line_number() - 1) self.parent += msg self.parent += transition return [], 'Body', [] @@ -2250,8 +2248,8 @@ class Line(SpecializedText): except IndexError: blocktext = overline + '\n' + title msg = self.reporter.severe( - 'Incomplete section title at line %s.' % lineno, '', - nodes.literal_block(blocktext, blocktext)) + 'Incomplete section title.', '', + nodes.literal_block(blocktext, blocktext), line=lineno) self.parent += msg return [], 'Body', [] source = '%s\n%s\n%s' % (overline, title, underline) @@ -2259,22 +2257,22 @@ class Line(SpecializedText): underline = underline.rstrip() if not self.transitions['underline'][0].match(underline): msg = self.reporter.severe( - 'Missing underline for overline at line %s.' % lineno, '', - nodes.literal_block(source, source)) + 'Missing underline for overline.', '', + nodes.literal_block(source, source), line=lineno) self.parent += msg return [], 'Body', [] elif overline != underline: msg = self.reporter.severe( - 'Title overline & underline mismatch at ' 'line %s.' - % lineno, '', nodes.literal_block(source, source)) + 'Title overline & underline mismatch.', '', + nodes.literal_block(source, source), line=lineno) self.parent += msg return [], 'Body', [] title = title.rstrip() messages = [] if len(title) > len(overline): msg = self.reporter.warning( - 'Title overline too short at line %s.'% lineno, '', - nodes.literal_block(source, source)) + 'Title overline too short.', '', + nodes.literal_block(source, source), line=lineno) messages.append(msg) style = (overline[0], underline[0]) self.eofcheck = 0 # @@@ not sure this is correct @@ -2287,9 +2285,9 @@ class Line(SpecializedText): def underline(self, match=None, context=None, next_state=None): blocktext = context[0] + '\n' + self.state_machine.line msg = self.reporter.error( - 'Invalid section title or transition marker at line %s.' - % (self.state_machine.abs_line_number() - 1), '', - nodes.literal_block(blocktext, blocktext)) + 'Invalid section title or transition marker.', '', + nodes.literal_block(blocktext, blocktext), + line=self.state_machine.abs_line_number() - 1) self.parent += msg return [], 'Body', [] -- cgit v1.2.1 From 1368e12ba7bc99bbaab878786482331e3cee07ed Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 6 Sep 2002 02:12:54 +0000 Subject: Fixed a substitution reference edge case. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@636 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 88d4f3562..0d5b8ba20 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -469,7 +469,7 @@ class Inliner: r'\*(?!\*)', # emphasis but not strong r'``', # literal r'_`', # inline internal target - r'\|'] # substitution reference + r'\|(?!\|)'] # substitution reference ), ('whole', '', end_string_suffix, # whole constructs [# reference name & end-string -- cgit v1.2.1 From 8d99e24bdb9eeee509fb25513a0d88f7ac03dd57 Mon Sep 17 00:00:00 2001 From: chodorowski Date: Fri, 6 Sep 2002 16:04:40 +0000 Subject: Added support for 'align'. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@640 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index e63105a12..0e0c14277 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -23,7 +23,9 @@ def unchanged(arg): image_option_spec = {'alt': unchanged, 'height': int, 'width': int, - 'scale': int} + 'scale': int, + 'align': unchanged} + def image(match, type_name, data, state, state_machine, option_presets): lineno = state_machine.abs_line_number() -- cgit v1.2.1 From 4a16efd0a29ad89070e8bd19e16b141014935189 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 7 Sep 2002 02:31:14 +0000 Subject: Added the "--pep-references" and "--rfc-references" options. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@643 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/__init__.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/__init__.py b/docutils/parsers/rst/__init__.py index 7894d8869..4bc8970c4 100644 --- a/docutils/parsers/rst/__init__.py +++ b/docutils/parsers/rst/__init__.py @@ -58,6 +58,16 @@ class Parser(docutils.parsers.Parser): supported = ('restructuredtext', 'rst', 'rest', 'restx', 'rtxt', 'rstx') """Aliases this parser supports.""" + cmdline_options = ( + 'reStructuredText Parser Options', + None, + (('Recognize and link to PEP references (like "PEP 258").', + ['--pep-references'], + {'action': 'store_true'}), + ('Recognize and link to RFC references (like "RFC 822").', + ['--rfc-references'], + {'action': 'store_true'}),)) + def __init__(self, rfc2822=None, inliner=None): if rfc2822: self.initial_state = 'RFC2822Body' -- cgit v1.2.1 From aba194af678474835e94a9c686d6e5a202706af0 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 7 Sep 2002 02:32:37 +0000 Subject: Added support for "--pep-references" and "--rfc-references" options; reworked ``Inliner`` code to make customization easier. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@644 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 77 +++++++++++++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 12 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 0d5b8ba20..d66e52bbd 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -148,6 +148,7 @@ class RSTStateMachine(StateMachineWS): self.match_titles = match_titles if inliner is None: inliner = Inliner() + inliner.init_customizations(document.options) self.memo = Stuff(document=document, reporter=document.reporter, language=self.language, @@ -407,6 +408,20 @@ class Inliner: Parse inline markup; call the `parse()` method. """ + def __init__(self): + self.implicit_dispatch = [(self.patterns.uri, self.standalone_uri),] + """List of (pattern, bound method) tuples, used by + `self.implicit_inline`.""" + + def init_customizations(self, options): + """Option-based customizations; run when parsing begins.""" + if options.pep_references: + self.implicit_dispatch.append((self.patterns.pep, + self.pep_reference)) + if options.rfc_references: + self.implicit_dispatch.append((self.patterns.rfc, + self.rfc_reference)) + def parse(self, text, lineno, memo, parent): """ Return 2 lists: nodes (text and inline elements), and system_messages. @@ -548,7 +563,21 @@ class Inliner: ) ) %(end_string_suffix)s - """ % locals(), re.VERBOSE)) + """ % locals(), re.VERBOSE), + pep=re.compile( + r""" + %(start_string_prefix)s + ( + (pep-(?P\d+)(.txt)?) # reference to source file + | + (PEP\s+(?P\d+)) # reference by name + ) + %(end_string_suffix)s""" % locals(), re.VERBOSE), + rfc=re.compile( + r""" + %(start_string_prefix)s + (RFC(-|\s+)?(?P\d+)) + %(end_string_suffix)s""" % locals(), re.VERBOSE)) def quoted_start(self, match): """Return 1 if inline markup start-string is 'quoted', 0 if not.""" @@ -787,31 +816,55 @@ class Inliner: else: # not a valid scheme raise MarkupMismatch - implicit = ((patterns.uri, standalone_uri),) - """List of (pattern, dispatch method) pairs.""" + pep_url_local = 'pep-%04d.html' + pep_url_absolute = 'http://www.python.org/peps/pep-%04d.html' + pep_url = pep_url_absolute + + def pep_reference(self, match, lineno): + text = match.group(0) + if text.startswith('pep-'): + pepnum = int(match.group('pepnum1')) + elif text.startswith('PEP'): + pepnum = int(match.group('pepnum2')) + else: + raise MarkupMismatch + ref = self.pep_url % pepnum + unescaped = unescape(text, 0) + return [nodes.reference(unescape(text, 1), unescaped, refuri=ref)] + + rfc_url = 'http://www.faqs.org/rfcs/rfc%d.html' + + def rfc_reference(self, match, lineno): + text = match.group(0) + if text.startswith('RFC'): + rfcnum = int(match.group('rfcnum')) + ref = self.rfc_url % rfcnum + else: + raise MarkupMismatch + unescaped = unescape(text, 0) + return [nodes.reference(unescape(text, 1), unescaped, refuri=ref)] def implicit_inline(self, text, lineno): """ - Check each of the patterns in `self.implicit` for a match, and - dispatch to the stored method for the pattern. Recursively check the - text before and after the match. Return a list of `nodes.Text` and - inline element nodes. + Check each of the patterns in `self.implicit_dispatch` for a match, + and dispatch to the stored method for the pattern. Recursively check + the text before and after the match. Return a list of `nodes.Text` + and inline element nodes. """ if not text: return [] - for pattern, dispatch in self.implicit: + for pattern, method in self.implicit_dispatch: match = pattern.search(text) if match: try: # Must recurse on strings before *and* after the match; # there may be multiple patterns. return (self.implicit_inline(text[:match.start()], lineno) - + dispatch(self, match, lineno) + + + method(match, lineno) + self.implicit_inline(text[match.end():], lineno)) except MarkupMismatch: pass return [nodes.Text(unescape(text))] - dispatch = {'*': emphasis, '**': strong, @@ -1047,10 +1100,10 @@ class Body(RSTState): try: next_line = self.state_machine.next_line() except IndexError: # end of input lines - self.state_machine.previous_line() + self.state_machine.previous_line() return 1 else: - self.state_machine.previous_line() + self.state_machine.previous_line() if not next_line[:1].strip(): # blank or indented return 1 next_enumerator = self.make_enumerator(ordinal + 1, sequence, format) -- cgit v1.2.1 From 5d6d0b13b959ef217fe9d19dbb5a184446336453 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 7 Sep 2002 02:41:55 +0000 Subject: Removed tabs git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@652 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index 0e0c14277..b8198dd6a 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -24,8 +24,7 @@ image_option_spec = {'alt': unchanged, 'height': int, 'width': int, 'scale': int, - 'align': unchanged} - + 'align': unchanged} def image(match, type_name, data, state, state_machine, option_presets): lineno = state_machine.abs_line_number() -- cgit v1.2.1 From 5b8929c3291e2e0625c1336dcf6d12530bc00f36 Mon Sep 17 00:00:00 2001 From: chodorowski Date: Mon, 9 Sep 2002 17:21:43 +0000 Subject: Make sure that the keyword passed to the 'align' option is one of 'bottom', 'middle', 'top', 'left', 'center' or 'right'. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@655 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index b8198dd6a..439f24531 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -20,11 +20,31 @@ from docutils import nodes, utils def unchanged(arg): return arg # unchanged! +def format_allowed( allowed ): + qouted = map( lambda s: '"%s"' % s, allowed ) + return ' or '.join( [ ', '.join( qouted[:-1] ), qouted[-1] ] ) + +def align( argument ): + allowed = ( 'top', 'middle', 'bottom', 'left', 'center', 'right' ) + + try: + value = argument.lower().strip() + except AttributeError: + raise TypeError('must supply an argument; choose from %s', + format_allowed( allowed )) + + if value in allowed: + return value + else: + raise ValueError( + '"%s" unknown; choose from %s' % (argument, format_allowed( allowed )) ) + + image_option_spec = {'alt': unchanged, 'height': int, 'width': int, 'scale': int, - 'align': unchanged} + 'align': align} def image(match, type_name, data, state, state_machine, option_presets): lineno = state_machine.abs_line_number() -- cgit v1.2.1 From c84ea50f0fb04462de27076b70fc7297f5d71eaa Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 10 Sep 2002 03:28:03 +0000 Subject: Added ``flag()``, ``unchanged()``, and ``choice()`` directive option helper functions. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@658 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 419350110..3968d575e 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -109,3 +109,28 @@ def directive(directive_name, language_module): except AttributeError: return None return function + +def flag(argument): + if argument and argument.strip(): + raise ValueError('no argument is allowed; "%s" supplied' % argument) + else: + return None + +def unchanged(argument): + return argument # unchanged! + +def format_values(values): + return '%s, or "%s"' % (', '.join(['"%s"' % s for s in values[:-1]]), + values[-1]) + +def choice(argument, values): + try: + value = argument.lower().strip() + except AttributeError: + raise TypeError('must supply an argument; choose from %s', + format_values(values)) + if value in values: + return value + else: + raise ValueError('"%s" unknown; choose from %s' + % (argument, format_values(values))) -- cgit v1.2.1 From 4d9b2b3cd409effab2c8ee243e5aa69f38371099 Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 10 Sep 2002 03:29:36 +0000 Subject: Moved ``unchanged()`` helper function and code from ``align()`` to __init__.py; updated. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@659 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index 439f24531..bb997bc58 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -14,33 +14,16 @@ __docformat__ = 'reStructuredText' import sys -from docutils.parsers.rst import states from docutils import nodes, utils +from docutils.parsers.rst import directives -def unchanged(arg): - return arg # unchanged! -def format_allowed( allowed ): - qouted = map( lambda s: '"%s"' % s, allowed ) - return ' or '.join( [ ', '.join( qouted[:-1] ), qouted[-1] ] ) - -def align( argument ): - allowed = ( 'top', 'middle', 'bottom', 'left', 'center', 'right' ) - - try: - value = argument.lower().strip() - except AttributeError: - raise TypeError('must supply an argument; choose from %s', - format_allowed( allowed )) - - if value in allowed: - return value - else: - raise ValueError( - '"%s" unknown; choose from %s' % (argument, format_allowed( allowed )) ) +align_values = ('top', 'middle', 'bottom', 'left', 'center', 'right') +def align(argument): + return directives.choice(argument, align_values) -image_option_spec = {'alt': unchanged, +image_option_spec = {'alt': directives.unchanged, 'height': int, 'width': int, 'scale': int, @@ -109,7 +92,8 @@ def figure(match, type_name, data, state, state_machine, option_presets): caption = nodes.caption(firstnode.rawsource, '', *firstnode.children) figurenode += caption - elif not (isinstance(firstnode, nodes.comment) and len(firstnode) == 0): + elif not (isinstance(firstnode, nodes.comment) + and len(firstnode) == 0): error = state_machine.reporter.error( 'Figure caption must be a paragraph or empty comment.', '', nodes.literal_block(blocktext, blocktext), line=lineno) -- cgit v1.2.1 From 0c5fd85359f37a4c3d25c5df8dfd6e0c4702d692 Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 10 Sep 2002 03:31:21 +0000 Subject: Updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@660 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/parts.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py index bb7527d05..9a3e9e71c 100644 --- a/docutils/parsers/rst/directives/parts.py +++ b/docutils/parsers/rst/directives/parts.py @@ -14,27 +14,20 @@ __docformat__ = 'reStructuredText' from docutils import nodes from docutils.transforms import parts +from docutils.parsers.rst import directives -def unchanged(arg): - return arg # unchanged! +backlinks_values = ('top', 'entry', 'none') def backlinks(arg): - try: - value = arg.lower().strip() - except AttributeError: - raise TypeError('must supply an argument; choose from "top", ' - '"entry", or "none"') + value = directives.choice(arg, backlinks_values) if value == 'none': return None - elif value == 'top' or arg == 'entry': - return value else: - raise ValueError( - '"%s" unknown; choose from "top", "entry", or "none"' % arg) + return value contents_option_spec = {'depth': int, - 'local': unchanged, + 'local': directives.flag, 'backlinks': backlinks} #'qa': unchanged} -- cgit v1.2.1 From 6b549311b8e4d646cc2922743dd7544bee035b21 Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 10 Sep 2002 03:35:17 +0000 Subject: fix git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@661 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 3968d575e..9cdde6d31 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -127,8 +127,8 @@ def choice(argument, values): try: value = argument.lower().strip() except AttributeError: - raise TypeError('must supply an argument; choose from %s', - format_values(values)) + raise TypeError('must supply an argument; choose from %s' + % format_values(values)) if value in values: return value else: -- cgit v1.2.1 From a07bc663d7654004db7594bb1601525b18d46f4a Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 11 Sep 2002 02:52:01 +0000 Subject: Removed "field_argument" element & support; "field_name" may contain multiple words and whitespace. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@664 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index d66e52bbd..fa2d6260f 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1163,13 +1163,11 @@ class Body(RSTState): return [], next_state, [] def field(self, match): - name, args = self.parse_field_marker(match) + name = self.parse_field_marker(match) indented, indent, line_offset, blank_finish = \ self.state_machine.get_first_known_indented(match.end()) fieldnode = nodes.field() fieldnode += nodes.field_name(name, name) - for arg in args: - fieldnode += nodes.field_argument(arg, arg) fieldbody = nodes.field_body('\n'.join(indented)) fieldnode += fieldbody if indented: @@ -1178,11 +1176,10 @@ class Body(RSTState): return fieldnode, blank_finish def parse_field_marker(self, match): - """Extract & return name & argument list from a field marker match.""" + """Extract & return field name from a field marker match.""" field = match.string[1:] # strip off leading ':' field = field[:field.find(':')] # strip off trailing ':' etc. - tokens = field.split() - return tokens[0], tokens[1:] # first == name, others == args + return field def option_marker(self, match, context, next_state): """Option list item.""" -- cgit v1.2.1 From 2ba8fffc2b3bf0e74aedfd33533f10a54a5b77be Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 11 Sep 2002 02:54:23 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@665 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/html.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/html.py b/docutils/parsers/rst/directives/html.py index 0e7527592..732ef7b56 100644 --- a/docutils/parsers/rst/directives/html.py +++ b/docutils/parsers/rst/directives/html.py @@ -27,7 +27,8 @@ def meta(match, type_name, data, state, state_machine, option_presets): new_line_offset, blank_finish = state.nested_list_parse( block, offset, node, initial_state='MetaBody', blank_finish=blank_finish, state_machine_kwargs=metaSMkwargs) - if (new_line_offset - offset) != len(block): # incomplete parse of block? + if (new_line_offset - offset) != len(block): + # incomplete parse of block? blocktext = '\n'.join(state_machine.input_lines[ line_offset : state_machine.line_offset+1]) msg = state_machine.reporter.error( @@ -58,7 +59,7 @@ class MetaBody(states.SpecializedBody): return [], next_state, [] def parsemeta(self, match): - name, args = self.parse_field_marker(match) + name = self.parse_field_marker(match) indented, indent, line_offset, blank_finish = \ self.state_machine.get_first_known_indented(match.end()) node = self.meta() @@ -72,20 +73,21 @@ class MetaBody(states.SpecializedBody): nodes.literal_block(line, line), line=self.state_machine.abs_line_number()) return msg, blank_finish + tokens = name.split() try: - attname, val = utils.extract_name_value(name)[0] + attname, val = utils.extract_name_value(tokens[0])[0] node[attname.lower()] = val except utils.NameValueError: - node['name'] = name - for arg in args: + node['name'] = tokens[0] + for token in tokens[1:]: try: - attname, val = utils.extract_name_value(arg)[0] + attname, val = utils.extract_name_value(token)[0] node[attname.lower()] = val except utils.NameValueError, detail: line = self.state_machine.line msg = self.reporter.error( 'Error parsing meta tag attribute "%s": %s.' - % (arg, detail), '', nodes.literal_block(line, line), + % (token, detail), '', nodes.literal_block(line, line), line=self.state_machine.abs_line_number()) return msg, blank_finish self.document.note_pending(pending) -- cgit v1.2.1 From 0b774599f04c5ff6c27b3c271019a949500ea002 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 19 Sep 2002 00:41:42 +0000 Subject: Added support for short section title over/underlines. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@689 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 145 +++++++++++++++++++++++++++++------------ 1 file changed, 105 insertions(+), 40 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index fa2d6260f..fa940c49a 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1,10 +1,10 @@ -""" -:Author: David Goodger -:Contact: goodger@users.sourceforge.net -:Revision: $Revision$ -:Date: $Date$ -:Copyright: This module has been placed in the public domain. +# Author: David Goodger +# Contact: goodger@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. +""" This is the ``docutils.parsers.restructuredtext.states`` module, the core of the reStructuredText parser. It defines the following: @@ -217,9 +217,23 @@ class RSTState(StateWS): """ try: self.state_machine.goto_line(abs_line_offset) - except IndexError: + except EOFError: pass + def no_match(self, context, transitions): + """ + Override `StateWS.no_match` to generate a system message. + + This code should never be run. + """ + self.reporter.severe( + 'Internal error: no transition pattern match. State: "%s"; ' + 'transitions: %s; context: %s; current line: %r.' + % (self.__class__.__name__, transitions, context, + self.state_machine.line), + line=self.state_machine.abs_line_number()) + return context, None, [] + def bof(self, context): """Called at beginning of file.""" return [], [] @@ -950,7 +964,7 @@ class Body(RSTState): 'simple_table_top': simple_table_top_pat, 'explicit_markup': r'\.\.( +|$)', 'anonymous': r'__( +|$)', - 'line': r'(%(nonalphanum7bit)s)\1\1\1+ *$' % pats, + 'line': r'(%(nonalphanum7bit)s)\1* *$' % pats, 'text': r''} initial_transitions = ( 'bullet', @@ -1099,7 +1113,7 @@ class Body(RSTState): return None try: next_line = self.state_machine.next_line() - except IndexError: # end of input lines + except EOFError: # end of input lines self.state_machine.previous_line() return 1 else: @@ -1830,6 +1844,13 @@ class Body(RSTState): """Section title overline or transition marker.""" if self.state_machine.match_titles: return [match.string], 'Line', [] + elif len(match.string.strip()) < 4: + msg = self.reporter.info( + 'Unexpected possible title overline or transition.\n' + "Treating it as ordinary text because it's so short.", '', + line=self.state_machine.abs_line_number()) + self.parent += msg + raise statemachine.TransitionCorrection('text') else: blocktext = self.state_machine.line msg = self.reporter.severe( @@ -2127,11 +2148,19 @@ class Text(RSTState): source = title + '\n' + underline messages = [] if len(title) > len(underline): - blocktext = context[0] + '\n' + self.state_machine.line - msg = self.reporter.warning( - 'Title underline too short.', '', - nodes.literal_block(blocktext, blocktext), line=lineno) - messages.append(msg) + 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: + blocktext = context[0] + '\n' + self.state_machine.line + msg = self.reporter.warning( + 'Title underline too short.', '', + nodes.literal_block(blocktext, blocktext), line=lineno) + messages.append(msg) style = underline[0] context[:] = [] self.section(title, source, style, lineno - 1, messages) @@ -2153,7 +2182,7 @@ class Text(RSTState): if literalnext: try: self.state_machine.next_line() - except IndexError: + except EOFError: pass self.parent += self.literal_block() return [], next_state, [] @@ -2260,6 +2289,9 @@ class Line(SpecializedText): def eof(self, context): """Transition marker at end of section or document.""" + marker = context[0].strip() + if len(marker) < 4: + self.state_correction(context) if self.eofcheck: # ignore EOFError with sections transition = nodes.transition(context[0]) self.parent += transition @@ -2272,7 +2304,10 @@ class Line(SpecializedText): def blank(self, match, context, next_state): """Transition marker.""" - transition = nodes.transition(context[0]) + marker = context[0].strip() + if len(marker) < 4: + self.state_correction(context) + transition = nodes.transition(marker) if len(self.parent) == 0: msg = self.reporter.error( 'Document or section may not begin with a transition.', @@ -2295,35 +2330,50 @@ class Line(SpecializedText): underline = '' try: underline = self.state_machine.next_line() - except IndexError: + except EOFError: blocktext = overline + '\n' + title - msg = self.reporter.severe( - 'Incomplete section title.', '', - nodes.literal_block(blocktext, blocktext), line=lineno) - self.parent += msg - return [], 'Body', [] + if len(overline.rstrip()) < 4: + self.short_overline(context, blocktext, lineno, 2) + else: + msg = self.reporter.severe( + 'Incomplete section title.', '', + nodes.literal_block(blocktext, blocktext), line=lineno) + self.parent += msg + return [], 'Body', [] source = '%s\n%s\n%s' % (overline, title, underline) overline = overline.rstrip() underline = underline.rstrip() if not self.transitions['underline'][0].match(underline): - msg = self.reporter.severe( - 'Missing underline for overline.', '', - nodes.literal_block(source, source), line=lineno) - self.parent += msg - return [], 'Body', [] + blocktext = overline + '\n' + title + '\n' + underline + if len(overline.rstrip()) < 4: + self.short_overline(context, blocktext, lineno, 2) + else: + msg = self.reporter.severe( + 'Missing underline for overline.', '', + nodes.literal_block(source, source), line=lineno) + self.parent += msg + return [], 'Body', [] elif overline != underline: - msg = self.reporter.severe( - 'Title overline & underline mismatch.', '', - nodes.literal_block(source, source), line=lineno) - self.parent += msg - return [], 'Body', [] + blocktext = overline + '\n' + title + '\n' + underline + if len(overline.rstrip()) < 4: + self.short_overline(context, blocktext, lineno, 2) + else: + msg = self.reporter.severe( + 'Title overline & underline mismatch.', '', + nodes.literal_block(source, source), line=lineno) + self.parent += msg + return [], 'Body', [] title = title.rstrip() messages = [] if len(title) > len(overline): - msg = self.reporter.warning( - 'Title overline too short.', '', - nodes.literal_block(source, source), line=lineno) - messages.append(msg) + blocktext = overline + '\n' + title + '\n' + underline + if len(overline.rstrip()) < 4: + self.short_overline(context, blocktext, lineno, 2) + else: + msg = self.reporter.warning( + 'Title overline too short.', '', + nodes.literal_block(source, source), line=lineno) + messages.append(msg) style = (overline[0], underline[0]) self.eofcheck = 0 # @@@ not sure this is correct self.section(title.lstrip(), source, style, lineno + 1, messages) @@ -2332,15 +2382,30 @@ class Line(SpecializedText): indent = text # indented title - def underline(self, match=None, context=None, next_state=None): - blocktext = context[0] + '\n' + self.state_machine.line + def underline(self, match, context, next_state): + overline = context[0] + blocktext = overline + '\n' + self.state_machine.line + lineno = self.state_machine.abs_line_number() - 1 + if len(overline.rstrip()) < 4: + self.short_overline(context, blocktext, lineno, 1) msg = self.reporter.error( 'Invalid section title or transition marker.', '', - nodes.literal_block(blocktext, blocktext), - line=self.state_machine.abs_line_number() - 1) + nodes.literal_block(blocktext, blocktext), line=lineno) self.parent += msg return [], 'Body', [] + def short_overline(self, context, blocktext, lineno, lines=1): + msg = self.reporter.info( + 'Possible incomplete section title.\nTreating the overline as ' + "ordinary text because it's so short.", '', line=lineno) + self.parent += msg + self.state_correction(context, lines) + + def state_correction(self, context, lines=1): + self.state_machine.previous_line(lines) + context[:] = [] + raise statemachine.StateCorrection('Body', 'text') + state_classes = (Body, BulletList, DefinitionList, EnumeratedList, FieldList, OptionList, Explicit, Text, Definition, Line, -- cgit v1.2.1 From ca21c540669d234443c007298437b7fc60ebc678 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 19 Sep 2002 00:42:39 +0000 Subject: Fixed a bug that was producing unwanted empty rows in "simple" tables. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@690 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/tableparser.py | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/tableparser.py b/docutils/parsers/rst/tableparser.py index d304445c8..3ef7e7d68 100644 --- a/docutils/parsers/rst/tableparser.py +++ b/docutils/parsers/rst/tableparser.py @@ -1,10 +1,10 @@ -""" -:Author: David Goodger -:Contact: goodger@users.sourceforge.net -:Revision: $Revision$ -:Date: $Date$ -:Copyright: This module has been placed in the public domain. +# Author: David Goodger +# Contact: goodger@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. +""" This module defines table parser classes,which parse plaintext-graphic tables and produce a well-formed data structure suitable for building a CALS table. @@ -401,16 +401,16 @@ class SimpleTableParser(TableParser): offset += 1 if self.span_pat.match(line): # Column span underline or border; row is complete. - self.parse_row(rowlines, line) + self.parse_row(rowlines, (line.rstrip(), offset)) rowlines = [] elif line[firststart:firstend].strip(): # First column not blank, therefore it's a new row. if rowlines: self.parse_row(rowlines) - rowlines = [(line, offset)] + rowlines = [(line.rstrip(), offset)] else: # Accumulate lines of incomplete row. - rowlines.append((line, offset)) + rowlines.append((line.rstrip(), offset)) def parse_columns(self, line): """ @@ -458,10 +458,19 @@ class SimpleTableParser(TableParser): adjust for insigificant whitespace. """ if spanline: - columns = self.parse_columns(spanline) + columns = self.parse_columns(spanline[0]) else: columns = self.columns[:] - row = self.init_row(columns, lines[0][1]) + while lines and not lines[-1][0]: + lines.pop() # Remove blank trailing lines. + if lines: + offset = lines[0][1] + elif spanline: + offset = spanline[1] + else: + # No new row, just blank lines. + return + row = self.init_row(columns, offset) # "Infinite" value for a dummy last column's beginning, used to # check for text overflow: columns.append((sys.maxint, None)) -- cgit v1.2.1 From c2291595af5c117f10061fd9bf68fa0ff69d74fa Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 19 Sep 2002 00:51:03 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@695 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 663325ead..25e0a6467 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -1,14 +1,10 @@ -#! /usr/bin/env python +# Author: David Goodger +# Contact: goodger@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. -""" -:Author: David Goodger -:Contact: goodger@users.sourceforge.net -:Revision: $Revision$ -:Date: $Date$ -:Copyright: This module has been placed in the public domain. - -Miscellaneous directives. -""" +"""Miscellaneous directives.""" __docformat__ = 'reStructuredText' @@ -26,7 +22,7 @@ def directive_test_function(match, type_name, data, state, state_machine, state_machine.next_line() indented, indent, offset, blank_finish = state_machine.get_indented() text = '\n'.join(indented) - except IndexError: + except EOFError: text = '' blank_finish = 1 if text: -- cgit v1.2.1 From c42533ff80a5543fb3a207c102cf8655b9cb6ffc Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 20 Sep 2002 02:51:33 +0000 Subject: Fixed "simple reference name" regexp to ignore text like "object.__method__"; not an anonymous reference. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@700 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index fa940c49a..742aa94f2 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -488,7 +488,8 @@ class Inliner: non_whitespace_before = r'(? Date: Tue, 24 Sep 2002 02:12:46 +0000 Subject: Initial support for improved diagnostics. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@709 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 742aa94f2..4380b3864 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -156,6 +156,7 @@ class RSTStateMachine(StateMachineWS): section_level=0, inliner=inliner) self.document = self.memo.document + self.attach_observer(self.document.note_state_machine_change) self.reporter = self.memo.reporter self.node = document results = StateMachineWS.run(self, input_lines, input_offset) @@ -179,6 +180,7 @@ class NestedStateMachine(StateMachineWS): self.match_titles = match_titles self.memo = memo self.document = memo.document + self.attach_observer(self.document.note_state_machine_change) self.reporter = memo.reporter self.node = node results = StateMachineWS.run(self, input_lines, input_offset) -- cgit v1.2.1 From 6e26d36491f9f2c7ac4790d64ccf28d9a3de92b7 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 2 Oct 2002 03:13:24 +0000 Subject: Added ``path()`` and ``nonnegative_int()`` directive option helper functions. Updated docstring. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@742 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 140 ++++++++++++++++++++++------ 1 file changed, 110 insertions(+), 30 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 9cdde6d31..58175040f 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -1,39 +1,79 @@ -#! /usr/bin/env python +# Author: David Goodger +# Contact: goodger@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. """ -:Author: David Goodger -:Contact: goodger@users.sourceforge.net -:Revision: $Revision$ -:Date: $Date$ -:Copyright: This module has been placed in the public domain. - This package contains directive implementation modules. The interface for directive functions is as follows:: - def directivefn(match, type_name, data, state, state_machine, - option_presets): + def directive_fn(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + code... + + # Set function attributes: + directive_fn.arguments = ... + directive_fn.options = ... + direcitve_fn.content = ... + +Parameters: + +- ``name`` is the directive type or name. + +- ``arguments`` is a list of positional arguments. + +- ``options`` is a dictionary mapping option names to values. + +- ``content`` is a list of strings, the directive content. + +- ``lineno`` is the line number of the first line of the directive. -Where: +- ``content_offset`` is the line offset of the first line of the content from + the beginning of the current input. Used when initiating a nested parse. + +- ``block_text`` is a string containing the entire directive. Include it as + the content of a literal block in a system message if there is a problem. -- ``match`` is a regular expression match object which matched the first line - of the directive. ``match.group(1)`` gives the directive name. -- ``type_name`` is the directive type or name. -- ``data`` contains the remainder of the first line of the directive after the - "::". - ``state`` is the state which called the directive function. + - ``state_machine`` is the state machine which controls the state which called the directive function. -- ``option_presets`` is a dictionary of preset options which may be added to - the element the directive produces. Currently, only an "alt" option is - passed by substitution definitions (value: the substitution name), which may - be used by an embedded image directive. -Directive functions return a tuple of two values: +Function attributes, interpreted by the directive parser (which calls the +directive function): + +- ``arguments``: A 3-tuple specifying the expected positional arguments, or + ``None`` if the directive has no arguments. The 3 items in the tuple are + ``(required, optional, whitespace OK in last argument)``: + + 1. The number of required arguments. + 2. The number of optional arguments. + 3. A boolean, indicating if the final argument may contain whitespace. + + Arguments are normally single whitespace-separated words. The final + argument may contain whitespace if the third item in the argument spec tuple + is 1/True. If the form of the arguments is more complex, specify only one + argument (either required or optional) and indicate that final whitespace is + OK; the client code must do any context-sensitive parsing. + +- ``options``: A dictionary, mapping known option names to conversion + functions such as `int` or `float`. ``None`` or an empty dict implies no + options to parse. + +- ``content``: A boolean; true if content is allowed. Client code must handle + the case where content is required but not supplied (an empty content list + will be supplied). + +Directive functions return a list of nodes which will be inserted into the +document tree at the point where the directive was encountered (can be an +empty list). -- a list of nodes which will be inserted into the document tree at the point - where the directive was encountered (can be an empty list), and -- a boolean: true iff the directive block finished at a blank line. +See `Creating reStructuredText Directives`_ for more information. + +.. _Creating reStructuredText Directives: + http://docutils.sourceforge.net/spec/howto/rst-directives.html """ __docformat__ = 'reStructuredText' @@ -64,11 +104,13 @@ _directive_registry = { 'target-notes': ('references', 'target_notes'), 'meta': ('html', 'meta'), #'imagemap': ('html', 'imagemap'), - #'raw': ('misc', 'raw'), + 'raw': ('misc', 'raw'), + 'include': ('misc', 'include'), + 'replace': ('misc', 'replace'), 'restructuredtext-test-directive': ('misc', 'directive_test_function'),} -"""Mapping of directive name to (module name, function name). The directive -'name' is canonical & must be lowercase; language-dependent names are defined -in the language package.""" +"""Mapping of directive name to (module name, function name). The directive +name is canonical & must be lowercase. Language-dependent names are defined +in the ``language`` subpackage.""" _modules = {} """Cache of imported directive modules.""" @@ -111,13 +153,51 @@ def directive(directive_name, language_module): return function def flag(argument): + """ + Check for a valid flag option (no argument) and return ``None``. + + Raise ``ValueError`` if an argument is found. + """ if argument and argument.strip(): raise ValueError('no argument is allowed; "%s" supplied' % argument) else: return None def unchanged(argument): - return argument # unchanged! + """ + Return the argument, unchanged. + + Raise ``ValueError`` if no argument is found. + """ + if argument is None: + raise ValueError('argument required but none supplied') + else: + return argument # unchanged! + +def path(argument): + """ + Return the path argument unwrapped (with newlines removed). + + Raise ``ValueError`` if no argument is found or if the path contains + internal whitespace. + """ + if argument is None: + raise ValueError('argument required but none supplied') + else: + path = ''.join([s.strip() for s in argument.splitlines()]) + if path.find(' ') == -1: + return path + else: + raise ValueError('path contains whitespace') + +def nonnegative_int(argument): + """ + Check for a nonnegative integer argument; raise ``ValueError`` if not. + """ + value = int(argument) + if value < 0: + raise ValueError('negative value; must be positive or zero') + return value def format_values(values): return '%s, or "%s"' % (', '.join(['"%s"' % s for s in values[:-1]]), @@ -127,8 +207,8 @@ def choice(argument, values): try: value = argument.lower().strip() except AttributeError: - raise TypeError('must supply an argument; choose from %s' - % format_values(values)) + raise ValueError('must supply an argument; choose from %s' + % format_values(values)) if value in values: return value else: -- cgit v1.2.1 From a93ae74d425bb3a12c671949a57a92cc83ec6dce Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 2 Oct 2002 03:14:48 +0000 Subject: Added "include", "raw", and "replace" directives, courtesy of Dethe Elza. Updated all directive functions to new API, including better reporting. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@743 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 170 ++++++++++++++++++++++++++++---- 1 file changed, 150 insertions(+), 20 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 25e0a6467..484422bec 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -1,4 +1,4 @@ -# Author: David Goodger +# Authors: David Goodger, Dethe Elza # Contact: goodger@users.sourceforge.net # Revision: $Revision$ # Date: $Date$ @@ -8,30 +8,160 @@ __docformat__ = 'reStructuredText' +import sys +from urllib2 import urlopen, URLError +from docutils import nodes, statemachine +from docutils.parsers.rst import directives, states -from docutils import nodes +def include(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + """Include a reST file as part of the content of this reST file.""" + path = ''.join(arguments[0].splitlines()) + if path.find(' ') != -1: + error = state_machine.reporter.error( + '"%s" directive path contains whitespace.' % name, '', + nodes.literal_block(block_text, block_text), line=lineno) + return [error] + try: + include_file = open(path) + except IOError, error: + severe = state_machine.reporter.severe( + 'Problems with "%s" directive path:\n%s.' % (name, error), '', + nodes.literal_block(block_text, block_text), line=lineno) + return [severe] + include_text = include_file.read() + include_file.close() + if options.has_key('literal'): + literal_block = nodes.literal_block(include_text, include_text, + source=path) + literal_block.line = 1 + return literal_block + else: + include_lines = statemachine.string2lines(include_text, + convert_whitespace=1) + current_source = state.document.current_source + state.document.note_source(path) + state.memo.reporter.source = path + state.nested_parse(include_lines, 0, node=state_machine.node, + match_titles=state_machine.match_titles) + state.document.note_source(current_source) + state.memo.reporter.source = current_source + return [] -def raw(match, type_name, data, state, state_machine, option_presets): - return [], 1 +include.arguments = (1, 0, 1) +include.options = {'literal': directives.flag} -def directive_test_function(match, type_name, data, state, state_machine, - option_presets): - lineno = state_machine.abs_line_number() - try: - state_machine.next_line() - indented, indent, offset, blank_finish = state_machine.get_indented() - text = '\n'.join(indented) - except EOFError: - text = '' - blank_finish = 1 +def raw(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + """ + Pass through content unchanged + + Content is included in output based on type argument + + Content may be included inline (content section of directive) or + imported from a file or url. + """ + attributes = {'format': arguments[0]} + if content: + if options.has_key('file') or options.has_key('url'): + error = state_machine.reporter.error( + '"%s" directive may not both specify an external file and ' + 'have content.' % name, '', + nodes.literal_block(block_text, block_text), line=lineno) + return [error] + text = '\n'.join(content) + elif options.has_key('file'): + if options.has_key('url'): + error = state_machine.reporter.error( + 'The "file" and "url" options may not be simultaneously ' + 'specified for the "%s" directive.' % name, '', + nodes.literal_block(block_text, block_text), line=lineno) + return [error] + try: + raw_file = open(options['file']) + except IOError, error: + severe = state_machine.reporter.severe( + 'Problems with "%s" directive path:\n%s.' % (name, error), + '', nodes.literal_block(block_text, block_text), + line=lineno) + return [severe] + text = raw_file.read() + raw_file.close() + attributes['source'] = options['file'] + elif options.has_key('url'): + try: + raw_file = urlopen(options['url']) + except (URLError, IOError, OSError), error: + severe = state_machine.reporter.severe( + 'Problems with "%s" directive URL "%s":\n%s.' + % (name, options['url'], error), '', + nodes.literal_block(block_text, block_text), line=lineno) + return [severe] + text = raw_file.read() + raw_file.close() + attributes['source'] = options['file'] + else: + error = state_machine.reporter.warning( + 'The "%s" directive requires content; none supplied.' % (name), + '', nodes.literal_block(block_text, block_text), line=lineno) + return [error] + raw_node = nodes.raw('', text, **attributes) + return [raw_node] + +raw.arguments = (1, 0, 1) +raw.options = {'file': directives.path, + 'url': directives.path} +raw.content = 1 + +def replace(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + if not isinstance(state, states.SubstitutionDef): + error = state_machine.reporter.error( + 'Invalid context: the "%s" directive can only be used within a ' + 'substitution definition.' % (name), '', + nodes.literal_block(block_text, block_text), line=lineno) + return [error] + text = '\n'.join(content) + element = nodes.Element(text) if text: + state.nested_parse(content, content_offset, element) + if len(element) != 1 or not isinstance(element[0], nodes.paragraph): + messages = [] + for node in element: + if isinstance(node, nodes.system_message): + if node.has_key('backrefs'): + del node['backrefs'] + messages.append(node) + error = state_machine.reporter.error( + 'Error in "%s" directive: may contain a single paragraph ' + 'only.' % (name), line=lineno) + messages.append(error) + return messages + else: + return element[0].children + else: + error = state_machine.reporter.error( + 'The "%s" directive is empty; content required.' % (name), + line=lineno) + return [error] + +replace.content = 1 + +def directive_test_function(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + if content: + text = '\n'.join(content) info = state_machine.reporter.info( - 'Directive processed. Type="%s", data="%s", directive block:' - % (type_name, data), '', nodes.literal_block(text, text), - line=lineno) + 'Directive processed. Type="%s", arguments=%r, options=%r, ' + 'content:' % (name, arguments, options), '', + nodes.literal_block(text, text), line=lineno) else: info = state_machine.reporter.info( - 'Directive processed. Type="%s", data="%s", directive block: ' - 'None' % (type_name, data), line=lineno) - return [info], blank_finish + 'Directive processed. Type="%s", arguments=%r, options=%r, ' + 'content: None' % (name, arguments, options), line=lineno) + return [info] + +directive_test_function.arguments = (0, 1, 1) +directive_test_function.options = {'option': directives.unchanged} +directive_test_function.content = 1 -- cgit v1.2.1 From 7b12a12a016617200529e8b611ad2f2a866ad7f9 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 2 Oct 2002 03:17:43 +0000 Subject: Updated all directive functions to new API, including better reporting. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@744 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/admonitions.py | 83 ++++++++++------- docutils/parsers/rst/directives/body.py | 89 ++++++++---------- docutils/parsers/rst/directives/html.py | 55 ++++++----- docutils/parsers/rst/directives/images.py | 121 +++++++++---------------- docutils/parsers/rst/directives/parts.py | 87 +++++------------- docutils/parsers/rst/directives/references.py | 23 ++--- 6 files changed, 193 insertions(+), 265 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/admonitions.py b/docutils/parsers/rst/directives/admonitions.py index e1506610f..000dd4708 100644 --- a/docutils/parsers/rst/directives/admonitions.py +++ b/docutils/parsers/rst/directives/admonitions.py @@ -1,12 +1,10 @@ -#! /usr/bin/env python +# Author: David Goodger +# Contact: goodger@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. """ -:Author: David Goodger -:Contact: goodger@users.sourceforge.net -:Revision: $Revision$ -:Date: $Date$ -:Copyright: This module has been placed in the public domain. - Admonition directives. """ @@ -17,39 +15,60 @@ from docutils.parsers.rst import states from docutils import nodes -def admonition(node_class, match, type_name, data, state, state_machine, - option_presets): - indented, indent, line_offset, blank_finish \ - = state_machine.get_first_known_indented(match.end()) - text = '\n'.join(indented) +def admonition(node_class, name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + text = '\n'.join(content) admonition_node = node_class(text) if text: - state.nested_parse(indented, line_offset, admonition_node) - return [admonition_node], blank_finish + state.nested_parse(content, content_offset, admonition_node) + return [admonition_node] + else: + error = state_machine.reporter.error( + 'The "%s" admonition is empty; content required.' % (name), '', + nodes.literal_block(block_text, block_text), line=lineno) + return [error] + +def attention(*args): + return admonition(nodes.attention, *args) + +attention.content = 1 + +def caution(*args): + return admonition(nodes.caution, *args) + +caution.content = 1 + +def danger(*args): + return admonition(nodes.danger, *args) + +danger.content = 1 + +def error(*args): + return admonition(nodes.error, *args) + +error.content = 1 + +def important(*args): + return admonition(nodes.important, *args) -def attention(*args, **kwargs): - return admonition(nodes.attention, *args, **kwargs) +important.content = 1 -def caution(*args, **kwargs): - return admonition(nodes.caution, *args, **kwargs) +def note(*args): + return admonition(nodes.note, *args) -def danger(*args, **kwargs): - return admonition(nodes.danger, *args, **kwargs) +note.content = 1 -def error(*args, **kwargs): - return admonition(nodes.error, *args, **kwargs) +def tip(*args): + return admonition(nodes.tip, *args) -def important(*args, **kwargs): - return admonition(nodes.important, *args, **kwargs) +tip.content = 1 -def note(*args, **kwargs): - return admonition(nodes.note, *args, **kwargs) +def hint(*args): + return admonition(nodes.hint, *args) -def tip(*args, **kwargs): - return admonition(nodes.tip, *args, **kwargs) +hint.content = 1 -def hint(*args, **kwargs): - return admonition(nodes.hint, *args, **kwargs) +def warning(*args): + return admonition(nodes.warning, *args) -def warning(*args, **kwargs): - return admonition(nodes.warning, *args, **kwargs) +warning.content = 1 diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index 7d74e7a2b..55be7e36f 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -1,12 +1,10 @@ -#! /usr/bin/env python +# Author: David Goodger +# Contact: goodger@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. """ -:Author: David Goodger -:Contact: goodger@users.sourceforge.net -:Revision: $Revision$ -:Date: $Date$ -:Copyright: This module has been placed in the public domain. - Directives for additional body elements. """ @@ -17,57 +15,50 @@ import sys from docutils import nodes -def topic(match, type_name, data, state, state_machine, option_presets): - lineno = state_machine.abs_line_number() - initial_offset = state_machine.line_offset - indented, indent, line_offset, blank_finish \ - = state_machine.get_first_known_indented(match.end()) - blocktext = '\n'.join(state_machine.input_lines[ - initial_offset : line_offset + len(indented) - 1]) +def topic(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): if not state_machine.match_titles: error = state_machine.reporter.error( - 'Topics may not be nested within body elements.', '', - nodes.literal_block(blocktext, blocktext), line=lineno) - return [error], blank_finish - if not indented: - return [], blank_finish - title_text = indented.pop(0) + 'Topics may not be nested within topics or body elements.', '', + nodes.literal_block(block_text, block_text), line=lineno) + return [error] + if not content: + warning = state_machine.reporter.warning( + 'Content block expected for the "%s" directive; none found.' + % name, '', nodes.literal_block(block_text, block_text), + line=lineno) + return [warning] + title_text = arguments[0] textnodes, messages = state.inline_text(title_text, lineno) title = nodes.title(title_text, '', *textnodes) - if indented: - if indented[0].strip(): - warning = state_machine.reporter.warning( - 'The second line of a topic block must be blank.', - line=lineno + 1 + line_offset - initial_offset) - messages.append(warning) - text = '\n'.join(indented) - else: - text = '' + text = '\n'.join(content) topic_node = nodes.topic(text, title, *messages) if text: - state.nested_parse(indented, line_offset + 1, topic_node) - return [topic_node], blank_finish + state.nested_parse(content, content_offset, topic_node) + return [topic_node] +topic.arguments = (1, 0, 1) +topic.content = 1 -def line_block(match, type_name, data, state, state_machine, option_presets, +def line_block(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine, node_class=nodes.line_block): - lineno = state_machine.abs_line_number() - indented, indent, line_offset, blank_finish \ - = state_machine.get_first_known_indented(match.end()) - while indented and not indented[-1].strip(): - indented.pop() - if not indented: + if not content: warning = state_machine.reporter.warning( - 'Text block expected for the "%s" directive; none found.' - % type_name, line=lineno) - return [warning], blank_finish - text = '\n'.join(indented) - textnodes, messages = state.inline_text(text, lineno) - node = node_class(text, '', *textnodes) - return [node] + messages, blank_finish + 'Content block expected for the "%s" directive; none found.' + % name, nodes.literal_block(block_text, block_text), line=lineno) + return [warning] + text = '\n'.join(content) + text_nodes, messages = state.inline_text(text, lineno) + node = node_class(text, '', *text_nodes) + return [node] + messages + +line_block.content = 1 +def parsed_literal(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + return line_block(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine, + node_class=nodes.literal_block) -def parsed_literal(match, type_name, data, state, state_machine, - option_presets): - return line_block(match, type_name, data, state, state_machine, - option_presets, node_class=nodes.literal_block) +parsed_literal.content = 1 diff --git a/docutils/parsers/rst/directives/html.py b/docutils/parsers/rst/directives/html.py index 732ef7b56..560554d49 100644 --- a/docutils/parsers/rst/directives/html.py +++ b/docutils/parsers/rst/directives/html.py @@ -1,49 +1,46 @@ -#! /usr/bin/env python +# Author: David Goodger +# Contact: goodger@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. """ -:Author: David Goodger -:Contact: goodger@users.sourceforge.net -:Revision: $Revision$ -:Date: $Date$ -:Copyright: This module has been placed in the public domain. - Directives for typically HTML-specific constructs. """ __docformat__ = 'reStructuredText' - +import sys from docutils import nodes, utils from docutils.parsers.rst import states from docutils.transforms import components -def meta(match, type_name, data, state, state_machine, option_presets): - line_offset = state_machine.line_offset - block, indent, offset, blank_finish = \ - state_machine.get_first_known_indented(match.end(), until_blank=1) +def meta(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): node = nodes.Element() - if block: + if content: new_line_offset, blank_finish = state.nested_list_parse( - block, offset, node, initial_state='MetaBody', - blank_finish=blank_finish, state_machine_kwargs=metaSMkwargs) - if (new_line_offset - offset) != len(block): + content, content_offset, node, initial_state='MetaBody', + blank_finish=1, state_machine_kwargs=metaSMkwargs) + if (new_line_offset - content_offset) != len(content): # incomplete parse of block? - blocktext = '\n'.join(state_machine.input_lines[ - line_offset : state_machine.line_offset+1]) - msg = state_machine.reporter.error( - 'Invalid meta directive.', '', - nodes.literal_block(blocktext, blocktext), - line=state_machine.abs_line_number()) - node += msg + error = state_machine.reporter.error( + 'Invalid meta directive.', '', + nodes.literal_block(block_text, block_text), line=lineno) + node += error else: - msg = state_machine.reporter.error( - 'Empty meta directive.', line=state_machine.abs_line_number()) - node += msg - return node.get_children(), blank_finish + error = state_machine.reporter.error( + 'Empty meta directive.', '', + nodes.literal_block(block_text, block_text), line=lineno) + node += error + return node.get_children() + +meta.content = 1 -def imagemap(match, type_name, data, state, state_machine, option_presets): - return [], 0 +def imagemap(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + return [] class MetaBody(states.SpecializedBody): diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index bb997bc58..1617947ba 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -1,12 +1,10 @@ -#! /usr/bin/env python +# Author: David Goodger +# Contact: goodger@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. """ -:Author: David Goodger -:Contact: goodger@users.sourceforge.net -:Revision: $Revision$ -:Date: $Date$ -:Copyright: This module has been placed in the public domain. - Directives for figures and simple images. """ @@ -23,81 +21,50 @@ align_values = ('top', 'middle', 'bottom', 'left', 'center', 'right') def align(argument): return directives.choice(argument, align_values) -image_option_spec = {'alt': directives.unchanged, - 'height': int, - 'width': int, - 'scale': int, - 'align': align} - -def image(match, type_name, data, state, state_machine, option_presets): - lineno = state_machine.abs_line_number() - line_offset = state_machine.line_offset - datablock, indent, offset, blank_finish = \ - state_machine.get_first_known_indented(match.end(), until_blank=1) - blocktext = '\n'.join(state_machine.input_lines[ - line_offset : line_offset + len(datablock) + 1]) - for i in range(len(datablock)): - if datablock[i][:1] == ':': - attlines = datablock[i:] - datablock = datablock[:i] - break - else: - attlines = [] - if not datablock: - error = state_machine.reporter.error( - 'Missing image URI argument.', '', - nodes.literal_block(blocktext, blocktext), line=lineno) - return [error], blank_finish - attoffset = line_offset + i - reference = ''.join([line.strip() for line in datablock]) +def image(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + reference = ''.join(arguments[0].split('\n')) if reference.find(' ') != -1: error = state_machine.reporter.error( 'Image URI contains whitespace.', '', - nodes.literal_block(blocktext, blocktext), line=lineno) - return [error], blank_finish - if attlines: - success, data, blank_finish = state.parse_extension_options( - image_option_spec, attlines, blank_finish) - if success: # data is a dict of options - option_presets.update(data) - else: # data is an error string - error = state_machine.reporter.error( - 'Error in "%s" directive options:\n%s.' - % (match.group(1), data), '', - nodes.literal_block(blocktext, blocktext), line=lineno) - return [error], blank_finish - option_presets['uri'] = reference - imagenode = nodes.image(blocktext, **option_presets) - return [imagenode], blank_finish + nodes.literal_block(block_text, block_text), line=lineno) + return [error] + options['uri'] = reference + image_node = nodes.image(block_text, **options) + return [image_node] + +image.arguments = (1, 0, 1) +image.options = {'alt': directives.unchanged, + 'height': directives.nonnegative_int, + 'width': directives.nonnegative_int, + 'scale': directives.nonnegative_int, + 'align': align} -def figure(match, type_name, data, state, state_machine, option_presets): - lineno = state_machine.abs_line_number() - line_offset = state_machine.line_offset - (imagenode,), blank_finish = image(match, type_name, data, state, - state_machine, option_presets) - indented, indent, offset, blank_finish \ - = state_machine.get_first_known_indented(sys.maxint) - blocktext = '\n'.join(state_machine.input_lines[ - line_offset : state_machine.line_offset + 1]) - if isinstance(imagenode, nodes.system_message): - if indented: - imagenode[-1] = nodes.literal_block(blocktext, blocktext) - return [imagenode], blank_finish - figurenode = nodes.figure('', imagenode) - if indented: +def figure(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + (image_node,) = image(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine) + if isinstance(image_node, nodes.system_message): + return [image_node] + figure_node = nodes.figure('', image_node) + if content: node = nodes.Element() # anonymous container for parsing - state.nested_parse(indented, line_offset, node) - firstnode = node[0] - if isinstance(firstnode, nodes.paragraph): - caption = nodes.caption(firstnode.rawsource, '', - *firstnode.children) - figurenode += caption - elif not (isinstance(firstnode, nodes.comment) - and len(firstnode) == 0): + state.nested_parse(content, content_offset, node) + first_node = node[0] + if isinstance(first_node, nodes.paragraph): + caption = nodes.caption(first_node.rawsource, '', + *first_node.children) + figure_node += caption + elif not (isinstance(first_node, nodes.comment) + and len(first_node) == 0): error = state_machine.reporter.error( 'Figure caption must be a paragraph or empty comment.', '', - nodes.literal_block(blocktext, blocktext), line=lineno) - return [figurenode, error], blank_finish + nodes.literal_block(block_text, block_text), line=lineno) + return [figure_node, error] if len(node) > 1: - figurenode += nodes.legend('', *node[1:]) - return [figurenode], blank_finish + figure_node += nodes.legend('', *node[1:]) + return [figure_node] + +figure.arguments = (1, 0, 1) +figure.options = image.options +figure.content = 1 diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py index 9a3e9e71c..9512b835d 100644 --- a/docutils/parsers/rst/directives/parts.py +++ b/docutils/parsers/rst/directives/parts.py @@ -1,12 +1,10 @@ -#! /usr/bin/env python +# Author: David Goodger, Dmitry Jemerov +# Contact: goodger@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. """ -:Author: David Goodger, Dmitry Jemerov -:Contact: goodger@users.sourceforge.net -:Revision: $Revision$ -:Date: $Date$ -:Copyright: This module has been placed in the public domain. - Directives for document parts. """ @@ -26,70 +24,33 @@ def backlinks(arg): else: return value -contents_option_spec = {'depth': int, - 'local': directives.flag, - 'backlinks': backlinks} - #'qa': unchanged} - -def contents(match, type_name, data, state, state_machine, option_presets): +def contents(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): """Table of contents.""" - lineno = state_machine.abs_line_number() - line_offset = state_machine.line_offset - datablock, indent, offset, blank_finish = \ - state_machine.get_first_known_indented(match.end(), until_blank=1) - blocktext = '\n'.join(state_machine.input_lines[ - line_offset : line_offset + len(datablock) + 1]) - for i in range(len(datablock)): - if datablock[i][:1] == ':': - attlines = datablock[i:] - datablock = datablock[:i] - break - else: - attlines = [] - i = 0 - titletext = ' '.join([line.strip() for line in datablock]) - if titletext: - textnodes, messages = state.inline_text(titletext, lineno) - title = nodes.title(titletext, '', *textnodes) + if arguments: + title_text = arguments[0] + text_nodes, messages = state.inline_text(title_text, lineno) + title = nodes.title(title_text, '', *text_nodes) else: messages = [] title = None pending = nodes.pending(parts.Contents, 'first writer', {'title': title}, - blocktext) - if attlines: - success, data, blank_finish = state.parse_extension_options( - contents_option_spec, attlines, blank_finish) - if success: # data is a dict of options - pending.details.update(data) - else: # data is an error string - error = state_machine.reporter.error( - 'Error in "%s" directive options:\n%s.' - % (match.group(1), data), '', - nodes.literal_block(blocktext, blocktext), line=lineno) - return [error] + messages, blank_finish + block_text) + pending.details.update(options) state_machine.document.note_pending(pending) - return [pending] + messages, blank_finish + return [pending] + messages -sectnum_option_spec = {'depth': int} +contents.arguments = (0, 1, 1) +contents.options = {'depth': directives.nonnegative_int, + 'local': directives.flag, + 'backlinks': backlinks} -def sectnum(match, type_name, data, state, state_machine, option_presets): +def sectnum(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): """Automatic section numbering.""" - lineno = state_machine.abs_line_number() - line_offset = state_machine.line_offset - datablock, indent, offset, blank_finish = \ - state_machine.get_first_known_indented(match.end(), until_blank=1) pending = nodes.pending(parts.SectNum, 'last reader', {}) - success, data, blank_finish = state.parse_extension_options( - sectnum_option_spec, datablock, blank_finish) - if success: # data is a dict of options - pending.details.update(data) - else: # data is an error string - blocktext = '\n'.join(state_machine.input_lines[ - line_offset : line_offset + len(datablock) + 1]) - error = state_machine.reporter.error( - 'Error in "%s" directive options:\n%s.' - % (match.group(1), data), '', - nodes.literal_block(blocktext, blocktext), line=lineno) - return [error], blank_finish + pending.details.update(options) state_machine.document.note_pending(pending) - return [pending], blank_finish + return [pending] + +sectnum.options = {'depth': int} diff --git a/docutils/parsers/rst/directives/references.py b/docutils/parsers/rst/directives/references.py index 0a8b2afd0..815bc1477 100644 --- a/docutils/parsers/rst/directives/references.py +++ b/docutils/parsers/rst/directives/references.py @@ -1,12 +1,10 @@ -#! /usr/bin/env python +# Author: David Goodger, Dmitry Jemerov +# Contact: goodger@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. """ -:Author: David Goodger, Dmitry Jemerov -:Contact: goodger@users.sourceforge.net -:Revision: $Revision$ -:Date: $Date$ -:Copyright: This module has been placed in the public domain. - Directives for references and targets. """ @@ -16,15 +14,10 @@ from docutils import nodes from docutils.transforms import references -def target_notes(match, type_name, data, state, state_machine, - option_presets): +def target_notes(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): """Target footnote generation.""" pending = nodes.pending(references.TargetNotes, 'first reader', {}) state_machine.document.note_pending(pending) nodelist = [pending] - if data: - warning = state_machine.reporter.warning( - 'The "%s" directive takes no data; "%s" ignored.' - % (match.group(1), data), line=state_machine.abs_line_number()) - nodelist.append(warning) - return nodelist, state_machine.is_next_line_blank() + return nodelist -- cgit v1.2.1 From 9d50fb6eee483d2125cc5ca65c4b23ff6d51ff0a Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 2 Oct 2002 03:18:24 +0000 Subject: Reworked directive API. Added ``Body.parse_directive()``, ``.parse_directive_options()``, ``.parse_directive_arguments()`` methods. Added ``ExtensionOptions`` class, to parse directive options without parsing field bodies. Factored ``Body.parse_field_body()`` out of ``Body.field()``, overridden in ``ExtensionOptions``. Generalized some state transition return values (``next_state``). git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@745 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 203 ++++++++++++++++++++++++++++++++++------- 1 file changed, 170 insertions(+), 33 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 4380b3864..35d08ca7c 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -21,6 +21,7 @@ the reStructuredText parser. It defines the following: - `FieldList`: Second+ fields. - `OptionList`: Second+ option_list_items. - `RFC2822List`: Second+ RFC2822-style fields. + - `ExtensionOptions`: Parses directive option fields. - `Explicit`: Second+ explicit markup constructs. - `SubstitutionDef`: For embedded directives in substitution definitions. - `Text`: Classifier of second line of a text block. @@ -1188,8 +1189,7 @@ class Body(RSTState): fieldbody = nodes.field_body('\n'.join(indented)) fieldnode += fieldbody if indented: - self.nested_parse(indented, input_offset=line_offset, - node=fieldbody) + self.parse_field_body(indented, line_offset, fieldbody) return fieldnode, blank_finish def parse_field_marker(self, match): @@ -1198,6 +1198,9 @@ class Body(RSTState): field = field[:field.find(':')] # strip off trailing ':' etc. return field + def parse_field_body(self, indented, offset, node): + self.nested_parse(indented, input_offset=offset, node=node) + def option_marker(self, match, context, next_state): """Option list item.""" optionlist = nodes.option_list() @@ -1660,26 +1663,129 @@ class Body(RSTState): def directive(self, match, **option_presets): type_name = match.group(1) - directivefunction = directives.directive(type_name, - self.memo.language) - data = match.string[match.end():].strip() - if directivefunction: - return directivefunction(match, type_name, data, self, - self.state_machine, option_presets) + directive_function = directives.directive(type_name, + self.memo.language) + if directive_function: + return self.parse_directive( + directive_function, match, type_name, option_presets) else: - return self.unknown_directive(type_name, data) + return self.unknown_directive(type_name) + + def parse_directive(self, directive_fn, match, type_name, option_presets): + """ + Parse a directive then run its directive function. + + Parameters: + + - `directive_fn`: The function implementing the directive. Must have + function attributes ``arguments``, ``options``, and ``content``. - def unknown_directive(self, type_name, data): + - `match`: A regular expression match object which matched the first + line of the directive. + + - `type_name`: The directive name, as used in the source text. + + - `option_presets`: A dictionary of preset options, defaults for the + directive options. Currently, only an "alt" option is passed by + substitution definitions (value: the substitution name), which may + be used by an embedded image directive. + + Returns a 2-tuple: list of nodes, and a "blank finish" boolean. + """ + arguments = [] + options = {} + content = [] + argument_spec = option_spec = content_spec = None + if hasattr(directive_fn, 'arguments'): + argument_spec = directive_fn.arguments + if argument_spec[:2] == (0, 0): + argument_spec = None + if hasattr(directive_fn, 'options'): + option_spec = directive_fn.options + if hasattr(directive_fn, 'content'): + content_spec = directive_fn.content lineno = self.state_machine.abs_line_number() - indented, indent, offset, blank_finish = \ - self.state_machine.get_first_known_indented(0, strip_indent=0) - text = '\n'.join(indented) - error = self.reporter.error( - 'Unknown directive type "%s".' % type_name, '', - nodes.literal_block(text, text), line=lineno) - return [error], blank_finish + initial_line_offset = self.state_machine.line_offset + indented, indent, line_offset, blank_finish \ + = self.state_machine.get_first_known_indented(match.end(), + strip_top=0) + block_text = '\n'.join(self.state_machine.input_lines[ + initial_line_offset : self.state_machine.line_offset + 1]) + if indented and not indented[0].strip(): + indented.pop(0) + line_offset += 1 + while indented and not indented[-1].strip(): + indented.pop() + if indented and (argument_spec or option_spec): + for i in range(len(indented)): + if not indented[i].strip(): + break + else: + i += 1 + arg_block = indented[:i] + content = indented[i+1:] + content_offset = line_offset + i + 1 + else: + content = indented + content_offset = line_offset + arg_block = [] + while content and not content[0].strip(): + content.pop(0) + content_offset += 1 + try: + if option_spec: + options, arg_block = self.parse_directive_options( + option_presets, option_spec, arg_block) + if argument_spec: + arguments = self.parse_directive_arguments(argument_spec, + arg_block) + if content and not content_spec: + raise MarkupError('no content permitted.') + except MarkupError, detail: + error = self.reporter.error( + 'Error in "%s" directive:\n%s.' % (type_name, detail), '', + nodes.literal_block(block_text, block_text), line=lineno) + return [error], blank_finish + result = directive_fn( + type_name, arguments, options, content, lineno, content_offset, + block_text, self, self.state_machine) + return result, blank_finish + + def parse_directive_options(self, option_presets, option_spec, arg_block): + options = option_presets.copy() + for i in range(len(arg_block)): + if arg_block[i][:1] == ':': + opt_block = arg_block[i:] + arg_block = arg_block[:i] + break + else: + opt_block = [] + if opt_block: + success, data = self.parse_extension_options(option_spec, + opt_block) + if success: # data is a dict of options + options.update(data) + else: # data is an error string + raise MarkupError(data) + return options, arg_block + + def parse_directive_arguments(self, argument_spec, arg_block): + required, optional, last_whitespace = argument_spec + arg_text = '\n'.join(arg_block) + arguments = arg_text.split() + if len(arguments) < required: + raise MarkupError('%s argument(s) required, %s supplied' + % (required, len(arguments))) + elif len(arguments) > required + optional: + if last_whitespace: + arguments = arg_text.split(None, required + optional - 1) + else: + raise MarkupError( + 'maximum %s argument(s) allowed, %s supplied' + % (required + optional, len(arguments))) + return arguments - def parse_extension_options(self, option_spec, datalines, blank_finish): + def parse_extension_options(self, option_spec, datalines): """ Parse `datalines` for a field list containing extension options matching `option_spec`. @@ -1688,28 +1794,39 @@ class Body(RSTState): - `option_spec`: a mapping of option name to conversion function, which should raise an exception on bad input. - `datalines`: a list of input strings. - - `blank_finish`: :Return: - Success value, 1 or 0. - An option dictionary on success, an error string on failure. - - Updated `blank_finish` flag. """ node = nodes.field_list() newline_offset, blank_finish = self.nested_list_parse( - datalines, 0, node, initial_state='FieldList', - blank_finish=blank_finish) + datalines, 0, node, initial_state='ExtensionOptions', + blank_finish=1) if newline_offset != len(datalines): # incomplete parse of block - return 0, 'invalid option block', blank_finish + return 0, 'invalid option block' try: options = utils.extract_extension_options(node, option_spec) except KeyError, detail: - return 0, ('unknown option: "%s"' % detail), blank_finish + return 0, ('unknown option: "%s"' % detail) except (ValueError, TypeError), detail: - return 0, ('invalid option value: %s' % detail), blank_finish + return 0, ('invalid option value: %s' % detail) except utils.ExtensionOptionError, detail: - return 0, ('invalid option data: %s' % detail), blank_finish - return 1, options, blank_finish + return 0, ('invalid option data: %s' % detail) + if blank_finish: + return 1, options + else: + return 0, 'option data incompletely parsed' + + def unknown_directive(self, type_name): + lineno = self.state_machine.abs_line_number() + indented, indent, offset, blank_finish = \ + self.state_machine.get_first_known_indented(0, strip_indent=0) + text = '\n'.join(indented) + error = self.reporter.error( + 'Unknown directive type "%s".' % type_name, '', + nodes.literal_block(text, text), line=lineno) + return [error], blank_finish def comment(self, match): if not match.string[match.end():].strip() \ @@ -1968,7 +2085,7 @@ class BulletList(SpecializedBody): listitem, blank_finish = self.list_item(match.end()) self.parent += listitem self.blank_finish = blank_finish - return [], 'BulletList', [] + return [], next_state, [] class DefinitionList(SpecializedBody): @@ -1998,7 +2115,7 @@ class EnumeratedList(SpecializedBody): self.parent += listitem self.blank_finish = blank_finish self.lastordinal = ordinal - return [], 'EnumeratedList', [] + return [], next_state, [] class FieldList(SpecializedBody): @@ -2010,7 +2127,7 @@ class FieldList(SpecializedBody): field, blank_finish = self.field(match) self.parent += field self.blank_finish = blank_finish - return [], 'FieldList', [] + return [], next_state, [] class OptionList(SpecializedBody): @@ -2025,7 +2142,7 @@ class OptionList(SpecializedBody): self.invalid_input() self.parent += option_list_item self.blank_finish = blank_finish - return [], 'OptionList', [] + return [], next_state, [] class RFC2822List(SpecializedBody, RFC2822Body): @@ -2045,6 +2162,26 @@ class RFC2822List(SpecializedBody, RFC2822Body): blank = SpecializedBody.invalid_input +class ExtensionOptions(FieldList): + + """ + Parse field_list fields for extension options. + + No nested parsing is done (including inline markup parsing). + """ + + def parse_field_body(self, indented, offset, node): + """Override `Body.parse_field_body` for simpler parsing.""" + lines = [] + for line in indented + ['']: + if line.strip(): + lines.append(line) + elif lines: + text = '\n'.join(lines) + node += nodes.paragraph(text, text) + lines = [] + + class Explicit(SpecializedBody): """Second and subsequent explicit markup construct.""" @@ -2411,8 +2548,8 @@ class Line(SpecializedText): state_classes = (Body, BulletList, DefinitionList, EnumeratedList, FieldList, - OptionList, Explicit, Text, Definition, Line, - SubstitutionDef, RFC2822Body, RFC2822List) + OptionList, ExtensionOptions, Explicit, Text, Definition, + Line, SubstitutionDef, RFC2822Body, RFC2822List) """Standard set of State classes used to start `RSTStateMachine`.""" -- cgit v1.2.1 From ed28012e60a40b2a0774a987d0d25240e2f592a8 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 3 Oct 2002 22:21:58 +0000 Subject: Improved definition list term/classifier parsing. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@761 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 35d08ca7c..bc19f07ab 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -882,7 +882,7 @@ class Inliner: self.implicit_inline(text[match.end():], lineno)) except MarkupMismatch: pass - return [nodes.Text(unescape(text))] + return [nodes.Text(unescape(text), rawsource=unescape(text, 1))] dispatch = {'*': emphasis, '**': strong, @@ -2365,17 +2365,24 @@ class Text(RSTState): def term(self, lines, lineno): """Return a definition_list's term and optional classifier.""" assert len(lines) == 1 - nodelist = [] - parts = lines[0].split(' : ', 1) # split into 1 or 2 parts - termpart = parts[0].rstrip() - textnodes, messages = self.inline_text(termpart, lineno) - nodelist = [nodes.term(termpart, '', *textnodes)] - if len(parts) == 2: - classifierpart = parts[1].lstrip() - textnodes, cpmessages = self.inline_text(classifierpart, lineno) - nodelist.append(nodes.classifier(classifierpart, '', *textnodes)) - messages += cpmessages - return nodelist, messages + text_nodes, messages = self.inline_text(lines[0], lineno) + term_node = nodes.term() + node_list = [term_node] + for i in range(len(text_nodes)): + node = text_nodes[i] + if isinstance(node, nodes.Text): + parts = node.rawsource.split(' : ', 1) + if len(parts) == 1: + term_node += node + else: + term_node += nodes.Text(parts[0].rstrip()) + classifier_node = nodes.classifier('', parts[1]) + classifier_node += text_nodes[i+1:] + node_list.append(classifier_node) + break + else: + term_node += node + return node_list, messages class SpecializedText(Text): -- cgit v1.2.1 From 3b4c2985f3efb3e92507e3067995f7a313bee040 Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 8 Oct 2002 01:25:17 +0000 Subject: Updated (Reporter API). git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@769 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/admonitions.py | 2 +- docutils/parsers/rst/directives/body.py | 4 ++-- docutils/parsers/rst/directives/html.py | 8 ++++---- docutils/parsers/rst/directives/images.py | 4 ++-- docutils/parsers/rst/directives/misc.py | 19 +++++++++---------- 5 files changed, 18 insertions(+), 19 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/admonitions.py b/docutils/parsers/rst/directives/admonitions.py index 000dd4708..7a349ad75 100644 --- a/docutils/parsers/rst/directives/admonitions.py +++ b/docutils/parsers/rst/directives/admonitions.py @@ -24,7 +24,7 @@ def admonition(node_class, name, arguments, options, content, lineno, return [admonition_node] else: error = state_machine.reporter.error( - 'The "%s" admonition is empty; content required.' % (name), '', + 'The "%s" admonition is empty; content required.' % (name), nodes.literal_block(block_text, block_text), line=lineno) return [error] diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index 55be7e36f..8bc2d7a4f 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -19,13 +19,13 @@ def topic(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): if not state_machine.match_titles: error = state_machine.reporter.error( - 'Topics may not be nested within topics or body elements.', '', + 'Topics may not be nested within topics or body elements.', nodes.literal_block(block_text, block_text), line=lineno) return [error] if not content: warning = state_machine.reporter.warning( 'Content block expected for the "%s" directive; none found.' - % name, '', nodes.literal_block(block_text, block_text), + % name, nodes.literal_block(block_text, block_text), line=lineno) return [warning] title_text = arguments[0] diff --git a/docutils/parsers/rst/directives/html.py b/docutils/parsers/rst/directives/html.py index 560554d49..88675c284 100644 --- a/docutils/parsers/rst/directives/html.py +++ b/docutils/parsers/rst/directives/html.py @@ -26,12 +26,12 @@ def meta(name, arguments, options, content, lineno, if (new_line_offset - content_offset) != len(content): # incomplete parse of block? error = state_machine.reporter.error( - 'Invalid meta directive.', '', + 'Invalid meta directive.', nodes.literal_block(block_text, block_text), line=lineno) node += error else: error = state_machine.reporter.error( - 'Empty meta directive.', '', + 'Empty meta directive.', nodes.literal_block(block_text, block_text), line=lineno) node += error return node.get_children() @@ -66,7 +66,7 @@ class MetaBody(states.SpecializedBody): if not indented: line = self.state_machine.line msg = self.reporter.info( - 'No content for meta tag "%s".' % name, '', + 'No content for meta tag "%s".' % name, nodes.literal_block(line, line), line=self.state_machine.abs_line_number()) return msg, blank_finish @@ -84,7 +84,7 @@ class MetaBody(states.SpecializedBody): line = self.state_machine.line msg = self.reporter.error( 'Error parsing meta tag attribute "%s": %s.' - % (token, detail), '', nodes.literal_block(line, line), + % (token, detail), nodes.literal_block(line, line), line=self.state_machine.abs_line_number()) return msg, blank_finish self.document.note_pending(pending) diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index 1617947ba..8509bf7fc 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -26,7 +26,7 @@ def image(name, arguments, options, content, lineno, reference = ''.join(arguments[0].split('\n')) if reference.find(' ') != -1: error = state_machine.reporter.error( - 'Image URI contains whitespace.', '', + 'Image URI contains whitespace.', nodes.literal_block(block_text, block_text), line=lineno) return [error] options['uri'] = reference @@ -58,7 +58,7 @@ def figure(name, arguments, options, content, lineno, elif not (isinstance(first_node, nodes.comment) and len(first_node) == 0): error = state_machine.reporter.error( - 'Figure caption must be a paragraph or empty comment.', '', + 'Figure caption must be a paragraph or empty comment.', nodes.literal_block(block_text, block_text), line=lineno) return [figure_node, error] if len(node) > 1: diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 484422bec..58af1336f 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -20,14 +20,14 @@ def include(name, arguments, options, content, lineno, path = ''.join(arguments[0].splitlines()) if path.find(' ') != -1: error = state_machine.reporter.error( - '"%s" directive path contains whitespace.' % name, '', + '"%s" directive path contains whitespace.' % name, nodes.literal_block(block_text, block_text), line=lineno) return [error] try: include_file = open(path) except IOError, error: severe = state_machine.reporter.severe( - 'Problems with "%s" directive path:\n%s.' % (name, error), '', + 'Problems with "%s" directive path:\n%s.' % (name, error), nodes.literal_block(block_text, block_text), line=lineno) return [severe] include_text = include_file.read() @@ -67,7 +67,7 @@ def raw(name, arguments, options, content, lineno, if options.has_key('file') or options.has_key('url'): error = state_machine.reporter.error( '"%s" directive may not both specify an external file and ' - 'have content.' % name, '', + 'have content.' % name, nodes.literal_block(block_text, block_text), line=lineno) return [error] text = '\n'.join(content) @@ -75,7 +75,7 @@ def raw(name, arguments, options, content, lineno, if options.has_key('url'): error = state_machine.reporter.error( 'The "file" and "url" options may not be simultaneously ' - 'specified for the "%s" directive.' % name, '', + 'specified for the "%s" directive.' % name, nodes.literal_block(block_text, block_text), line=lineno) return [error] try: @@ -83,8 +83,7 @@ def raw(name, arguments, options, content, lineno, except IOError, error: severe = state_machine.reporter.severe( 'Problems with "%s" directive path:\n%s.' % (name, error), - '', nodes.literal_block(block_text, block_text), - line=lineno) + nodes.literal_block(block_text, block_text), line=lineno) return [severe] text = raw_file.read() raw_file.close() @@ -95,7 +94,7 @@ def raw(name, arguments, options, content, lineno, except (URLError, IOError, OSError), error: severe = state_machine.reporter.severe( 'Problems with "%s" directive URL "%s":\n%s.' - % (name, options['url'], error), '', + % (name, options['url'], error), nodes.literal_block(block_text, block_text), line=lineno) return [severe] text = raw_file.read() @@ -104,7 +103,7 @@ def raw(name, arguments, options, content, lineno, else: error = state_machine.reporter.warning( 'The "%s" directive requires content; none supplied.' % (name), - '', nodes.literal_block(block_text, block_text), line=lineno) + nodes.literal_block(block_text, block_text), line=lineno) return [error] raw_node = nodes.raw('', text, **attributes) return [raw_node] @@ -119,7 +118,7 @@ def replace(name, arguments, options, content, lineno, if not isinstance(state, states.SubstitutionDef): error = state_machine.reporter.error( 'Invalid context: the "%s" directive can only be used within a ' - 'substitution definition.' % (name), '', + 'substitution definition.' % (name), nodes.literal_block(block_text, block_text), line=lineno) return [error] text = '\n'.join(content) @@ -154,7 +153,7 @@ def directive_test_function(name, arguments, options, content, lineno, text = '\n'.join(content) info = state_machine.reporter.info( 'Directive processed. Type="%s", arguments=%r, options=%r, ' - 'content:' % (name, arguments, options), '', + 'content:' % (name, arguments, options), nodes.literal_block(text, text), line=lineno) else: info = state_machine.reporter.info( -- cgit v1.2.1 From 9f5cd7076855bb066a91602e60862435a4c63b40 Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 8 Oct 2002 01:25:40 +0000 Subject: Updated for improved diagnostics & Reporter API. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@770 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 75 ++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 35 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index bc19f07ab..f64eb3f5f 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -333,9 +333,9 @@ class RSTState(StateWS): return None def title_inconsistent(self, sourcetext, lineno): - literalblock = nodes.literal_block('', sourcetext) - error = self.reporter.severe('Title level inconsistent:', '', - literalblock, line=lineno) + error = self.reporter.severe( + 'Title level inconsistent:', nodes.literal_block('', sourcetext), + line=lineno) return error def new_subsection(self, title, lineno, messages): @@ -382,6 +382,7 @@ class RSTState(StateWS): literalnext = 0 textnodes, messages = self.inline_text(text, lineno) p = nodes.paragraph(data, '', *textnodes) + p.line = lineno return [p] + messages, literalnext def inline_text(self, text, lineno): @@ -1182,9 +1183,11 @@ class Body(RSTState): def field(self, match): name = self.parse_field_marker(match) + lineno = self.state_machine.abs_line_number() indented, indent, line_offset, blank_finish = \ self.state_machine.get_first_known_indented(match.end()) fieldnode = nodes.field() + fieldnode.line = lineno fieldnode += nodes.field_name(name, name) fieldbody = nodes.field_body('\n'.join(indented)) fieldnode += fieldbody @@ -1404,8 +1407,7 @@ class Body(RSTState): lineno = self.state_machine.abs_line_number() - len(block) + 1 if detail: message += '\n' + detail - error = self.reporter.error(message, '', - nodes.literal_block(data, data), + error = self.reporter.error(message, nodes.literal_block(data, data), line=lineno) return [error] @@ -1491,11 +1493,13 @@ class Body(RSTState): """ % vars(Inliner), re.VERBOSE),) def footnote(self, match): + lineno = self.state_machine.abs_line_number() indented, indent, offset, blank_finish = \ self.state_machine.get_first_known_indented(match.end()) label = match.group(1) name = normalize_name(label) footnote = nodes.footnote('\n'.join(indented)) + footnote.line = lineno if name[0] == '#': # auto-numbered name = name[1:] # autonumber label footnote['auto'] = 1 @@ -1513,17 +1517,19 @@ class Body(RSTState): if name: self.document.note_explicit_target(footnote, footnote) else: - self.document.set_id(footnote) + self.document.set_id(footnote, footnote) if indented: self.nested_parse(indented, input_offset=offset, node=footnote) return [footnote], blank_finish def citation(self, match): + lineno = self.state_machine.abs_line_number() indented, indent, offset, blank_finish = \ self.state_machine.get_first_known_indented(match.end()) label = match.group(1) name = normalize_name(label) citation = nodes.citation('\n'.join(indented)) + citation.line = lineno citation += nodes.label('', label) citation['name'] = name self.document.note_citation(citation) @@ -1558,6 +1564,7 @@ class Body(RSTState): refname = self.is_reference(reference) if refname: target = nodes.target(blocktext, '', refname=refname) + target.line = lineno self.add_target(targetmatch.group('name'), '', target) self.document.note_indirect_target(target) return [target], blank_finish @@ -1566,12 +1573,13 @@ class Body(RSTState): if reference.find(' ') != -1: warning = self.reporter.warning( 'Hyperlink target contains whitespace. Perhaps a footnote ' - 'was intended?', '', + 'was intended?', nodes.literal_block(blocktext, blocktext), line=lineno) nodelist.append(warning) else: unescaped = unescape(reference) target = nodes.target(blocktext, '') + target.line = lineno self.add_target(targetmatch.group('name'), unescaped, target) nodelist.append(target) return nodelist, blank_finish @@ -1628,6 +1636,7 @@ class Body(RSTState): name = normalize_name(subname) substitutionnode = nodes.substitution_definition( blocktext, name=name, alt=subname) + substitutionnode.line = lineno if block: block[0] = block[0].strip() newabsoffset, blank_finish = self.nested_list_parse( @@ -1646,7 +1655,7 @@ class Body(RSTState): if len(substitutionnode) == 0: msg = self.reporter.warning( 'Substitution definition "%s" empty or invalid.' - % subname, '', + % subname, nodes.literal_block(blocktext, blocktext), line=lineno) self.parent += msg else: @@ -1657,7 +1666,7 @@ class Body(RSTState): else: msg = self.reporter.warning( 'Substitution definition "%s" missing contents.' % subname, - '', nodes.literal_block(blocktext, blocktext), line=lineno) + nodes.literal_block(blocktext, blocktext), line=lineno) self.parent += msg return [], blank_finish @@ -1674,7 +1683,7 @@ class Body(RSTState): def parse_directive(self, directive_fn, match, type_name, option_presets): """ Parse a directive then run its directive function. - + Parameters: - `directive_fn`: The function implementing the directive. Must have @@ -1689,21 +1698,17 @@ class Body(RSTState): directive options. Currently, only an "alt" option is passed by substitution definitions (value: the substitution name), which may be used by an embedded image directive. - + Returns a 2-tuple: list of nodes, and a "blank finish" boolean. """ arguments = [] options = {} content = [] - argument_spec = option_spec = content_spec = None - if hasattr(directive_fn, 'arguments'): - argument_spec = directive_fn.arguments - if argument_spec[:2] == (0, 0): - argument_spec = None - if hasattr(directive_fn, 'options'): - option_spec = directive_fn.options - if hasattr(directive_fn, 'content'): - content_spec = directive_fn.content + argument_spec = getattr(directive_fn, 'arguments', None) + if argument_spec and argument_spec[:2] == (0, 0): + argument_spec = None + option_spec = getattr(directive_fn, 'options', None) + content_spec = getattr(directive_fn, 'content', None) lineno = self.state_machine.abs_line_number() initial_line_offset = self.state_machine.line_offset indented, indent, line_offset, blank_finish \ @@ -1743,7 +1748,7 @@ class Body(RSTState): raise MarkupError('no content permitted.') except MarkupError, detail: error = self.reporter.error( - 'Error in "%s" directive:\n%s.' % (type_name, detail), '', + 'Error in "%s" directive:\n%s.' % (type_name, detail), nodes.literal_block(block_text, block_text), line=lineno) return [error], blank_finish result = directive_fn( @@ -1824,7 +1829,7 @@ class Body(RSTState): self.state_machine.get_first_known_indented(0, strip_indent=0) text = '\n'.join(indented) error = self.reporter.error( - 'Unknown directive type "%s".' % type_name, '', + 'Unknown directive type "%s".' % type_name, nodes.literal_block(text, text), line=lineno) return [error], blank_finish @@ -1947,7 +1952,7 @@ class Body(RSTState): lineno = self.state_machine.abs_line_number() - len(block) + 1 warning = self.reporter.warning( 'Anonymous hyperlink target contains whitespace. Perhaps a ' - 'footnote was intended?', '', + 'footnote was intended?', nodes.literal_block(blocktext, blocktext), line=lineno) nodelist.append(warning) @@ -1967,14 +1972,14 @@ class Body(RSTState): elif len(match.string.strip()) < 4: msg = self.reporter.info( 'Unexpected possible title overline or transition.\n' - "Treating it as ordinary text because it's so short.", '', + "Treating it as ordinary text because it's so short.", line=self.state_machine.abs_line_number()) self.parent += msg raise statemachine.TransitionCorrection('text') else: blocktext = self.state_machine.line msg = self.reporter.severe( - 'Unexpected section title or transition.', '', + 'Unexpected section title or transition.', nodes.literal_block(blocktext, blocktext), line=self.state_machine.abs_line_number()) self.parent += msg @@ -2279,8 +2284,8 @@ class Text(RSTState): 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) + 'Unexpected section title.', + nodes.literal_block(blocktext, blocktext), line=lineno) self.parent += msg return [], next_state, [] title = context[0].rstrip() @@ -2291,14 +2296,14 @@ class Text(RSTState): 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.", '', + "Treating it as ordinary text because it's so short.", line=lineno) self.parent += msg raise statemachine.TransitionCorrection('text') else: blocktext = context[0] + '\n' + self.state_machine.line msg = self.reporter.warning( - 'Title underline too short.', '', + 'Title underline too short.', nodes.literal_block(blocktext, blocktext), line=lineno) messages.append(msg) style = underline[0] @@ -2483,7 +2488,7 @@ class Line(SpecializedText): self.short_overline(context, blocktext, lineno, 2) else: msg = self.reporter.severe( - 'Incomplete section title.', '', + 'Incomplete section title.', nodes.literal_block(blocktext, blocktext), line=lineno) self.parent += msg return [], 'Body', [] @@ -2496,7 +2501,7 @@ class Line(SpecializedText): self.short_overline(context, blocktext, lineno, 2) else: msg = self.reporter.severe( - 'Missing underline for overline.', '', + 'Missing underline for overline.', nodes.literal_block(source, source), line=lineno) self.parent += msg return [], 'Body', [] @@ -2506,7 +2511,7 @@ class Line(SpecializedText): self.short_overline(context, blocktext, lineno, 2) else: msg = self.reporter.severe( - 'Title overline & underline mismatch.', '', + 'Title overline & underline mismatch.', nodes.literal_block(source, source), line=lineno) self.parent += msg return [], 'Body', [] @@ -2518,7 +2523,7 @@ class Line(SpecializedText): self.short_overline(context, blocktext, lineno, 2) else: msg = self.reporter.warning( - 'Title overline too short.', '', + 'Title overline too short.', nodes.literal_block(source, source), line=lineno) messages.append(msg) style = (overline[0], underline[0]) @@ -2536,7 +2541,7 @@ class Line(SpecializedText): if len(overline.rstrip()) < 4: self.short_overline(context, blocktext, lineno, 1) msg = self.reporter.error( - 'Invalid section title or transition marker.', '', + 'Invalid section title or transition marker.', nodes.literal_block(blocktext, blocktext), line=lineno) self.parent += msg return [], 'Body', [] @@ -2544,7 +2549,7 @@ class Line(SpecializedText): def short_overline(self, context, blocktext, lineno, lines=1): msg = self.reporter.info( 'Possible incomplete section title.\nTreating the overline as ' - "ordinary text because it's so short.", '', line=lineno) + "ordinary text because it's so short.", line=lineno) self.parent += msg self.state_correction(context, lines) -- cgit v1.2.1 From efdd39867964b92520a58c6796658895e412c441 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 9 Oct 2002 00:51:53 +0000 Subject: changed docstring field lists into comments git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@778 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/__init__.py | 12 ++++++------ docutils/parsers/rst/__init__.py | 15 +++++++-------- docutils/parsers/rst/languages/__init__.py | 12 +++++------- docutils/parsers/rst/languages/en.py | 12 +++++------- docutils/parsers/rst/languages/sv.py | 12 +++++------- 5 files changed, 28 insertions(+), 35 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/__init__.py b/docutils/parsers/__init__.py index 0294da0f8..b5717e0d3 100644 --- a/docutils/parsers/__init__.py +++ b/docutils/parsers/__init__.py @@ -1,11 +1,11 @@ -#! /usr/bin/env python +# Author: David Goodger +# Contact: goodger@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. """ -:Author: David Goodger -:Contact: goodger@users.sourceforge.net -:Revision: $Revision$ -:Date: $Date$ -:Copyright: This module has been placed in the public domain. +This package contains Docutils parser modules. """ __docformat__ = 'reStructuredText' diff --git a/docutils/parsers/rst/__init__.py b/docutils/parsers/rst/__init__.py index 4bc8970c4..1a8b26c72 100644 --- a/docutils/parsers/rst/__init__.py +++ b/docutils/parsers/rst/__init__.py @@ -1,13 +1,12 @@ -#! /usr/bin/env python +# Author: David Goodger +# Contact: goodger@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. """ -:Author: David Goodger -:Contact: goodger@users.sourceforge.net -:Revision: $Revision$ -:Date: $Date$ -:Copyright: This module has been placed in the public domain. - -This is ``docutils.parsers.rst`` package. It exports a single class, `Parser`. +This is ``docutils.parsers.rst`` package. It exports a single class, `Parser`, +the reStructuredText parser. Usage ===== diff --git a/docutils/parsers/rst/languages/__init__.py b/docutils/parsers/rst/languages/__init__.py index 4a5441e9e..8f78fc481 100644 --- a/docutils/parsers/rst/languages/__init__.py +++ b/docutils/parsers/rst/languages/__init__.py @@ -1,12 +1,10 @@ -#! /usr/bin/env python +# Author: David Goodger +# Contact: goodger@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. """ -:Author: David Goodger -:Contact: goodger@users.sourceforge.net -:Revision: $Revision$ -:Date: $Date$ -:Copyright: This module has been placed in the public domain. - This package contains modules for language-dependent features of reStructuredText. """ diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index 34c4c101a..f162c7a9a 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -1,12 +1,10 @@ -#! /usr/bin/env python +# Author: David Goodger +# Contact: goodger@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. """ -:Author: David Goodger -:Contact: goodger@users.sourceforge.net -:Revision: $Revision$ -:Date: $Date$ -:Copyright: This module has been placed in the public domain. - English-language mappings for language-dependent features of reStructuredText. """ diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index 2d45a5222..b68040cf3 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -1,12 +1,10 @@ -#! /usr/bin/env python +# Author: Adam Chodorowski +# Contact: chodorowski@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. """ -:Author: Adam Chodorowski -:Contact: chodorowski@users.sourceforge.net -:Revision: $Revision$ -:Date: $Date$ -:Copyright: This module has been placed in the public domain. - Swedish language mappings for language-dependent features of reStructuredText. """ -- cgit v1.2.1 From 62de3120694f48834addfcd85a9c85dc95feac42 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 11 Oct 2002 01:34:35 +0000 Subject: Added "--tab-width" option. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@786 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/__init__.py b/docutils/parsers/rst/__init__.py index 1a8b26c72..c8077de48 100644 --- a/docutils/parsers/rst/__init__.py +++ b/docutils/parsers/rst/__init__.py @@ -65,7 +65,10 @@ class Parser(docutils.parsers.Parser): {'action': 'store_true'}), ('Recognize and link to RFC references (like "RFC 822").', ['--rfc-references'], - {'action': 'store_true'}),)) + {'action': 'store_true'}), + ('Set number of spaces for tab expansion (default 8).', + ['--tab-width'], + {'metavar': '', 'type': 'int', 'default': 8}),)) def __init__(self, rfc2822=None, inliner=None): if rfc2822: @@ -84,5 +87,6 @@ class Parser(docutils.parsers.Parser): initial_state=self.initial_state, debug=debug) inputlines = docutils.statemachine.string2lines( - inputstring, convert_whitespace=1) + inputstring, tab_width=document.options.tab_width, + convert_whitespace=1) self.statemachine.run(inputlines, document, inliner=self.inliner) -- cgit v1.2.1 From a4760f9d42ef26b2132ff305a85e370a95ed93a5 Mon Sep 17 00:00:00 2001 From: grubert Date: Tue, 15 Oct 2002 08:58:50 +0000 Subject: + add directives mapping for german. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@801 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/de.py | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 docutils/parsers/rst/languages/de.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py new file mode 100644 index 000000000..e381a18a2 --- /dev/null +++ b/docutils/parsers/rst/languages/de.py @@ -0,0 +1,44 @@ +# Author: David Goodger +# Contact: goodger@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +""" +German-language mappings for language-dependent features of +reStructuredText. +""" + +__docformat__ = 'reStructuredText' + + +directives = { + 'Achtung': 'attention', + 'Vorsicht': 'caution', + 'Gefahr': 'danger', + 'Fehler': 'error', + 'Hinweis': 'hint', + 'Wichtig': 'important', + 'Notiz': 'note', + 'Tip': 'tip', + 'Warnung': 'warning', + 'Topic': 'topic', # Inhalt, Thema or Überbegriff + 'line-block': 'line-block', + 'parsed-literal': 'parsed-literal', + #'questions': 'questions', + #'qa': 'questions', + #'faq': 'questions', + 'meta': 'meta', + #'imagemap': 'imagemap', + 'Bild': 'image', + 'figure': 'figure', # also Bild ? + #'raw': 'raw', + 'Inhalt': 'contents', + 'sectnum': 'sectnum', + 'section-numbering': 'sectnum', + 'target-notes': 'target-notes', + #'footnotes': 'footnotes', + #'citations': 'citations', + 'restructuredtext-test-directive': 'restructuredtext-test-directive'} +"""English name to registered (in directives/__init__.py) directive name +mapping.""" -- cgit v1.2.1 From 16a25cf1c6c5e5fa9214bce8c3d45e882783215a Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 17 Oct 2002 01:35:34 +0000 Subject: Added warnings for unknown directives. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@808 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 24 ++++++++++++++++++------ docutils/parsers/rst/states.py | 7 +++++-- 2 files changed, 23 insertions(+), 8 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 58175040f..034a88e64 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -78,6 +78,7 @@ See `Creating reStructuredText Directives`_ for more information. __docformat__ = 'reStructuredText' +from docutils import nodes from docutils.parsers.rst.languages import en as _fallback_language_module @@ -118,39 +119,50 @@ _modules = {} _directives = {} """Cache of imported directive functions.""" -def directive(directive_name, language_module): +def directive(directive_name, language_module, document): """ Locate and return a directive function from its language-dependent name. If not found in the current language, check English. """ normname = directive_name.lower() + messages = [] if _directives.has_key(normname): - return _directives[normname] + return _directives[normname], messages try: canonicalname = language_module.directives[normname] except (KeyError, AttributeError): + warning = document.reporter.warning( + 'No directive entry for "%s" in module "%s".' + % (directive_name, language_module.__name__), + line=document.current_line) try: # Try English as a fallback: canonicalname = _fallback_language_module.directives[normname] + warning[-1] += nodes.Text( + 'Using English fallback for directive "%s".' % directive_name) except KeyError: + warning[-1] += nodes.Text( + 'Trying "%s" as canonical directive name.' % directive_name) # The canonical name should be an English name, but just in case: canonicalname = normname + messages.append(warning) try: modulename, functionname = _directive_registry[canonicalname] except KeyError: - return None + return None, messages if _modules.has_key(modulename): module = _modules[modulename] else: try: module = __import__(modulename, globals(), locals()) except ImportError: - return None + return None, messages try: function = getattr(module, functionname) + _directives[normname] = function except AttributeError: - return None - return function + return None, messages + return function, messages def flag(argument): """ diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index f64eb3f5f..27784dc27 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1672,8 +1672,9 @@ class Body(RSTState): def directive(self, match, **option_presets): type_name = match.group(1) - directive_function = directives.directive(type_name, - self.memo.language) + directive_function, messages = directives.directive( + type_name, self.memo.language, self.document) + self.parent += messages if directive_function: return self.parse_directive( directive_function, match, type_name, option_presets) @@ -1969,6 +1970,8 @@ class Body(RSTState): """Section title overline or transition marker.""" if self.state_machine.match_titles: return [match.string], 'Line', [] + elif match.string.strip() == '::': + raise statemachine.TransitionCorrection('text') elif len(match.string.strip()) < 4: msg = self.reporter.info( 'Unexpected possible title overline or transition.\n' -- cgit v1.2.1 From fd593bed5456e2ef6d58dab0b1379764d0ab3823 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 17 Oct 2002 01:45:03 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@811 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/en.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index f162c7a9a..0d5e0da34 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -32,7 +32,9 @@ directives = { #'imagemap': 'imagemap', 'image': 'image', 'figure': 'figure', - #'raw': 'raw', + 'include': 'include', + 'raw': 'raw', + 'replace': 'replace', 'contents': 'contents', 'sectnum': 'sectnum', 'section-numbering': 'sectnum', -- cgit v1.2.1 From 7a48b3972754ebd5e339322f77b3119c895fffa1 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 18 Oct 2002 04:45:18 +0000 Subject: Fixed path handling in "include" and "raw" directives. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@823 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 58af1336f..3bd088e39 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -9,20 +9,25 @@ __docformat__ = 'reStructuredText' import sys +import os.path from urllib2 import urlopen, URLError -from docutils import nodes, statemachine +from docutils import nodes, statemachine, utils from docutils.parsers.rst import directives, states def include(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): """Include a reST file as part of the content of this reST file.""" + source_dir = os.path.dirname( + os.path.abspath(state.document.current_source)) path = ''.join(arguments[0].splitlines()) if path.find(' ') != -1: error = state_machine.reporter.error( '"%s" directive path contains whitespace.' % name, nodes.literal_block(block_text, block_text), line=lineno) return [error] + path = os.path.normpath(os.path.join(source_dir, path)) + path = utils.relative_path(None, path) try: include_file = open(path) except IOError, error: @@ -78,8 +83,12 @@ def raw(name, arguments, options, content, lineno, 'specified for the "%s" directive.' % name, nodes.literal_block(block_text, block_text), line=lineno) return [error] + source_dir = os.path.dirname( + os.path.abspath(state.document.current_source)) + path = os.path.normpath(os.path.join(source_dir, options['file'])) + path = utils.relative_path(None, path) try: - raw_file = open(options['file']) + raw_file = open(path) except IOError, error: severe = state_machine.reporter.severe( 'Problems with "%s" directive path:\n%s.' % (name, error), @@ -87,7 +96,7 @@ def raw(name, arguments, options, content, lineno, return [severe] text = raw_file.read() raw_file.close() - attributes['source'] = options['file'] + attributes['source'] = path elif options.has_key('url'): try: raw_file = urlopen(options['url']) -- cgit v1.2.1 From afeedfb343c2904e9357997d2a50f8f3cabb2568 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 18 Oct 2002 04:55:21 +0000 Subject: Refactored names (options -> settings; .transform() -> .apply(); etc.); updated. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@825 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/__init__.py | 4 ++-- docutils/parsers/rst/states.py | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/__init__.py b/docutils/parsers/rst/__init__.py index c8077de48..82e8c59af 100644 --- a/docutils/parsers/rst/__init__.py +++ b/docutils/parsers/rst/__init__.py @@ -57,7 +57,7 @@ class Parser(docutils.parsers.Parser): supported = ('restructuredtext', 'rst', 'rest', 'restx', 'rtxt', 'rstx') """Aliases this parser supports.""" - cmdline_options = ( + settings_spec = ( 'reStructuredText Parser Options', None, (('Recognize and link to PEP references (like "PEP 258").', @@ -87,6 +87,6 @@ class Parser(docutils.parsers.Parser): initial_state=self.initial_state, debug=debug) inputlines = docutils.statemachine.string2lines( - inputstring, tab_width=document.options.tab_width, + inputstring, tab_width=document.settings.tab_width, convert_whitespace=1) self.statemachine.run(inputlines, document, inliner=self.inliner) diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 27784dc27..6600391ff 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -145,11 +145,12 @@ class RSTStateMachine(StateMachineWS): StateMachine, and return the resulting document. """ - self.language = languages.get_language(document.options.language_code) + self.language = languages.get_language( + document.settings.language_code) self.match_titles = match_titles if inliner is None: inliner = Inliner() - inliner.init_customizations(document.options) + inliner.init_customizations(document.settings) self.memo = Stuff(document=document, reporter=document.reporter, language=self.language, @@ -431,12 +432,12 @@ class Inliner: """List of (pattern, bound method) tuples, used by `self.implicit_inline`.""" - def init_customizations(self, options): - """Option-based customizations; run when parsing begins.""" - if options.pep_references: + def init_customizations(self, settings): + """Setting-based customizations; run when parsing begins.""" + if settings.pep_references: self.implicit_dispatch.append((self.patterns.pep, self.pep_reference)) - if options.rfc_references: + if settings.rfc_references: self.implicit_dispatch.append((self.patterns.rfc, self.rfc_reference)) -- cgit v1.2.1 From a3d5874e951e34373fc39ac5dc502ec4ef01d89e Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 18 Oct 2002 23:44:47 +0000 Subject: Renamed ``Stuff`` to ``Struct``. Fixed a bug. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@830 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 6600391ff..06c6cb1c1 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -28,7 +28,7 @@ the reStructuredText parser. It defines the following: - `SpecializedText`: Superclass for continuation lines of Text-variants. - `Definition`: Second line of potential definition_list_item. - `Line`: Second line of overlined section title or transition marker. - - `Stuff`: An auxiliary collection class. + - `Struct`: An auxiliary collection class. :Exception classes: - `MarkupError` @@ -120,9 +120,9 @@ class ParserError(ApplicationError): pass class MarkupMismatch(Exception): pass -class Stuff: +class Struct: - """Stores a bunch of stuff for dotted-attribute access.""" + """Stores data attributes for dotted-attribute access.""" def __init__(self, **keywordargs): self.__dict__.update(keywordargs) @@ -151,12 +151,12 @@ class RSTStateMachine(StateMachineWS): if inliner is None: inliner = Inliner() inliner.init_customizations(document.settings) - self.memo = Stuff(document=document, - reporter=document.reporter, - language=self.language, - title_styles=[], - section_level=0, - inliner=inliner) + self.memo = Struct(document=document, + reporter=document.reporter, + language=self.language, + title_styles=[], + section_level=0, + inliner=inliner) self.document = self.memo.document self.attach_observer(self.document.note_state_machine_change) self.reporter = self.memo.reporter @@ -524,7 +524,7 @@ class Inliner: ) ] ) - patterns = Stuff( + patterns = Struct( initial=build_regexp(parts), emphasis=re.compile(non_whitespace_escape_before + r'(\*)' + end_string_suffix), @@ -903,13 +903,13 @@ class Body(RSTState): Generic classifier of the first line of a block. """ - enum = Stuff() + enum = Struct() """Enumerated list parsing information.""" enum.formatinfo = { - 'parens': Stuff(prefix='(', suffix=')', start=1, end=-1), - 'rparen': Stuff(prefix='', suffix=')', start=0, end=-1), - 'period': Stuff(prefix='', suffix='.', start=0, end=-1)} + 'parens': Struct(prefix='(', suffix=')', start=1, end=-1), + 'rparen': Struct(prefix='', suffix=')', start=0, end=-1), + 'period': Struct(prefix='', suffix='.', start=0, end=-1)} enum.formats = enum.formatinfo.keys() enum.sequences = ['arabic', 'loweralpha', 'upperalpha', 'lowerroman', 'upperroman'] # ORDERED! @@ -1449,10 +1449,10 @@ class Body(RSTState): return row - explicit = Stuff() + explicit = Struct() """Patterns and constants used for explicit markup recognition.""" - explicit.patterns = Stuff( + explicit.patterns = Struct( target=re.compile(r""" ( _ # anonymous target @@ -1903,10 +1903,7 @@ class Body(RSTState): try: return method(self, expmatch) except MarkupError, (message, lineno): # never reached? - errors.append( - self.reporter.warning( - '%s: %s' % (detail.__class__.__name__, message), - line=lineno)) + errors.append(self.reporter.warning(message, line=lineno)) break nodelist, blank_finish = self.comment(match) return nodelist + errors, blank_finish -- cgit v1.2.1 From 2586836579f852ed06ddaad9f4933e3e2b8a6af5 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 24 Oct 2002 00:40:03 +0000 Subject: Added ``Parser.finish_parse()`` method; updated. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@846 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/__init__.py b/docutils/parsers/__init__.py index b5717e0d3..5b1e964be 100644 --- a/docutils/parsers/__init__.py +++ b/docutils/parsers/__init__.py @@ -15,14 +15,22 @@ from docutils import Component class Parser(Component): + component_type = 'parser' + def parse(self, inputstring, document): """Override to parse `inputstring` into document tree `document`.""" raise NotImplementedError('subclass must override this method') def setup_parse(self, inputstring, document): - """Initial setup, used by `parse()`.""" + """Initial parse setup. Call at start of `self.parse()`.""" self.inputstring = inputstring self.document = document + document.reporter.attach_observer(document.note_parse_message) + + def finish_parse(self): + """Finalize parse details. Call at end of `self.parse()`.""" + self.document.reporter.detach_observer( + self.document.note_parse_message) _parser_aliases = { -- cgit v1.2.1 From 3e8c56e56bd1d9c62e125da837698dff2b11718f Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 24 Oct 2002 00:41:19 +0000 Subject: Detect bad column spans in "simple" tables. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@847 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/tableparser.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/tableparser.py b/docutils/parsers/rst/tableparser.py index 3ef7e7d68..6b2ffe3ee 100644 --- a/docutils/parsers/rst/tableparser.py +++ b/docutils/parsers/rst/tableparser.py @@ -377,6 +377,7 @@ class SimpleTableParser(TableParser): self.block[-1] = self.block[-1].replace('=', '-') self.head_body_sep = None self.columns = [] + self.border_end = None self.table = [] self.done = [-1] * len(block[0]) self.rowseps = {0: [0]} @@ -390,7 +391,8 @@ class SimpleTableParser(TableParser): job. """ # Top border must fully describe all table columns. - self.columns = self.parse_columns(self.block[0]) + self.columns = self.parse_columns(self.block[0], 0) + self.border_end = self.columns[-1][1] firststart, firstend = self.columns[0] block = self.block[1:] offset = 0 @@ -412,7 +414,7 @@ class SimpleTableParser(TableParser): # Accumulate lines of incomplete row. rowlines.append((line.rstrip(), offset)) - def parse_columns(self, line): + def parse_columns(self, line, offset): """ Given a column span underline, return a list of (begin, end) pairs. """ @@ -427,6 +429,9 @@ class SimpleTableParser(TableParser): end = len(line) cols.append((begin, end)) if self.columns: + if cols[-1][1] != self.border_end: + raise TableMarkupError('Column span incomplete at line ' + 'offset %s.' % offset) # Allow for an unbounded rightmost column: cols[-1] = (cols[-1][0], self.columns[-1][1]) return cols @@ -457,10 +462,6 @@ class SimpleTableParser(TableParser): text from each line, and check for text in column margins. Finally, adjust for insigificant whitespace. """ - if spanline: - columns = self.parse_columns(spanline[0]) - else: - columns = self.columns[:] while lines and not lines[-1][0]: lines.pop() # Remove blank trailing lines. if lines: @@ -470,6 +471,10 @@ class SimpleTableParser(TableParser): else: # No new row, just blank lines. return + if spanline: + columns = self.parse_columns(*spanline) + else: + columns = self.columns[:] row = self.init_row(columns, offset) # "Infinite" value for a dummy last column's beginning, used to # check for text overflow: -- cgit v1.2.1 From a714d9a65946eaec2c775e27e24159ce65ce10a1 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 24 Oct 2002 01:01:53 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@856 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/__init__.py | 1 + docutils/parsers/rst/directives/html.py | 6 ++++-- docutils/parsers/rst/directives/parts.py | 5 ++--- docutils/parsers/rst/directives/references.py | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/__init__.py b/docutils/parsers/rst/__init__.py index 82e8c59af..ad60a319d 100644 --- a/docutils/parsers/rst/__init__.py +++ b/docutils/parsers/rst/__init__.py @@ -90,3 +90,4 @@ class Parser(docutils.parsers.Parser): inputstring, tab_width=document.settings.tab_width, convert_whitespace=1) self.statemachine.run(inputlines, document, inliner=self.inliner) + self.finish_parse() diff --git a/docutils/parsers/rst/directives/html.py b/docutils/parsers/rst/directives/html.py index 88675c284..a6e656994 100644 --- a/docutils/parsers/rst/directives/html.py +++ b/docutils/parsers/rst/directives/html.py @@ -60,8 +60,10 @@ class MetaBody(states.SpecializedBody): indented, indent, line_offset, blank_finish = \ self.state_machine.get_first_known_indented(match.end()) node = self.meta() - pending = nodes.pending(components.Filter, 'first writer', - {'writer': 'html', 'nodes': [node]}) + pending = nodes.pending(components.Filter, + {'component': 'writer', + 'format': 'html', + 'nodes': [node]}) node['content'] = ' '.join(indented) if not indented: line = self.state_machine.line diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py index 9512b835d..e4ca8d3df 100644 --- a/docutils/parsers/rst/directives/parts.py +++ b/docutils/parsers/rst/directives/parts.py @@ -34,8 +34,7 @@ def contents(name, arguments, options, content, lineno, else: messages = [] title = None - pending = nodes.pending(parts.Contents, 'first writer', {'title': title}, - block_text) + pending = nodes.pending(parts.Contents, {'title': title}, block_text) pending.details.update(options) state_machine.document.note_pending(pending) return [pending] + messages @@ -48,7 +47,7 @@ contents.options = {'depth': directives.nonnegative_int, def sectnum(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): """Automatic section numbering.""" - pending = nodes.pending(parts.SectNum, 'last reader', {}) + pending = nodes.pending(parts.SectNum) pending.details.update(options) state_machine.document.note_pending(pending) return [pending] diff --git a/docutils/parsers/rst/directives/references.py b/docutils/parsers/rst/directives/references.py index 815bc1477..92966140f 100644 --- a/docutils/parsers/rst/directives/references.py +++ b/docutils/parsers/rst/directives/references.py @@ -17,7 +17,7 @@ from docutils.transforms import references def target_notes(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): """Target footnote generation.""" - pending = nodes.pending(references.TargetNotes, 'first reader', {}) + pending = nodes.pending(references.TargetNotes) state_machine.document.note_pending(pending) nodelist = [pending] return nodelist -- cgit v1.2.1 From b4f387efe3f819802be5bdbcecc3e420f244a0b2 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 31 Oct 2002 02:38:00 +0000 Subject: Now flagged as errors: transitions at the beginning or end of sections, empty sections (except title), and empty documents. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@869 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 60 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 11 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 06c6cb1c1..ebfee3430 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -163,8 +163,16 @@ class RSTStateMachine(StateMachineWS): self.node = document results = StateMachineWS.run(self, input_lines, input_offset) assert results == [], 'RSTStateMachine.run() results should be empty!' + self.check_document() self.node = self.memo = None # remove unneeded references + def check_document(self): + """Check for illegal structure: empty document.""" + if len(self.document) == 0: + error = self.reporter.error( + 'Document empty; must have contents.', line=0) + self.document += error + class NestedStateMachine(StateMachineWS): @@ -344,27 +352,53 @@ class RSTState(StateWS): memo = self.memo mylevel = memo.section_level memo.section_level += 1 - sectionnode = nodes.section() - self.parent += sectionnode + section_node = nodes.section() + self.parent += section_node textnodes, title_messages = self.inline_text(title, lineno) titlenode = nodes.title(title, '', *textnodes) name = normalize_name(titlenode.astext()) - sectionnode['name'] = name - sectionnode += titlenode - sectionnode += messages - sectionnode += title_messages - self.document.note_implicit_target(sectionnode, sectionnode) + section_node['name'] = name + section_node += titlenode + section_node += messages + section_node += title_messages + self.document.note_implicit_target(section_node, section_node) offset = self.state_machine.line_offset + 1 absoffset = self.state_machine.abs_line_offset() + 1 newabsoffset = self.nested_parse( self.state_machine.input_lines[offset:], input_offset=absoffset, - node=sectionnode, match_titles=1) + node=section_node, match_titles=1) self.goto_line(newabsoffset) + self.check_section(section_node) if memo.section_level <= mylevel: # can't handle next section? raise EOFError # bubble up to supersection # reset section_level; next pass will detect it properly memo.section_level = mylevel + def check_section(self, section): + """ + Check for illegal structure: empty section, misplaced transitions. + """ + lineno = section.line + if len(section) <= 1: + error = self.reporter.error( + 'Section empty; must have contents.', line=lineno) + section += error + return + if not isinstance(section[0], nodes.title): # shouldn't ever happen + error = self.reporter.error( + 'First element of section must be a title.', line=lineno) + section.insert(0, error) + if isinstance(section[1], nodes.transition): + error = self.reporter.error( + 'Section may not begin with a transition.', + line=section[1].line) + section.insert(1, error) + if len(section) > 2 and isinstance(section[-1], nodes.transition): + error = self.reporter.error( + 'Section may not end with a transition.', + line=section[-1].line) + section += error + def paragraph(self, lines, lineno): """ Return a list (paragraph & messages) & a boolean: literal_block next? @@ -2446,31 +2480,35 @@ class Line(SpecializedText): if len(marker) < 4: self.state_correction(context) if self.eofcheck: # ignore EOFError with sections + lineno = self.state_machine.abs_line_number() - 1 transition = nodes.transition(context[0]) + transition.line = lineno self.parent += transition msg = self.reporter.error( 'Document or section may not end with a transition.', - line=self.state_machine.abs_line_number() - 1) + line=lineno) self.parent += msg self.eofcheck = 1 return [] def blank(self, match, context, next_state): """Transition marker.""" + lineno = self.state_machine.abs_line_number() - 1 marker = context[0].strip() if len(marker) < 4: self.state_correction(context) transition = nodes.transition(marker) + transition.line = lineno if len(self.parent) == 0: msg = self.reporter.error( 'Document or section may not begin with a transition.', - line=self.state_machine.abs_line_number() - 1) + line=lineno) self.parent += msg elif isinstance(self.parent[-1], nodes.transition): msg = self.reporter.error( 'At least one body element must separate transitions; ' 'adjacent transitions not allowed.', - line=self.state_machine.abs_line_number() - 1) + line=lineno) self.parent += msg self.parent += transition return [], 'Body', [] -- cgit v1.2.1 From bbff5bae14890845feab785b384f2893ffcd18f9 Mon Sep 17 00:00:00 2001 From: grubert Date: Tue, 5 Nov 2002 15:40:28 +0000 Subject: + add sk.py to docutils/languages. + added missing labels to docutils/languages/de.py and sv.py (none swedish). + changed de directives to lowercase. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@887 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/de.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index e381a18a2..f05e032a6 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -13,16 +13,16 @@ __docformat__ = 'reStructuredText' directives = { - 'Achtung': 'attention', - 'Vorsicht': 'caution', - 'Gefahr': 'danger', - 'Fehler': 'error', - 'Hinweis': 'hint', - 'Wichtig': 'important', - 'Notiz': 'note', - 'Tip': 'tip', - 'Warnung': 'warning', - 'Topic': 'topic', # Inhalt, Thema or Überbegriff + 'achtung': 'attention', + 'vorsicht': 'caution', + 'gefahr': 'danger', + 'fehler': 'error', + 'hinweis': 'hint', + 'wichtig': 'important', + 'notiz': 'note', + 'tip': 'tip', + 'warnung': 'warning', + 'topic': 'topic', # Inhalt, Thema or Überbegriff 'line-block': 'line-block', 'parsed-literal': 'parsed-literal', #'questions': 'questions', @@ -30,10 +30,10 @@ directives = { #'faq': 'questions', 'meta': 'meta', #'imagemap': 'imagemap', - 'Bild': 'image', + 'bild': 'image', 'figure': 'figure', # also Bild ? #'raw': 'raw', - 'Inhalt': 'contents', + 'inhalt': 'contents', 'sectnum': 'sectnum', 'section-numbering': 'sectnum', 'target-notes': 'target-notes', -- cgit v1.2.1 From 6b524e8a1b83734a01deda7fe8e15c13f2cdec9e Mon Sep 17 00:00:00 2001 From: grubert Date: Thu, 7 Nov 2002 08:29:08 +0000 Subject: + add directives and todo. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@903 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/de.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index f05e032a6..9cd35fa15 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -22,7 +22,7 @@ directives = { 'notiz': 'note', 'tip': 'tip', 'warnung': 'warning', - 'topic': 'topic', # Inhalt, Thema or Überbegriff + 'topic': 'topic', # Überbegriff 'line-block': 'line-block', 'parsed-literal': 'parsed-literal', #'questions': 'questions', @@ -31,8 +31,11 @@ directives = { 'meta': 'meta', #'imagemap': 'imagemap', 'bild': 'image', - 'figure': 'figure', # also Bild ? - #'raw': 'raw', + 'abbildung': 'figure', + 'raw': 'raw', # unbearbeitet + 'include': 'include', # einfügen, "füge ein" would be more like a command. + # einfügung would be the noun. + 'replace': 'replace', # ersetzen, ersetze 'inhalt': 'contents', 'sectnum': 'sectnum', 'section-numbering': 'sectnum', -- cgit v1.2.1 From 7cd7af54b57b79f893d016e447ece46a0c3e03f8 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 8 Nov 2002 01:25:27 +0000 Subject: *I* didn't write it! git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@907 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/de.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index 9cd35fa15..25e6c4dd6 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -1,5 +1,5 @@ -# Author: David Goodger -# Contact: goodger@users.sourceforge.net +# Author: Engelbert Gruber +# Contact: grubert@users.sourceforge.net # Revision: $Revision$ # Date: $Date$ # Copyright: This module has been placed in the public domain. -- cgit v1.2.1 From 42233c8cbb5e89ce57ad0705aca74eae61346622 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 8 Nov 2002 01:29:22 +0000 Subject: Simplified "include" directive code. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@912 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 3bd088e39..3ff9eb93f 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -45,13 +45,7 @@ def include(name, arguments, options, content, lineno, else: include_lines = statemachine.string2lines(include_text, convert_whitespace=1) - current_source = state.document.current_source - state.document.note_source(path) - state.memo.reporter.source = path - state.nested_parse(include_lines, 0, node=state_machine.node, - match_titles=state_machine.match_titles) - state.document.note_source(current_source) - state.memo.reporter.source = current_source + state_machine.insert_input(include_lines, path) return [] include.arguments = (1, 0, 1) -- cgit v1.2.1 From 39148f8101ca745fbf08dc91862537dc5b8a1668 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 8 Nov 2002 01:30:20 +0000 Subject: Updated for ``statemachine.StringList``. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@913 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 72 ++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 28 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index ebfee3430..9c4eeafab 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -157,11 +157,12 @@ class RSTStateMachine(StateMachineWS): title_styles=[], section_level=0, inliner=inliner) - self.document = self.memo.document - self.attach_observer(self.document.note_state_machine_change) + self.document = document + self.attach_observer(document.note_source) self.reporter = self.memo.reporter self.node = document - results = StateMachineWS.run(self, input_lines, input_offset) + results = StateMachineWS.run(self, input_lines, input_offset, + input_source=document['source']) assert results == [], 'RSTStateMachine.run() results should be empty!' self.check_document() self.node = self.memo = None # remove unneeded references @@ -190,7 +191,7 @@ class NestedStateMachine(StateMachineWS): self.match_titles = match_titles self.memo = memo self.document = memo.document - self.attach_observer(self.document.note_state_machine_change) + self.attach_observer(self.document.note_source) self.reporter = memo.reporter self.node = node results = StateMachineWS.run(self, input_lines, input_offset) @@ -260,12 +261,16 @@ class RSTState(StateWS): state_machine_class = self.nested_sm if state_machine_kwargs is None: state_machine_kwargs = self.nested_sm_kwargs + block_length = len(block) state_machine = state_machine_class(debug=self.debug, **state_machine_kwargs) state_machine.run(block, input_offset, memo=self.memo, node=node, match_titles=match_titles) state_machine.unlink() - return state_machine.abs_line_offset() + new_offset = state_machine.abs_line_offset() + # Adjustment for block if modified in nested parse: + self.state_machine.next_line(len(block) - block_length) + return new_offset def nested_list_parse(self, block, input_offset, node, initial_state, blank_finish, @@ -1270,10 +1275,12 @@ class Body(RSTState): return [], next_state, [] def option_list_item(self, match): + offset = self.state_machine.abs_line_offset() options = self.parse_option_marker(match) indented, indent, line_offset, blank_finish = \ self.state_machine.get_first_known_indented(match.end()) if not indented: # not an option list item + self.goto_line(offset) raise statemachine.TransitionCorrection('text') option_group = nodes.option_group('', *options) description = nodes.description('\n'.join(indented)) @@ -1366,10 +1373,11 @@ class Body(RSTState): try: block = self.state_machine.get_text_block(flush_left=1) except statemachine.UnexpectedIndentationError, instance: - block, lineno = instance.args + block, source, lineno = instance.args messages.append(self.reporter.error('Unexpected indentation.', - line=lineno)) + source=source, line=lineno)) blank_finish = 0 + block.disconnect() width = len(block[0].strip()) for i in range(len(block)): block[i] = block[i].strip() @@ -1649,7 +1657,9 @@ class Body(RSTState): self.state_machine.get_first_known_indented(match.end(), strip_indent=0) blocktext = (match.string[:match.end()] + '\n'.join(block)) - block = [escape2null(line) for line in block] + block.disconnect() + for i in range(len(block)): + block[i] = escape2null(block[i]) escaped = block[0].rstrip() blockindex = 0 while 1: @@ -1667,6 +1677,8 @@ class Body(RSTState): if not block[0]: del block[0] offset += 1 + while block and not block[-1].strip(): + block.pop() subname = subdefmatch.group('name') name = normalize_name(subname) substitutionnode = nodes.substitution_definition( @@ -1674,11 +1686,9 @@ class Body(RSTState): substitutionnode.line = lineno if block: block[0] = block[0].strip() - newabsoffset, blank_finish = self.nested_list_parse( + new_abs_offset, blank_finish = self.nested_list_parse( block, input_offset=offset, node=substitutionnode, initial_state='SubstitutionDef', blank_finish=blank_finish) - self.state_machine.previous_line( - len(block) + offset - newabsoffset - 1) i = 0 for node in substitutionnode[:]: if not (isinstance(node, nodes.Inline) or @@ -1692,7 +1702,7 @@ class Body(RSTState): 'Substitution definition "%s" empty or invalid.' % subname, nodes.literal_block(blocktext, blocktext), line=lineno) - self.parent += msg + return [msg], blank_finish else: del substitutionnode['alt'] self.document.note_substitution_def( @@ -1702,8 +1712,7 @@ class Body(RSTState): msg = self.reporter.warning( 'Substitution definition "%s" missing contents.' % subname, nodes.literal_block(blocktext, blocktext), line=lineno) - self.parent += msg - return [], blank_finish + return [msg], blank_finish def directive(self, match, **option_presets): type_name = match.group(1) @@ -1722,8 +1731,9 @@ class Body(RSTState): Parameters: - - `directive_fn`: The function implementing the directive. Must have - function attributes ``arguments``, ``options``, and ``content``. + - `directive_fn`: The function implementing the directive. Uses + function attributes ``arguments``, ``options``, and/or ``content`` + if present. - `match`: A regular expression match object which matched the first line of the directive. @@ -1753,10 +1763,10 @@ class Body(RSTState): block_text = '\n'.join(self.state_machine.input_lines[ initial_line_offset : self.state_machine.line_offset + 1]) if indented and not indented[0].strip(): - indented.pop(0) + indented.trim_start() line_offset += 1 while indented and not indented[-1].strip(): - indented.pop() + indented.trim_end() if indented and (argument_spec or option_spec): for i in range(len(indented)): if not indented[i].strip(): @@ -1771,7 +1781,7 @@ class Body(RSTState): content_offset = line_offset arg_block = [] while content and not content[0].strip(): - content.pop(0) + content.trim_start() content_offset += 1 try: if option_spec: @@ -1790,7 +1800,7 @@ class Body(RSTState): result = directive_fn( type_name, arguments, options, content, lineno, content_offset, block_text, self, self.state_machine) - return result, blank_finish + return result, blank_finish or self.state_machine.is_next_line_blank() def parse_directive_options(self, option_presets, option_spec, arg_block): options = option_presets.copy() @@ -1875,6 +1885,8 @@ class Body(RSTState): return [nodes.comment()], 1 # "A tiny but practical wart." indented, indent, offset, blank_finish = \ self.state_machine.get_first_known_indented(match.end()) + while indented and not indented[-1].strip(): + indented.trim_end() text = '\n'.join(indented) return [nodes.comment(text, text)], blank_finish @@ -2059,7 +2071,8 @@ class RFC2822Body(Body): def rfc2822_field(self, match): name = match.string[:match.string.find(':')] indented, indent, line_offset, blank_finish = \ - self.state_machine.get_first_known_indented(match.end()) + self.state_machine.get_first_known_indented(match.end(), + until_blank=1) fieldnode = nodes.field() fieldnode += nodes.field_name(name, name) fieldbody = nodes.field_body('\n'.join(indented)) @@ -2213,7 +2226,7 @@ class ExtensionOptions(FieldList): def parse_field_body(self, indented, offset, node): """Override `Body.parse_field_body` for simpler parsing.""" lines = [] - for line in indented + ['']: + for line in list(indented) + ['']: if line.strip(): lines.append(line) elif lines: @@ -2240,6 +2253,8 @@ class Explicit(SpecializedBody): self.blank_finish = blank_finish return [], next_state, [] + blank = SpecializedBody.invalid_input + class SubstitutionDef(Body): @@ -2353,9 +2368,10 @@ class Text(RSTState): try: block = self.state_machine.get_text_block(flush_left=1) except statemachine.UnexpectedIndentationError, instance: - block, lineno = instance.args - msg = self.reporter.error('Unexpected indentation.', line=lineno) - lines = context + block + block, source, lineno = instance.args + msg = self.reporter.error('Unexpected indentation.', + source=source, line=lineno) + lines = context + list(block) paragraph, literalnext = self.paragraph(lines, startline) self.parent += paragraph self.parent += msg @@ -2373,7 +2389,7 @@ class Text(RSTState): self.state_machine.get_indented() nodelist = [] while indented and not indented[-1].strip(): - indented.pop() + indented.trim_end() if indented: data = '\n'.join(indented) nodelist.append(nodes.literal_block(data, data)) @@ -2388,8 +2404,8 @@ class Text(RSTState): def definition_list_item(self, termline): indented, indent, line_offset, blank_finish = \ self.state_machine.get_indented() - definitionlistitem = nodes.definition_list_item('\n'.join(termline - + indented)) + definitionlistitem = nodes.definition_list_item( + '\n'.join(termline + list(indented))) termlist, messages = self.term( termline, self.state_machine.abs_line_number() - 1) definitionlistitem += termlist -- cgit v1.2.1 From 47e460c659b1e295d43604762eff2e9147d7df6c Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 8 Nov 2002 01:38:11 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@917 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/tableparser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/tableparser.py b/docutils/parsers/rst/tableparser.py index 6b2ffe3ee..35b52e578 100644 --- a/docutils/parsers/rst/tableparser.py +++ b/docutils/parsers/rst/tableparser.py @@ -131,7 +131,7 @@ class GridTableParser(TableParser): head_body_separator_pat = re.compile(r'\+=[=+]+=\+ *$') def setup(self, block): - self.block = block[:] # make a copy; it may be modified + self.block = list(block) # make a copy; it may be modified self.bottom = len(block) - 1 self.right = len(block[0]) - 1 self.head_body_sep = None @@ -371,7 +371,7 @@ class SimpleTableParser(TableParser): span_pat = re.compile('-[ -]*$') def setup(self, block): - self.block = block[:] # make a copy; it will be modified + self.block = list(block) # make a copy; it will be modified # Convert top & bottom borders to column span underlines: self.block[0] = self.block[0].replace('=', '-') self.block[-1] = self.block[-1].replace('=', '-') -- cgit v1.2.1 From 0b5556688eb293cdd373a5cf0cd3ee5af5842b8a Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 8 Nov 2002 22:06:30 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@923 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 034a88e64..14f10e3f7 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -131,20 +131,19 @@ def directive(directive_name, language_module, document): try: canonicalname = language_module.directives[normname] except (KeyError, AttributeError): - warning = document.reporter.warning( - 'No directive entry for "%s" in module "%s".' - % (directive_name, language_module.__name__), - line=document.current_line) + msg_text = ('No directive entry for "%s" in module "%s".' + % (directive_name, language_module.__name__)) try: - # Try English as a fallback: canonicalname = _fallback_language_module.directives[normname] - warning[-1] += nodes.Text( - 'Using English fallback for directive "%s".' % directive_name) + msg_text += ('\nUsing English fallback for directive "%s".' + % directive_name) except KeyError: - warning[-1] += nodes.Text( - 'Trying "%s" as canonical directive name.' % directive_name) + msg_text += ('\nTrying "%s" as canonical directive name.' + % directive_name) # The canonical name should be an English name, but just in case: canonicalname = normname + warning = document.reporter.warning( + msg_text, line=document.current_line) messages.append(warning) try: modulename, functionname = _directive_registry[canonicalname] -- cgit v1.2.1 From 2b381bc3e90ce06ba0046d3eb6c6bc3de9a94ab8 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 14 Nov 2002 02:24:57 +0000 Subject: Improved ``directive()`` function: Return ``None`` for missing directives. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@947 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 30 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 14f10e3f7..4593d8f23 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -122,29 +122,37 @@ _directives = {} def directive(directive_name, language_module, document): """ Locate and return a directive function from its language-dependent name. - If not found in the current language, check English. + If not found in the current language, check English. Return None if the + named directive cannot be found. """ normname = directive_name.lower() messages = [] + msg_text = [] if _directives.has_key(normname): return _directives[normname], messages + canonicalname = None try: canonicalname = language_module.directives[normname] - except (KeyError, AttributeError): - msg_text = ('No directive entry for "%s" in module "%s".' - % (directive_name, language_module.__name__)) + except AttributeError, error: + msg_text.append('Problem retrieving directive entry from language ' + 'module %r: %s.' % (language_module, error)) + except KeyError: + msg_text.append('No directive entry for "%s" in module "%s".' + % (directive_name, language_module.__name__)) + if not canonicalname: try: canonicalname = _fallback_language_module.directives[normname] - msg_text += ('\nUsing English fallback for directive "%s".' - % directive_name) + msg_text.append('Using English fallback for directive "%s".' + % directive_name) except KeyError: - msg_text += ('\nTrying "%s" as canonical directive name.' - % directive_name) + msg_text.append('Trying "%s" as canonical directive name.' + % directive_name) # The canonical name should be an English name, but just in case: canonicalname = normname - warning = document.reporter.warning( - msg_text, line=document.current_line) - messages.append(warning) + if msg_text: + message = document.reporter.info( + '\n'.join(msg_text), line=document.current_line) + messages.append(message) try: modulename, functionname = _directive_registry[canonicalname] except KeyError: -- cgit v1.2.1 From 855c2a721ff3d63b9450eb71c200fe97a418ef33 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 14 Nov 2002 02:25:38 +0000 Subject: Return ``None`` for missing language modules. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@948 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/__init__.py b/docutils/parsers/rst/languages/__init__.py index 8f78fc481..86bfd03ba 100644 --- a/docutils/parsers/rst/languages/__init__.py +++ b/docutils/parsers/rst/languages/__init__.py @@ -16,6 +16,9 @@ _languages = {} def get_language(language_code): if _languages.has_key(language_code): return _languages[language_code] - module = __import__(language_code, globals(), locals()) + try: + module = __import__(language_code, globals(), locals()) + except ImportError: + return None _languages[language_code] = module return module -- cgit v1.2.1 From 77f2ee4872ec99a61ca1756c2dad1be556877a3a Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 14 Nov 2002 02:31:34 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@949 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/sv.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index b68040cf3..36a576343 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -21,19 +21,18 @@ directives = { u'notera': 'note', u'tips': 'tip', u'varning': 'warning', - u'fr\u00e5gor': 'questions', + # u'fr\u00e5gor': 'questions', # NOTE: A bit long, but recommended by http://www.nada.kth.se/dataterm/: - u'fr\u00e5gor-och-svar': 'questions', - u'vanliga-fr\u00e5gor': 'questions', + # u'fr\u00e5gor-och-svar': 'questions', + # u'vanliga-fr\u00e5gor': 'questions', u'meta': 'meta', # u'bildkarta': 'imagemap', # FIXME: Translation might be too literal. u'bild': 'image', u'figur': 'figure', - # u'r\u00e5': 'raw', # FIXME: Translation might be too literal. + u'r\u00e5': 'raw', # FIXME: Translation might be too literal. u'inneh\u00e5ll': 'contents', # u'fotnoter': 'footnotes', # u'citeringar': 'citations', - # u'\u00e4mne': 'topic', - u'restructuredtext-test-directive': 'restructuredtext-test-directive' } + u'\u00e4mne': 'topic'} """Swedish name to registered (in directives/__init__.py) directive name mapping.""" -- cgit v1.2.1 From c5ce75c3c1fb6a65e9f61b968238a7cbc79e2d35 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 14 Nov 2002 02:43:49 +0000 Subject: Slovak mappings, by Miroslav Vasko. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@950 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/sk.py | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 docutils/parsers/rst/languages/sk.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/sk.py b/docutils/parsers/rst/languages/sk.py new file mode 100644 index 000000000..e23bc3988 --- /dev/null +++ b/docutils/parsers/rst/languages/sk.py @@ -0,0 +1,45 @@ +# Author: Miroslav Vasko +# Contact: zemiak@zoznam.sk +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +""" +Slovak-language mappings for language-dependent features of +reStructuredText. +""" + +__docformat__ = 'reStructuredText' + + +directives = { + u'pozor': 'attention', + u'opatrne': 'caution', + u'nebezpe\xe8enstvo': 'danger', + u'chyba': 'error', + u'rada': 'hint', + u'd\xf4le\x9eit\xe9': 'important', + u'pozn\xe1mka': 'note', + u'tip': 'tip', + u'varovanie': 'warning', + u't\xe9ma': 'topic', + u'blok-riadkov': 'line-block', + u'parsed-literal': 'parsed-literal', + #u'questions': 'questions', + #u'qa': 'questions', + #u'faq': 'questions', + u'meta': 'meta', + #u'imagemap': 'imagemap', + u'obr\xe1zok': 'image', + u'tvar': 'figure', + u'vlo\x9ei\x9d': 'include', + u'raw': 'raw', + u'nahradi\x9d': 'replace', + u'obsah': 'contents', + u'\xe8as\x9d': 'sectnum', + u'\xe8as\x9d-\xe8\xedslovanie': 'sectnum', + u'cie\xbeov\xe9-pozn\xe1mky': 'target-notes', + #u'footnotes': 'footnotes', + #u'citations': 'citations',} +"""Slovak name to registered (in directives/__init__.py) directive name +mapping.""" -- cgit v1.2.1 From dcd1c7643fe745cbd8dd0637bef9390c390d584b Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 14 Nov 2002 02:51:50 +0000 Subject: typo git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@952 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/sk.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/sk.py b/docutils/parsers/rst/languages/sk.py index e23bc3988..e88fda694 100644 --- a/docutils/parsers/rst/languages/sk.py +++ b/docutils/parsers/rst/languages/sk.py @@ -40,6 +40,7 @@ directives = { u'\xe8as\x9d-\xe8\xedslovanie': 'sectnum', u'cie\xbeov\xe9-pozn\xe1mky': 'target-notes', #u'footnotes': 'footnotes', - #u'citations': 'citations',} + #u'citations': 'citations', + } """Slovak name to registered (in directives/__init__.py) directive name mapping.""" -- cgit v1.2.1 From 3d389e7cded3fe068f30fab1546e87ff6e79ccc9 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 16 Nov 2002 02:27:00 +0000 Subject: Enabled recognition of schemeless email addresses in targets. Added support for embedded URIs in hyperlink references. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@954 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 84 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 68 insertions(+), 16 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 9c4eeafab..3f49a9954 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -534,9 +534,17 @@ class Inliner: non_whitespace_after = r'(?![ \n])' # Alphanumerics with isolated internal [-._] chars (i.e. not 2 together): simplename = r'(?:(?!_)\w)+(?:[-._](?:(?!_)\w)+)*' + # Valid URI characters (see RFC 2396 & RFC 2732): uric = r"""[-_.!~*'()[\];/:@&=+$,%a-zA-Z0-9]""" - urilast = r"""[_~/\]a-zA-Z0-9]""" # no punctuation + # Last URI character; same as uric but no punctuation: + urilast = r"""[_~/a-zA-Z0-9]""" emailc = r"""[-_!~*'{|}/#?^`&=+$%a-zA-Z0-9]""" + email_pattern = r""" + %(emailc)s+(?:\.%(emailc)s+)* # name + @ # at + %(emailc)s+(?:\.%(emailc)s*)* # host + %(urilast)s # final URI char + """ parts = ('initial_inline', start_string_prefix, '', [('start', '', non_whitespace_after, # simple start-strings [r'\*\*', # strong @@ -581,6 +589,18 @@ class Inliner: ) %(end_string_suffix)s """ % locals(), re.VERBOSE | re.UNICODE), + embedded_uri=re.compile( + r""" + ( + [ \n]+ # spaces or beginning of line + < # open bracket + %(non_whitespace_after)s + ([^<>\0]+) # anything but angle brackets & nulls + %(non_whitespace_before)s + > # close bracket w/o whitespace before + ) + $ # end of string + """ % locals(), re.VERBOSE), literal=re.compile(non_whitespace_before + '(``)' + end_string_suffix), target=re.compile(non_whitespace_escape_before @@ -588,8 +608,9 @@ class Inliner: substitution_ref=re.compile(non_whitespace_escape_before + r'(\|_{0,2})' + end_string_suffix), + email=re.compile(email_pattern % locals() + '$', re.VERBOSE), uri=re.compile( - r""" + (r""" %(start_string_prefix)s (?P (?P # absolute URI @@ -615,14 +636,11 @@ class Inliner: ) | # *OR* (?P # email address - %(emailc)s+(\.%(emailc)s+)* # name - @ # at - %(emailc)s+(\.%(emailc)s*)* # host - %(urilast)s # final URI char + """ + email_pattern + r""" ) ) %(end_string_suffix)s - """ % locals(), re.VERBOSE), + """) % locals(), re.VERBOSE), pep=re.compile( r""" %(start_string_prefix)s @@ -736,7 +754,7 @@ class Inliner: prb = self.problematic(text, text, msg) return string[:rolestart], [prb], string[textend:], [msg] return self.phrase_ref(string[:matchstart], string[textend:], - rawsource, text) + rawsource, escaped, text) else: return self.interpreted(string[:rolestart], string[textend:], rawsource, text, role, position) @@ -747,16 +765,46 @@ class Inliner: prb = self.problematic(text, text, msg) return string[:matchstart], [prb], string[matchend:], [msg] - def phrase_ref(self, before, after, rawsource, text): + def phrase_ref(self, before, after, rawsource, escaped, text): + match = self.patterns.embedded_uri.search(escaped) + if match: + text = unescape(escaped[:match.start(0)]) + uri_text = match.group(2) + uri = ''.join(uri_text.split()) + uri = self.adjust_uri(uri) + if uri: + target = nodes.target(match.group(1), refuri=uri) + else: + raise ApplicationError('problem with URI: %r' % uri_text) + else: + target = None refname = normalize_name(text) reference = nodes.reference(rawsource, text) + node_list = [reference] if rawsource[-2:] == '__': - reference['anonymous'] = 1 - self.document.note_anonymous_ref(reference) + if target: + reference['refuri'] = uri + else: + reference['anonymous'] = 1 + self.document.note_anonymous_ref(reference) else: - reference['refname'] = refname - self.document.note_refname(reference) - return before, [reference], after, [] + if target: + reference['refuri'] = uri + target['name'] = refname + self.document.note_external_target(target) + self.document.note_explicit_target(target, self.parent) + node_list.append(target) + else: + reference['refname'] = refname + self.document.note_refname(reference) + return before, node_list, after, [] + + def adjust_uri(self, uri): + match = self.patterns.email.match(uri) + if match: + return 'mailto:' + uri + else: + return uri def interpreted(self, before, after, rawsource, text, role, position): if role: @@ -1639,8 +1687,12 @@ class Body(RSTState): name = normalize_name(unescape(targetname)) target['name'] = name if refuri: - target['refuri'] = refuri - self.document.note_external_target(target) + uri = self.inliner.adjust_uri(refuri) + if uri: + target['refuri'] = uri + self.document.note_external_target(target) + else: + raise ApplicationError('problem with URI: %r' % refuri) else: self.document.note_internal_target(target) self.document.note_explicit_target(target, self.parent) -- cgit v1.2.1 From 872c2c52b9aac7313cdcb135cdd8da81fb256142 Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 19 Nov 2002 02:34:42 +0000 Subject: Fixed "include" directive path manipulation & encoding bugs. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@965 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 3ff9eb93f..b9409aca8 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -11,15 +11,16 @@ __docformat__ = 'reStructuredText' import sys import os.path from urllib2 import urlopen, URLError -from docutils import nodes, statemachine, utils +from docutils import io, nodes, statemachine, utils from docutils.parsers.rst import directives, states def include(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): """Include a reST file as part of the content of this reST file.""" - source_dir = os.path.dirname( - os.path.abspath(state.document.current_source)) + source = state_machine.input_lines.source( + lineno - state_machine.input_offset - 1) + source_dir = os.path.dirname(os.path.abspath(source)) path = ''.join(arguments[0].splitlines()) if path.find(' ') != -1: error = state_machine.reporter.error( @@ -29,14 +30,13 @@ def include(name, arguments, options, content, lineno, path = os.path.normpath(os.path.join(source_dir, path)) path = utils.relative_path(None, path) try: - include_file = open(path) + include_file = io.FileInput(state.document.settings, source_path=path) except IOError, error: severe = state_machine.reporter.severe( 'Problems with "%s" directive path:\n%s.' % (name, error), nodes.literal_block(block_text, block_text), line=lineno) return [severe] include_text = include_file.read() - include_file.close() if options.has_key('literal'): literal_block = nodes.literal_block(include_text, include_text, source=path) -- cgit v1.2.1 From df0b272dc4cd35d6b1ab106ffd1285c7da2177ac Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 19 Nov 2002 02:37:08 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@966 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 1 - 1 file changed, 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 3f49a9954..5ddcbb5bb 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1801,7 +1801,6 @@ class Body(RSTState): """ arguments = [] options = {} - content = [] argument_spec = getattr(directive_fn, 'arguments', None) if argument_spec and argument_spec[:2] == (0, 0): argument_spec = None -- cgit v1.2.1 From 29b0b7275b12f306a4753590fb7012006745ad45 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 21 Nov 2002 02:23:46 +0000 Subject: expanded docstring git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@969 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/__init__.py | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/__init__.py b/docutils/parsers/rst/__init__.py index ad60a319d..b242ad9cb 100644 --- a/docutils/parsers/rst/__init__.py +++ b/docutils/parsers/rst/__init__.py @@ -8,15 +8,16 @@ This is ``docutils.parsers.rst`` package. It exports a single class, `Parser`, the reStructuredText parser. + Usage ===== 1. Create a parser:: - parser = docutils.parsers.restructuredtext.Parser() + parser = docutils.parsers.rst.Parser() Several optional arguments may be passed to modify the parser's behavior. - Please see `docutils.parsers.Parser` for details. + Please see `Customizing the Parser`_ below for details. 2. Gather input (a multi-line string), by reading a file or the standard input:: @@ -25,7 +26,7 @@ Usage 3. Create a new empty `docutils.nodes.document` tree:: - document = docutils.utils.new_document(source) + document = docutils.utils.new_document(source, settings) See `docutils.utils.new_document()` for parameter details. @@ -33,6 +34,7 @@ Usage parser.parse(input, document) + Parser Overview =============== @@ -40,6 +42,31 @@ The reStructuredText parser is implemented as a state machine, examining its input one line at a time. To understand how the parser works, please first 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). """ __docformat__ = 'reStructuredText' -- cgit v1.2.1 From 673c882e62ff706d8706218bfe74c203c46c87f5 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 28 Nov 2002 03:45:11 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@983 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index b9409aca8..cc8019886 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -30,7 +30,8 @@ def include(name, arguments, options, content, lineno, path = os.path.normpath(os.path.join(source_dir, path)) path = utils.relative_path(None, path) try: - include_file = io.FileInput(state.document.settings, source_path=path) + include_file = io.FileInput( + source_path=path, encoding=state.document.settings.input_encoding) except IOError, error: severe = state_machine.reporter.severe( 'Problems with "%s" directive path:\n%s.' % (name, error), -- cgit v1.2.1 From a5017ad1128d5d901ce4c80c31cf4d06a43d5637 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 12 Dec 2002 02:44:44 +0000 Subject: fixed a bug with ellipsis etc. (<=3 char underline) on second line of a block quote paragraph git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1013 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 5ddcbb5bb..ab1266f9a 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -2382,24 +2382,18 @@ class Text(RSTState): def underline(self, match, context, next_state): """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() source = title + '\n' + underline messages = [] 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 + 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: blocktext = context[0] + '\n' + self.state_machine.line @@ -2407,6 +2401,14 @@ class Text(RSTState): 'Title underline too short.', 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[:] = [] self.section(title, source, style, lineno - 1, messages) -- cgit v1.2.1 From eb82300e688f6e452b1db58d5abadd76be56025d Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 17 Dec 2002 02:25:19 +0000 Subject: Added support for backslash-escape after inline markup. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1023 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index ab1266f9a..fb95cdd6a 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -528,7 +528,7 @@ class Inliner: openers = '\'"([{<' closers = '\'")]}>' start_string_prefix = (r'((?<=^)|(?<=[-/: \n%s]))' % re.escape(openers)) - end_string_suffix = (r'((?=$)|(?=[-/:.,;!? \n%s]))' % re.escape(closers)) + end_string_suffix = (r'((?=$)|(?=[-/:.,;!? \n\x00%s]))' % re.escape(closers)) non_whitespace_before = r'(? Date: Sun, 29 Dec 2002 16:18:41 +0000 Subject: Italian language support by Nicola Larosa git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1044 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/it.py | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 docutils/parsers/rst/languages/it.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py new file mode 100644 index 000000000..fe7610eb0 --- /dev/null +++ b/docutils/parsers/rst/languages/it.py @@ -0,0 +1,46 @@ +# Author: Nicola Larosa +# Contact: docutils@tekNico.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +""" +Italian-language mappings for language-dependent features of +reStructuredText. +""" + +__docformat__ = 'reStructuredText' + + +directives = { + 'attenzione': 'attention', + 'cautela': 'caution', + 'pericolo': 'danger', + 'errore': 'error', + 'suggerimento': 'hint', + 'importante': 'important', + 'nota': 'note', + 'consiglio': 'tip', + 'avvertenza': 'warning', + 'argomento': 'topic', + 'blocco di linee': 'line-block', + 'parsed-literal': 'parsed-literal', + #'questions': 'questions', + #'qa': 'questions', + #'faq': 'questions', + 'meta': 'meta', + #'imagemap': 'imagemap', + 'immagine': 'image', + 'figura': 'figure', + 'includi': 'include', + 'grezzo': 'raw', + 'sostituisci': 'replace', + 'indice': 'contents', + 'seznum': 'sectnum', + 'section-numbering': 'sectnum', + 'target-notes': 'target-notes', + #'footnotes': 'footnotes', + #'citations': 'citations', + 'restructuredtext-test-directive': 'restructuredtext-test-directive'} +"""English name to registered (in directives/__init__.py) directive name +mapping.""" -- cgit v1.2.1 From f6d2823bed3483be7c3a126c2499d7e9018fae8d Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 1 Jan 2003 02:41:16 +0000 Subject: redundant; CVSROOT/cvsignore is global git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1048 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/.cvsignore | 1 - docutils/parsers/rst/.cvsignore | 1 - docutils/parsers/rst/directives/.cvsignore | 1 - docutils/parsers/rst/languages/.cvsignore | 1 - 4 files changed, 4 deletions(-) delete mode 100644 docutils/parsers/.cvsignore delete mode 100644 docutils/parsers/rst/.cvsignore delete mode 100644 docutils/parsers/rst/directives/.cvsignore delete mode 100644 docutils/parsers/rst/languages/.cvsignore (limited to 'docutils/parsers') diff --git a/docutils/parsers/.cvsignore b/docutils/parsers/.cvsignore deleted file mode 100644 index 0d20b6487..000000000 --- a/docutils/parsers/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/docutils/parsers/rst/.cvsignore b/docutils/parsers/rst/.cvsignore deleted file mode 100644 index 0d20b6487..000000000 --- a/docutils/parsers/rst/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/docutils/parsers/rst/directives/.cvsignore b/docutils/parsers/rst/directives/.cvsignore deleted file mode 100644 index 0d20b6487..000000000 --- a/docutils/parsers/rst/directives/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/docutils/parsers/rst/languages/.cvsignore b/docutils/parsers/rst/languages/.cvsignore deleted file mode 100644 index 0d20b6487..000000000 --- a/docutils/parsers/rst/languages/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc -- cgit v1.2.1 From 56b72a68001ef0999d3447f566220bd3145556e8 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 3 Jan 2003 00:47:13 +0000 Subject: placeholder translations; awaiting the real thing git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1051 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/fr.py | 46 ++++++++++++++++++++++++++++++++++++ docutils/parsers/rst/languages/sv.py | 12 ++++++++-- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 docutils/parsers/rst/languages/fr.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py new file mode 100644 index 000000000..19cdc5be8 --- /dev/null +++ b/docutils/parsers/rst/languages/fr.py @@ -0,0 +1,46 @@ +# Author: your name here! +# Contact: goodger@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +""" +French-language mappings for language-dependent features of +reStructuredText. +""" + +__docformat__ = 'reStructuredText' + + +directives = { + 'attention (translation required)': 'attention', + 'caution (translation required)': 'caution', + 'danger (translation required)': 'danger', + 'error (translation required)': 'error', + 'hint (translation required)': 'hint', + 'important (translation required)': 'important', + 'note (translation required)': 'note', + 'tip (translation required)': 'tip', + 'warning (translation required)': 'warning', + 'topic (translation required)': 'topic', + 'line-block (translation required)': 'line-block', + 'parsed-literal (translation required)': 'parsed-literal', + #'questions (translation required)': 'questions', + #'qa (translation required)': 'questions', + #'faq (translation required)': 'questions', + 'meta (translation required)': 'meta', + #'imagemap (translation required)': 'imagemap', + 'image (translation required)': 'image', + 'figure (translation required)': 'figure', + 'include (translation required)': 'include', + 'raw (translation required)': 'raw', + 'replace (translation required)': 'replace', + 'contents (translation required)': 'contents', + 'sectnum (translation required)': 'sectnum', + 'section-numbering (translation required)': 'sectnum', + 'target-notes (translation required)': 'target-notes', + #'footnotes (translation required)': 'footnotes', + #'citations (translation required)': 'citations', + } +"""French name to registered (in directives/__init__.py) directive name +mapping.""" diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index 36a576343..9686194df 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -13,7 +13,7 @@ __docformat__ = 'reStructuredText' directives = { u'observera': 'attention', - u'varning': 'caution', + u'caution (translation required)': 'caution', u'fara': 'danger', u'fel': 'error', u'v\u00e4gledning': 'hint', @@ -21,6 +21,9 @@ directives = { u'notera': 'note', u'tips': 'tip', u'varning': 'warning', + u'\u00e4mne': 'topic', + 'line-block (translation required)': 'line-block', + 'parsed-literal (translation required)': 'parsed-literal', # u'fr\u00e5gor': 'questions', # NOTE: A bit long, but recommended by http://www.nada.kth.se/dataterm/: # u'fr\u00e5gor-och-svar': 'questions', @@ -29,10 +32,15 @@ directives = { # u'bildkarta': 'imagemap', # FIXME: Translation might be too literal. u'bild': 'image', u'figur': 'figure', + 'include (translation required)': 'include', u'r\u00e5': 'raw', # FIXME: Translation might be too literal. + 'replace (translation required)': 'replace', u'inneh\u00e5ll': 'contents', + 'sectnum (translation required)': 'sectnum', + 'section-numbering (translation required)': 'sectnum', + 'target-notes (translation required)': 'target-notes', # u'fotnoter': 'footnotes', # u'citeringar': 'citations', - u'\u00e4mne': 'topic'} + } """Swedish name to registered (in directives/__init__.py) directive name mapping.""" -- cgit v1.2.1 From ac1c77d4c74b175a60843b9f628c1afe8aeb3da1 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 3 Jan 2003 00:49:44 +0000 Subject: Python 2.3 compatibility fix git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1053 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index fb95cdd6a..8c3f43a30 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1910,7 +1910,7 @@ class Body(RSTState): try: options = utils.extract_extension_options(node, option_spec) except KeyError, detail: - return 0, ('unknown option: "%s"' % detail) + return 0, ('unknown option: "%s"' % detail.args[0]) except (ValueError, TypeError), detail: return 0, ('invalid option value: %s' % detail) except utils.ExtensionOptionError, detail: -- cgit v1.2.1 From edaeb226e0a505faa5ca54f8bb473a534f3e7b81 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 10 Jan 2003 02:12:36 +0000 Subject: Added support for correct interpreted text processing. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1078 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 148 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 140 insertions(+), 8 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 8c3f43a30..2ddd50809 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -113,9 +113,12 @@ from docutils import ApplicationError, DataError from docutils.statemachine import StateMachineWS, StateWS from docutils.utils import normalize_name from docutils.parsers.rst import directives, languages, tableparser +from docutils.parsers.rst.languages import en as _fallback_language_module class MarkupError(DataError): pass +class UnknownInterpretedRoleError(DataError): pass +class InterpretedRoleNotImplementedError(DataError): pass class ParserError(ApplicationError): pass class MarkupMismatch(Exception): pass @@ -466,11 +469,53 @@ class Inliner: Parse inline markup; call the `parse()` method. """ - def __init__(self): + _interpreted_roles = { + # Values of ``None`` mean "not implemented yet": + 'title-reference': 'title_reference_role', + 'abbreviation': None, + 'acronym': None, + 'index': None, + 'emphasis': None, + 'strong': None, + 'literal': None, + 'named-reference': None, + 'anonymous-reference': None, + 'uri-reference': None, + 'pep-reference': 'pep_reference_role', + 'rfc-reference': 'rfc_reference_role', + 'footnote-reference': None, + 'citation-reference': None, + 'substitution-reference': None, + 'target': None, + } + """Mapping of canonical interpreted text role name to method name. + Initializes a name to bound-method mapping in `__init__`.""" + + default_interpreted_role = 'title-reference' + """The role to use when no explicit role is given. + Override in subclasses.""" + + def __init__(self, roles=None): + """ + `roles` is a mapping of canonical role name to role function or bound + method, which enables additional interpreted text roles. + """ + self.implicit_dispatch = [(self.patterns.uri, self.standalone_uri),] """List of (pattern, bound method) tuples, used by `self.implicit_inline`.""" + self.interpreted_roles = {} + """Mapping of canonical role name to role function or bound method. + Items removed from this mapping will be disabled.""" + + for canonical, method in self._interpreted_roles.items(): + if method: + self.interpreted_roles[canonical] = getattr(self, method) + else: + self.interpreted_roles[canonical] = None + self.interpreted_roles.update(roles or {}) + def init_customizations(self, settings): """Setting-based customizations; run when parsing begins.""" if settings.pep_references: @@ -496,6 +541,7 @@ class Inliner: """ self.reporter = memo.reporter self.document = memo.document + self.language = memo.language self.parent = parent pattern_search = self.patterns.initial.search dispatch = self.dispatch @@ -528,7 +574,8 @@ class Inliner: openers = '\'"([{<' closers = '\'")]}>' start_string_prefix = (r'((?<=^)|(?<=[-/: \n%s]))' % re.escape(openers)) - end_string_suffix = (r'((?=$)|(?=[-/:.,;!? \n\x00%s]))' % re.escape(closers)) + end_string_suffix = (r'((?=$)|(?=[-/:.,;!? \n\x00%s]))' + % re.escape(closers)) non_whitespace_before = r'(? 9999: + raise ValueError + except ValueError: + msg = self.reporter.error( + 'PEP number must be a number from 0 to 9999; "%s" is invalid.' + % text, line=lineno) + prb = self.problematic(text, text, msg) + return [prb], [msg] + ref = self.pep_url % pepnum + return [nodes.reference(rawtext, 'PEP ' + text, refuri=ref)], [] + + def rfc_reference_role(self, role, rawtext, text, lineno): + try: + rfcnum = int(text) + if rfcnum <= 0: + raise ValueError + except ValueError: + msg = self.reporter.error( + 'RFC number must be a number greater than or equal to 1; ' + '"%s" is invalid.' % text, line=lineno) + prb = self.problematic(text, text, msg) + return [prb], [msg] + ref = self.rfc_url % rfcnum + return [nodes.reference(rawtext, 'RFC ' + text, refuri=ref)], [] + class Body(RSTState): -- cgit v1.2.1 From d95ba708da2b525259ed786ab17eeb1f5830a112 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 10 Jan 2003 02:13:10 +0000 Subject: Added interpreted text roles mapping. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1079 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/en.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index 0d5e0da34..60bd8b733 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -44,3 +44,33 @@ directives = { 'restructuredtext-test-directive': 'restructuredtext-test-directive'} """English name to registered (in directives/__init__.py) directive name mapping.""" + +roles = { + 'abbreviation': 'abbreviation', + 'ab': 'abbreviation', + 'acronym': 'acronym', + 'ac': 'acronym', + 'index': 'index', + 'i': 'index', + 'title-reference': 'title-reference', + 'title': 'title-reference', + 't': 'title-reference', + 'pep-reference': 'pep-reference', + 'pep': 'pep-reference', + 'rfc-reference': 'rfc-reference', + 'rfc': 'rfc-reference', + 'emphasis': 'emphasis', + 'strong': 'strong', + 'literal': 'literal', + 'named-reference': 'named-reference', + 'anonymous-reference': 'anonymous-reference', + 'footnote-reference': 'footnote-reference', + 'citation-reference': 'citation-reference', + 'substitution-reference': 'substitution-reference', + 'target': 'target', + 'uri-reference': 'uri-reference', + 'uri': 'uri-reference', + 'url': 'uri-reference', + } +"""Mapping of English role names to canonical role names for interpreted text. +""" -- cgit v1.2.1 From c6a8b09215bf080177a35cbd1ad9154be6328970 Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 21 Jan 2003 18:24:54 +0000 Subject: correction git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1151 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 2ddd50809..e7b5a91a7 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1974,7 +1974,7 @@ class Body(RSTState): arguments = self.parse_directive_arguments(argument_spec, arg_block) if content and not content_spec: - raise MarkupError('no content permitted.') + raise MarkupError('no content permitted') except MarkupError, detail: error = self.reporter.error( 'Error in "%s" directive:\n%s.' % (type_name, detail), -- cgit v1.2.1 From 22a29d348c7ca6a4d8f0d080f3edd07e7397eec5 Mon Sep 17 00:00:00 2001 From: chodorowski Date: Tue, 28 Jan 2003 18:15:19 +0000 Subject: Translated some more terms. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1155 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/sv.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index 9686194df..419ea4257 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -32,12 +32,11 @@ directives = { # u'bildkarta': 'imagemap', # FIXME: Translation might be too literal. u'bild': 'image', u'figur': 'figure', - 'include (translation required)': 'include', + u'inkludera': 'include', u'r\u00e5': 'raw', # FIXME: Translation might be too literal. - 'replace (translation required)': 'replace', + u'ers\u00e4tt': 'replace', u'inneh\u00e5ll': 'contents', - 'sectnum (translation required)': 'sectnum', - 'section-numbering (translation required)': 'sectnum', + u'sektionsnumrering': 'sectnum', 'target-notes (translation required)': 'target-notes', # u'fotnoter': 'footnotes', # u'citeringar': 'citations', -- cgit v1.2.1 From c20a5143b933667b65436e21e5e5a24ef927cc6e Mon Sep 17 00:00:00 2001 From: fdrake Date: Tue, 4 Feb 2003 16:58:40 +0000 Subject: Add a source encoding declaration for Python 2.3; this avoids a compile-time warning for this file. I *think* Latin-1 is the right encoding; hopefully someone more knowledgable can confirm. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1160 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/de.py | 1 + 1 file changed, 1 insertion(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index 25e6c4dd6..78cbc1b0e 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -1,3 +1,4 @@ +# -*- coding: iso-8859-1 -*- # Author: Engelbert Gruber # Contact: grubert@users.sourceforge.net # Revision: $Revision$ -- cgit v1.2.1 From 9d4fcb00e8f6023b8ab16b20679198ffbd1acf45 Mon Sep 17 00:00:00 2001 From: pobrien Date: Thu, 20 Feb 2003 14:19:55 +0000 Subject: Added sidebar directive. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1193 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 1 + docutils/parsers/rst/directives/body.py | 27 +++++++++++++++++++++++++++ docutils/parsers/rst/languages/de.py | 1 + docutils/parsers/rst/languages/en.py | 1 + docutils/parsers/rst/languages/fr.py | 1 + docutils/parsers/rst/languages/it.py | 1 + docutils/parsers/rst/languages/sk.py | 1 + docutils/parsers/rst/languages/sv.py | 1 + 8 files changed, 34 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 4593d8f23..93461c1ed 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -92,6 +92,7 @@ _directive_registry = { 'tip': ('admonitions', 'tip'), 'hint': ('admonitions', 'hint'), 'warning': ('admonitions', 'warning'), + 'sidebar': ('body', 'sidebar'), 'topic': ('body', 'topic'), 'line-block': ('body', 'line_block'), 'parsed-literal': ('body', 'parsed_literal'), diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index 8bc2d7a4f..9793e0bc3 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -13,6 +13,7 @@ __docformat__ = 'reStructuredText' import sys from docutils import nodes +from docutils.parsers.rst import directives def topic(name, arguments, options, content, lineno, @@ -40,6 +41,32 @@ def topic(name, arguments, options, content, lineno, topic.arguments = (1, 0, 1) topic.content = 1 +def sidebar(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + if not state_machine.match_titles: + error = state_machine.reporter.error( + 'Sidebars may not be nested within sidebars or body elements.', + nodes.literal_block(block_text, block_text), line=lineno) + return [error] + if not content: + warning = state_machine.reporter.warning( + 'Content block expected for the "%s" directive; none found.' + % name, nodes.literal_block(block_text, block_text), + line=lineno) + return [warning] + title_text = arguments[0] + textnodes, messages = state.inline_text(title_text, lineno) + title = nodes.title(title_text, '', *textnodes) + text = '\n'.join(content) + sidebar_node = nodes.sidebar(text, title, *messages, **options) + if text: + state.nested_parse(content, content_offset, sidebar_node) + return [sidebar_node] + +sidebar.arguments = (1, 0, 1) +sidebar.options = {'subtitle': directives.unchanged} +sidebar.content = 1 + def line_block(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine, node_class=nodes.line_block): diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index 78cbc1b0e..fafb6f4fa 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -23,6 +23,7 @@ directives = { 'notiz': 'note', 'tip': 'tip', 'warnung': 'warning', + 'sidebar (translation required)': 'sidebar', 'topic': 'topic', # Überbegriff 'line-block': 'line-block', 'parsed-literal': 'parsed-literal', diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index 60bd8b733..7d0976471 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -22,6 +22,7 @@ directives = { 'note': 'note', 'tip': 'tip', 'warning': 'warning', + 'sidebar': 'sidebar', 'topic': 'topic', 'line-block': 'line-block', 'parsed-literal': 'parsed-literal', diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index 19cdc5be8..4a7d85176 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -22,6 +22,7 @@ directives = { 'note (translation required)': 'note', 'tip (translation required)': 'tip', 'warning (translation required)': 'warning', + 'sidebar (translation required)': 'sidebar', 'topic (translation required)': 'topic', 'line-block (translation required)': 'line-block', 'parsed-literal (translation required)': 'parsed-literal', diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index fe7610eb0..93cba7936 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -22,6 +22,7 @@ directives = { 'nota': 'note', 'consiglio': 'tip', 'avvertenza': 'warning', + 'sidebar (translation required)': 'sidebar', 'argomento': 'topic', 'blocco di linee': 'line-block', 'parsed-literal': 'parsed-literal', diff --git a/docutils/parsers/rst/languages/sk.py b/docutils/parsers/rst/languages/sk.py index e88fda694..585bf934d 100644 --- a/docutils/parsers/rst/languages/sk.py +++ b/docutils/parsers/rst/languages/sk.py @@ -22,6 +22,7 @@ directives = { u'pozn\xe1mka': 'note', u'tip': 'tip', u'varovanie': 'warning', + u'sidebar (translation required)': 'sidebar', u't\xe9ma': 'topic', u'blok-riadkov': 'line-block', u'parsed-literal': 'parsed-literal', diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index 419ea4257..c63922c5e 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -21,6 +21,7 @@ directives = { u'notera': 'note', u'tips': 'tip', u'varning': 'warning', + u'sidebar (translation required)': 'sidebar', u'\u00e4mne': 'topic', 'line-block (translation required)': 'line-block', 'parsed-literal (translation required)': 'parsed-literal', -- cgit v1.2.1 From 813c817e2696f9eba43e10cd147ba4a04244a1d1 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 20 Feb 2003 22:35:49 +0000 Subject: sidebar improvements git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1196 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/body.py | 41 +++++++++++++-------------------- docutils/parsers/rst/states.py | 3 ++- 2 files changed, 18 insertions(+), 26 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index 9793e0bc3..f24edb325 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -17,10 +17,12 @@ from docutils.parsers.rst import directives def topic(name, arguments, options, content, lineno, - content_offset, block_text, state, state_machine): + content_offset, block_text, state, state_machine, + node_class=nodes.topic): if not state_machine.match_titles: error = state_machine.reporter.error( - 'Topics may not be nested within topics or body elements.', + 'The "%s" directive may not be used within topics, sidebars, ' + 'or body elements.' % name, nodes.literal_block(block_text, block_text), line=lineno) return [error] if not content: @@ -31,37 +33,26 @@ def topic(name, arguments, options, content, lineno, return [warning] title_text = arguments[0] textnodes, messages = state.inline_text(title_text, lineno) - title = nodes.title(title_text, '', *textnodes) + titles = [nodes.title(title_text, '', *textnodes)] + if options.has_key('subtitle'): + textnodes, more_messages = state.inline_text(options['subtitle'], + lineno) + titles.append(nodes.subtitle(options['subtitle'], '', *textnodes)) + messages.extend(more_messages) text = '\n'.join(content) - topic_node = nodes.topic(text, title, *messages) + node = node_class(text, *(titles + messages)) if text: - state.nested_parse(content, content_offset, topic_node) - return [topic_node] + state.nested_parse(content, content_offset, node) + return [node] topic.arguments = (1, 0, 1) topic.content = 1 def sidebar(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): - if not state_machine.match_titles: - error = state_machine.reporter.error( - 'Sidebars may not be nested within sidebars or body elements.', - nodes.literal_block(block_text, block_text), line=lineno) - return [error] - if not content: - warning = state_machine.reporter.warning( - 'Content block expected for the "%s" directive; none found.' - % name, nodes.literal_block(block_text, block_text), - line=lineno) - return [warning] - title_text = arguments[0] - textnodes, messages = state.inline_text(title_text, lineno) - title = nodes.title(title_text, '', *textnodes) - text = '\n'.join(content) - sidebar_node = nodes.sidebar(text, title, *messages, **options) - if text: - state.nested_parse(content, content_offset, sidebar_node) - return [sidebar_node] + return topic(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine, + node_class=nodes.sidebar) sidebar.arguments = (1, 0, 1) sidebar.options = {'subtitle': directives.unchanged} diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index e7b5a91a7..d10b07a68 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -2147,7 +2147,8 @@ class Body(RSTState): self.state_machine.input_lines[offset:], input_offset=self.state_machine.abs_line_offset() + 1, node=self.parent, initial_state='Explicit', - blank_finish=blank_finish) + blank_finish=blank_finish, + match_titles=self.state_machine.match_titles) self.goto_line(newline_offset) if not blank_finish: self.parent += self.unindent_warning('Explicit markup') -- cgit v1.2.1 From 3cf105681c70001de69a7bc12e5d77dee6329e61 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 22 Mar 2003 06:02:17 +0000 Subject: support & docs for character-level inline markup git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1226 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index d10b07a68..68b3b6853 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -2820,8 +2820,13 @@ def escape2null(text): start = found + 2 # skip character after escape def unescape(text, restore_backslashes=0): - """Return a string with nulls removed or restored to backslashes.""" + """ + Return a string with nulls removed or restored to backslashes. + Backslash-escaped spaces are also removed. + """ if restore_backslashes: return text.replace('\x00', '\\') else: - return ''.join(text.split('\x00')) + for sep in ['\x00 ', '\x00\n', '\x00']: + text = ''.join(text.split(sep)) + return text -- cgit v1.2.1 From adf281a00341eae13815afb97acf04ded5fa6f2d Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 27 Mar 2003 00:28:07 +0000 Subject: beginnings of substitution case-sensitizing git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1235 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 68b3b6853..d712cbea2 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -111,7 +111,7 @@ from types import TupleType from docutils import nodes, statemachine, utils, roman, urischemes from docutils import ApplicationError, DataError from docutils.statemachine import StateMachineWS, StateWS -from docutils.utils import normalize_name +from docutils.nodes import fully_normalize_name as normalize_name from docutils.parsers.rst import directives, languages, tableparser from docutils.parsers.rst.languages import en as _fallback_language_module -- cgit v1.2.1 From 1c87d959eb6be73667ca61bbb48d69b075a846df Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 27 Mar 2003 03:56:37 +0000 Subject: substitutions made case-sensitive but forgiving (case-insensitive fallback) git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1236 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 58 +++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 34 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index d712cbea2..481ac1259 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -936,26 +936,22 @@ class Inliner: match, lineno, self.patterns.substitution_ref, nodes.substitution_reference) if len(inlines) == 1: - subrefnode = inlines[0] - if isinstance(subrefnode, nodes.substitution_reference): - subreftext = subrefnode.astext() - refname = normalize_name(subreftext) - subrefnode['refname'] = refname - self.document.note_substitution_ref( - subrefnode) + subref_node = inlines[0] + if isinstance(subref_node, nodes.substitution_reference): + subref_text = subref_node.astext() + self.document.note_substitution_ref(subref_node, subref_text) if endstring[-1:] == '_': - referencenode = nodes.reference( - '|%s%s' % (subreftext, endstring), '') + reference_node = nodes.reference( + '|%s%s' % (subref_text, endstring), '') if endstring[-2:] == '__': - referencenode['anonymous'] = 1 + reference_node['anonymous'] = 1 self.document.note_anonymous_ref( - referencenode) + reference_node) else: - referencenode['refname'] = refname - self.document.note_refname( - referencenode) - referencenode += subrefnode - inlines = [referencenode] + reference_node['refname'] = normalize_name(subref_text) + self.document.note_refname(reference_node) + reference_node += subref_node + inlines = [reference_node] return before, inlines, remaining, sysmessages def footnote_reference(self, match, lineno): @@ -1864,34 +1860,31 @@ class Body(RSTState): while block and not block[-1].strip(): block.pop() subname = subdefmatch.group('name') - name = normalize_name(subname) - substitutionnode = nodes.substitution_definition( - blocktext, name=name, alt=subname) - substitutionnode.line = lineno + substitution_node = nodes.substitution_definition(blocktext) + substitution_node.line = lineno + self.document.note_substitution_def( + substitution_node,subname, self.parent) if block: block[0] = block[0].strip() new_abs_offset, blank_finish = self.nested_list_parse( - block, input_offset=offset, node=substitutionnode, + block, input_offset=offset, node=substitution_node, initial_state='SubstitutionDef', blank_finish=blank_finish) i = 0 - for node in substitutionnode[:]: + for node in substitution_node[:]: if not (isinstance(node, nodes.Inline) or isinstance(node, nodes.Text)): - self.parent += substitutionnode[i] - del substitutionnode[i] + self.parent += substitution_node[i] + del substitution_node[i] else: i += 1 - if len(substitutionnode) == 0: + if len(substitution_node) == 0: msg = self.reporter.warning( 'Substitution definition "%s" empty or invalid.' % subname, nodes.literal_block(blocktext, blocktext), line=lineno) return [msg], blank_finish else: - del substitutionnode['alt'] - self.document.note_substitution_def( - substitutionnode, self.parent) - return [substitutionnode], blank_finish + return [substitution_node], blank_finish else: msg = self.reporter.warning( 'Substitution definition "%s" missing contents.' % subname, @@ -2453,11 +2446,8 @@ class SubstitutionDef(Body): initial_transitions = ['embedded_directive', 'text'] def embedded_directive(self, match, context, next_state): - if self.parent.has_key('alt'): - option_presets = {'alt': self.parent['alt']} - else: - option_presets = {} - nodelist, blank_finish = self.directive(match, **option_presets) + nodelist, blank_finish = self.directive(match, + alt=self.parent['name']) self.parent += nodelist if not self.state_machine.at_eof(): self.blank_finish = blank_finish -- cgit v1.2.1 From 5e80a885d5886f2f8f071689143cd2f40f92f27f Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 3 Apr 2003 01:12:26 +0000 Subject: initial rough translations; awaiting native French speaker final translations git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1254 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/fr.py | 59 ++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 29 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index 4a7d85176..c4ff72716 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -13,35 +13,36 @@ __docformat__ = 'reStructuredText' directives = { - 'attention (translation required)': 'attention', - 'caution (translation required)': 'caution', - 'danger (translation required)': 'danger', - 'error (translation required)': 'error', - 'hint (translation required)': 'hint', - 'important (translation required)': 'important', - 'note (translation required)': 'note', - 'tip (translation required)': 'tip', - 'warning (translation required)': 'warning', - 'sidebar (translation required)': 'sidebar', - 'topic (translation required)': 'topic', - 'line-block (translation required)': 'line-block', - 'parsed-literal (translation required)': 'parsed-literal', - #'questions (translation required)': 'questions', - #'qa (translation required)': 'questions', - #'faq (translation required)': 'questions', - 'meta (translation required)': 'meta', - #'imagemap (translation required)': 'imagemap', - 'image (translation required)': 'image', - 'figure (translation required)': 'figure', - 'include (translation required)': 'include', - 'raw (translation required)': 'raw', - 'replace (translation required)': 'replace', - 'contents (translation required)': 'contents', - 'sectnum (translation required)': 'sectnum', - 'section-numbering (translation required)': 'sectnum', - 'target-notes (translation required)': 'target-notes', - #'footnotes (translation required)': 'footnotes', - #'citations (translation required)': 'citations', + u'attention': u'attention', + u'avertissement': u'caution', + u'danger': u'danger', + u'erreur': u'error', + u'indication': u'hint', + u'important': u'important', + u'note': u'note', + u'astuce': u'tip', + u'avis': u'warning', + u'sidebar (translation required)': u'sidebar', + u'topic (translation required)': u'topic', + u'line-block (translation required)': u'line-block', + u'parsed-literal (translation required)': u'parsed-literal', + #u'questions (translation required)': u'questions', + #u'qa (translation required)': u'questions', + #u'faq (translation required)': u'questions', + u'meta (translation required)': u'meta', + #u'imagemap (translation required)': u'imagemap', + u'image': u'image', + u'figure (translation required)': u'figure', + u'inclure': u'include', + u'brut': u'raw', + u'remplacer': u'replace', + u'mati\u00E8res': u'contents', + u'table-des-mati\u00E8res': u'contents', + u'sectnum (translation required)': u'sectnum', + u'section-numbering (translation required)': u'sectnum', + u'target-notes (translation required)': u'target-notes', + #u'footnotes (translation required)': u'footnotes', + #u'citations (translation required)': u'citations', } """French name to registered (in directives/__init__.py) directive name mapping.""" -- cgit v1.2.1 From 6284806f895c09a82ebe4cf5847647726dc8ec55 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 3 Apr 2003 15:22:36 +0000 Subject: updated with translations from William Dode (& me) git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1256 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/fr.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index c4ff72716..455c02b8e 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -1,4 +1,4 @@ -# Author: your name here! +# Authors: David Goodger; William Dode # Contact: goodger@users.sourceforge.net # Revision: $Revision$ # Date: $Date$ @@ -22,25 +22,25 @@ directives = { u'note': u'note', u'astuce': u'tip', u'avis': u'warning', - u'sidebar (translation required)': u'sidebar', - u'topic (translation required)': u'topic', - u'line-block (translation required)': u'line-block', - u'parsed-literal (translation required)': u'parsed-literal', + u'encart': u'sidebar', + u'sujet': u'topic', + u'bloc-ligne': u'line-block', + u'bloc-analys\u00E9': u'parsed-literal', #u'questions (translation required)': u'questions', #u'qa (translation required)': u'questions', #u'faq (translation required)': u'questions', - u'meta (translation required)': u'meta', + u'meta': u'meta', #u'imagemap (translation required)': u'imagemap', u'image': u'image', - u'figure (translation required)': u'figure', + u'figure': u'figure', u'inclure': u'include', u'brut': u'raw', u'remplacer': u'replace', u'mati\u00E8res': u'contents', u'table-des-mati\u00E8res': u'contents', - u'sectnum (translation required)': u'sectnum', - u'section-numbering (translation required)': u'sectnum', - u'target-notes (translation required)': u'target-notes', + u'sectnum': u'sectnum', + u'section-num\u00E9rot\u00E9e': u'sectnum', + u'liens': u'target-notes', #u'footnotes (translation required)': u'footnotes', #u'citations (translation required)': u'citations', } -- cgit v1.2.1 From 85926fa8addd84c3d6411d73039a5bf1c6bc196d Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 18 Apr 2003 21:41:59 +0000 Subject: added "figwidth" option to "figure" directive git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1280 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index 8509bf7fc..8baa223e9 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -15,6 +15,10 @@ import sys from docutils import nodes, utils from docutils.parsers.rst import directives +try: + import Image # PIL +except ImportError: + Image = None align_values = ('top', 'middle', 'bottom', 'left', 'center', 'right') @@ -42,11 +46,24 @@ image.options = {'alt': directives.unchanged, def figure(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): + figwidth = options.setdefault('figwidth') + del options['figwidth'] (image_node,) = image(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine) if isinstance(image_node, nodes.system_message): return [image_node] figure_node = nodes.figure('', image_node) + if figwidth == 'image': + if Image: + # PIL doesn't like Unicode paths: + try: + i = Image.open(str(image_node['uri'])) + except (IOError, UnicodeError): + pass + else: + figure_node['width'] = i.size[0] + elif figwidth is not None: + figure_node['width'] = figwidth if content: node = nodes.Element() # anonymous container for parsing state.nested_parse(content, content_offset, node) @@ -65,6 +82,13 @@ def figure(name, arguments, options, content, lineno, figure_node += nodes.legend('', *node[1:]) return [figure_node] +def figwidth_value(argument): + if argument.lower() == 'image': + return 'image' + else: + return directives.nonnegative_int(argument) + figure.arguments = (1, 0, 1) -figure.options = image.options +figure.options = {'figwidth': figwidth_value} +figure.options.update(image.options) figure.content = 1 -- cgit v1.2.1 From 515aac3e6c6e46538147a0cc59d2d70476737a4f Mon Sep 17 00:00:00 2001 From: wilk Date: Sun, 20 Apr 2003 12:15:19 +0000 Subject: french translation git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1284 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/fr.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index 455c02b8e..e246ff0d7 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -14,21 +14,22 @@ __docformat__ = 'reStructuredText' directives = { u'attention': u'attention', - u'avertissement': u'caution', + u'pr\u00E9caution': u'caution', u'danger': u'danger', u'erreur': u'error', - u'indication': u'hint', + u'conseil': u'hint', u'important': u'important', u'note': u'note', u'astuce': u'tip', - u'avis': u'warning', - u'encart': u'sidebar', + u'avertissement': u'warning', + u'encadr\u00E9': u'sidebar', u'sujet': u'topic', - u'bloc-ligne': u'line-block', - u'bloc-analys\u00E9': u'parsed-literal', - #u'questions (translation required)': u'questions', - #u'qa (translation required)': u'questions', - #u'faq (translation required)': u'questions', + u'bloc-textuel': u'line-block', + u'bloc-interpr\u00E9t\u00E9': u'parsed-literal', + u'code-interpr\u00E9t\u00E9': u'parsed-literal', + #u'questions': u'questions', + #u'qr': u'questions', + #u'faq': u'questions', u'meta': u'meta', #u'imagemap (translation required)': u'imagemap', u'image': u'image', @@ -36,7 +37,7 @@ directives = { u'inclure': u'include', u'brut': u'raw', u'remplacer': u'replace', - u'mati\u00E8res': u'contents', + u'sommaire': u'contents', u'table-des-mati\u00E8res': u'contents', u'sectnum': u'sectnum', u'section-num\u00E9rot\u00E9e': u'sectnum', -- cgit v1.2.1 From 1a8014ec77441bbc1793ed60c2fd51494d5372f6 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 23 Apr 2003 23:41:05 +0000 Subject: Added ``register_directive()``, thanks to William Dode and Paul Moore git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1288 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 93461c1ed..d8a6c33bc 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -172,6 +172,10 @@ def directive(directive_name, language_module, document): return None, messages return function, messages +def register_directive(name, directive): + """Register a nonstandard application-defined directive function.""" + _directives[name] = directive + def flag(argument): """ Check for a valid flag option (no argument) and return ``None``. -- cgit v1.2.1 From bd61a20c2fa1a7b09df66561eb26b5fc509806c2 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 24 May 2003 20:46:45 +0000 Subject: Added support for block quote attributions. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1327 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 70 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 6 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 481ac1259..838d495c4 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1204,16 +1204,72 @@ class Body(RSTState): """Block quote.""" indented, indent, line_offset, blank_finish = \ self.state_machine.get_indented() - blockquote = self.block_quote(indented, line_offset) + blockquote, messages = self.block_quote(indented, line_offset) self.parent += blockquote + self.parent += messages if not blank_finish: self.parent += self.unindent_warning('Block quote') return context, next_state, [] def block_quote(self, indented, line_offset): + blockquote_lines, attribution_lines, attribution_offset = \ + self.check_attribution(indented, line_offset) blockquote = nodes.block_quote() - self.nested_parse(indented, line_offset, blockquote) - return blockquote + self.nested_parse(blockquote_lines, line_offset, blockquote) + messages = [] + if attribution_lines: + attribution, messages = self.parse_attribution(attribution_lines, + attribution_offset) + blockquote += attribution + return blockquote, messages + + attribution_pattern = re.compile(r'--(?![-\n]) *(?=[^ \n])') + + def check_attribution(self, indented, line_offset): + """ + Check for an attribution in the last contiguous block of `indented`. + + * First line after last blank line must begin with "--" (etc.). + * Every line after that must have consistent indentation. + + Return a 3-tuple: (block quote lines, attribution lines, + attribution offset). + """ + blank = None + nonblank_seen = None + indent = 0 + for i in range(len(indented) - 1, 0, -1): # don't check first line + this_line_blank = not indented[i].strip() + if nonblank_seen and this_line_blank: + match = self.attribution_pattern.match(indented[i + 1]) + if match: + blank = i + break + elif not this_line_blank: + nonblank_seen = 1 + if blank and len(indented) - blank > 2: # multi-line attribution + indent = (len(indented[blank + 2]) + - len(indented[blank + 2].lstrip())) + for j in range(blank + 3, len(indented)): + if indent != (len(indented[j]) + - len(indented[j].lstrip())): # bad shape + blank = None + break + if blank: + a_lines = indented[blank + 1:] + a_lines.strip_indent(match.end(), end=1) + a_lines.strip_indent(indent, start=1) + return (indented[:blank], a_lines, line_offset + blank + 1) + else: + return (indented, None, None) + + def parse_attribution(self, indented, line_offset): + text = '\n'.join(indented).rstrip() + lineno = self.state_machine.abs_line_number() + line_offset + textnodes, messages = self.inline_text(text, lineno) + node = nodes.attribution(text, '', *textnodes) + node.line = lineno + return node, messages def bullet(self, match, context, next_state): """Bullet list item.""" @@ -1432,8 +1488,9 @@ class Body(RSTState): self.parent += msg indented, indent, line_offset, blank_finish = \ self.state_machine.get_first_known_indented(match.end()) - blockquote = self.block_quote(indented, line_offset) + blockquote, messages = self.block_quote(indented, line_offset) self.parent += blockquote + self.parent += messages if not blank_finish: self.parent += self.unindent_warning('Option list') return [], next_state, [] @@ -2582,8 +2639,9 @@ class Text(RSTState): self.state_machine.get_indented() definitionlistitem = nodes.definition_list_item( '\n'.join(termline + list(indented))) - termlist, messages = self.term( - termline, self.state_machine.abs_line_number() - 1) + lineno = self.state_machine.abs_line_number() - 1 + definitionlistitem.line = lineno + termlist, messages = self.term(termline, lineno) definitionlistitem += termlist definition = nodes.definition('', *messages) definitionlistitem += definition -- cgit v1.2.1 From 4e571e82dee78fbe4773223e3ad3c3c6e8cd5012 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 24 May 2003 20:46:59 +0000 Subject: Added ``class_option()`` directive option helper function. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1328 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index d8a6c33bc..814197eab 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -92,10 +92,14 @@ _directive_registry = { 'tip': ('admonitions', 'tip'), 'hint': ('admonitions', 'hint'), 'warning': ('admonitions', 'warning'), + 'admonition': ('admonitions', 'admonition'), 'sidebar': ('body', 'sidebar'), 'topic': ('body', 'topic'), 'line-block': ('body', 'line_block'), 'parsed-literal': ('body', 'parsed_literal'), + 'rubric': ('body', 'rubric'), + 'epigraph': ('body', 'epigraph'), + 'highlights': ('body', 'highlights'), #'questions': ('body', 'question_list'), 'image': ('images', 'image'), 'figure': ('images', 'figure'), @@ -109,6 +113,8 @@ _directive_registry = { 'raw': ('misc', 'raw'), 'include': ('misc', 'include'), 'replace': ('misc', 'replace'), + 'unicode': ('misc', 'unicode_directive'), + 'class': ('misc', 'class_directive'), 'restructuredtext-test-directive': ('misc', 'directive_test_function'),} """Mapping of directive name to (module name, function name). The directive name is canonical & must be lowercase. Language-dependent names are defined @@ -238,3 +244,8 @@ def choice(argument, values): else: raise ValueError('"%s" unknown; choose from %s' % (argument, format_values(values))) + +def class_option(argument): + if argument is None: + raise ValueError('argument required but none supplied') + return nodes.make_id(argument) -- cgit v1.2.1 From fc72a15de8be988e497d9245029dd8ff2c01d333 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 24 May 2003 20:47:13 +0000 Subject: Added "admonition" directive. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1329 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/admonitions.py | 60 ++++++++++++++++---------- 1 file changed, 38 insertions(+), 22 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/admonitions.py b/docutils/parsers/rst/directives/admonitions.py index 7a349ad75..8e3a92895 100644 --- a/docutils/parsers/rst/directives/admonitions.py +++ b/docutils/parsers/rst/directives/admonitions.py @@ -11,64 +11,80 @@ Admonition directives. __docformat__ = 'reStructuredText' -from docutils.parsers.rst import states +from docutils.parsers.rst import states, directives from docutils import nodes -def admonition(node_class, name, arguments, options, content, lineno, - content_offset, block_text, state, state_machine): - text = '\n'.join(content) - admonition_node = node_class(text) - if text: - state.nested_parse(content, content_offset, admonition_node) - return [admonition_node] - else: +def make_admonition(node_class, name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + if not content: error = state_machine.reporter.error( 'The "%s" admonition is empty; content required.' % (name), nodes.literal_block(block_text, block_text), line=lineno) return [error] + text = '\n'.join(content) + admonition_node = node_class(text) + if arguments: + title_text = arguments[0] + textnodes, messages = state.inline_text(title_text, lineno) + admonition_node += nodes.title(title_text, '', *textnodes) + admonition_node += messages + if options.has_key('class'): + class_value = options['class'] + else: + class_value = 'admonition-' + nodes.make_id(title_text) + admonition_node.set_class(class_value) + state.nested_parse(content, content_offset, admonition_node) + return [admonition_node] + +def admonition(*args): + return make_admonition(nodes.admonition, *args) + +admonition.arguments = (1, 0, 1) +admonition.options = {'class': directives.class_option} +admonition.content = 1 def attention(*args): - return admonition(nodes.attention, *args) + return make_admonition(nodes.attention, *args) attention.content = 1 def caution(*args): - return admonition(nodes.caution, *args) + return make_admonition(nodes.caution, *args) caution.content = 1 def danger(*args): - return admonition(nodes.danger, *args) + return make_admonition(nodes.danger, *args) danger.content = 1 def error(*args): - return admonition(nodes.error, *args) + return make_admonition(nodes.error, *args) error.content = 1 +def hint(*args): + return make_admonition(nodes.hint, *args) + +hint.content = 1 + def important(*args): - return admonition(nodes.important, *args) + return make_admonition(nodes.important, *args) important.content = 1 def note(*args): - return admonition(nodes.note, *args) + return make_admonition(nodes.note, *args) note.content = 1 def tip(*args): - return admonition(nodes.tip, *args) + return make_admonition(nodes.tip, *args) tip.content = 1 -def hint(*args): - return admonition(nodes.hint, *args) - -hint.content = 1 - def warning(*args): - return admonition(nodes.warning, *args) + return make_admonition(nodes.warning, *args) warning.content = 1 -- cgit v1.2.1 From 0e4f3603edbe99da05838c005078328d55fe4ec3 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 24 May 2003 20:47:32 +0000 Subject: Added "rubric", "epigraph", and "highlights" directives. Added "class" options to "topic", "sidebar", "line-block", and "parsed-literal". git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1330 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/body.py | 36 +++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index f24edb325..bc3f5b742 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -41,11 +41,14 @@ def topic(name, arguments, options, content, lineno, messages.extend(more_messages) text = '\n'.join(content) node = node_class(text, *(titles + messages)) + if options.has_key('class'): + node.set_class(options['class']) if text: state.nested_parse(content, content_offset, node) return [node] topic.arguments = (1, 0, 1) +topic.options = {'class': directives.class_option} topic.content = 1 def sidebar(name, arguments, options, content, lineno, @@ -55,7 +58,8 @@ def sidebar(name, arguments, options, content, lineno, node_class=nodes.sidebar) sidebar.arguments = (1, 0, 1) -sidebar.options = {'subtitle': directives.unchanged} +sidebar.options = {'subtitle': directives.unchanged, + 'class': directives.class_option} sidebar.content = 1 def line_block(name, arguments, options, content, lineno, @@ -68,9 +72,10 @@ def line_block(name, arguments, options, content, lineno, return [warning] text = '\n'.join(content) text_nodes, messages = state.inline_text(text, lineno) - node = node_class(text, '', *text_nodes) + node = node_class(text, '', *text_nodes, **options) return [node] + messages +line_block.options = {'class': directives.class_option} line_block.content = 1 def parsed_literal(name, arguments, options, content, lineno, @@ -79,4 +84,31 @@ def parsed_literal(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine, node_class=nodes.literal_block) +parsed_literal.options = {'class': directives.class_option} parsed_literal.content = 1 + +def rubric(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + rubric_text = arguments[0] + textnodes, messages = state.inline_text(rubric_text, lineno) + rubric = nodes.rubric(rubric_text, '', *textnodes, **options) + return [rubric] + messages + +rubric.arguments = (1, 0, 1) +rubric.options = {'class': directives.class_option} + +def epigraph(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + block_quote, messages = state.block_quote(content, content_offset) + block_quote.set_class('epigraph') + return [block_quote] + messages + +epigraph.content = 1 + +def highlights(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + block_quote, messages = state.block_quote(content, content_offset) + block_quote.set_class('highlights') + return [block_quote] + messages + +highlights.content = 1 -- cgit v1.2.1 From 8edecf9f21f56b524484fa27ede5d189b879a49e Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 24 May 2003 20:47:43 +0000 Subject: Added "class" option to "image", and "figclass" to "figure". git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1331 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index 8baa223e9..d193edffd 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -42,12 +42,15 @@ image.options = {'alt': directives.unchanged, 'height': directives.nonnegative_int, 'width': directives.nonnegative_int, 'scale': directives.nonnegative_int, - 'align': align} + 'align': align, + 'class': directives.class_option} def figure(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): figwidth = options.setdefault('figwidth') + figclass = options.setdefault('figclass') del options['figwidth'] + del options['figclass'] (image_node,) = image(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine) if isinstance(image_node, nodes.system_message): @@ -64,6 +67,8 @@ def figure(name, arguments, options, content, lineno, figure_node['width'] = i.size[0] elif figwidth is not None: figure_node['width'] = figwidth + if figclass: + figure_node.set_class(figclass) if content: node = nodes.Element() # anonymous container for parsing state.nested_parse(content, content_offset, node) @@ -89,6 +94,7 @@ def figwidth_value(argument): return directives.nonnegative_int(argument) figure.arguments = (1, 0, 1) -figure.options = {'figwidth': figwidth_value} +figure.options = {'figwidth': figwidth_value, + 'figclass': directives.class_option} figure.options.update(image.options) figure.content = 1 -- cgit v1.2.1 From 35ec6b12ea21441d7310c33cf6ae9db6301fe63f Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 24 May 2003 20:48:06 +0000 Subject: Added "unicode" and "class" directives. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1332 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index cc8019886..d1c993478 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -10,9 +10,11 @@ __docformat__ = 'reStructuredText' import sys import os.path +import re from urllib2 import urlopen, URLError from docutils import io, nodes, statemachine, utils from docutils.parsers.rst import directives, states +from docutils.transforms import misc def include(name, arguments, options, content, lineno, @@ -151,6 +153,57 @@ def replace(name, arguments, options, content, lineno, replace.content = 1 +def unicode_directive(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + r""" + Convert Unicode character codes (numbers) to characters. Codes may be + decimal numbers, hexadecimal numbers (prefixed by ``0x``, ``x``, ``\x``, + ``u``, or ``\u``), or XML-style numbered character entities (e.g. + ``ᨫ``). + """ + if not isinstance(state, states.SubstitutionDef): + error = state_machine.reporter.error( + 'Invalid context: the "%s" directive can only be used within a ' + 'substitution definition.' % (name), + nodes.literal_block(block_text, block_text), line=lineno) + return [error] + codes = arguments[0].split() + element = nodes.Element() + for code in codes: + if code.isdigit(): + element += nodes.Text(int(code)) + else: + match = unicode_pattern.match(code) + if match: + element += nodes.Text(unichr(int(match.group(2), 16))) + else: + element += nodes.Text(code) + return element.children + +unicode_directive.arguments = (1, 0, 1) +unicode_pattern = re.compile(r'(0x|x|\x00x|u|\x00u|&#x)([0-9a-f]+);?$', + re.IGNORECASE) + +def class_directive(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + """""" + class_value = nodes.make_id(arguments[0]) + if class_value: + pending = nodes.pending(misc.ClassAttribute, + {'class': class_value, 'directive': name}, + block_text) + state_machine.document.note_pending(pending) + return [pending] + else: + error = state_machine.reporter.error( + 'Invalid class attribute value for "%s" directive: %s' + % (name, arguments[0]), + nodes.literal_block(block_text, block_text), line=lineno) + return [error] + +class_directive.arguments = (1, 0, 0) +class_directive.content = 1 + def directive_test_function(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): if content: -- cgit v1.2.1 From 43b1e6fde04bd51b01ddc651dc18f2a103bc9ef1 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 24 May 2003 20:48:20 +0000 Subject: Added "class" option to "contents" directive. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1333 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/parts.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py index e4ca8d3df..2faaca44b 100644 --- a/docutils/parsers/rst/directives/parts.py +++ b/docutils/parsers/rst/directives/parts.py @@ -42,7 +42,8 @@ def contents(name, arguments, options, content, lineno, contents.arguments = (0, 1, 1) contents.options = {'depth': directives.nonnegative_int, 'local': directives.flag, - 'backlinks': backlinks} + 'backlinks': backlinks, + 'class': directives.class_option} def sectnum(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): -- cgit v1.2.1 From e8c6ddb8ee857e0387997db70b0786243465b84b Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 24 May 2003 20:54:11 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1340 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/de.py | 6 ++++ docutils/parsers/rst/languages/en.py | 8 ++++- docutils/parsers/rst/languages/fr.py | 68 ++++++++++++++++++++---------------- docutils/parsers/rst/languages/it.py | 6 ++++ docutils/parsers/rst/languages/sk.py | 6 ++++ docutils/parsers/rst/languages/sv.py | 12 +++++-- 6 files changed, 71 insertions(+), 35 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index fafb6f4fa..03ec58530 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -23,10 +23,14 @@ directives = { 'notiz': 'note', 'tip': 'tip', 'warnung': 'warning', + 'admonition (translation required)': 'admonition', 'sidebar (translation required)': 'sidebar', 'topic': 'topic', # Überbegriff 'line-block': 'line-block', 'parsed-literal': 'parsed-literal', + 'rubric (translation required)': 'rubric', + 'epigraph (translation required)': 'epigraph', + 'highlights (translation required)': 'highlights', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', @@ -38,6 +42,8 @@ directives = { 'include': 'include', # einfügen, "füge ein" would be more like a command. # einfügung would be the noun. 'replace': 'replace', # ersetzen, ersetze + 'unicode': 'unicode', + 'class (translation required)': 'class', 'inhalt': 'contents', 'sectnum': 'sectnum', 'section-numbering': 'sectnum', diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index 7d0976471..01d30e2b8 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -22,10 +22,14 @@ directives = { 'note': 'note', 'tip': 'tip', 'warning': 'warning', + 'admonition': 'admonition', 'sidebar': 'sidebar', 'topic': 'topic', 'line-block': 'line-block', 'parsed-literal': 'parsed-literal', + 'rubric': 'rubric', + 'epigraph': 'epigraph', + 'highlights': 'highlights', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', @@ -36,12 +40,14 @@ directives = { 'include': 'include', 'raw': 'raw', 'replace': 'replace', + 'unicode': 'unicode', + 'class': 'class', 'contents': 'contents', 'sectnum': 'sectnum', 'section-numbering': 'sectnum', - 'target-notes': 'target-notes', #'footnotes': 'footnotes', #'citations': 'citations', + 'target-notes': 'target-notes', 'restructuredtext-test-directive': 'restructuredtext-test-directive'} """English name to registered (in directives/__init__.py) directive name mapping.""" diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index e246ff0d7..94ef05fcf 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -13,37 +13,43 @@ __docformat__ = 'reStructuredText' directives = { - u'attention': u'attention', - u'pr\u00E9caution': u'caution', - u'danger': u'danger', - u'erreur': u'error', - u'conseil': u'hint', - u'important': u'important', - u'note': u'note', - u'astuce': u'tip', - u'avertissement': u'warning', - u'encadr\u00E9': u'sidebar', - u'sujet': u'topic', - u'bloc-textuel': u'line-block', - u'bloc-interpr\u00E9t\u00E9': u'parsed-literal', - u'code-interpr\u00E9t\u00E9': u'parsed-literal', - #u'questions': u'questions', - #u'qr': u'questions', - #u'faq': u'questions', - u'meta': u'meta', - #u'imagemap (translation required)': u'imagemap', - u'image': u'image', - u'figure': u'figure', - u'inclure': u'include', - u'brut': u'raw', - u'remplacer': u'replace', - u'sommaire': u'contents', - u'table-des-mati\u00E8res': u'contents', - u'sectnum': u'sectnum', - u'section-num\u00E9rot\u00E9e': u'sectnum', - u'liens': u'target-notes', - #u'footnotes (translation required)': u'footnotes', - #u'citations (translation required)': u'citations', + u'attention': 'attention', + u'pr\u00E9caution': 'caution', + u'danger': 'danger', + u'erreur': 'error', + u'conseil': 'hint', + u'important': 'important', + u'note': 'note', + u'astuce': 'tip', + u'avertissement': 'warning', + u'admonestation': 'admonition', + u'encadr\u00E9': 'sidebar', + u'sujet': 'topic', + u'bloc-textuel': 'line-block', + u'bloc-interpr\u00E9t\u00E9': 'parsed-literal', + u'code-interpr\u00E9t\u00E9': 'parsed-literal', + u'inter-titre': 'rubric', + u'exergue': 'epigraph', + u'chapeau': 'highlights', + #u'questions': 'questions', + #u'qr': 'questions', + #u'faq': 'questions', + u'meta': 'meta', + #u'imagemap (translation required)': 'imagemap', + u'image': 'image', + u'figure': 'figure', + u'inclure': 'include', + u'brut': 'raw', + u'remplacer': 'replace', + u'unicode': 'unicode', + u'classe': 'class', + u'sommaire': 'contents', + u'table-des-mati\u00E8res': 'contents', + u'sectnum': 'sectnum', + u'section-num\u00E9rot\u00E9e': 'sectnum', + u'liens': 'target-notes', + #u'footnotes (translation required)': 'footnotes', + #u'citations (translation required)': 'citations', } """French name to registered (in directives/__init__.py) directive name mapping.""" diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index 93cba7936..fc93e3451 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -22,10 +22,14 @@ directives = { 'nota': 'note', 'consiglio': 'tip', 'avvertenza': 'warning', + 'admonition (translation required)': 'admonition', 'sidebar (translation required)': 'sidebar', 'argomento': 'topic', 'blocco di linee': 'line-block', 'parsed-literal': 'parsed-literal', + 'rubric (translation required)': 'rubric', + 'epigraph (translation required)': 'epigraph', + 'highlights (translation required)': 'highlights', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', @@ -36,6 +40,8 @@ directives = { 'includi': 'include', 'grezzo': 'raw', 'sostituisci': 'replace', + 'unicode': 'unicode', + 'class (translation required)': 'class', 'indice': 'contents', 'seznum': 'sectnum', 'section-numbering': 'sectnum', diff --git a/docutils/parsers/rst/languages/sk.py b/docutils/parsers/rst/languages/sk.py index 585bf934d..433f37f2f 100644 --- a/docutils/parsers/rst/languages/sk.py +++ b/docutils/parsers/rst/languages/sk.py @@ -22,10 +22,14 @@ directives = { u'pozn\xe1mka': 'note', u'tip': 'tip', u'varovanie': 'warning', + u'admonition (translation required)': 'admonition', u'sidebar (translation required)': 'sidebar', u't\xe9ma': 'topic', u'blok-riadkov': 'line-block', u'parsed-literal': 'parsed-literal', + u'rubric (translation required)': 'rubric', + u'epigraph (translation required)': 'epigraph', + u'highlights (translation required)': 'highlights', #u'questions': 'questions', #u'qa': 'questions', #u'faq': 'questions', @@ -36,6 +40,8 @@ directives = { u'vlo\x9ei\x9d': 'include', u'raw': 'raw', u'nahradi\x9d': 'replace', + u'unicode': 'unicode', + u'class (translation required)': 'class', u'obsah': 'contents', u'\xe8as\x9d': 'sectnum', u'\xe8as\x9d-\xe8\xedslovanie': 'sectnum', diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index c63922c5e..fe31c9b7f 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -21,10 +21,14 @@ directives = { u'notera': 'note', u'tips': 'tip', u'varning': 'warning', + u'admonition (translation required)': 'admonition', u'sidebar (translation required)': 'sidebar', u'\u00e4mne': 'topic', - 'line-block (translation required)': 'line-block', - 'parsed-literal (translation required)': 'parsed-literal', + u'line-block (translation required)': 'line-block', + u'parsed-literal (translation required)': 'parsed-literal', + u'mellanrubrik': 'rubric', + u'epigraph (translation required)': 'epigraph', + u'highlights (translation required)': 'highlights', # u'fr\u00e5gor': 'questions', # NOTE: A bit long, but recommended by http://www.nada.kth.se/dataterm/: # u'fr\u00e5gor-och-svar': 'questions', @@ -36,9 +40,11 @@ directives = { u'inkludera': 'include', u'r\u00e5': 'raw', # FIXME: Translation might be too literal. u'ers\u00e4tt': 'replace', + u'unicode': 'unicode', + u'class (translation required)': 'class', u'inneh\u00e5ll': 'contents', u'sektionsnumrering': 'sectnum', - 'target-notes (translation required)': 'target-notes', + u'target-notes (translation required)': 'target-notes', # u'fotnoter': 'footnotes', # u'citeringar': 'citations', } -- cgit v1.2.1 From ea87be65128106e35aea589545f563f31e5c13bb Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 25 May 2003 14:59:30 +0000 Subject: Added a kludge to work-around a conflict between the bubble-up parser strategy and short titles (<= 3 char-long over- & underlines). Fixes SF bug #738803 "infinite loop with multiple titles" submitted by Jason Diamond. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1344 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 838d495c4..3901d6078 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -159,6 +159,7 @@ class RSTStateMachine(StateMachineWS): language=self.language, title_styles=[], section_level=0, + section_bubble_up_kludge=0, inliner=inliner) self.document = document self.attach_observer(document.note_source) @@ -340,6 +341,8 @@ class RSTState(StateWS): return None if level <= mylevel: # sibling or supersection memo.section_level = level # bubble up to parent section + if len(style) == 2: + memo.section_bubble_up_kludge = 1 # back up 2 lines for underline title, 3 for overline title self.state_machine.previous_line(len(style) + 1) raise EOFError # let parent section re-evaluate @@ -2727,7 +2730,9 @@ class Line(SpecializedText): def eof(self, context): """Transition marker at end of section or document.""" marker = context[0].strip() - if len(marker) < 4: + if self.memo.section_bubble_up_kludge: + self.memo.section_bubble_up_kludge = 0 + elif len(marker) < 4: self.state_correction(context) if self.eofcheck: # ignore EOFError with sections lineno = self.state_machine.abs_line_number() - 1 -- cgit v1.2.1 From 9e963da38dd474d0fb414a81dfbbd3877373348f Mon Sep 17 00:00:00 2001 From: wilk Date: Sun, 25 May 2003 15:34:05 +0000 Subject: =?UTF-8?q?admonition=20pour=20admonition=20intertitre=20au=20lieu?= =?UTF-8?q?=20de=20inter-titre=20=EF=BF=BDpigraphe=20pour=20epigraph?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1347 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/fr.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index 94ef05fcf..dbce1ab38 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -22,14 +22,15 @@ directives = { u'note': 'note', u'astuce': 'tip', u'avertissement': 'warning', - u'admonestation': 'admonition', + u'admonition': 'admonition', u'encadr\u00E9': 'sidebar', u'sujet': 'topic', u'bloc-textuel': 'line-block', u'bloc-interpr\u00E9t\u00E9': 'parsed-literal', u'code-interpr\u00E9t\u00E9': 'parsed-literal', - u'inter-titre': 'rubric', + u'intertitre': 'rubric', u'exergue': 'epigraph', + u'\u00E9pigraphe': 'epigraph', u'chapeau': 'highlights', #u'questions': 'questions', #u'qr': 'questions', -- cgit v1.2.1 From 4b58b2fdd49004676d1785bcf043241d318cc3ba Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 29 May 2003 15:16:21 +0000 Subject: Spanish mappings by Marcelo Huerta San Martin git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1358 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/es.py | 92 ++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 docutils/parsers/rst/languages/es.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py new file mode 100644 index 000000000..d92800187 --- /dev/null +++ b/docutils/parsers/rst/languages/es.py @@ -0,0 +1,92 @@ +# Author: Marcelo Huerta San Martín +# Contact: mghsm@uol.com.ar +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +""" +Spanish-language mappings for language-dependent features of +reStructuredText. +""" + +__docformat__ = 'reStructuredText' + + +directives = { + u'atenci\u00f3n': 'attention', + u'atencion': 'attention', + u'precauci\u00f3n': 'caution', + u'precaucion': 'caution', + u'peligro': 'danger', + u'error': 'error', + u'sugerencia': 'hint', + u'importante': 'important', + u'nota': 'note', + u'consejo': 'tip', + u'advertencia': 'warning', + u'admonition (translation required)': 'admonition', + u'nota-al-margen': 'sidebar', + u'tema': 'topic', + u'bloque-de-lineas': 'line-block', + u'bloque-de-l\u00edneas': 'line-block', + u'literal-evaluado': 'parsed-literal', + u'rubric (translation required)': 'rubric', + u'epigraph (translation required)': 'epigraph', + u'highlights (translation required)': 'highlights', + #'questions': 'questions', + #'qa': 'questions', + #'faq': 'questions', + u'meta': 'meta', + #'imagemap': 'imagemap', + u'imagen': 'image', + u'figura': 'figure', + u'incluir': 'include', + u'raw': 'raw', + u'reemplazar': 'replace', + u'unicode': 'unicode', + u'class (translation required)': 'class', + u'contenido': 'contents', + u'numseccion': 'sectnum', + u'numsecci\u00f3n': 'sectnum', + u'numeracion-seccion': 'sectnum', + u'numeraci\u00f3n-secci\u00f3n': 'sectnum', + u'notas-destino': 'target-notes', + #'footnotes': 'footnotes', + #'citations': 'citations', + u'restructuredtext-test-directive': 'restructuredtext-test-directive'} +"""English name to registered (in directives/__init__.py) directive name +mapping.""" + +roles = { + u'abreviatura': 'abbreviation', + u'ab': 'abbreviation', + u'acronimo': 'acronym', + u'acronimo': 'acronym', + u'ac': 'acronym', + u'indice': 'index', + u'i': 'index', + u'referencia-titulo': 'title-reference', + u'titulo': 'title-reference', + u't': 'title-reference', + u'referencia-pep': 'pep-reference', + u'pep': 'pep-reference', + u'referencia-rfc': 'rfc-reference', + u'rfc': 'rfc-reference', + u'enfasis': 'emphasis', + u'\u00e9nfasis': 'emphasis', + u'destacado': 'strong', + u'literal': 'literal', + u'referencia-con-nombre': 'named-reference', + u'referencia-anonima': 'anonymous-reference', + u'referencia-an\u00f3nima': 'anonymous-reference', + u'referencia-nota-al-pie': 'footnote-reference', + u'referencia-cita': 'citation-reference', + u'referencia-sustitucion': 'substitution-reference', + u'referencia-sustituci\u00f3n': 'substitution-reference', + u'destino': 'target', + u'referencia-uri': 'uri-reference', + u'uri': 'uri-reference', + u'url': 'uri-reference', + } +"""Mapping of Spanish role names to canonical role names for interpreted text. +""" -- cgit v1.2.1 From 9323acb9584c1a30e1fd6cf3a7c48c8adf6dfd1f Mon Sep 17 00:00:00 2001 From: richieadler Date: Sat, 31 May 2003 02:15:47 +0000 Subject: no message git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1363 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/es.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index d92800187..ee0ae5247 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -24,15 +24,17 @@ directives = { u'nota': 'note', u'consejo': 'tip', u'advertencia': 'warning', - u'admonition (translation required)': 'admonition', + u'exhortacion': 'admonition', + u'exhortaci\u00f3n': 'admonition', u'nota-al-margen': 'sidebar', u'tema': 'topic', u'bloque-de-lineas': 'line-block', u'bloque-de-l\u00edneas': 'line-block', u'literal-evaluado': 'parsed-literal', - u'rubric (translation required)': 'rubric', - u'epigraph (translation required)': 'epigraph', - u'highlights (translation required)': 'highlights', + u'firma': 'rubric', + u'ep\u00edgrafe': 'epigraph', + u'epigrafe': 'epigraph', + u'destacado': 'highlights', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', @@ -44,7 +46,7 @@ directives = { u'raw': 'raw', u'reemplazar': 'replace', u'unicode': 'unicode', - u'class (translation required)': 'class', + u'clase': 'class', u'contenido': 'contents', u'numseccion': 'sectnum', u'numsecci\u00f3n': 'sectnum', -- cgit v1.2.1 From f43900b985a1c3fae98d7a99847250750039b6b4 Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 3 Jun 2003 02:16:59 +0000 Subject: Added "pull-quote" directive. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1373 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 1 + docutils/parsers/rst/directives/body.py | 8 ++++++++ docutils/parsers/rst/languages/de.py | 1 + docutils/parsers/rst/languages/en.py | 1 + docutils/parsers/rst/languages/es.py | 1 + docutils/parsers/rst/languages/fr.py | 1 + docutils/parsers/rst/languages/it.py | 1 + docutils/parsers/rst/languages/sk.py | 1 + docutils/parsers/rst/languages/sv.py | 1 + 9 files changed, 16 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 814197eab..1a113db2d 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -100,6 +100,7 @@ _directive_registry = { 'rubric': ('body', 'rubric'), 'epigraph': ('body', 'epigraph'), 'highlights': ('body', 'highlights'), + 'pull-quote': ('body', 'pull_quote'), #'questions': ('body', 'question_list'), 'image': ('images', 'image'), 'figure': ('images', 'figure'), diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index bc3f5b742..c2fd6b99d 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -112,3 +112,11 @@ def highlights(name, arguments, options, content, lineno, return [block_quote] + messages highlights.content = 1 + +def pull_quote(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + block_quote, messages = state.block_quote(content, content_offset) + block_quote.set_class('pull-quote') + return [block_quote] + messages + +pull_quote.content = 1 diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index 03ec58530..b91b16736 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -31,6 +31,7 @@ directives = { 'rubric (translation required)': 'rubric', 'epigraph (translation required)': 'epigraph', 'highlights (translation required)': 'highlights', + 'pull-quote (translation required)': 'pull-quote', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index 01d30e2b8..cb3ec000d 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -30,6 +30,7 @@ directives = { 'rubric': 'rubric', 'epigraph': 'epigraph', 'highlights': 'highlights', + 'pull-quote': 'pull-quote', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index ee0ae5247..2d51a793e 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -35,6 +35,7 @@ directives = { u'ep\u00edgrafe': 'epigraph', u'epigrafe': 'epigraph', u'destacado': 'highlights', + u'pull-quote (translation required)': 'pull-quote', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index dbce1ab38..0164fe0eb 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -32,6 +32,7 @@ directives = { u'exergue': 'epigraph', u'\u00E9pigraphe': 'epigraph', u'chapeau': 'highlights', + u'pull-quote (translation required)': 'pull-quote', #u'questions': 'questions', #u'qr': 'questions', #u'faq': 'questions', diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index fc93e3451..21ede5bce 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -30,6 +30,7 @@ directives = { 'rubric (translation required)': 'rubric', 'epigraph (translation required)': 'epigraph', 'highlights (translation required)': 'highlights', + 'pull-quote (translation required)': 'pull-quote', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/sk.py b/docutils/parsers/rst/languages/sk.py index 433f37f2f..772f0433f 100644 --- a/docutils/parsers/rst/languages/sk.py +++ b/docutils/parsers/rst/languages/sk.py @@ -30,6 +30,7 @@ directives = { u'rubric (translation required)': 'rubric', u'epigraph (translation required)': 'epigraph', u'highlights (translation required)': 'highlights', + u'pull-quote (translation required)': 'pull-quote', #u'questions': 'questions', #u'qa': 'questions', #u'faq': 'questions', diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index fe31c9b7f..e126b9dd1 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -29,6 +29,7 @@ directives = { u'mellanrubrik': 'rubric', u'epigraph (translation required)': 'epigraph', u'highlights (translation required)': 'highlights', + u'pull-quote (translation required)': 'pull-quote', # u'fr\u00e5gor': 'questions', # NOTE: A bit long, but recommended by http://www.nada.kth.se/dataterm/: # u'fr\u00e5gor-och-svar': 'questions', -- cgit v1.2.1 From 200e86c1464ff1c86d01270ed45bfef065b21a52 Mon Sep 17 00:00:00 2001 From: wilk Date: Wed, 4 Jun 2003 21:55:55 +0000 Subject: accroche = pull-quote git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1377 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/fr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index 0164fe0eb..311c5db0f 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -32,7 +32,7 @@ directives = { u'exergue': 'epigraph', u'\u00E9pigraphe': 'epigraph', u'chapeau': 'highlights', - u'pull-quote (translation required)': 'pull-quote', + u'accroche': 'pull-quote', #u'questions': 'questions', #u'qr': 'questions', #u'faq': 'questions', -- cgit v1.2.1 From 26f053068c13c1b4fdcf5447a6f0ef8422b45d3a Mon Sep 17 00:00:00 2001 From: richieadler Date: Thu, 5 Jun 2003 00:33:38 +0000 Subject: "pull quote" translation git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1378 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/es.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index 2d51a793e..3b0a15b95 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -35,7 +35,7 @@ directives = { u'ep\u00edgrafe': 'epigraph', u'epigrafe': 'epigraph', u'destacado': 'highlights', - u'pull-quote (translation required)': 'pull-quote', + u'destacado': 'pull-quote', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', -- cgit v1.2.1 From 47edfa1d498f5bbecc83c26380cdce3c9990cf43 Mon Sep 17 00:00:00 2001 From: richieadler Date: Thu, 5 Jun 2003 00:42:44 +0000 Subject: no message git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1379 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/es.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index 3b0a15b95..5f3f964a6 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -35,7 +35,7 @@ directives = { u'ep\u00edgrafe': 'epigraph', u'epigrafe': 'epigraph', u'destacado': 'highlights', - u'destacado': 'pull-quote', + u'cita-destacada': 'pull-quote', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', -- cgit v1.2.1 From 389a395279a3fa0459a6ebe5dfa992b2973c4956 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 5 Jun 2003 15:14:36 +0000 Subject: Added explicit interpreted text roles for standard inline markup: "emphasis", "strong", "literal". Implemented "superscript" and "subscript" interpreted text roles. Added initial support for "abbreviation" and "acronym" roles; incomplete. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1383 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 97 ++++++++++++++++++++++++++---------------- 1 file changed, 60 insertions(+), 37 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 3901d6078..4a4da3478 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -474,13 +474,15 @@ class Inliner: _interpreted_roles = { # Values of ``None`` mean "not implemented yet": - 'title-reference': 'title_reference_role', - 'abbreviation': None, - 'acronym': None, + 'title-reference': 'generic_interpreted_role', + 'abbreviation': 'generic_interpreted_role', + 'acronym': 'generic_interpreted_role', 'index': None, - 'emphasis': None, - 'strong': None, - 'literal': None, + 'subscript': 'generic_interpreted_role', + 'superscript': 'generic_interpreted_role', + 'emphasis': 'generic_interpreted_role', + 'strong': 'generic_interpreted_role', + 'literal': 'generic_interpreted_role', 'named-reference': None, 'anonymous-reference': None, 'uri-reference': None, @@ -490,7 +492,7 @@ class Inliner: 'citation-reference': None, 'substitution-reference': None, 'target': None, - } + 'restructuredtext-unimplemented-role': None} """Mapping of canonical interpreted text role name to method name. Initializes a name to bound-method mapping in `__init__`.""" @@ -498,6 +500,18 @@ class Inliner: """The role to use when no explicit role is given. Override in subclasses.""" + generic_roles = {'abbreviation': nodes.abbreviation, + 'acronym': nodes.acronym, + 'emphasis': nodes.emphasis, + 'literal': nodes.literal, + 'strong': nodes.strong, + 'subscript': nodes.subscript, + 'superscript': nodes.superscript, + 'title-reference': nodes.title_reference,} + """Mapping of canonical interpreted text role name to node class. + Used by the `generic_interpreted_role` method for simple, straightforward + roles (simple wrapping; no extra processing).""" + def __init__(self, roles=None): """ `roles` is a mapping of canonical role name to role function or bound @@ -875,9 +889,11 @@ class Inliner: return uri def interpreted(self, before, after, rawsource, text, role, lineno): - role_function, messages = self.get_role_function(role, lineno) + role_function, canonical, messages = self.get_role_function(role, + lineno) if role_function: - nodelist, messages2 = role_function(role, rawsource, text, lineno) + nodelist, messages2 = role_function(canonical, rawsource, text, + lineno) messages.extend(messages2) return before, nodelist, after, messages else: @@ -888,34 +904,34 @@ class Inliner: msg_text = [] if role: name = role.lower() - canonical = None - try: - canonical = self.language.roles[name] - except AttributeError, error: - msg_text.append('Problem retrieving role entry from language ' - 'module %r: %s.' % (self.language, error)) - except KeyError: - msg_text.append('No role entry for "%s" in module "%s".' - % (role, self.language.__name__)) - if not canonical: - try: - canonical = _fallback_language_module.roles[name] - msg_text.append('Using English fallback for role "%s".' - % role) - except KeyError: - msg_text.append('Trying "%s" as canonical role name.' - % role) - # Should be an English name, but just in case: - canonical = name - if msg_text: - message = self.reporter.info('\n'.join(msg_text), line=lineno) - messages.append(message) + else: + name = self.default_interpreted_role + canonical = None + try: + canonical = self.language.roles[name] + except AttributeError, error: + msg_text.append('Problem retrieving role entry from language ' + 'module %r: %s.' % (self.language, error)) + except KeyError: + msg_text.append('No role entry for "%s" in module "%s".' + % (name, self.language.__name__)) + if not canonical: try: - return self.interpreted_roles[canonical], messages + canonical = _fallback_language_module.roles[name] + msg_text.append('Using English fallback for role "%s".' + % name) except KeyError: - raise UnknownInterpretedRoleError(messages) - else: - return self.interpreted_roles[self.default_interpreted_role], [] + msg_text.append('Trying "%s" as canonical role name.' + % name) + # Should be an English name, but just in case: + canonical = name + if msg_text: + message = self.reporter.info('\n'.join(msg_text), line=lineno) + messages.append(message) + try: + return self.interpreted_roles[canonical], canonical, messages + except KeyError: + raise UnknownInterpretedRoleError(messages) def literal(self, match, lineno): before, inlines, remaining, sysmessages, endstring = self.inline_obj( @@ -1083,8 +1099,15 @@ class Inliner: '_': reference, '__': anonymous_reference} - def title_reference_role(self, role, rawtext, text, lineno): - return [nodes.title_reference(rawtext, text)], [] + def generic_interpreted_role(self, role, rawtext, text, lineno): + try: + role_class = self.generic_roles[role] + except KeyError: + msg = self.reporter.error('Unknown interpreted text role: "%s".' + % role, line=lineno) + prb = self.problematic(text, text, msg) + return [prb], [msg] + return [role_class(rawtext, text)], [] def pep_reference_role(self, role, rawtext, text, lineno): try: -- cgit v1.2.1 From 6accfecf813ed11c110351c02d98e11b43f57c0a Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 5 Jun 2003 15:15:42 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1385 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/en.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index cb3ec000d..bc488a53e 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -60,6 +60,10 @@ roles = { 'ac': 'acronym', 'index': 'index', 'i': 'index', + 'subscript': 'subscript', + 'sub': 'subscript', + 'superscript': 'superscript', + 'sup': 'superscript', 'title-reference': 'title-reference', 'title': 'title-reference', 't': 'title-reference', @@ -78,7 +82,6 @@ roles = { 'target': 'target', 'uri-reference': 'uri-reference', 'uri': 'uri-reference', - 'url': 'uri-reference', - } + 'url': 'uri-reference',} """Mapping of English role names to canonical role names for interpreted text. """ -- cgit v1.2.1 From 1fc858bc8b0d46f289961e0c03ccabbede70d6fc Mon Sep 17 00:00:00 2001 From: goodger Date: Mon, 9 Jun 2003 15:06:07 +0000 Subject: Added "--trim-footnote-reference-space" option. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1403 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/__init__.py b/docutils/parsers/rst/__init__.py index b242ad9cb..899a49bc8 100644 --- a/docutils/parsers/rst/__init__.py +++ b/docutils/parsers/rst/__init__.py @@ -95,7 +95,10 @@ class Parser(docutils.parsers.Parser): {'action': 'store_true'}), ('Set number of spaces for tab expansion (default 8).', ['--tab-width'], - {'metavar': '', 'type': 'int', 'default': 8}),)) + {'metavar': '', 'type': 'int', 'default': 8}), + ('Remove spaces before footnote references.', + ['--trim-footnote-reference-space'], + {'action': 'store_true'}),)) def __init__(self, rfc2822=None, inliner=None): if rfc2822: -- cgit v1.2.1 From 0cf867bc975f087ce49b13340e925ff9311b4f8a Mon Sep 17 00:00:00 2001 From: goodger Date: Mon, 9 Jun 2003 15:06:34 +0000 Subject: Support for "--trim-footnote-reference-space" option. Optional space before colons in directives & hyperlink targets. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1404 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 4a4da3478..296bc57b4 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -980,6 +980,9 @@ class Inliner: """ label = match.group('footnotelabel') refname = normalize_name(label) + string = match.string + before = string[:match.start('whole')] + remaining = string[match.end('whole'):] if match.group('citationlabel'): refnode = nodes.citation_reference('[%s]_' % label, refname=refname) @@ -1001,10 +1004,9 @@ class Inliner: if refname: refnode['refname'] = refname self.document.note_footnote_ref(refnode) - string = match.string - matchstart = match.start('whole') - matchend = match.end('whole') - return (string[:matchstart], [refnode], string[matchend:], []) + if self.document.settings.trim_footnote_reference_space: + before = before.rstrip() + return (before, [refnode], remaining, []) def reference(self, match, lineno, anonymous=None): referencename = match.group('refname') @@ -1768,6 +1770,7 @@ class Body(RSTState): (?P=quote) # close quote if open quote used ) %(non_whitespace_escape_before)s + [ ]? # optional space : # end of reference name ([ ]+|$) # followed by whitespace """ % vars(Inliner), re.VERBOSE), @@ -2188,6 +2191,7 @@ class Body(RSTState): re.compile(r""" \.\.[ ]+ # explicit markup start (%s) # directive name + [ ]? # optional space :: # directive delimiter ([ ]+|$) # whitespace or end of line """ % Inliner.simplename, re.VERBOSE | re.UNICODE))] -- cgit v1.2.1 From a1c52851ebebe162cd925f39b6221d1b09724a19 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 12 Jun 2003 19:35:34 +0000 Subject: "unicode": added support for "U+" notation, and catching wide-Unicode errors git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1433 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index d1c993478..c220c84cb 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -170,19 +170,26 @@ def unicode_directive(name, arguments, options, content, lineno, codes = arguments[0].split() element = nodes.Element() for code in codes: - if code.isdigit(): - element += nodes.Text(int(code)) - else: - match = unicode_pattern.match(code) - if match: - element += nodes.Text(unichr(int(match.group(2), 16))) + try: + if code.isdigit(): + element += nodes.Text(unichr(int(code))) else: - element += nodes.Text(code) + match = unicode_pattern.match(code) + if match: + value = match.group(1) or match.group(2) + element += nodes.Text(unichr(int(value, 16))) + else: + element += nodes.Text(code) + except ValueError, err: + error = state_machine.reporter.error( + 'Invalid character code: %s\n%s' % (code, err), + nodes.literal_block(block_text, block_text), line=lineno) + return [error] return element.children unicode_directive.arguments = (1, 0, 1) -unicode_pattern = re.compile(r'(0x|x|\x00x|u|\x00u|&#x)([0-9a-f]+);?$', - re.IGNORECASE) +unicode_pattern = re.compile( + r'(?:0x|x|\x00x|U\+?|\x00u)([0-9a-f]+)$|&#x([0-9a-f]+);$', re.IGNORECASE) def class_directive(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): -- cgit v1.2.1 From dfe2aa11eee34d0e4c433d5b80647ca58d850345 Mon Sep 17 00:00:00 2001 From: grubert Date: Fri, 13 Jun 2003 17:01:58 +0000 Subject: possible translations. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1446 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/de.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index b91b16736..9c6337b2d 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -24,14 +24,14 @@ directives = { 'tip': 'tip', 'warnung': 'warning', 'admonition (translation required)': 'admonition', - 'sidebar (translation required)': 'sidebar', - 'topic': 'topic', # Überbegriff + 'sidebar (translation required)': 'sidebar', # kasten ? + 'topic': 'topic', # Überbegriff, Thema ? 'line-block': 'line-block', 'parsed-literal': 'parsed-literal', - 'rubric (translation required)': 'rubric', + 'rubrik': 'rubric', 'epigraph (translation required)': 'epigraph', 'highlights (translation required)': 'highlights', - 'pull-quote (translation required)': 'pull-quote', + 'pull-quote (translation required)': 'pull-quote', # kasten too ? #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', -- cgit v1.2.1 From 4d5856ed0b53ed121be993e520271fc0e4a1ce55 Mon Sep 17 00:00:00 2001 From: goodger Date: Mon, 16 Jun 2003 03:26:53 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1470 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 296bc57b4..2fc1f8866 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -107,8 +107,9 @@ __docformat__ = 'reStructuredText' import sys import re +import roman from types import TupleType -from docutils import nodes, statemachine, utils, roman, urischemes +from docutils import nodes, statemachine, utils, urischemes from docutils import ApplicationError, DataError from docutils.statemachine import StateMachineWS, StateWS from docutils.nodes import fully_normalize_name as normalize_name -- cgit v1.2.1 From 79266acb6c5e3c2e4e152c811bcbb5601845cb42 Mon Sep 17 00:00:00 2001 From: grubert Date: Tue, 17 Jun 2003 06:15:50 +0000 Subject: add translations. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1485 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/de.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index 9c6337b2d..7f2a25e78 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -23,9 +23,9 @@ directives = { 'notiz': 'note', 'tip': 'tip', 'warnung': 'warning', - 'admonition (translation required)': 'admonition', - 'sidebar (translation required)': 'sidebar', # kasten ? - 'topic': 'topic', # Überbegriff, Thema ? + 'ermahnung': 'admonition', + 'kasten': 'sidebar', # seitenkasten ? + 'thema': 'topic', 'line-block': 'line-block', 'parsed-literal': 'parsed-literal', 'rubrik': 'rubric', @@ -42,9 +42,9 @@ directives = { 'raw': 'raw', # unbearbeitet 'include': 'include', # einfügen, "füge ein" would be more like a command. # einfügung would be the noun. - 'replace': 'replace', # ersetzen, ersetze + 'ersetzung': 'replace', # ersetzen, ersetze 'unicode': 'unicode', - 'class (translation required)': 'class', + 'klasse': 'class', # offer class too ? 'inhalt': 'contents', 'sectnum': 'sectnum', 'section-numbering': 'sectnum', -- cgit v1.2.1 From 34e673460e676a67ed552c7c66e2381c6e0c2dbb Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 22 Jun 2003 22:21:28 +0000 Subject: added comments to "unicode" directive git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1494 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index c220c84cb..581c10269 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -158,8 +158,9 @@ def unicode_directive(name, arguments, options, content, lineno, r""" Convert Unicode character codes (numbers) to characters. Codes may be decimal numbers, hexadecimal numbers (prefixed by ``0x``, ``x``, ``\x``, - ``u``, or ``\u``), or XML-style numbered character entities (e.g. - ``ᨫ``). + ``U+``, ``u``, or ``\u``; e.g. ``U+262E``), or XML-style numeric character + entities (e.g. ``☮``). Text following ".." is a comment and is + ignored. Spaces are ignored, and any other text remains as-is. """ if not isinstance(state, states.SubstitutionDef): error = state_machine.reporter.error( @@ -167,7 +168,7 @@ def unicode_directive(name, arguments, options, content, lineno, 'substitution definition.' % (name), nodes.literal_block(block_text, block_text), line=lineno) return [error] - codes = arguments[0].split() + codes = arguments[0].split('.. ')[0].split() element = nodes.Element() for code in codes: try: -- cgit v1.2.1 From 19398b08d732989638849d03a7cdc21a366fb811 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 26 Jun 2003 18:32:02 +0000 Subject: added explanatory comments for language mappings git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1510 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/__init__.py | 3 +++ docutils/parsers/rst/languages/de.py | 5 +++++ docutils/parsers/rst/languages/en.py | 7 +++++++ docutils/parsers/rst/languages/es.py | 5 +++++ docutils/parsers/rst/languages/fr.py | 5 +++++ docutils/parsers/rst/languages/it.py | 5 +++++ docutils/parsers/rst/languages/sk.py | 5 +++++ docutils/parsers/rst/languages/sv.py | 5 +++++ 8 files changed, 40 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/__init__.py b/docutils/parsers/rst/languages/__init__.py index 86bfd03ba..ea4218657 100644 --- a/docutils/parsers/rst/languages/__init__.py +++ b/docutils/parsers/rst/languages/__init__.py @@ -4,6 +4,9 @@ # Date: $Date$ # Copyright: This module has been placed in the public domain. +# Internationalization details are documented in +# . + """ This package contains modules for language-dependent features of reStructuredText. diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index 7f2a25e78..001b7c3b9 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -5,6 +5,11 @@ # Date: $Date$ # Copyright: This module has been placed in the public domain. +# New language mappings are welcome. Before doing a new translation, please +# read . Two files must be +# translated for each language: one in docutils/languages, the other in +# docutils/parsers/rst/languages. + """ German-language mappings for language-dependent features of reStructuredText. diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index bc488a53e..a9b060f82 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -4,6 +4,11 @@ # Date: $Date$ # Copyright: This module has been placed in the public domain. +# New language mappings are welcome. Before doing a new translation, please +# read . Two files must be +# translated for each language: one in docutils/languages, the other in +# docutils/parsers/rst/languages. + """ English-language mappings for language-dependent features of reStructuredText. @@ -13,6 +18,7 @@ __docformat__ = 'reStructuredText' directives = { + # language-dependent: fixed 'attention': 'attention', 'caution': 'caution', 'danger': 'danger', @@ -54,6 +60,7 @@ directives = { mapping.""" roles = { + # language-dependent: fixed 'abbreviation': 'abbreviation', 'ab': 'abbreviation', 'acronym': 'acronym', diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index 5f3f964a6..d052d918c 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -4,6 +4,11 @@ # Date: $Date$ # Copyright: This module has been placed in the public domain. +# New language mappings are welcome. Before doing a new translation, please +# read . Two files must be +# translated for each language: one in docutils/languages, the other in +# docutils/parsers/rst/languages. + """ Spanish-language mappings for language-dependent features of reStructuredText. diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index 311c5db0f..f75cf6c78 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -4,6 +4,11 @@ # Date: $Date$ # Copyright: This module has been placed in the public domain. +# New language mappings are welcome. Before doing a new translation, please +# read . Two files must be +# translated for each language: one in docutils/languages, the other in +# docutils/parsers/rst/languages. + """ French-language mappings for language-dependent features of reStructuredText. diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index 21ede5bce..aed0f2be5 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -4,6 +4,11 @@ # Date: $Date$ # Copyright: This module has been placed in the public domain. +# New language mappings are welcome. Before doing a new translation, please +# read . Two files must be +# translated for each language: one in docutils/languages, the other in +# docutils/parsers/rst/languages. + """ Italian-language mappings for language-dependent features of reStructuredText. diff --git a/docutils/parsers/rst/languages/sk.py b/docutils/parsers/rst/languages/sk.py index 772f0433f..eb426ed47 100644 --- a/docutils/parsers/rst/languages/sk.py +++ b/docutils/parsers/rst/languages/sk.py @@ -4,6 +4,11 @@ # Date: $Date$ # Copyright: This module has been placed in the public domain. +# New language mappings are welcome. Before doing a new translation, please +# read . Two files must be +# translated for each language: one in docutils/languages, the other in +# docutils/parsers/rst/languages. + """ Slovak-language mappings for language-dependent features of reStructuredText. diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index e126b9dd1..a2f6b77cc 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -4,6 +4,11 @@ # Date: $Date$ # Copyright: This module has been placed in the public domain. +# New language mappings are welcome. Before doing a new translation, please +# read . Two files must be +# translated for each language: one in docutils/languages, the other in +# docutils/parsers/rst/languages. + """ Swedish language mappings for language-dependent features of reStructuredText. """ -- cgit v1.2.1 From 78994b64301991d92e7e0f610c940059e72ff095 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 27 Jun 2003 15:03:30 +0000 Subject: Afrikaans language mappings by Jannie Hofmeyr git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1513 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/af.py | 92 ++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 docutils/parsers/rst/languages/af.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/af.py b/docutils/parsers/rst/languages/af.py new file mode 100644 index 000000000..8ad023ed1 --- /dev/null +++ b/docutils/parsers/rst/languages/af.py @@ -0,0 +1,92 @@ +# Author: Jannie Hofmeyr +# Contact: jhsh@sun.ac.za +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +# New language mappings are welcome. Before doing a new translation, please +# read . Two files must be +# translated for each language: one in docutils/languages, the other in +# docutils/parsers/rst/languages. + +""" +Afrikaans-language mappings for language-dependent features of +reStructuredText. +""" + +__docformat__ = 'reStructuredText' + + +directives = { + 'aandag': 'attention', + 'versigtig': 'caution', + 'gevaar': 'danger', + 'fout': 'error', + 'wenk': 'hint', + 'belangrik': 'important', + 'nota': 'note', + 'tip': 'tip', # hint and tip both have the same translation: wenk + 'waarskuwing': 'warning', + 'vermaning': 'admonition', + 'kantstreep': 'sidebar', + 'onderwerp': 'topic', + 'lynblok': 'line-block', + 'parsed-literal (translation required)': 'parsed-literal', + 'rubriek': 'rubric', + 'epigraaf': 'epigraph', + 'hoogtepunte': 'highlights', + 'pull-quote (translation required)': 'pull-quote', + #'vrae': 'questions', + #'qa': 'questions', + #'faq': 'questions', + 'meta': 'meta', + #'beeldkaart': 'imagemap', + 'beeld': 'image', + 'figuur': 'figure', + 'insluiting': 'include', + 'rou': 'raw', + 'vervang': 'replace', + 'unicode': 'unicode', # should this be translated? unikode + 'klas': 'class', + 'inhoud': 'contents', + 'sectnum': 'sectnum', + 'section-numbering': 'sectnum', + #'voetnote': 'footnotes', + #'aanhalings': 'citations', + 'teikennotas': 'target-notes', + 'restructuredtext-test-directive': 'restructuredtext-test-directive'} +"""Afrikaans name to registered (in directives/__init__.py) directive name +mapping.""" + +roles = { + 'afkorting': 'abbreviation', + 'ab': 'abbreviation', + 'akroniem': 'acronym', + 'ac': 'acronym', + 'indeks': 'index', + 'i': 'index', + 'voetskrif': 'subscript', + 'sub': 'subscript', + 'boskrif': 'superscript', + 'sup': 'superscript', + 'titelverwysing': 'title-reference', + 'titel': 'title-reference', + 't': 'title-reference', + 'pep-verwysing': 'pep-reference', + 'pep': 'pep-reference', + 'rfc-verwysing': 'rfc-reference', + 'rfc': 'rfc-reference', + 'nadruk': 'emphasis', + 'sterk': 'strong', + 'literal (translation required)': 'literal', + 'benoemde verwysing': 'named-reference', + 'anonieme verwysing': 'anonymous-reference', + 'voetnootverwysing': 'footnote-reference', + 'aanhalingverwysing': 'citation-reference', + 'vervangingsverwysing': 'substitution-reference', + 'teiken': 'target', + 'uri-verwysing': 'uri-reference', + 'uri': 'uri-reference', + 'url': 'uri-reference',} +"""Mapping of Afrikaans role names to canonical role names for interpreted text. +""" -- cgit v1.2.1 From 38b5d3c93e10b9be8d781f48d286871f3222f135 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 28 Jun 2003 04:26:35 +0000 Subject: Russian language mappings by Roman Suzi git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1515 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/ru.py | 79 ++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 docutils/parsers/rst/languages/ru.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/ru.py b/docutils/parsers/rst/languages/ru.py new file mode 100644 index 000000000..d1bb1bc94 --- /dev/null +++ b/docutils/parsers/rst/languages/ru.py @@ -0,0 +1,79 @@ +# Author: Roman Suzi +# Contact: rnd@onego.ru +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +# New language mappings are welcome. Before doing a new translation, please +# read . Two files must be +# translated for each language: one in docutils/languages, the other in +# docutils/parsers/rst/languages. + +""" +Russian-language mappings for language-dependent features of +reStructuredText. +""" + +__docformat__ = 'reStructuredText' + +directives = { + u'line-block': u'line-block', + u'meta': u'meta', + u'parsed-literal': u'parsed-literal', + u'pull-quote': u'pull-quote', + u'raw': u'raw', + u'replace': u'replace', + u'restructuredtext-test-directive': u'restructuredtext-test-directive', + u'target-notes': u'target-notes', + u'unicode': u'unicode', + u'\u0431\u043e\u043a\u043e\u0432\u043e\u0435-\u043c\u0435\u043d\u044e': + u'sidebar', + u'\u0432\u0430\u0436\u043d\u043e': u'important', + u'\u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c': u'include', + u'\u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435': u'attention', + u'\u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435': u'highlights', + u'\u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435': u'admonition', + u'\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435': + u'image', + u'\u043a\u043b\u0430\u0441\u0441': u'class', + u'\u043d\u043e\u043c\u0435\u0440-\u0440\u0430\u0437\u0434\u0435\u043b\u0430': + u'sectnum', + u'\u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f-\u0440\u0430\u0437' + u'\u0434\u0435\u043b\u043e\u0432': u'sectnum', + u'\u043e\u043f\u0430\u0441\u043d\u043e': u'danger', + u'\u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e': u'caution', + u'\u043e\u0448\u0438\u0431\u043a\u0430': u'error', + u'\u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430': u'tip', + u'\u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d' + u'\u0438\u0435': u'warning', + u'\u043f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435': u'note', + u'\u0440\u0438\u0441\u0443\u043d\u043e\u043a': u'figure', + u'\u0440\u0443\u0431\u0440\u0438\u043a\u0430': u'rubric', + u'\u0441\u043e\u0432\u0435\u0442': u'hint', + u'\u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435': u'contents', + u'\u0442\u0435\u043c\u0430': u'topic', + u'\u044d\u043f\u0438\u0433\u0440\u0430\u0444': u'epigraph'} +"""Russian name to registered (in directives/__init__.py) directive name +mapping.""" + +roles = { + u'abbreviation (translation required)': 'abbreviation', + u'acronym (translation required)': 'acronym', + u'index (translation required)': 'index', + u'subscript (translation required)': 'subscript', + u'superscript (translation required)': 'superscript', + u'title-reference (translation required)': 'title-reference', + u'pep-reference (translation required)': 'pep-reference', + u'rfc-reference (translation required)': 'rfc-reference', + u'emphasis (translation required)': 'emphasis', + u'strong (translation required)': 'strong', + u'literal (translation required)': 'literal', + u'named-reference (translation required)': 'named-reference', + u'anonymous-reference (translation required)': 'anonymous-reference', + u'footnote-reference (translation required)': 'footnote-reference', + u'citation-reference (translation required)': 'citation-reference', + u'substitution-reference (translation required)': 'substitution-reference', + u'target (translation required)': 'target', + u'uri-reference (translation required)': 'uri-reference',} +"""Mapping of Russian role names to canonical role names for interpreted text. +""" -- cgit v1.2.1 From d3cfd957a5f0b80907bbb272a92e818b09556bf6 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 28 Jun 2003 04:27:51 +0000 Subject: cleaned up & added "roles" mapping to language modules git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1516 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/de.py | 24 +++++++++++++++++++++++- docutils/parsers/rst/languages/es.py | 4 +++- docutils/parsers/rst/languages/fr.py | 22 ++++++++++++++++++++++ docutils/parsers/rst/languages/it.py | 24 +++++++++++++++++++++++- docutils/parsers/rst/languages/sk.py | 22 ++++++++++++++++++++++ docutils/parsers/rst/languages/sv.py | 22 ++++++++++++++++++++++ 6 files changed, 115 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index 001b7c3b9..017a2e851 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -57,5 +57,27 @@ directives = { #'footnotes': 'footnotes', #'citations': 'citations', 'restructuredtext-test-directive': 'restructuredtext-test-directive'} -"""English name to registered (in directives/__init__.py) directive name +"""German name to registered (in directives/__init__.py) directive name mapping.""" + +roles = { + 'abbreviation (translation required)': 'abbreviation', + 'acronym (translation required)': 'acronym', + 'index (translation required)': 'index', + 'subscript (translation required)': 'subscript', + 'superscript (translation required)': 'superscript', + 'title-reference (translation required)': 'title-reference', + 'pep-reference (translation required)': 'pep-reference', + 'rfc-reference (translation required)': 'rfc-reference', + 'emphasis (translation required)': 'emphasis', + 'strong (translation required)': 'strong', + 'literal (translation required)': 'literal', + 'named-reference (translation required)': 'named-reference', + 'anonymous-reference (translation required)': 'anonymous-reference', + 'footnote-reference (translation required)': 'footnote-reference', + 'citation-reference (translation required)': 'citation-reference', + 'substitution-reference (translation required)': 'substitution-reference', + 'target (translation required)': 'target', + 'uri-reference (translation required)': 'uri-reference',} +"""Mapping of German role names to canonical role names for interpreted text. +""" diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index d052d918c..53bb9ff77 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -62,7 +62,7 @@ directives = { #'footnotes': 'footnotes', #'citations': 'citations', u'restructuredtext-test-directive': 'restructuredtext-test-directive'} -"""English name to registered (in directives/__init__.py) directive name +"""Spanish name to registered (in directives/__init__.py) directive name mapping.""" roles = { @@ -73,6 +73,8 @@ roles = { u'ac': 'acronym', u'indice': 'index', u'i': 'index', + u'subscript (translation required)': 'subscript', + u'superscript (translation required)': 'superscript', u'referencia-titulo': 'title-reference', u'titulo': 'title-reference', u't': 'title-reference', diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index f75cf6c78..25f0586a2 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -60,3 +60,25 @@ directives = { } """French name to registered (in directives/__init__.py) directive name mapping.""" + +roles = { + u'abbreviation (translation required)': 'abbreviation', + u'acronym (translation required)': 'acronym', + u'index (translation required)': 'index', + u'subscript (translation required)': 'subscript', + u'superscript (translation required)': 'superscript', + u'title-reference (translation required)': 'title-reference', + u'pep-reference (translation required)': 'pep-reference', + u'rfc-reference (translation required)': 'rfc-reference', + u'emphasis (translation required)': 'emphasis', + u'strong (translation required)': 'strong', + u'literal (translation required)': 'literal', + u'named-reference (translation required)': 'named-reference', + u'anonymous-reference (translation required)': 'anonymous-reference', + u'footnote-reference (translation required)': 'footnote-reference', + u'citation-reference (translation required)': 'citation-reference', + u'substitution-reference (translation required)': 'substitution-reference', + u'target (translation required)': 'target', + u'uri-reference (translation required)': 'uri-reference',} +"""Mapping of French role names to canonical role names for interpreted text. +""" diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index aed0f2be5..911c69a66 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -55,5 +55,27 @@ directives = { #'footnotes': 'footnotes', #'citations': 'citations', 'restructuredtext-test-directive': 'restructuredtext-test-directive'} -"""English name to registered (in directives/__init__.py) directive name +"""Italian name to registered (in directives/__init__.py) directive name mapping.""" + +roles = { + 'abbreviation (translation required)': 'abbreviation', + 'acronym (translation required)': 'acronym', + 'index (translation required)': 'index', + 'subscript (translation required)': 'subscript', + 'superscript (translation required)': 'superscript', + 'title-reference (translation required)': 'title-reference', + 'pep-reference (translation required)': 'pep-reference', + 'rfc-reference (translation required)': 'rfc-reference', + 'emphasis (translation required)': 'emphasis', + 'strong (translation required)': 'strong', + 'literal (translation required)': 'literal', + 'named-reference (translation required)': 'named-reference', + 'anonymous-reference (translation required)': 'anonymous-reference', + 'footnote-reference (translation required)': 'footnote-reference', + 'citation-reference (translation required)': 'citation-reference', + 'substitution-reference (translation required)': 'substitution-reference', + 'target (translation required)': 'target', + 'uri-reference (translation required)': 'uri-reference',} +"""Mapping of Italian role names to canonical role names for interpreted text. +""" diff --git a/docutils/parsers/rst/languages/sk.py b/docutils/parsers/rst/languages/sk.py index eb426ed47..caf3ed5c4 100644 --- a/docutils/parsers/rst/languages/sk.py +++ b/docutils/parsers/rst/languages/sk.py @@ -57,3 +57,25 @@ directives = { } """Slovak name to registered (in directives/__init__.py) directive name mapping.""" + +roles = { + u'abbreviation (translation required)': 'abbreviation', + u'acronym (translation required)': 'acronym', + u'index (translation required)': 'index', + u'subscript (translation required)': 'subscript', + u'superscript (translation required)': 'superscript', + u'title-reference (translation required)': 'title-reference', + u'pep-reference (translation required)': 'pep-reference', + u'rfc-reference (translation required)': 'rfc-reference', + u'emphasis (translation required)': 'emphasis', + u'strong (translation required)': 'strong', + u'literal (translation required)': 'literal', + u'named-reference (translation required)': 'named-reference', + u'anonymous-reference (translation required)': 'anonymous-reference', + u'footnote-reference (translation required)': 'footnote-reference', + u'citation-reference (translation required)': 'citation-reference', + u'substitution-reference (translation required)': 'substitution-reference', + u'target (translation required)': 'target', + u'uri-reference (translation required)': 'uri-reference',} +"""Mapping of Slovak role names to canonical role names for interpreted text. +""" diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index a2f6b77cc..04d105f90 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -56,3 +56,25 @@ directives = { } """Swedish name to registered (in directives/__init__.py) directive name mapping.""" + +roles = { + u'abbreviation (translation required)': 'abbreviation', + u'acronym (translation required)': 'acronym', + u'index (translation required)': 'index', + u'subscript (translation required)': 'subscript', + u'superscript (translation required)': 'superscript', + u'title-reference (translation required)': 'title-reference', + u'pep-reference (translation required)': 'pep-reference', + u'rfc-reference (translation required)': 'rfc-reference', + u'emphasis (translation required)': 'emphasis', + u'strong (translation required)': 'strong', + u'literal (translation required)': 'literal', + u'named-reference (translation required)': 'named-reference', + u'anonymous-reference (translation required)': 'anonymous-reference', + u'footnote-reference (translation required)': 'footnote-reference', + u'citation-reference (translation required)': 'citation-reference', + u'substitution-reference (translation required)': 'substitution-reference', + u'target (translation required)': 'target', + u'uri-reference (translation required)': 'uri-reference',} +"""Mapping of Swedish role names to canonical role names for interpreted text. +""" -- cgit v1.2.1 From cdb8635afb5913cd53eed6fc5aae4b3fce782660 Mon Sep 17 00:00:00 2001 From: rnd0110 Date: Sat, 28 Jun 2003 11:35:58 +0000 Subject: roles translation added git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1520 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/ru.py | 46 ++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 18 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/ru.py b/docutils/parsers/rst/languages/ru.py index d1bb1bc94..df2ea0312 100644 --- a/docutils/parsers/rst/languages/ru.py +++ b/docutils/parsers/rst/languages/ru.py @@ -57,23 +57,33 @@ directives = { mapping.""" roles = { - u'abbreviation (translation required)': 'abbreviation', - u'acronym (translation required)': 'acronym', - u'index (translation required)': 'index', - u'subscript (translation required)': 'subscript', - u'superscript (translation required)': 'superscript', - u'title-reference (translation required)': 'title-reference', - u'pep-reference (translation required)': 'pep-reference', - u'rfc-reference (translation required)': 'rfc-reference', - u'emphasis (translation required)': 'emphasis', - u'strong (translation required)': 'strong', - u'literal (translation required)': 'literal', - u'named-reference (translation required)': 'named-reference', - u'anonymous-reference (translation required)': 'anonymous-reference', - u'footnote-reference (translation required)': 'footnote-reference', - u'citation-reference (translation required)': 'citation-reference', - u'substitution-reference (translation required)': 'substitution-reference', - u'target (translation required)': 'target', - u'uri-reference (translation required)': 'uri-reference',} + u'\u0430\u043a\u0440\u043e\u043d\u0438\u043c': 'acronym', + u'\u0430\u043d\u043e\u043d\u0438\u043c\u043d\u0430\u044f-\u0441\u0441\u044b\u043b\u043a\u0430': + 'anonymous-reference', + u'\u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e': 'literal', + u'\u0432\u0435\u0440\u0445\u043d\u0438\u0439-\u0438\u043d\u0434\u0435\u043a\u0441': + 'superscript', + u'\u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435': 'emphasis', + u'\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u0430\u044f-\u0441\u0441\u044b\u043b\u043a\u0430': + 'named-reference', + u'\u0438\u043d\u0434\u0435\u043a\u0441': 'index', + u'\u043d\u0438\u0436\u043d\u0438\u0439-\u0438\u043d\u0434\u0435\u043a\u0441': + 'subscript', + u'\u0441\u0438\u043b\u044c\u043d\u043e\u0435-\u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435': + 'strong', + u'\u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u0435': + 'abbreviation', + u'\u0441\u0441\u044b\u043b\u043a\u0430-\u0437\u0430\u043c\u0435\u043d\u0430': + 'substitution-reference', + u'\u0441\u0441\u044b\u043b\u043a\u0430-\u043d\u0430-pep': 'pep-reference', + u'\u0441\u0441\u044b\u043b\u043a\u0430-\u043d\u0430-rfc': 'rfc-reference', + u'\u0441\u0441\u044b\u043b\u043a\u0430-\u043d\u0430-uri': 'uri-reference', + u'\u0441\u0441\u044b\u043b\u043a\u0430-\u043d\u0430-\u0437\u0430\u0433\u043b\u0430\u0432\u0438\u0435': + 'title-reference', + u'\u0441\u0441\u044b\u043b\u043a\u0430-\u043d\u0430-\u0441\u043d\u043e\u0441\u043a\u0443': + 'footnote-reference', + u'\u0446\u0438\u0442\u0430\u0442\u043d\u0430\u044f-\u0441\u0441\u044b\u043b\u043a\u0430': + 'citation-reference', + u'\u044f\u043a\u043e\u0440\u044c': 'target'} """Mapping of Russian role names to canonical role names for interpreted text. """ -- cgit v1.2.1 From b21306e492669e1ef941794018d0347e2dbc31f9 Mon Sep 17 00:00:00 2001 From: rnd0110 Date: Sat, 28 Jun 2003 15:01:21 +0000 Subject: More and better translations git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1521 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/ru.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/ru.py b/docutils/parsers/rst/languages/ru.py index df2ea0312..366f4505f 100644 --- a/docutils/parsers/rst/languages/ru.py +++ b/docutils/parsers/rst/languages/ru.py @@ -17,16 +17,20 @@ reStructuredText. __docformat__ = 'reStructuredText' directives = { - u'line-block': u'line-block', + u'\u0431\u043b\u043e\u043a-\u0441\u0442\u0440\u043e\u043a': u'line-block', u'meta': u'meta', - u'parsed-literal': u'parsed-literal', - u'pull-quote': u'pull-quote', - u'raw': u'raw', - u'replace': u'replace', - u'restructuredtext-test-directive': u'restructuredtext-test-directive', - u'target-notes': u'target-notes', + u'\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439-\u043b\u0438\u0442\u0435\u0440\u0430\u043b': + u'parsed-literal', + u'\u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u0430\u044f-\u0446\u0438\u0442\u0430\u0442\u0430': + u'pull-quote', + u'\u0441\u044b\u0440\u043e\u0439': u'raw', + u'\u0437\u0430\u043c\u0435\u043d\u0430': u'replace', + u'\u0442\u0435\u0441\u0442\u043e\u0432\u0430\u044f-\u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430-restructuredtext': + u'restructuredtext-test-directive', + u'\u0446\u0435\u043b\u0435\u0432\u044b\u0435-\u0441\u043d\u043e\u0441\u043a\u0438': + u'target-notes', u'unicode': u'unicode', - u'\u0431\u043e\u043a\u043e\u0432\u043e\u0435-\u043c\u0435\u043d\u044e': + u'\u0431\u043e\u043a\u043e\u0432\u0430\u044f-\u043f\u043e\u043b\u043e\u0441\u0430': u'sidebar', u'\u0432\u0430\u0436\u043d\u043e': u'important', u'\u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c': u'include', @@ -84,6 +88,6 @@ roles = { 'footnote-reference', u'\u0446\u0438\u0442\u0430\u0442\u043d\u0430\u044f-\u0441\u0441\u044b\u043b\u043a\u0430': 'citation-reference', - u'\u044f\u043a\u043e\u0440\u044c': 'target'} + u'\u0446\u0435\u043b\u044c': 'target'} """Mapping of Russian role names to canonical role names for interpreted text. """ -- cgit v1.2.1 From 5a8e95129e0a2603d6b711b5d22b060d071e2021 Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 29 Jun 2003 15:39:51 +0000 Subject: improved error message; suggestion by Roman Suzi git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1527 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 2fc1f8866..c8d04325f 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -2823,7 +2823,7 @@ class Line(SpecializedText): self.short_overline(context, blocktext, lineno, 2) else: msg = self.reporter.severe( - 'Missing underline for overline.', + 'Missing matching underline for section title overline.', nodes.literal_block(source, source), line=lineno) self.parent += msg return [], 'Body', [] -- cgit v1.2.1 From ba89d44c4b8dc3f864afeb94a33aa871c749c727 Mon Sep 17 00:00:00 2001 From: wilk Date: Tue, 1 Jul 2003 09:45:46 +0000 Subject: =?UTF-8?q?m=EF=BF=BDta=20=3D=20meta=20remplace=20=3D=20replace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1541 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/fr.py | 43 ++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index 25f0586a2..7fa0004d3 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -41,13 +41,14 @@ directives = { #u'questions': 'questions', #u'qr': 'questions', #u'faq': 'questions', - u'meta': 'meta', + u'm\u00E9ta': 'meta', #u'imagemap (translation required)': 'imagemap', u'image': 'image', u'figure': 'figure', u'inclure': 'include', u'brut': 'raw', u'remplacer': 'replace', + u'remplace': 'replace', u'unicode': 'unicode', u'classe': 'class', u'sommaire': 'contents', @@ -62,23 +63,27 @@ directives = { mapping.""" roles = { - u'abbreviation (translation required)': 'abbreviation', - u'acronym (translation required)': 'acronym', - u'index (translation required)': 'index', - u'subscript (translation required)': 'subscript', - u'superscript (translation required)': 'superscript', - u'title-reference (translation required)': 'title-reference', - u'pep-reference (translation required)': 'pep-reference', - u'rfc-reference (translation required)': 'rfc-reference', - u'emphasis (translation required)': 'emphasis', - u'strong (translation required)': 'strong', - u'literal (translation required)': 'literal', - u'named-reference (translation required)': 'named-reference', - u'anonymous-reference (translation required)': 'anonymous-reference', - u'footnote-reference (translation required)': 'footnote-reference', - u'citation-reference (translation required)': 'citation-reference', - u'substitution-reference (translation required)': 'substitution-reference', - u'target (translation required)': 'target', - u'uri-reference (translation required)': 'uri-reference',} + u'abr\u00E9viation': 'abbreviation', + u'acronyme': 'acronym', + u'sigle': 'acronym', + u'index': 'index', + u'indice': 'subscript', + u'ind': 'subscript', + u'exposant': 'superscript', + u'exp': 'superscript', + u'titre-r\u00E9f\u00E9rence': 'title-reference', + u'titre': 'title-reference', + u'pep-r\u00E9f\u00E9rence': 'pep-reference', + u'rfc-r\u00E9f\u00E9rence': 'rfc-reference', + u'emphase': 'emphasis', + u'gras': 'strong', + u'litt\u00E9ral': 'literal', + u'nomm\u00E9e-r\u00E9f\u00E9rence': 'named-reference', + u'anonyme-r\u00E9f\u00E9rence': 'anonymous-reference', + u'note-r\u00E9f\u00E9rence': 'footnote-reference', + u'citation-r\u00E9f\u00E9rence': 'citation-reference', + u'substitution-r\u00E9f\u00E9rence': 'substitution-reference', + u'lien': 'target', + u'uri-r\u00E9f\u00E9rence': 'uri-reference',} """Mapping of French role names to canonical role names for interpreted text. """ -- cgit v1.2.1 From 2bab11599eb2b1c483cd583a7cac724782eb461a Mon Sep 17 00:00:00 2001 From: wilk Date: Tue, 1 Jul 2003 09:50:59 +0000 Subject: fort = strong git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1542 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/fr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index 7fa0004d3..ba0bcb014 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -76,7 +76,7 @@ roles = { u'pep-r\u00E9f\u00E9rence': 'pep-reference', u'rfc-r\u00E9f\u00E9rence': 'rfc-reference', u'emphase': 'emphasis', - u'gras': 'strong', + u'fort': 'strong', u'litt\u00E9ral': 'literal', u'nomm\u00E9e-r\u00E9f\u00E9rence': 'named-reference', u'anonyme-r\u00E9f\u00E9rence': 'anonymous-reference', -- cgit v1.2.1 From 3a29321390896b511eecbb1327be76da51d8a809 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 4 Jul 2003 01:42:50 +0000 Subject: Added ``handle_io_errors`` parameter to ``FileInput`` & ``FileOutput`` to enable caller error handling. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1563 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 581c10269..c8af316a2 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -33,10 +33,12 @@ def include(name, arguments, options, content, lineno, path = utils.relative_path(None, path) try: include_file = io.FileInput( - source_path=path, encoding=state.document.settings.input_encoding) + source_path=path, encoding=state.document.settings.input_encoding, + handle_io_errors=None) except IOError, error: severe = state_machine.reporter.severe( - 'Problems with "%s" directive path:\n%s.' % (name, error), + 'Problems with "%s" directive path:\n%s: %s.' + % (name, error.__class__.__name__, error), nodes.literal_block(block_text, block_text), line=lineno) return [severe] include_text = include_file.read() -- cgit v1.2.1 From 2313cb61ce61101b1d6bf7152b273b78196e4bcc Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 5 Jul 2003 19:38:11 +0000 Subject: updated ``RSTState.nested_parse`` for "include" in table cells, but not sure of correctness git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1569 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index c8d04325f..dce993f89 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -273,8 +273,13 @@ class RSTState(StateWS): node=node, match_titles=match_titles) state_machine.unlink() new_offset = state_machine.abs_line_offset() - # Adjustment for block if modified in nested parse: - self.state_machine.next_line(len(block) - block_length) + try: + # Adjustment for block if modified in nested parse: + self.state_machine.next_line(len(block) - block_length) + except EOFError: + # @@@ This accommodates "include" directives in table cells, + # but I'm not sure it's the correct solution. + pass return new_offset def nested_list_parse(self, block, input_offset, node, initial_state, @@ -1286,8 +1291,8 @@ class Body(RSTState): break if blank: a_lines = indented[blank + 1:] - a_lines.strip_indent(match.end(), end=1) - a_lines.strip_indent(indent, start=1) + a_lines.trim_left(match.end(), end=1) + a_lines.trim_left(indent, start=1) return (indented[:blank], a_lines, line_offset + blank + 1) else: return (indented, None, None) -- cgit v1.2.1 From 8056a097d274a6063ef5028200bd28c732697c1d Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 5 Jul 2003 19:40:57 +0000 Subject: reworked for ``StringList``, to support "include" directives in table cells git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1570 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/tableparser.py | 116 ++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 63 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/tableparser.py b/docutils/parsers/rst/tableparser.py index 35b52e578..0fb674eae 100644 --- a/docutils/parsers/rst/tableparser.py +++ b/docutils/parsers/rst/tableparser.py @@ -131,7 +131,8 @@ class GridTableParser(TableParser): head_body_separator_pat = re.compile(r'\+=[=+]+=\+ *$') def setup(self, block): - self.block = list(block) # make a copy; it may be modified + self.block = block[:] # make a copy; it may be modified + self.block.disconnect() self.bottom = len(block) - 1 self.right = len(block[0]) - 1 self.head_body_sep = None @@ -165,7 +166,8 @@ class GridTableParser(TableParser): update_dict_of_lists(self.rowseps, rowseps) update_dict_of_lists(self.colseps, colseps) self.mark_done(top, left, bottom, right) - cellblock = self.get_cell_block(top, left, bottom, right) + cellblock = self.block.get_2D_block(top + 1, left + 1, + bottom, right) self.cells.append((top, left, bottom, right, cellblock)) corners.extend([(top, right), (bottom, left)]) corners.sort() @@ -188,19 +190,6 @@ class GridTableParser(TableParser): return None return 1 - def get_cell_block(self, top, left, bottom, right): - """Given the corners, extract the text of a cell.""" - cellblock = [] - margin = right - for lineno in range(top + 1, bottom): - line = self.block[lineno][left + 1 : right].rstrip() - cellblock.append(line) - if line: - margin = min(margin, len(line) - len(line.lstrip())) - if 0 < margin < right: - cellblock = [line[margin:] for line in cellblock] - return cellblock - def scan_cell(self, top, left): """Starting at the top-left corner, start tracing out a cell.""" assert self.block[top][left] == '+' @@ -278,7 +267,7 @@ class GridTableParser(TableParser): def structure_from_cells(self): """ - From the data colledted by `scan_cell()`, convert to the final data + From the data collected by `scan_cell()`, convert to the final data structure. """ rowseps = self.rowseps.keys() # list of row boundaries @@ -371,7 +360,8 @@ class SimpleTableParser(TableParser): span_pat = re.compile('-[ -]*$') def setup(self, block): - self.block = list(block) # make a copy; it will be modified + self.block = block[:] # make a copy; it will be modified + self.block.disconnect() # Convert top & bottom borders to column span underlines: self.block[0] = self.block[0].replace('=', '-') self.block[-1] = self.block[-1].replace('=', '-') @@ -394,25 +384,26 @@ class SimpleTableParser(TableParser): self.columns = self.parse_columns(self.block[0], 0) self.border_end = self.columns[-1][1] firststart, firstend = self.columns[0] - block = self.block[1:] - offset = 0 - # Container for accumulating text lines until a row is complete: - rowlines = [] - while block: - line = block.pop(0) - offset += 1 + offset = 1 # skip top border + start = 1 + text_found = None + while offset < len(self.block): + line = self.block[offset] if self.span_pat.match(line): # Column span underline or border; row is complete. - self.parse_row(rowlines, (line.rstrip(), offset)) - rowlines = [] + self.parse_row(self.block[start:offset], start, + (line.rstrip(), offset)) + start = offset + 1 + text_found = None elif line[firststart:firstend].strip(): # First column not blank, therefore it's a new row. - if rowlines: - self.parse_row(rowlines) - rowlines = [(line.rstrip(), offset)] - else: - # Accumulate lines of incomplete row. - rowlines.append((line.rstrip(), offset)) + if text_found and offset != start: + self.parse_row(self.block[start:offset], start) + start = offset + text_found = 1 + elif not text_found: + start = offset + 1 + offset += 1 def parse_columns(self, line, offset): """ @@ -448,12 +439,12 @@ class SimpleTableParser(TableParser): morecols += 1 except (AssertionError, IndexError): raise TableMarkupError('Column span alignment problem at ' - 'line offset %s.' % offset) - cells.append((0, morecols, offset, [])) + 'line offset %s.' % (offset + 1)) + cells.append([0, morecols, offset, []]) i += 1 return cells - def parse_row(self, lines, spanline=None): + def parse_row(self, lines, start, spanline=None): """ Given the text `lines` of a row, parse it and append to `self.table`. @@ -462,20 +453,29 @@ class SimpleTableParser(TableParser): text from each line, and check for text in column margins. Finally, adjust for insigificant whitespace. """ - while lines and not lines[-1][0]: - lines.pop() # Remove blank trailing lines. - if lines: - offset = lines[0][1] - elif spanline: - offset = spanline[1] - else: + if not (lines or spanline): # No new row, just blank lines. return if spanline: columns = self.parse_columns(*spanline) + span_offset = spanline[1] else: columns = self.columns[:] - row = self.init_row(columns, offset) + span_offset = start + self.check_columns(lines, start, columns) + row = self.init_row(columns, start) + for i in range(len(columns)): + start, end = columns[i] + cellblock = lines.get_2D_block(0, start, len(lines), end) + row[i][3] = cellblock + self.table.append(row) + + def check_columns(self, lines, first_line, columns): + """ + Check for text in column margins and text overflow in the last column. + Raise TableMarkupError if anything but whitespace is in column margins. + Adjust the end value for the last column if there is text overflow. + """ # "Infinite" value for a dummy last column's beginning, used to # check for text overflow: columns.append((sys.maxint, None)) @@ -483,30 +483,20 @@ class SimpleTableParser(TableParser): for i in range(len(columns) - 1): start, end = columns[i] nextstart = columns[i+1][0] - block = [] - margin = sys.maxint - for line, offset in lines: + offset = 0 + for line in lines: if i == lastcol and line[end:].strip(): text = line[start:].rstrip() - columns[lastcol] = (start, start + len(text)) - self.adjust_last_column(start + len(text)) + new_end = start + len(text) + columns[i] = (start, new_end) + main_start, main_end = self.columns[-1] + if new_end > main_end: + self.columns[-1] = (main_start, new_end) elif line[end:nextstart].strip(): raise TableMarkupError('Text in column margin at line ' - 'offset %s.' % offset) - else: - text = line[start:end].rstrip() - block.append(text) - if text: - margin = min(margin, len(text) - len(text.lstrip())) - if 0 < margin < sys.maxint: - block = [line[margin:] for line in block] - row[i][3].extend(block) - self.table.append(row) - - def adjust_last_column(self, new_end): - start, end = self.columns[-1] - if new_end > end: - self.columns[-1] = (start, new_end) + 'offset %s.' % (first_line + offset)) + offset += 1 + columns.pop() def structure_from_cells(self): colspecs = [end - start for start, end in self.columns] -- cgit v1.2.1 From 58f7621cb2d8e18bfebf255eafc705c5a12c3fae Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 5 Jul 2003 22:38:28 +0000 Subject: fixed table cell line sync problem ("include" directive in cells) git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1574 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 7 ++----- docutils/parsers/rst/tableparser.py | 6 ++++-- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index dce993f89..6c759367c 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -273,13 +273,10 @@ class RSTState(StateWS): node=node, match_titles=match_titles) state_machine.unlink() new_offset = state_machine.abs_line_offset() - try: + # No `block.parent` implies disconnected -- lines aren't in sync: + if block.parent: # Adjustment for block if modified in nested parse: self.state_machine.next_line(len(block) - block_length) - except EOFError: - # @@@ This accommodates "include" directives in table cells, - # but I'm not sure it's the correct solution. - pass return new_offset def nested_list_parse(self, block, input_offset, node, initial_state, diff --git a/docutils/parsers/rst/tableparser.py b/docutils/parsers/rst/tableparser.py index 0fb674eae..8529a65b0 100644 --- a/docutils/parsers/rst/tableparser.py +++ b/docutils/parsers/rst/tableparser.py @@ -132,7 +132,7 @@ class GridTableParser(TableParser): def setup(self, block): self.block = block[:] # make a copy; it may be modified - self.block.disconnect() + self.block.disconnect() # don't propagate changes to parent self.bottom = len(block) - 1 self.right = len(block[0]) - 1 self.head_body_sep = None @@ -168,6 +168,7 @@ class GridTableParser(TableParser): self.mark_done(top, left, bottom, right) cellblock = self.block.get_2D_block(top + 1, left + 1, bottom, right) + cellblock.disconnect() # lines in cell can't sync with parent self.cells.append((top, left, bottom, right, cellblock)) corners.extend([(top, right), (bottom, left)]) corners.sort() @@ -361,7 +362,7 @@ class SimpleTableParser(TableParser): def setup(self, block): self.block = block[:] # make a copy; it will be modified - self.block.disconnect() + self.block.disconnect() # don't propagate changes to parent # Convert top & bottom borders to column span underlines: self.block[0] = self.block[0].replace('=', '-') self.block[-1] = self.block[-1].replace('=', '-') @@ -467,6 +468,7 @@ class SimpleTableParser(TableParser): for i in range(len(columns)): start, end = columns[i] cellblock = lines.get_2D_block(0, start, len(lines), end) + cellblock.disconnect() # lines in cell can't sync with parent row[i][3] = cellblock self.table.append(row) -- cgit v1.2.1 From 8c126d1f6afe2e774adb545664ad7c5302e0d5de Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 9 Jul 2003 17:59:37 +0000 Subject: Renamed ``unchanged()`` directive option conversion function to ``unchanged_required``, and added a new ``unchanged``. Updated docstrings. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1577 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 54 ++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 8 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 1a113db2d..c63fee6a0 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -60,7 +60,8 @@ directive function): - ``options``: A dictionary, mapping known option names to conversion functions such as `int` or `float`. ``None`` or an empty dict implies no - options to parse. + options to parse. Several directive option conversion functions are defined + in this module. - ``content``: A boolean; true if content is allowed. Client code must handle the case where content is required but not supplied (an empty content list @@ -186,6 +187,7 @@ def register_directive(name, directive): def flag(argument): """ Check for a valid flag option (no argument) and return ``None``. + (Directive option conversion function.) Raise ``ValueError`` if an argument is found. """ @@ -194,9 +196,10 @@ def flag(argument): else: return None -def unchanged(argument): +def unchanged_required(argument): """ - Return the argument, unchanged. + Return the argument text, unchanged. + (Directive option conversion function.) Raise ``ValueError`` if no argument is found. """ @@ -205,9 +208,22 @@ def unchanged(argument): else: return argument # unchanged! +def unchanged(argument): + """ + Return the argument text, unchanged. + (Directive option conversion function.) + + No argument implies empty string (""). + """ + if argument is None: + return u'' + else: + return argument # unchanged! + def path(argument): """ Return the path argument unwrapped (with newlines removed). + (Directive option conversion function.) Raise ``ValueError`` if no argument is found or if the path contains internal whitespace. @@ -224,17 +240,44 @@ def path(argument): def nonnegative_int(argument): """ Check for a nonnegative integer argument; raise ``ValueError`` if not. + (Directive option conversion function.) """ value = int(argument) if value < 0: raise ValueError('negative value; must be positive or zero') return value + +def class_option(argument): + """ + Convert the argument into an ID-compatible string and return it. + (Directive option conversion function.) + + Raise ``ValueError`` if no argument is found. + """ + if argument is None: + raise ValueError('argument required but none supplied') + return nodes.make_id(argument) + def format_values(values): return '%s, or "%s"' % (', '.join(['"%s"' % s for s in values[:-1]]), values[-1]) def choice(argument, values): + """ + Directive option utility function, supplied to enable options whose + argument must be a member of a finite set of possible values (must be + lower case). A custom conversion function must be written to use it. For + example:: + + from docutils.parsers.rst import directives + + def yesno(argument): + return directives.choice(argument, ('yes', 'no')) + + Raise ``ValueError`` if no argument is found or if the argument's value is + not valid (not an entry in the supplied list). + """ try: value = argument.lower().strip() except AttributeError: @@ -245,8 +288,3 @@ def choice(argument, values): else: raise ValueError('"%s" unknown; choose from %s' % (argument, format_values(values))) - -def class_option(argument): - if argument is None: - raise ValueError('argument required but none supplied') - return nodes.make_id(argument) -- cgit v1.2.1 From 5fa4d3b2f10a3fb657a03e04733b4f0a346b6dcc Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 9 Jul 2003 18:00:50 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1578 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/body.py | 2 +- docutils/parsers/rst/directives/misc.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index c2fd6b99d..47e1423c8 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -58,7 +58,7 @@ def sidebar(name, arguments, options, content, lineno, node_class=nodes.sidebar) sidebar.arguments = (1, 0, 1) -sidebar.options = {'subtitle': directives.unchanged, +sidebar.options = {'subtitle': directives.unchanged_required, 'class': directives.class_option} sidebar.content = 1 diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index c8af316a2..8c5ff797d 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -229,5 +229,5 @@ def directive_test_function(name, arguments, options, content, lineno, return [info] directive_test_function.arguments = (0, 1, 1) -directive_test_function.options = {'option': directives.unchanged} +directive_test_function.options = {'option': directives.unchanged_required} directive_test_function.content = 1 -- cgit v1.2.1 From 335ac850858ac7eed71df75e491cddeb42da9f7e Mon Sep 17 00:00:00 2001 From: richieadler Date: Fri, 11 Jul 2003 01:30:52 +0000 Subject: Add Esperanto support git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1583 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/eo.py | 100 +++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 docutils/parsers/rst/languages/eo.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/eo.py b/docutils/parsers/rst/languages/eo.py new file mode 100644 index 000000000..35c3a6765 --- /dev/null +++ b/docutils/parsers/rst/languages/eo.py @@ -0,0 +1,100 @@ +# Author: Marcelo Huerta San Martin +# Contact: richieadler@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +# New language mappings are welcome. Before doing a new translation, please +# read . Two files must be +# translated for each language: one in docutils/languages, the other in +# docutils/parsers/rst/languages. + +""" +Esperanto-language mappings for language-dependent features of +reStructuredText. +""" + +__docformat__ = 'reStructuredText' + + +directives = { + # language-dependent: fixed + u'atentu': 'attention', + u'zorgu': 'caution', + u'dangxero': 'danger', + u'dan\u011dero': 'danger', + u'eraro': 'error', + u'spuro': 'hint', + u'grava': 'important', + u'noto': 'note', + u'helpeto': 'tip', + u'averto': 'warning', + u'admono': 'admonition', + u'flankteksto': 'sidebar', + u'temo': 'topic', + u'linea-bloko': 'line-block', + u'analizota-literalo': 'parsed-literal', + u'rubriko': 'rubric', + u'epigrafo': 'epigraph', + u'elstarajxoj': 'highlights', + u'elstara\u0135oj': 'highlights', + u'ekstera-citajxo': 'pull-quote', + u'ekstera-cita\u0135o': 'pull-quote', + #'questions': 'questions', + #'qa': 'questions', + #'faq': 'questions', + u'meta': 'meta', + #'imagemap': 'imagemap', + u'bildo': 'image', + u'figuro': 'figure', + u'inkludi': 'include', + u'senformata': 'raw', + u'anstatauxi': 'replace', + u'anstata\u016di': 'replace', + u'unicode': 'unicode', + u'klaso': 'class', + u'enhavo': 'contents', + u'seknum': 'sectnum', + u'sekcia-numerado': 'sectnum', + #'footnotes': 'footnotes', + #'citations': 'citations', + u'celaj-notoj': 'target-notes', + u'restructuredtext-test-directive': 'restructuredtext-test-directive'} +"""Esperanto name to registered (in directives/__init__.py) directive name +mapping.""" + +roles = { + # language-dependent: fixed + u'mallongigo': 'abbreviation', + u'mall': 'abbreviation', + u'komenclitero': 'acronym', + u'kl': 'acronym', + u'indekso': 'index', + u'i': 'index', + u'subskribo': 'subscript', + u'sub': 'subscript', + u'supraskribo': 'superscript', + u'sup': 'superscript', + u'titola-referenco': 'title-reference', + u'titolo': 'title-reference', + u't': 'title-reference', + u'pep-referenco': 'pep-reference', + u'pep': 'pep-reference', + u'rfc-referenco': 'rfc-reference', + u'rfc': 'rfc-reference', + u'emfazo': 'emphasis', + u'forta': 'strong', + u'litera': 'literal', + u'nomita-referenco': 'named-reference', + u'nenomita-referenco': 'anonymous-reference', + u'piednota-referenco': 'footnote-reference', + u'citajxo-referenco': 'citation-reference', + u'cita\u0135o-referenco': 'citation-reference', + u'anstatauxa-referenco': 'substitution-reference', + u'anstata\u016da-referenco': 'substitution-reference', + u'celo': 'target', + u'uri-referenco': 'uri-reference', + u'uri': 'uri-reference', + u'url': 'uri-reference',} +"""Mapping of Esperanto role names to canonical role names for interpreted text. +""" -- cgit v1.2.1 From 180fb329f6e70b36a04e3ae54238964eec9adf44 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 11 Jul 2003 02:05:37 +0000 Subject: Allowed true em-dash character as block quote attribution marker. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1584 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 6c759367c..216ea8da2 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1254,7 +1254,8 @@ class Body(RSTState): blockquote += attribution return blockquote, messages - attribution_pattern = re.compile(r'--(?![-\n]) *(?=[^ \n])') + # u'\u2014' is an em-dash: + attribution_pattern = re.compile(ur'(--|\u2014)(?![-\n]) *(?=[^ \n])') def check_attribution(self, indented, line_offset): """ -- cgit v1.2.1 From a3418f12380f5ca855453fa104445fcb52ed396c Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 12 Jul 2003 18:59:30 +0000 Subject: allow "---" for block quote attributions too git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1588 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 216ea8da2..6666366b6 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1255,7 +1255,7 @@ class Body(RSTState): return blockquote, messages # u'\u2014' is an em-dash: - attribution_pattern = re.compile(ur'(--|\u2014)(?![-\n]) *(?=[^ \n])') + attribution_pattern = re.compile(ur'(---?(?!-)|\u2014) *(?=[^ \n])') def check_attribution(self, indented, line_offset): """ -- cgit v1.2.1 From 132725742c97909ad694f79467969c5f395a603c Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 1 Aug 2003 23:38:38 +0000 Subject: catch unicode value too high error; fixes bug 781766 git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1618 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 8c5ff797d..dc4c09269 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -183,9 +183,10 @@ def unicode_directive(name, arguments, options, content, lineno, element += nodes.Text(unichr(int(value, 16))) else: element += nodes.Text(code) - except ValueError, err: + except (ValueError, OverflowError), err: error = state_machine.reporter.error( - 'Invalid character code: %s\n%s' % (code, err), + 'Invalid character code: %s\n%s: %s' + % (code, err.__class__.__name__, err), nodes.literal_block(block_text, block_text), line=lineno) return [error] return element.children -- cgit v1.2.1 From a13d6f62d9bd3d9ac04c40524b06578c37e2f58e Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 8 Aug 2003 15:21:09 +0000 Subject: encoding for comment git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1625 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/es.py | 1 + 1 file changed, 1 insertion(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index 53bb9ff77..abe883741 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -1,3 +1,4 @@ +# -*- coding: iso-8859-1 -*- # Author: Marcelo Huerta San Martín # Contact: mghsm@uol.com.ar # Revision: $Revision$ -- cgit v1.2.1 From ffa71e84747057982955e2bad3de2f8d3ed97c69 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 27 Aug 2003 20:50:43 +0000 Subject: Updated for configuration file reorganization. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1645 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/__init__.py | 1 + docutils/parsers/rst/__init__.py | 3 +++ 2 files changed, 4 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/__init__.py b/docutils/parsers/__init__.py index 5b1e964be..027c25a86 100644 --- a/docutils/parsers/__init__.py +++ b/docutils/parsers/__init__.py @@ -16,6 +16,7 @@ from docutils import Component class Parser(Component): component_type = 'parser' + config_section = 'parsers' def parse(self, inputstring, document): """Override to parse `inputstring` into document tree `document`.""" diff --git a/docutils/parsers/rst/__init__.py b/docutils/parsers/rst/__init__.py index 899a49bc8..0b46ad9e8 100644 --- a/docutils/parsers/rst/__init__.py +++ b/docutils/parsers/rst/__init__.py @@ -100,6 +100,9 @@ class Parser(docutils.parsers.Parser): ['--trim-footnote-reference-space'], {'action': 'store_true'}),)) + config_section = 'restructuredtext parser' + config_section_dependencies = ('parsers',) + def __init__(self, rfc2822=None, inliner=None): if rfc2822: self.initial_state = 'RFC2822Body' -- cgit v1.2.1 From 6bf1f3a52b24ff86ba93343d6a04e766601721de Mon Sep 17 00:00:00 2001 From: goodger Date: Mon, 1 Sep 2003 15:09:14 +0000 Subject: updated for setting validators git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1663 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/__init__.py b/docutils/parsers/rst/__init__.py index 0b46ad9e8..679539fb9 100644 --- a/docutils/parsers/rst/__init__.py +++ b/docutils/parsers/rst/__init__.py @@ -75,6 +75,7 @@ __docformat__ = 'reStructuredText' import docutils.parsers import docutils.statemachine from docutils.parsers.rst import states +from docutils import frontend class Parser(docutils.parsers.Parser): @@ -89,16 +90,16 @@ class Parser(docutils.parsers.Parser): None, (('Recognize and link to PEP references (like "PEP 258").', ['--pep-references'], - {'action': 'store_true'}), + {'action': 'store_true', 'validator': frontend.validate_boolean}), ('Recognize and link to RFC references (like "RFC 822").', ['--rfc-references'], - {'action': 'store_true'}), + {'action': 'store_true', 'validator': frontend.validate_boolean}), ('Set number of spaces for tab expansion (default 8).', ['--tab-width'], {'metavar': '', 'type': 'int', 'default': 8}), ('Remove spaces before footnote references.', ['--trim-footnote-reference-space'], - {'action': 'store_true'}),)) + {'action': 'store_true', 'validator': frontend.validate_boolean}),)) config_section = 'restructuredtext parser' config_section_dependencies = ('parsers',) -- cgit v1.2.1 From 296b45ebc25622c11469a55f08ecba9b0b3d8f5e Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 19 Sep 2003 03:01:44 +0000 Subject: Added support for complex option arguments (option lists). git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1695 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 6666366b6..bb84261ae 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1198,8 +1198,10 @@ class Body(RSTState): '|%(upperroman)s)' % enum.sequencepats) pats['optname'] = '%(alphanum)s%(alphanumplus)s*' % pats # @@@ Loosen up the pattern? Allow Unicode? - pats['optarg'] = '%(alpha)s%(alphanumplus)s*' % pats - pats['option'] = r'(--?|\+|/)%(optname)s([ =]%(optarg)s)?' % pats + pats['optarg'] = '(%(alpha)s%(alphanumplus)s*|<%(alphanum)s[^ <>]+>)' % pats + pats['shortopt'] = r'(-|\+)%(alphanum)s( ?%(optarg)s)?' % pats + pats['longopt'] = r'(--|/)%(optname)s([ =]%(optarg)s)?' % pats + pats['option'] = r'(%(shortopt)s|%(longopt)s)' % pats for format in enum.formats: pats[format] = '(?P<%s>%s%s%s)' % ( @@ -1572,6 +1574,12 @@ class Body(RSTState): if len(firstopt) > 1: tokens[:1] = firstopt delimiter = '=' + elif (len(tokens[0]) > 2 + and ((tokens[0].startswith('-') + and not tokens[0].startswith('--')) + or tokens[0].startswith('+'))): + tokens[:1] = [tokens[0][:2], tokens[0][2:]] + delimiter = '' if 0 < len(tokens) <= 2: option = nodes.option(optionstring) option += nodes.option_string(tokens[0], tokens[0]) -- cgit v1.2.1 From db535a208f73d2fc6af3887c5cb8d0030558213d Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 20 Sep 2003 17:22:11 +0000 Subject: Fixed handling of backslashes in substitution definitions. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1696 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 6 ++++-- docutils/parsers/rst/states.py | 6 ++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index dc4c09269..a567ac9e2 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -170,7 +170,7 @@ def unicode_directive(name, arguments, options, content, lineno, 'substitution definition.' % (name), nodes.literal_block(block_text, block_text), line=lineno) return [error] - codes = arguments[0].split('.. ')[0].split() + codes = unicode_comment_pattern.split(arguments[0])[0].split() element = nodes.Element() for code in codes: try: @@ -193,7 +193,9 @@ def unicode_directive(name, arguments, options, content, lineno, unicode_directive.arguments = (1, 0, 1) unicode_pattern = re.compile( - r'(?:0x|x|\x00x|U\+?|\x00u)([0-9a-f]+)$|&#x([0-9a-f]+);$', re.IGNORECASE) + r'(?:0x|x|\\x|U\+?|\\u)([0-9a-f]+)$|&#x([0-9a-f]+);$', re.IGNORECASE) +unicode_comment_pattern = re.compile(r'( |\n|^).. ') + def class_directive(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index bb84261ae..82ae15791 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1936,9 +1936,7 @@ class Body(RSTState): strip_indent=0) blocktext = (match.string[:match.end()] + '\n'.join(block)) block.disconnect() - for i in range(len(block)): - block[i] = escape2null(block[i]) - escaped = block[0].rstrip() + escaped = escape2null(block[0].rstrip()) blockindex = 0 while 1: subdefmatch = pattern.match(escaped) @@ -1946,7 +1944,7 @@ class Body(RSTState): break blockindex += 1 try: - escaped = escaped + ' ' + block[blockindex].strip() + escaped = escaped + ' ' + escape2null(block[blockindex].strip()) except IndexError: raise MarkupError('malformed substitution definition.', lineno) -- cgit v1.2.1 From a64ff7ddc4a8637fd9dda75947e93c005ee4a2de Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 7 Nov 2003 14:48:26 +0000 Subject: fixed off-by-1 error with extra whitespace after substitution definition directive git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1733 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 82ae15791..d85ad8dae 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1949,7 +1949,7 @@ class Body(RSTState): raise MarkupError('malformed substitution definition.', lineno) del block[:blockindex] # strip out the substitution marker - block[0] = (block[0] + ' ')[subdefmatch.end()-len(escaped)-1:].strip() + block[0] = (block[0].strip() + ' ')[subdefmatch.end()-len(escaped)-1:-1] if not block[0]: del block[0] offset += 1 -- cgit v1.2.1 From 9810caa640eceab1a8c3f73c8c5ce5a7fd1f2bee Mon Sep 17 00:00:00 2001 From: lalo Date: Mon, 1 Dec 2003 03:48:50 +0000 Subject: adding pt-br language files git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1753 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/pt-br.py | 94 +++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 docutils/parsers/rst/languages/pt-br.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/pt-br.py b/docutils/parsers/rst/languages/pt-br.py new file mode 100644 index 000000000..5fc68218a --- /dev/null +++ b/docutils/parsers/rst/languages/pt-br.py @@ -0,0 +1,94 @@ +# Author: David Goodger +# Contact: goodger@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +# New language mappings are welcome. Before doing a new translation, please +# read . Two files must be +# translated for each language: one in docutils/languages, the other in +# docutils/parsers/rst/languages. + +""" +Brazilian Portuguese-language mappings for language-dependent features of +reStructuredText. +""" + +__docformat__ = 'reStructuredText' + + +directives = { + # language-dependent: fixed + u'atenção': 'attention', + 'cuidado': 'caution', + 'perigo': 'danger', + 'erro': 'error', + u'sugestão': 'hint', + 'importante': 'important', + 'nota': 'note', + 'dica': 'tip', + 'aviso': 'warning', + u'exortação': 'admonition', + 'barra-lateral': 'sidebar', + u'tópico': 'topic', + 'bloco-de-linhas': 'line-block', + 'literal-interpretado': 'parsed-literal', + 'rubrica': 'rubric', + u'epígrafo': 'epigraph', + 'destaques': 'highlights', + u'citação-destacada': 'pull-quote', + #'perguntas': 'questions', + #'qa': 'questions', + #'faq': 'questions', + 'meta': 'meta', + #'imagemap': 'imagemap', + 'imagem': 'image', + 'figura': 'figure', + u'inclusão': 'include', + 'cru': 'raw', + u'substituição': 'replace', + 'unicode': 'unicode', + 'classe': 'class', + u'índice': 'contents', + 'numsec': 'sectnum', + u'numeração-de-seções': 'sectnum', + #u'notas-de-rorapé': 'footnotes', + #u'citações': 'citations', + u'links-no-rodapé': 'target-notes', + 'restructuredtext-test-directive': 'restructuredtext-test-directive'} +"""English name to registered (in directives/__init__.py) directive name +mapping.""" + +roles = { + # language-dependent: fixed + u'abbreviação': 'abbreviation', + 'ab': 'abbreviation', + u'acrônimo': 'acronym', + 'ac': 'acronym', + u'índice-remissivo': 'index', + 'i': 'index', + 'subscrito': 'subscript', + 'sub': 'subscript', + 'sobrescrito': 'superscript', + 'sob': 'superscript', + u'referência-a-título': 'title-reference', + u'título': 'title-reference', + 't': 'title-reference', + u'referência-a-pep': 'pep-reference', + 'pep': 'pep-reference', + u'referência-a-rfc': 'rfc-reference', + 'rfc': 'rfc-reference', + u'ênfase': 'emphasis', + 'forte': 'strong', + 'literal': 'literal', + u'referência-por-nome': 'named-reference', + u'referência-anônima': 'anonymous-reference', + u'referência-a-nota-de-rodapé': 'footnote-reference', + u'referência-a-citação': 'citation-reference', + u'referência-a-substituição': 'substitution-reference', + 'alvo': 'target', + u'referência-a-uri': 'uri-reference', + 'uri': 'uri-reference', + 'url': 'uri-reference',} +"""Mapping of English role names to canonical role names for interpreted text. +""" -- cgit v1.2.1 From 1a045085cb46a990840be96ba284f850aaf8491d Mon Sep 17 00:00:00 2001 From: goodger Date: Mon, 15 Dec 2003 14:13:55 +0000 Subject: added Czech-language mappings by Marek Blaha git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1767 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/cs.py | 94 ++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 docutils/parsers/rst/languages/cs.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/cs.py b/docutils/parsers/rst/languages/cs.py new file mode 100644 index 000000000..45fb5e657 --- /dev/null +++ b/docutils/parsers/rst/languages/cs.py @@ -0,0 +1,94 @@ +# Author: Marek Blaha +# Contact: mb@dat.cz +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +# New language mappings are welcome. Before doing a new translation, please +# read . Two files must be +# translated for each language: one in docutils/languages, the other in +# docutils/parsers/rst/languages. + +""" +Czech-language mappings for language-dependent features of +reStructuredText. +""" + +__docformat__ = 'reStructuredText' + + +directives = { + # language-dependent: fixed + u'pozor': 'attention', + u'caution': 'caution', # jak rozlisit caution a warning? + u'nebezpe\u010D\u00ED': 'danger', + u'chyba': 'error', + u'rada': 'hint', + u'd\u016Fle\u017Eit\u00E9': 'important', + u'pozn\u00E1mka': 'note', + u'tip': 'tip', + u'varov\u00E1n\u00ED': 'warning', + u'admonition': 'admonition', + u'sidebar': 'sidebar', + u't\u00E9ma': 'topic', + u'line-block': 'line-block', + u'parsed-literal': 'parsed-literal', + u'odd\u00EDl': 'rubric', + u'moto': 'epigraph', + u'highlights': 'highlights', + u'pull-quote': 'pull-quote', + #'questions': 'questions', + #'qa': 'questions', + #'faq': 'questions', + u'meta': 'meta', + #'imagemap': 'imagemap', + u'image': 'image', # obrazek + u'figure': 'figure', # a tady? + u'include': 'include', + u'raw': 'raw', + u'replace': 'replace', + u'unicode': 'unicode', + u't\u0159\u00EDda': 'class', + u'obsah': 'contents', + u'sectnum': 'sectnum', + u'section-numbering': 'sectnum', + #'footnotes': 'footnotes', + #'citations': 'citations', + u'target-notes': 'target-notes', + u'restructuredtext-test-directive': 'restructuredtext-test-directive'} +"""Czech name to registered (in directives/__init__.py) directive name +mapping.""" + +roles = { + # language-dependent: fixed + u'abbreviation': 'abbreviation', + u'ab': 'abbreviation', + u'acronym': 'acronym', + u'ac': 'acronym', + u'index': 'index', + u'i': 'index', + u'subscript': 'subscript', + u'sub': 'subscript', + u'superscript': 'superscript', + u'sup': 'superscript', + u'title-reference': 'title-reference', + u'title': 'title-reference', + u't': 'title-reference', + u'pep-reference': 'pep-reference', + u'pep': 'pep-reference', + u'rfc-reference': 'rfc-reference', + u'rfc': 'rfc-reference', + u'emphasis': 'emphasis', + u'strong': 'strong', + u'literal': 'literal', + u'named-reference': 'named-reference', + u'anonymous-reference': 'anonymous-reference', + u'footnote-reference': 'footnote-reference', + u'citation-reference': 'citation-reference', + u'substitution-reference': 'substitution-reference', + u'target': 'target', + u'uri-reference': 'uri-reference', + u'uri': 'uri-reference', + u'url': 'uri-reference',} +"""Mapping of Czech role names to canonical role names for interpreted text. +""" -- cgit v1.2.1 From c5e249ae47c1c7b96367b911b7aa7817ba85c797 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 19 Dec 2003 14:30:13 +0000 Subject: Added inline markup parsing to field lists' field names git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1771 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index d85ad8dae..be0ab922d 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1494,8 +1494,9 @@ class Body(RSTState): self.state_machine.get_first_known_indented(match.end()) fieldnode = nodes.field() fieldnode.line = lineno - fieldnode += nodes.field_name(name, name) - fieldbody = nodes.field_body('\n'.join(indented)) + name_nodes, name_messages = self.inline_text(name, lineno) + fieldnode += nodes.field_name(name, '', *name_nodes) + fieldbody = nodes.field_body('\n'.join(indented), *name_messages) fieldnode += fieldbody if indented: self.parse_field_body(indented, line_offset, fieldbody) -- cgit v1.2.1 From 19c14c68f9ae90da3cc2595df2eb74a9f56a9115 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 19 Dec 2003 14:35:47 +0000 Subject: improved some naming git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1772 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index be0ab922d..0d4e6ab03 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1472,15 +1472,15 @@ class Body(RSTState): def field_marker(self, match, context, next_state): """Field list item.""" - fieldlist = nodes.field_list() - self.parent += fieldlist + field_list = nodes.field_list() + self.parent += field_list field, blank_finish = self.field(match) - fieldlist += field + field_list += field offset = self.state_machine.line_offset + 1 # next line newline_offset, blank_finish = self.nested_list_parse( self.state_machine.input_lines[offset:], input_offset=self.state_machine.abs_line_offset() + 1, - node=fieldlist, initial_state='FieldList', + node=field_list, initial_state='FieldList', blank_finish=blank_finish) self.goto_line(newline_offset) if not blank_finish: @@ -1492,15 +1492,15 @@ class Body(RSTState): lineno = self.state_machine.abs_line_number() indented, indent, line_offset, blank_finish = \ self.state_machine.get_first_known_indented(match.end()) - fieldnode = nodes.field() - fieldnode.line = lineno + field_node = nodes.field() + field_node.line = lineno name_nodes, name_messages = self.inline_text(name, lineno) - fieldnode += nodes.field_name(name, '', *name_nodes) - fieldbody = nodes.field_body('\n'.join(indented), *name_messages) - fieldnode += fieldbody + field_node += nodes.field_name(name, '', *name_nodes) + field_body = nodes.field_body('\n'.join(indented), *name_messages) + field_node += field_body if indented: - self.parse_field_body(indented, line_offset, fieldbody) - return fieldnode, blank_finish + self.parse_field_body(indented, line_offset, field_body) + return field_node, blank_finish def parse_field_marker(self, match): """Extract & return field name from a field marker match.""" -- cgit v1.2.1 From f74494c19b8a9de8a1bb4d6c2acce694b24d802b Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 20 Dec 2003 18:48:23 +0000 Subject: Added support for quoted (and unindented) literal blocks. Driven in part by a bribe from Frank Siebenlist (thanks!). git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1773 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 102 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 91 insertions(+), 11 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 0d4e6ab03..571fe8f42 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -274,7 +274,7 @@ class RSTState(StateWS): state_machine.unlink() new_offset = state_machine.abs_line_offset() # No `block.parent` implies disconnected -- lines aren't in sync: - if block.parent: + if block.parent and (len(block) - block_length) != 0: # Adjustment for block if modified in nested parse: self.state_machine.next_line(len(block) - block_length) return new_offset @@ -2661,20 +2661,29 @@ class Text(RSTState): """Return a list of nodes.""" indented, indent, offset, blank_finish = \ self.state_machine.get_indented() - nodelist = [] while indented and not indented[-1].strip(): indented.trim_end() - if indented: - data = '\n'.join(indented) - nodelist.append(nodes.literal_block(data, data)) - if not blank_finish: - nodelist.append(self.unindent_warning('Literal block')) - else: - nodelist.append(self.reporter.warning( - 'Literal block expected; none found.', - line=self.state_machine.abs_line_number())) + if not indented: + return self.quoted_literal_block() + nodelist = [] + data = '\n'.join(indented) + nodelist.append(nodes.literal_block(data, data)) + if not blank_finish: + nodelist.append(self.unindent_warning('Literal block')) return nodelist + def quoted_literal_block(self): + abs_line_offset = self.state_machine.abs_line_offset() + offset = self.state_machine.line_offset + parent_node = nodes.Element() + new_abs_offset = self.nested_parse( + self.state_machine.input_lines[offset:], + input_offset=abs_line_offset, node=parent_node, match_titles=0, + state_machine_kwargs={'state_classes': (QuotedLiteralBlock,), + 'initial_state': 'QuotedLiteralBlock'}) + self.goto_line(new_abs_offset) + return parent_node.children + def definition_list_item(self, termline): indented, indent, line_offset, blank_finish = \ self.state_machine.get_indented() @@ -2891,6 +2900,77 @@ class Line(SpecializedText): raise statemachine.StateCorrection('Body', 'text') +class QuotedLiteralBlock(RSTState): + + """ + Nested parse handler for quoted (unindented) literal blocks. + + Special-purpose. Not for inclusion in `state_classes`. + """ + + patterns = {'initial_quoted': r'(%(nonalphanum7bit)s)' % Body.pats, + 'text': r''} + initial_transitions = ('initial_quoted', 'text') + + def __init__(self, state_machine, debug=0): + RSTState.__init__(self, state_machine, debug) + self.messages = [] + self.initial_lineno = None + + def blank(self, match, context, next_state): + if context: + raise EOFError + else: + return context, next_state, [] + + def eof(self, context): + if context: + text = '\n'.join(context) + literal_block = nodes.literal_block(text, text) + literal_block.line = self.initial_lineno + self.parent += literal_block + else: + self.parent += self.reporter.warning( + 'Literal block expected; none found.', + line=self.state_machine.abs_line_number()) + self.state_machine.previous_line() + self.parent += self.messages + return [] + + def indent(self, match, context, next_state): + assert context, ('QuotedLiteralBlock.indent: context should not ' + 'be empty!') + self.messages.append( + self.reporter.error('Unexpected indentation.', + line=self.state_machine.abs_line_number())) + self.state_machine.previous_line() + raise EOFError + + def initial_quoted(self, match, context, next_state): + """Match arbitrary quote character on the first line only.""" + self.remove_transition('initial_quoted') + quote = match.string[0] + pattern = re.compile(re.escape(quote)) + # New transition matches consistent quotes only: + self.add_transition('quoted', + (pattern, self.quoted, self.__class__.__name__)) + self.initial_lineno = self.state_machine.abs_line_number() + return [match.string], next_state, [] + + def quoted(self, match, context, next_state): + """Match consistent quotes on subsequent lines.""" + context.append(match.string) + return context, next_state, [] + + def text(self, match, context, next_state): + if context: + self.messages.append( + self.reporter.error('Inconsistent literal block quoting.', + line=self.state_machine.abs_line_number())) + self.state_machine.previous_line() + raise EOFError + + state_classes = (Body, BulletList, DefinitionList, EnumeratedList, FieldList, OptionList, ExtensionOptions, Explicit, Text, Definition, Line, SubstitutionDef, RFC2822Body, RFC2822List) -- cgit v1.2.1 From e4bb28bf3f6655e31095bf801d50c35566c6dc52 Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 21 Dec 2003 02:32:02 +0000 Subject: beefed up directive error reporting git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1774 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index c63fee6a0..fdddb6c9d 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -165,18 +165,29 @@ def directive(directive_name, language_module, document): try: modulename, functionname = _directive_registry[canonicalname] except KeyError: + messages.append(document.reporter.error( + 'Directive "%s" not registered (canonical name "%s").' + % (directive_name, canonicalname), line=document.current_line)) return None, messages if _modules.has_key(modulename): module = _modules[modulename] else: try: module = __import__(modulename, globals(), locals()) - except ImportError: + except ImportError, detail: + messages.append(document.reporter.error( + 'Error importing directive module "%s" (directive "%s"):\n%s' + % (modulename, directive_name, detail), + line=document.current_line)) return None, messages try: function = getattr(module, functionname) _directives[normname] = function except AttributeError: + messages.append(document.reporter.error( + 'No function "%s" in module "%s" (directive "%s").' + % (functionname, modulename, directive_name), + line=document.current_line)) return None, messages return function, messages -- cgit v1.2.1 From 0029088b1ff3335c7beae49ca03f4ddd7d0e5381 Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 21 Dec 2003 02:46:40 +0000 Subject: Isolated the import of the ``urllib2`` module; was causing problems on SourceForge (``libssl.so.2`` unavailable?). git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1775 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index a567ac9e2..446935831 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -11,11 +11,15 @@ __docformat__ = 'reStructuredText' import sys import os.path import re -from urllib2 import urlopen, URLError from docutils import io, nodes, statemachine, utils from docutils.parsers.rst import directives, states from docutils.transforms import misc +try: + import urllib2 +except ImportError: + urllib2 = None + def include(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): @@ -97,9 +101,16 @@ def raw(name, arguments, options, content, lineno, raw_file.close() attributes['source'] = path elif options.has_key('url'): + if not urllib2: + severe = state_machine.reporter.severe( + 'Problems with the "%s" directive and its "url" option: ' + 'unable to access the required functionality (from the ' + '"urllib2" module).' % name, + nodes.literal_block(block_text, block_text), line=lineno) + return [severe] try: - raw_file = urlopen(options['url']) - except (URLError, IOError, OSError), error: + raw_file = urllib2.urlopen(options['url']) + except (urllib2.URLError, IOError, OSError), error: severe = state_machine.reporter.severe( 'Problems with "%s" directive URL "%s":\n%s.' % (name, options['url'], error), -- cgit v1.2.1 From 1a9d3d2ed89b62a7ed5126355e3f11b70ed1e5c1 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 24 Dec 2003 15:05:18 +0000 Subject: Upon reviewing RFC 2396, I see that asterisks are valid URL characters, sometimes actually used. There's a conflict with emphasis, but backslash escapes should overcome that (they didn't). This fixes a bug in the parser that escaped asterisks in URLs weren't recognized. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1778 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 571fe8f42..1c9b65f20 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -601,11 +601,12 @@ class Inliner: non_whitespace_after = r'(?![ \n])' # Alphanumerics with isolated internal [-._] chars (i.e. not 2 together): simplename = r'(?:(?!_)\w)+(?:[-._](?:(?!_)\w)+)*' - # Valid URI characters (see RFC 2396 & RFC 2732): - uric = r"""[-_.!~*'()[\];/:@&=+$,%a-zA-Z0-9]""" + # Valid URI characters (see RFC 2396 & RFC 2732); + # final \x00 allows backslash escapes in URIs: + uric = r"""[-_.!~*'()[\];/:@&=+$,%a-zA-Z0-9\x00]""" # Last URI character; same as uric but no punctuation: urilast = r"""[_~/a-zA-Z0-9]""" - emailc = r"""[-_!~*'{|}/#?^`&=+$%a-zA-Z0-9]""" + emailc = r"""[-_!~*'{|}/#?^`&=+$%a-zA-Z0-9\x00]""" email_pattern = r""" %(emailc)s+(?:\.%(emailc)s+)* # name @ # at -- cgit v1.2.1 From 4e174f882eb88ad4fd1e41e785a5c21e347e0c53 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 24 Dec 2003 15:51:38 +0000 Subject: Made embedded-URIs' reference text omittable. Idea from Beni Cherniavsky. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1781 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 1c9b65f20..9e048099d 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -660,10 +660,10 @@ class Inliner: embedded_uri=re.compile( r""" ( - [ \n]+ # spaces or beginning of line + (?:[ \n]+|^) # spaces or beginning of line/string < # open bracket %(non_whitespace_after)s - ([^<>\0]+) # anything but angle brackets & nulls + ([^<>\x00]+) # anything but angle brackets & nulls %(non_whitespace_before)s > # close bracket w/o whitespace before ) @@ -862,6 +862,8 @@ class Inliner: target = nodes.target(match.group(1), refuri=uri) else: raise ApplicationError('problem with URI: %r' % uri_text) + if not text: + text = uri else: target = None refname = normalize_name(text) -- cgit v1.2.1 From 69e7ed1f66cc19205efaa870de5f76a30fdc09c4 Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 4 Jan 2004 17:34:17 +0000 Subject: Refactored explicit target processing code git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1790 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 85 ++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 45 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 9e048099d..26f55c566 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1880,30 +1880,48 @@ class Body(RSTState): raise MarkupError('malformed hyperlink target.', lineno) del block[:blockindex] block[0] = (block[0] + ' ')[targetmatch.end()-len(escaped)-1:].strip() + target = self.make_target(block, blocktext, lineno, + targetmatch.group('name')) + return [target], blank_finish + + def make_target(self, block, block_text, lineno, target_name): + target_type, data = self.parse_target(block, block_text, lineno) + if target_type == 'refname': + target = nodes.target(block_text, '', refname=data) + self.add_target(target_name, '', target, lineno) + self.document.note_indirect_target(target) + return target + elif target_type == 'refuri': + target = nodes.target(block_text, '') + self.add_target(target_name, data, target, lineno) + return target + else: + return data + + def parse_target(self, block, block_text, lineno): + """ + Determine the type of reference of a target. + + :Return: A 2-tuple, one of: + + - 'refname' and the indirect reference name + - 'refuri' and the URI + - 'malformed' and a system_message node + """ if block and block[-1].strip()[-1:] == '_': # possible indirect target reference = ' '.join([line.strip() for line in block]) refname = self.is_reference(reference) if refname: - target = nodes.target(blocktext, '', refname=refname) - target.line = lineno - self.add_target(targetmatch.group('name'), '', target) - self.document.note_indirect_target(target) - return [target], blank_finish - nodelist = [] + return 'refname', refname reference = ''.join([line.strip() for line in block]) - if reference.find(' ') != -1: + if reference.find(' ') == -1: + return 'refuri', unescape(reference) + else: warning = self.reporter.warning( 'Hyperlink target contains whitespace. Perhaps a footnote ' 'was intended?', - nodes.literal_block(blocktext, blocktext), line=lineno) - nodelist.append(warning) - else: - unescaped = unescape(reference) - target = nodes.target(blocktext, '') - target.line = lineno - self.add_target(targetmatch.group('name'), unescaped, target) - nodelist.append(target) - return nodelist, blank_finish + nodes.literal_block(block_text, block_text), line=lineno) + return 'malformed', warning def is_reference(self, reference): match = self.explicit.patterns.reference.match( @@ -1912,7 +1930,8 @@ class Body(RSTState): return None return unescape(match.group('simple') or match.group('phrase')) - def add_target(self, targetname, refuri, target): + def add_target(self, targetname, refuri, target, lineno): + target.line = lineno if targetname: name = normalize_name(unescape(targetname)) target['name'] = name @@ -2255,38 +2274,14 @@ class Body(RSTState): return [], next_state, [] def anonymous_target(self, match): + lineno = self.state_machine.abs_line_number() block, indent, offset, blank_finish \ = self.state_machine.get_first_known_indented(match.end(), until_blank=1) blocktext = match.string[:match.end()] + '\n'.join(block) - if block and block[-1].strip()[-1:] == '_': # possible indirect target - reference = escape2null(' '.join([line.strip() - for line in block])) - refname = self.is_reference(reference) - if refname: - target = nodes.target(blocktext, '', refname=refname, - anonymous=1) - self.document.note_anonymous_target(target) - self.document.note_indirect_target(target) - return [target], blank_finish - nodelist = [] - reference = escape2null(''.join([line.strip() for line in block])) - if reference.find(' ') != -1: - lineno = self.state_machine.abs_line_number() - len(block) + 1 - warning = self.reporter.warning( - 'Anonymous hyperlink target contains whitespace. Perhaps a ' - 'footnote was intended?', - nodes.literal_block(blocktext, blocktext), - line=lineno) - nodelist.append(warning) - else: - target = nodes.target(blocktext, '', anonymous=1) - if reference: - unescaped = unescape(reference) - target['refuri'] = unescaped - self.document.note_anonymous_target(target) - nodelist.append(target) - return nodelist, blank_finish + block = [escape2null(line) for line in block] + target = self.make_target(block, blocktext, lineno, '') + return [target], blank_finish def line(self, match, context, next_state): """Section title overline or transition marker.""" -- cgit v1.2.1 From 10a6b744053a86b58f789caa23bfac62c1afa5fb Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 4 Jan 2004 17:35:33 +0000 Subject: Added "target" option to "image" directive git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1791 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index d193edffd..a835d3d74 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -13,7 +13,7 @@ __docformat__ = 'reStructuredText' import sys from docutils import nodes, utils -from docutils.parsers.rst import directives +from docutils.parsers.rst import directives, states try: import Image # PIL @@ -34,8 +34,22 @@ def image(name, arguments, options, content, lineno, nodes.literal_block(block_text, block_text), line=lineno) return [error] options['uri'] = reference - image_node = nodes.image(block_text, **options) - return [image_node] + if options.has_key('target'): + block = states.escape2null(options['target']).splitlines() + block = [line for line in block] + target_type, data = state.parse_target(block, block_text, lineno) + if target_type == 'refuri': + node_list = nodes.reference(refuri=data) + elif target_type == 'refname': + node_list = nodes.reference(refname=data) + state.document.note_refname(node_list) + else: # malformed target + node_list = [data] # data is a system message + del options['target'] + else: + node_list = [] + node_list.append(nodes.image(block_text, **options)) + return node_list image.arguments = (1, 0, 1) image.options = {'alt': directives.unchanged, @@ -43,6 +57,7 @@ image.options = {'alt': directives.unchanged, 'width': directives.nonnegative_int, 'scale': directives.nonnegative_int, 'align': align, + 'target': directives.unchanged_required, 'class': directives.class_option} def figure(name, arguments, options, content, lineno, -- cgit v1.2.1 From 74bc7e3a7d5fe2ece9a48ffb4d368879e986b1bc Mon Sep 17 00:00:00 2001 From: goodger Date: Mon, 12 Jan 2004 16:27:25 +0000 Subject: added "table" directive git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1799 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 1 + docutils/parsers/rst/directives/body.py | 35 +++++++++++++++++++++++++++++ docutils/parsers/rst/languages/af.py | 1 + docutils/parsers/rst/languages/cs.py | 1 + docutils/parsers/rst/languages/de.py | 1 + docutils/parsers/rst/languages/en.py | 1 + docutils/parsers/rst/languages/eo.py | 1 + docutils/parsers/rst/languages/es.py | 1 + docutils/parsers/rst/languages/fr.py | 1 + docutils/parsers/rst/languages/it.py | 1 + docutils/parsers/rst/languages/pt-br.py | 1 + docutils/parsers/rst/languages/ru.py | 1 + docutils/parsers/rst/languages/sk.py | 1 + docutils/parsers/rst/languages/sv.py | 1 + 14 files changed, 48 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index fdddb6c9d..23ef04188 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -102,6 +102,7 @@ _directive_registry = { 'epigraph': ('body', 'epigraph'), 'highlights': ('body', 'highlights'), 'pull-quote': ('body', 'pull_quote'), + 'table': ('body', 'table'), #'questions': ('body', 'question_list'), 'image': ('images', 'image'), 'figure': ('images', 'figure'), diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index 47e1423c8..122b2ccc4 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -120,3 +120,38 @@ def pull_quote(name, arguments, options, content, lineno, return [block_quote] + messages pull_quote.content = 1 + +def table(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + if not content: + warning = state_machine.reporter.warning( + 'Content block expected for the "%s" directive; none found.' + % name, nodes.literal_block(block_text, block_text), + line=lineno) + return [warning] + if arguments: + title_text = arguments[0] + text_nodes, messages = state.inline_text(title_text, lineno) + title = nodes.title(title_text, '', *text_nodes) + else: + title = None + node = nodes.Element() # anonymous container for parsing + text = '\n'.join(content) + state.nested_parse(content, content_offset, node) + if len(node) != 1 or not isinstance(node[0], nodes.table): + error = state_machine.reporter.error( + 'Error parsing content block for the "%s" directive: ' + 'exactly one table expected.' + % name, nodes.literal_block(block_text, block_text), + line=lineno) + return [error] + table_node = node[0] + if options.has_key('class'): + table_node.set_class(options['class']) + if title: + table_node.insert(0, title) + return [table_node] + +table.arguments = (0, 1, 1) +table.options = {'class': directives.class_option} +table.content = 1 diff --git a/docutils/parsers/rst/languages/af.py b/docutils/parsers/rst/languages/af.py index 8ad023ed1..f714ca9b1 100644 --- a/docutils/parsers/rst/languages/af.py +++ b/docutils/parsers/rst/languages/af.py @@ -36,6 +36,7 @@ directives = { 'epigraaf': 'epigraph', 'hoogtepunte': 'highlights', 'pull-quote (translation required)': 'pull-quote', + 'table (translation required)': 'table', #'vrae': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/cs.py b/docutils/parsers/rst/languages/cs.py index 45fb5e657..23c551140 100644 --- a/docutils/parsers/rst/languages/cs.py +++ b/docutils/parsers/rst/languages/cs.py @@ -37,6 +37,7 @@ directives = { u'moto': 'epigraph', u'highlights': 'highlights', u'pull-quote': 'pull-quote', + u'table (translation required)': 'table', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index 017a2e851..cc3b71138 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -37,6 +37,7 @@ directives = { 'epigraph (translation required)': 'epigraph', 'highlights (translation required)': 'highlights', 'pull-quote (translation required)': 'pull-quote', # kasten too ? + 'table (translation required)': 'table', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index a9b060f82..d9068ee8e 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -37,6 +37,7 @@ directives = { 'epigraph': 'epigraph', 'highlights': 'highlights', 'pull-quote': 'pull-quote', + 'table': 'table', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/eo.py b/docutils/parsers/rst/languages/eo.py index 35c3a6765..0682f875c 100644 --- a/docutils/parsers/rst/languages/eo.py +++ b/docutils/parsers/rst/languages/eo.py @@ -40,6 +40,7 @@ directives = { u'elstara\u0135oj': 'highlights', u'ekstera-citajxo': 'pull-quote', u'ekstera-cita\u0135o': 'pull-quote', + u'table (translation required)': 'table', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index abe883741..27cfb9301 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -42,6 +42,7 @@ directives = { u'epigrafe': 'epigraph', u'destacado': 'highlights', u'cita-destacada': 'pull-quote', + u'table (translation required)': 'table', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index ba0bcb014..6ed792430 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -38,6 +38,7 @@ directives = { u'\u00E9pigraphe': 'epigraph', u'chapeau': 'highlights', u'accroche': 'pull-quote', + u'tableau': 'table', #u'questions': 'questions', #u'qr': 'questions', #u'faq': 'questions', diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index 911c69a66..035fd60c9 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -36,6 +36,7 @@ directives = { 'epigraph (translation required)': 'epigraph', 'highlights (translation required)': 'highlights', 'pull-quote (translation required)': 'pull-quote', + u'table (translation required)': 'table', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/pt-br.py b/docutils/parsers/rst/languages/pt-br.py index 5fc68218a..309a4f39b 100644 --- a/docutils/parsers/rst/languages/pt-br.py +++ b/docutils/parsers/rst/languages/pt-br.py @@ -37,6 +37,7 @@ directives = { u'epígrafo': 'epigraph', 'destaques': 'highlights', u'citação-destacada': 'pull-quote', + u'table (translation required)': 'table', #'perguntas': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/ru.py b/docutils/parsers/rst/languages/ru.py index 366f4505f..40823dd81 100644 --- a/docutils/parsers/rst/languages/ru.py +++ b/docutils/parsers/rst/languages/ru.py @@ -23,6 +23,7 @@ directives = { u'parsed-literal', u'\u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u0430\u044f-\u0446\u0438\u0442\u0430\u0442\u0430': u'pull-quote', + u'table (translation required)': 'table', u'\u0441\u044b\u0440\u043e\u0439': u'raw', u'\u0437\u0430\u043c\u0435\u043d\u0430': u'replace', u'\u0442\u0435\u0441\u0442\u043e\u0432\u0430\u044f-\u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430-restructuredtext': diff --git a/docutils/parsers/rst/languages/sk.py b/docutils/parsers/rst/languages/sk.py index caf3ed5c4..83f101908 100644 --- a/docutils/parsers/rst/languages/sk.py +++ b/docutils/parsers/rst/languages/sk.py @@ -36,6 +36,7 @@ directives = { u'epigraph (translation required)': 'epigraph', u'highlights (translation required)': 'highlights', u'pull-quote (translation required)': 'pull-quote', + u'table (translation required)': 'table', #u'questions': 'questions', #u'qa': 'questions', #u'faq': 'questions', diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index 04d105f90..3409c30f2 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -35,6 +35,7 @@ directives = { u'epigraph (translation required)': 'epigraph', u'highlights (translation required)': 'highlights', u'pull-quote (translation required)': 'pull-quote', + u'table (translation required)': 'table', # u'fr\u00e5gor': 'questions', # NOTE: A bit long, but recommended by http://www.nada.kth.se/dataterm/: # u'fr\u00e5gor-och-svar': 'questions', -- cgit v1.2.1 From 7aca2d56b7ae2bea193e91efd1531204d53e0195 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 14 Jan 2004 16:07:11 +0000 Subject: clarified system message git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1801 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 26f55c566..252a38f37 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -2695,8 +2695,8 @@ class Text(RSTState): definitionlistitem += definition if termline[0][-2:] == '::': definition += self.reporter.info( - 'Blank line missing before literal block? Interpreted as a ' - 'definition list item.', line=line_offset + 1) + 'Blank line missing before literal block (after the "::")? ' + 'Interpreted as a definition list item.', line=line_offset+1) self.nested_parse(indented, input_offset=line_offset, node=definition) return definitionlistitem, blank_finish -- cgit v1.2.1 From 14583868d63423cf7bb3154c1114659fc41d2a48 Mon Sep 17 00:00:00 2001 From: richieadler Date: Fri, 16 Jan 2004 02:27:32 +0000 Subject: New translated directive git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1802 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/eo.py | 2 +- docutils/parsers/rst/languages/es.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/eo.py b/docutils/parsers/rst/languages/eo.py index 0682f875c..dc9f59aa2 100644 --- a/docutils/parsers/rst/languages/eo.py +++ b/docutils/parsers/rst/languages/eo.py @@ -40,7 +40,7 @@ directives = { u'elstara\u0135oj': 'highlights', u'ekstera-citajxo': 'pull-quote', u'ekstera-cita\u0135o': 'pull-quote', - u'table (translation required)': 'table', + u'tabelo': 'table', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index 27cfb9301..f1354778b 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -42,7 +42,7 @@ directives = { u'epigrafe': 'epigraph', u'destacado': 'highlights', u'cita-destacada': 'pull-quote', - u'table (translation required)': 'table', + u'tabla': 'table', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', @@ -75,8 +75,10 @@ roles = { u'ac': 'acronym', u'indice': 'index', u'i': 'index', - u'subscript (translation required)': 'subscript', - u'superscript (translation required)': 'superscript', + u'subindice': 'subscript', + u'sub\u00edndice': 'subscript', + u'superindice': 'superscript', + u'super\u00edndice': 'superscript', u'referencia-titulo': 'title-reference', u'titulo': 'title-reference', u't': 'title-reference', -- cgit v1.2.1 From 7be3e33703c71319e161f9e233b687adb79cee58 Mon Sep 17 00:00:00 2001 From: lele Date: Wed, 21 Jan 2004 11:23:17 +0000 Subject: Translated several directive-aliases git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1807 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/it.py | 59 ++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 29 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index 035fd60c9..0dd5fbc30 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -1,7 +1,8 @@ -# Author: Nicola Larosa -# Contact: docutils@tekNico.net +# Author: Nicola Larosa, Lele Gaifax +# Contact: docutils@tekNico.net, lele@seldati.it # Revision: $Revision$ # Date: $Date$ +# Date: $Date$ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please @@ -27,13 +28,13 @@ directives = { 'nota': 'note', 'consiglio': 'tip', 'avvertenza': 'warning', - 'admonition (translation required)': 'admonition', - 'sidebar (translation required)': 'sidebar', + 'ammonizione': 'admonition', + 'riquadro': 'sidebar', 'argomento': 'topic', - 'blocco di linee': 'line-block', - 'parsed-literal': 'parsed-literal', - 'rubric (translation required)': 'rubric', - 'epigraph (translation required)': 'epigraph', + 'blocco-di-righe': 'line-block', + 'blocco-interpretato': 'parsed-literal', + 'rubrica': 'rubric', + 'epigrafe': 'epigraph', 'highlights (translation required)': 'highlights', 'pull-quote (translation required)': 'pull-quote', u'table (translation required)': 'table', @@ -48,11 +49,11 @@ directives = { 'grezzo': 'raw', 'sostituisci': 'replace', 'unicode': 'unicode', - 'class (translation required)': 'class', + 'classe': 'class', 'indice': 'contents', 'seznum': 'sectnum', - 'section-numbering': 'sectnum', - 'target-notes': 'target-notes', + 'sezioni-autonumerate': 'sectnum', + 'annota-riferimenti-esterni': 'target-notes', #'footnotes': 'footnotes', #'citations': 'citations', 'restructuredtext-test-directive': 'restructuredtext-test-directive'} @@ -60,23 +61,23 @@ directives = { mapping.""" roles = { - 'abbreviation (translation required)': 'abbreviation', - 'acronym (translation required)': 'acronym', - 'index (translation required)': 'index', - 'subscript (translation required)': 'subscript', - 'superscript (translation required)': 'superscript', - 'title-reference (translation required)': 'title-reference', - 'pep-reference (translation required)': 'pep-reference', - 'rfc-reference (translation required)': 'rfc-reference', - 'emphasis (translation required)': 'emphasis', - 'strong (translation required)': 'strong', - 'literal (translation required)': 'literal', - 'named-reference (translation required)': 'named-reference', - 'anonymous-reference (translation required)': 'anonymous-reference', - 'footnote-reference (translation required)': 'footnote-reference', - 'citation-reference (translation required)': 'citation-reference', - 'substitution-reference (translation required)': 'substitution-reference', - 'target (translation required)': 'target', - 'uri-reference (translation required)': 'uri-reference',} + 'abbreviazione': 'abbreviation', + 'acronimo': 'acronym', + 'indice': 'index', + 'deponente': 'subscript', + 'esponente': 'superscript', + 'riferimento-titolo': 'title-reference', + 'riferimento-pep': 'pep-reference', + 'riferimento-rfc': 'rfc-reference', + 'enfasi': 'emphasis', + 'forte': 'strong', + 'letterale': 'literal', + 'riferimento-con-nome': 'named-reference', + 'riferimento-anonimo': 'anonymous-reference', + 'riferimento-nota': 'footnote-reference', + 'riferimento-citazione': 'citation-reference', + 'riferimento-sostituzione': 'substitution-reference', + 'destinazione': 'target', + 'riferimento-uri': 'uri-reference',} """Mapping of Italian role names to canonical role names for interpreted text. """ -- cgit v1.2.1 From a2fddea53b1590ce050a76573ff1840bd4fb55bc Mon Sep 17 00:00:00 2001 From: lele Date: Wed, 21 Jan 2004 11:28:26 +0000 Subject: Removed a double Date header that slipped in git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1808 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/it.py | 6 ------ 1 file changed, 6 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index 0dd5fbc30..fc08452e1 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -2,14 +2,8 @@ # Contact: docutils@tekNico.net, lele@seldati.it # Revision: $Revision$ # Date: $Date$ -# Date: $Date$ # Copyright: This module has been placed in the public domain. -# New language mappings are welcome. Before doing a new translation, please -# read . Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. - """ Italian-language mappings for language-dependent features of reStructuredText. -- cgit v1.2.1 From 598ca90a5a7796f3344cff534f6912e1934d44b8 Mon Sep 17 00:00:00 2001 From: reggie Date: Mon, 22 Mar 2004 01:08:19 +0000 Subject: The "contents" directive does more work up-front, creating the "topic" and "title", and leaving the "pending" node for the transform. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1854 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/parts.py | 35 +++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py index 2faaca44b..5e6809142 100644 --- a/docutils/parsers/rst/directives/parts.py +++ b/docutils/parsers/rst/directives/parts.py @@ -10,7 +10,7 @@ Directives for document parts. __docformat__ = 'reStructuredText' -from docutils import nodes +from docutils import nodes, languages from docutils.transforms import parts from docutils.parsers.rst import directives @@ -27,17 +27,42 @@ def backlinks(arg): def contents(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): """Table of contents.""" + document = state_machine.document + language = languages.get_language(document.settings.language_code) + if arguments: title_text = arguments[0] text_nodes, messages = state.inline_text(title_text, lineno) title = nodes.title(title_text, '', *text_nodes) else: messages = [] - title = None - pending = nodes.pending(parts.Contents, {'title': title}, block_text) + if options.has_key('local'): + title = None + else: + title = nodes.title('', language.labels['contents']) + + topic = nodes.topic(CLASS='contents') + + cls = options.get('class') + if cls: + topic.set_class(cls) + + if title: + name = title.astext() + topic += title + else: + name = language.labels['contents'] + + name = nodes.fully_normalize_name(name) + if not document.has_name(name): + topic['name'] = name + document.note_implicit_target(topic) + + pending = nodes.pending(parts.Contents, rawsource=block_text) pending.details.update(options) - state_machine.document.note_pending(pending) - return [pending] + messages + document.note_pending(pending) + topic += pending + return [topic] + messages contents.arguments = (0, 1, 1) contents.options = {'depth': directives.nonnegative_int, -- cgit v1.2.1 From 2c868af6838d363ed0ca7fc5571b515622ecf3e2 Mon Sep 17 00:00:00 2001 From: reggie Date: Mon, 22 Mar 2004 01:12:45 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1857 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/body.py | 1 + 1 file changed, 1 insertion(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index 122b2ccc4..6c29d037e 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -34,6 +34,7 @@ def topic(name, arguments, options, content, lineno, title_text = arguments[0] textnodes, messages = state.inline_text(title_text, lineno) titles = [nodes.title(title_text, '', *textnodes)] + # sidebar uses this code if options.has_key('subtitle'): textnodes, more_messages = state.inline_text(options['subtitle'], lineno) -- cgit v1.2.1 From 00ee5f95c731a0e30a3a2504ce61561b9674dd7b Mon Sep 17 00:00:00 2001 From: mmgilbe Date: Tue, 23 Mar 2004 23:43:54 +0000 Subject: Verifying that external targets are truly targets and not indirect references. This is because we are now adding a "name" attribute to references in addition to targets. Note sure if this is correct! git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1882 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 4 +++- docutils/parsers/rst/states.py | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index a835d3d74..ab96a0a4e 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -14,6 +14,7 @@ __docformat__ = 'reStructuredText' import sys from docutils import nodes, utils from docutils.parsers.rst import directives, states +from docutils.nodes import whitespace_normalize_name try: import Image # PIL @@ -41,7 +42,8 @@ def image(name, arguments, options, content, lineno, if target_type == 'refuri': node_list = nodes.reference(refuri=data) elif target_type == 'refname': - node_list = nodes.reference(refname=data) + node_list = nodes.reference( + refname=data, name=whitespace_normalize_name(options['target'])) state.document.note_refname(node_list) else: # malformed target node_list = [data] # data is a system message diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 252a38f37..9b77d5d49 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -113,6 +113,7 @@ from docutils import nodes, statemachine, utils, urischemes from docutils import ApplicationError, DataError from docutils.statemachine import StateMachineWS, StateWS from docutils.nodes import fully_normalize_name as normalize_name +from docutils.nodes import whitespace_normalize_name from docutils.parsers.rst import directives, languages, tableparser from docutils.parsers.rst.languages import en as _fallback_language_module @@ -867,7 +868,8 @@ class Inliner: else: target = None refname = normalize_name(text) - reference = nodes.reference(rawsource, text) + reference = nodes.reference(rawsource, text, + name=whitespace_normalize_name(text)) node_list = [reference] if rawsource[-2:] == '__': if target: @@ -1017,8 +1019,9 @@ class Inliner: def reference(self, match, lineno, anonymous=None): referencename = match.group('refname') refname = normalize_name(referencename) - referencenode = nodes.reference(referencename + match.group('refend'), - referencename) + referencenode = nodes.reference( + referencename + match.group('refend'), referencename, + name=whitespace_normalize_name(referencename)) if anonymous: referencenode['anonymous'] = 1 self.document.note_anonymous_ref(referencenode) -- cgit v1.2.1 From 06305ebeb5bb98b2be5f754084ac12cefc58719e Mon Sep 17 00:00:00 2001 From: mmgilbe Date: Wed, 24 Mar 2004 16:53:29 +0000 Subject: Added "origuri" attribute to references which contain an embedded uri. Some writers (maybe other transforms) are interested in the original (non normalized) uri text. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1888 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 9b77d5d49..9a52cafca 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -854,6 +854,7 @@ class Inliner: def phrase_ref(self, before, after, rawsource, escaped, text): match = self.patterns.embedded_uri.search(escaped) + uri_text = None if match: text = unescape(escaped[:match.start(0)]) uri_text = match.group(2) @@ -868,8 +869,15 @@ class Inliner: else: target = None refname = normalize_name(text) - reference = nodes.reference(rawsource, text, - name=whitespace_normalize_name(text)) + # Only add origuri attribute if the rawsource does contain an + # embedded_uri + if uri_text: + reference = nodes.reference(rawsource, text, + name=whitespace_normalize_name(text), + origuri=uri_text) + else: + reference = nodes.reference(rawsource, text, + name=whitespace_normalize_name(text)) node_list = [reference] if rawsource[-2:] == '__': if target: -- cgit v1.2.1 From f9ce4af77d798fd979eee78a8d31d05783f6f6f3 Mon Sep 17 00:00:00 2001 From: mmgilbe Date: Thu, 25 Mar 2004 23:01:11 +0000 Subject: Added unknown_reference_resolvers list for each transformer. This list holds the list of functions provided by each component of the transformer that help resolve references. Removed all refernces to the origuri code, which was broken. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1894 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 9a52cafca..d1c63f7f1 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -854,7 +854,6 @@ class Inliner: def phrase_ref(self, before, after, rawsource, escaped, text): match = self.patterns.embedded_uri.search(escaped) - uri_text = None if match: text = unescape(escaped[:match.start(0)]) uri_text = match.group(2) @@ -869,15 +868,8 @@ class Inliner: else: target = None refname = normalize_name(text) - # Only add origuri attribute if the rawsource does contain an - # embedded_uri - if uri_text: - reference = nodes.reference(rawsource, text, - name=whitespace_normalize_name(text), - origuri=uri_text) - else: - reference = nodes.reference(rawsource, text, - name=whitespace_normalize_name(text)) + reference = nodes.reference(rawsource, text, + name=whitespace_normalize_name(text)) node_list = [reference] if rawsource[-2:] == '__': if target: @@ -1898,7 +1890,8 @@ class Body(RSTState): def make_target(self, block, block_text, lineno, target_name): target_type, data = self.parse_target(block, block_text, lineno) if target_type == 'refname': - target = nodes.target(block_text, '', refname=data) + target = nodes.target(block_text, '', refname=normalize_name(data)) + target.indirect_reference_name = data self.add_target(target_name, '', target, lineno) self.document.note_indirect_target(target) return target @@ -1936,7 +1929,7 @@ class Body(RSTState): def is_reference(self, reference): match = self.explicit.patterns.reference.match( - normalize_name(reference)) + whitespace_normalize_name(reference)) if not match: return None return unescape(match.group('simple') or match.group('phrase')) -- cgit v1.2.1 From d8c8903dfb10818aad93e126a7541877a774b5cd Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 8 Apr 2004 01:58:27 +0000 Subject: Fixed bug relating to role-less interpreted text in non-English contexts. Reported by Lele Gaifax. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1916 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index d1c63f7f1..065eb6ef3 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -912,17 +912,17 @@ class Inliner: msg_text = [] if role: name = role.lower() + canonical = None + try: + canonical = self.language.roles[name] + except AttributeError, error: + msg_text.append('Problem retrieving role entry from language ' + 'module %r: %s.' % (self.language, error)) + except KeyError: + msg_text.append('No role entry for "%s" in module "%s".' + % (name, self.language.__name__)) else: - name = self.default_interpreted_role - canonical = None - try: - canonical = self.language.roles[name] - except AttributeError, error: - msg_text.append('Problem retrieving role entry from language ' - 'module %r: %s.' % (self.language, error)) - except KeyError: - msg_text.append('No role entry for "%s" in module "%s".' - % (name, self.language.__name__)) + canonical = self.default_interpreted_role if not canonical: try: canonical = _fallback_language_module.roles[name] -- cgit v1.2.1 From 3c42f072860137e69457165ae638ac884bdb23ec Mon Sep 17 00:00:00 2001 From: wiemann Date: Thu, 15 Apr 2004 19:21:18 +0000 Subject: Added coding comment. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1936 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/pt-br.py | 1 + 1 file changed, 1 insertion(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/pt-br.py b/docutils/parsers/rst/languages/pt-br.py index 309a4f39b..6f8e3cf21 100644 --- a/docutils/parsers/rst/languages/pt-br.py +++ b/docutils/parsers/rst/languages/pt-br.py @@ -1,3 +1,4 @@ +# -*- coding: iso-8859-1 -*- # Author: David Goodger # Contact: goodger@users.sourceforge.net # Revision: $Revision$ -- cgit v1.2.1 From bee6561efe398179e59d465218a0aaefc9bf024b Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 16 Apr 2004 15:14:57 +0000 Subject: Reorganized interpreted text processing; moved code into the new roles.py module. roles.py contains interpreted text role functions, a registry for interpreted text roles, and an API for adding to and retrieving from the registry. Contributed by Edward Loper. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1943 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/roles.py | 187 +++++++++++++++++++++++++++++++++++++++++ docutils/parsers/rst/states.py | 169 ++++--------------------------------- 2 files changed, 205 insertions(+), 151 deletions(-) create mode 100644 docutils/parsers/rst/roles.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/roles.py b/docutils/parsers/rst/roles.py new file mode 100644 index 000000000..fd44c33e1 --- /dev/null +++ b/docutils/parsers/rst/roles.py @@ -0,0 +1,187 @@ +# Author: Edward Loper +# Contact: edloper@gradient.cis.upenn.edu +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +""" +This module defines a registry for interpreted roles. + +The interface for interpreted role functions is as follows:: + + def role_fn(name, rawtext, text, lineno, inliner): + code... + +Parameters: + +- ``name`` is the interpreted role type or name. + +- ``rawtext`` is a string containing the entire interpreted text. + Include it as the content of a system message if there is a + problem. + +- ``text`` is the interpreted text content. + +- ``lineno`` is the line number where the interpreted text beings. + +- ``inliner`` is the Inliner object that called the role function. + It defines the following useful attributes: ``reporter``, + ``problematic``, ``memo``, ``parent``, ``document``. + +Interpreted role functions return a tuple of two values: + +- A list of nodes which will be inserted into the document tree at the + point where the interpreted role was encountered (can be an empty + list). + +- A list of messages, which will be inserted into the document tree + immediately after the end of the current inline block. +""" + +__docformat__ = 'reStructuredText' + +from docutils import nodes +from docutils.parsers.rst.languages import en as _fallback_language_module + +DEFAULT_INTERPRETED_ROLE = 'title-reference' +""" +The canonical name of the default interpreted role. This role is used +when no role is specified for a piece of interpreted text. +""" + +_roles = {} +""" +The interpreted role registry. This registry map canonical role names +to role functions. Language-dependent role names are defined in the +``language`` subpackage. +""" + +def role(role_name, language_module, lineno, inliner): + """ + Locate and return a role function from its language-dependent + name. If not found in the current language, check English. + Return None if the named role cannot be found. + """ + normname = role_name.lower() + messages = [] + msg_text = [] + + canonicalname = None + try: + canonicalname = language_module.roles[normname] + except AttributeError, error: + msg_text.append('Problem retrieving role entry from language ' + 'module %r: %s.' % (language_module, error)) + except KeyError: + msg_text.append('No role entry for "%s" in module "%s".' + % (role_name, language_module.__name__)) + + # If we didn't find it, try english as a fallback. + if not canonicalname: + try: + canonicalname = _fallback_language_module.roles[normname] + msg_text.append('Using English fallback for role "%s".' + % role_name) + except KeyError: + msg_text.append('Trying "%s" as canonical role name.' + % role_name) + # The canonical name should be an English name, but just in case: + canonicalname = normname + + # Collect any messages that we generated. + if msg_text: + message = inliner.reporter.info('\n'.join(msg_text), line=lineno) + messages.append(message) + + # Look the role up in the registry, and return it. + if _roles.has_key(canonicalname): + return _roles[canonicalname], messages + else: + return None, messages # Error message will be generated by caller. + +def register_role(name, role_fn): + """ + Register an interpreted role. + + :Parameters: + - `name`: The canonical name of the interpreted role. + - `role_fn`: The role function. See the module docstring for + `docutils.parsers.rst.roles` for a description of the + signature for `role_fn`. + """ + _roles[name] = role_fn + +###################################################################### +# Create and register the standard roles: +###################################################################### + +def make_generic_role(node_class, role, rawtext, text, lineno, inliner): + # If we wanted to, we could recursively call inliner.nested_parse + # to interpret the text contents here (after appropriately + # refactoring Inliner.parse). + return [node_class(rawtext, text)], [] + +# Helper function: +def register_generic_role(name, node_class): + def role_fn(role, rawtext, text, lineno, inliner, nc=node_class): + return make_generic_role(nc, role, rawtext, text, lineno, inliner) + register_role(name, role_fn) + +register_generic_role('abbreviation', nodes.abbreviation) +register_generic_role('acronym', nodes.acronym) +register_generic_role('emphasis', nodes.emphasis) +register_generic_role('literal', nodes.literal) +register_generic_role('strong', nodes.strong) +register_generic_role('subscript', nodes.subscript) +register_generic_role('superscript', nodes.superscript) +register_generic_role('title-reference', nodes.title_reference) + +def pep_reference_role(role, rawtext, text, lineno, inliner): + try: + pepnum = int(text) + if pepnum < 0 or pepnum > 9999: + raise ValueError + except ValueError: + msg = inliner.reporter.error( + 'PEP number must be a number from 0 to 9999; "%s" is invalid.' + % text, line=lineno) + prb = inliner.problematic(text, text, msg) + return [prb], [msg] + ref = inliner.pep_url % pepnum # [XX] + return [nodes.reference(rawtext, 'PEP ' + text, refuri=ref)], [] +register_role('pep-reference', pep_reference_role) + +def rfc_reference_role(role, rawtext, text, lineno, inliner): + try: + rfcnum = int(text) + if rfcnum <= 0: + raise ValueError + except ValueError: + msg = inliner.reporter.error( + 'RFC number must be a number greater than or equal to 1; ' + '"%s" is invalid.' % text, line=lineno) + prb = inliner.problematic(text, text, msg) + return [prb], [msg] + ref = inliner.rfc_url % rfcnum # [XX] + return [nodes.reference(rawtext, 'RFC ' + text, refuri=ref)], [] +register_role('rfc-reference', rfc_reference_role) + +###################################################################### +# Register roles that are currently unimplemented. +###################################################################### + +def unimplemented_role(role, rawtext, text, lineno, inliner): + msg = inliner.reporter.error( + 'Interpreted text role "%s" not implemented.' % role, line=lineno) + prb = inliner.problematic(rawtext, rawtext, msg) + return [prb], [msg] + +register_role('index', unimplemented_role) +register_role('named-reference', unimplemented_role) +register_role('anonymous-reference', unimplemented_role) +register_role('uri-reference', unimplemented_role) +register_role('footnote-reference', unimplemented_role) +register_role('citation-reference', unimplemented_role) +register_role('substitution-reference', unimplemented_role) +register_role('target', unimplemented_role) +register_role('restructuredtext-unimplemented-role', unimplemented_role) diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 065eb6ef3..01075288f 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -114,7 +114,7 @@ from docutils import ApplicationError, DataError from docutils.statemachine import StateMachineWS, StateWS from docutils.nodes import fully_normalize_name as normalize_name from docutils.nodes import whitespace_normalize_name -from docutils.parsers.rst import directives, languages, tableparser +from docutils.parsers.rst import directives, languages, tableparser, roles from docutils.parsers.rst.languages import en as _fallback_language_module @@ -475,47 +475,10 @@ class Inliner: """ Parse inline markup; call the `parse()` method. """ - - _interpreted_roles = { - # Values of ``None`` mean "not implemented yet": - 'title-reference': 'generic_interpreted_role', - 'abbreviation': 'generic_interpreted_role', - 'acronym': 'generic_interpreted_role', - 'index': None, - 'subscript': 'generic_interpreted_role', - 'superscript': 'generic_interpreted_role', - 'emphasis': 'generic_interpreted_role', - 'strong': 'generic_interpreted_role', - 'literal': 'generic_interpreted_role', - 'named-reference': None, - 'anonymous-reference': None, - 'uri-reference': None, - 'pep-reference': 'pep_reference_role', - 'rfc-reference': 'rfc_reference_role', - 'footnote-reference': None, - 'citation-reference': None, - 'substitution-reference': None, - 'target': None, - 'restructuredtext-unimplemented-role': None} - """Mapping of canonical interpreted text role name to method name. - Initializes a name to bound-method mapping in `__init__`.""" - default_interpreted_role = 'title-reference' """The role to use when no explicit role is given. Override in subclasses.""" - generic_roles = {'abbreviation': nodes.abbreviation, - 'acronym': nodes.acronym, - 'emphasis': nodes.emphasis, - 'literal': nodes.literal, - 'strong': nodes.strong, - 'subscript': nodes.subscript, - 'superscript': nodes.superscript, - 'title-reference': nodes.title_reference,} - """Mapping of canonical interpreted text role name to node class. - Used by the `generic_interpreted_role` method for simple, straightforward - roles (simple wrapping; no extra processing).""" - def __init__(self, roles=None): """ `roles` is a mapping of canonical role name to role function or bound @@ -526,17 +489,6 @@ class Inliner: """List of (pattern, bound method) tuples, used by `self.implicit_inline`.""" - self.interpreted_roles = {} - """Mapping of canonical role name to role function or bound method. - Items removed from this mapping will be disabled.""" - - for canonical, method in self._interpreted_roles.items(): - if method: - self.interpreted_roles[canonical] = getattr(self, method) - else: - self.interpreted_roles[canonical] = None - self.interpreted_roles.update(roles or {}) - def init_customizations(self, settings): """Setting-based customizations; run when parsing begins.""" if settings.pep_references: @@ -825,26 +777,11 @@ class Inliner: return self.phrase_ref(string[:matchstart], string[textend:], rawsource, escaped, text) else: - try: - return self.interpreted( - string[:rolestart], string[textend:], - rawsource, text, role, lineno) - except UnknownInterpretedRoleError, detail: - msg = self.reporter.error( - 'Unknown interpreted text role "%s".' % role, - line=lineno) - text = unescape(string[rolestart:textend], 1) - prb = self.problematic(text, text, msg) - return (string[:rolestart], [prb], string[textend:], - detail.args[0] + [msg]) - except InterpretedRoleNotImplementedError, detail: - msg = self.reporter.error( - 'Interpreted text role "%s" not implemented.' % role, - line=lineno) - text = unescape(string[rolestart:textend], 1) - prb = self.problematic(text, text, msg) - return (string[:rolestart], [prb], string[textend:], - detail.args[0] + [msg]) + rawsource = unescape(string[rolestart:textend], 1) + nodelist, messages = self.interpreted(rawsource, text, role, + lineno) + return (string[:rolestart], nodelist, + string[textend:], messages) msg = self.reporter.warning( 'Inline interpreted text or phrase reference start-string ' 'without end-string.', line=lineno) @@ -896,50 +833,19 @@ class Inliner: else: return uri - def interpreted(self, before, after, rawsource, text, role, lineno): - role_function, canonical, messages = self.get_role_function(role, - lineno) - if role_function: - nodelist, messages2 = role_function(canonical, rawsource, text, - lineno) - messages.extend(messages2) - return before, nodelist, after, messages + def interpreted(self, rawsource, text, role, lineno): + if not role: + role = roles.DEFAULT_INTERPRETED_ROLE + role_fn, messages = roles.role(role, self.language, lineno, self) + if role_fn: + nodes, messages2 = role_fn(role, rawsource, text, lineno, self) + return nodes, messages + messages2 else: - raise InterpretedRoleNotImplementedError(messages) - - def get_role_function(self, role, lineno): - messages = [] - msg_text = [] - if role: - name = role.lower() - canonical = None - try: - canonical = self.language.roles[name] - except AttributeError, error: - msg_text.append('Problem retrieving role entry from language ' - 'module %r: %s.' % (self.language, error)) - except KeyError: - msg_text.append('No role entry for "%s" in module "%s".' - % (name, self.language.__name__)) - else: - canonical = self.default_interpreted_role - if not canonical: - try: - canonical = _fallback_language_module.roles[name] - msg_text.append('Using English fallback for role "%s".' - % name) - except KeyError: - msg_text.append('Trying "%s" as canonical role name.' - % name) - # Should be an English name, but just in case: - canonical = name - if msg_text: - message = self.reporter.info('\n'.join(msg_text), line=lineno) - messages.append(message) - try: - return self.interpreted_roles[canonical], canonical, messages - except KeyError: - raise UnknownInterpretedRoleError(messages) + msg = self.reporter.error( + 'Unknown interpreted text role "%s".' % role, + line=lineno) + return ([self.problematic(rawsource, rawsource, msg)], + messages + [msg]) def literal(self, match, lineno): before, inlines, remaining, sysmessages, endstring = self.inline_obj( @@ -1110,45 +1016,6 @@ class Inliner: '_': reference, '__': anonymous_reference} - def generic_interpreted_role(self, role, rawtext, text, lineno): - try: - role_class = self.generic_roles[role] - except KeyError: - msg = self.reporter.error('Unknown interpreted text role: "%s".' - % role, line=lineno) - prb = self.problematic(text, text, msg) - return [prb], [msg] - return [role_class(rawtext, text)], [] - - def pep_reference_role(self, role, rawtext, text, lineno): - try: - pepnum = int(text) - if pepnum < 0 or pepnum > 9999: - raise ValueError - except ValueError: - msg = self.reporter.error( - 'PEP number must be a number from 0 to 9999; "%s" is invalid.' - % text, line=lineno) - prb = self.problematic(text, text, msg) - return [prb], [msg] - ref = self.pep_url % pepnum - return [nodes.reference(rawtext, 'PEP ' + text, refuri=ref)], [] - - def rfc_reference_role(self, role, rawtext, text, lineno): - try: - rfcnum = int(text) - if rfcnum <= 0: - raise ValueError - except ValueError: - msg = self.reporter.error( - 'RFC number must be a number greater than or equal to 1; ' - '"%s" is invalid.' % text, line=lineno) - prb = self.problematic(text, text, msg) - return [prb], [msg] - ref = self.rfc_url % rfcnum - return [nodes.reference(rawtext, 'RFC ' + text, refuri=ref)], [] - - class Body(RSTState): """ -- cgit v1.2.1 From 3abac3279f845005f6313a8b0d16e14b6c8f8758 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 16 Apr 2004 15:38:21 +0000 Subject: Moved default interpreted text role processing to roles.py (canonical name, not language-dependent). Plus docstrings, whitespace. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1946 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/roles.py | 52 +++++++++++++++++++++++------------------- docutils/parsers/rst/states.py | 8 ++----- 2 files changed, 31 insertions(+), 29 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/roles.py b/docutils/parsers/rst/roles.py index fd44c33e1..03e4c934b 100644 --- a/docutils/parsers/rst/roles.py +++ b/docutils/parsers/rst/roles.py @@ -5,7 +5,9 @@ # Copyright: This module has been placed in the public domain. """ -This module defines a registry for interpreted roles. +This module defines standard interpreted text role functions, a registry for +interpreted text roles, and an API for adding to and retrieving from the +registry. The interface for interpreted role functions is as follows:: @@ -13,7 +15,7 @@ The interface for interpreted role functions is as follows:: code... Parameters: - + - ``name`` is the interpreted role type or name. - ``rawtext`` is a string containing the entire interpreted text. @@ -34,8 +36,8 @@ Interpreted role functions return a tuple of two values: point where the interpreted role was encountered (can be an empty list). -- A list of messages, which will be inserted into the document tree - immediately after the end of the current inline block. +- A list of system messages, which will be inserted into the document tree + immediately after the end of the current inline block (can also be empty). """ __docformat__ = 'reStructuredText' @@ -58,25 +60,28 @@ to role functions. Language-dependent role names are defined in the def role(role_name, language_module, lineno, inliner): """ - Locate and return a role function from its language-dependent - name. If not found in the current language, check English. - Return None if the named role cannot be found. + Locate and return a role function from its language-dependent name, along + with a list of system messages. If the role is not found in the current + language, check English. Return None if the named role cannot be found. """ normname = role_name.lower() messages = [] msg_text = [] - canonicalname = None - try: - canonicalname = language_module.roles[normname] - except AttributeError, error: - msg_text.append('Problem retrieving role entry from language ' - 'module %r: %s.' % (language_module, error)) - except KeyError: - msg_text.append('No role entry for "%s" in module "%s".' - % (role_name, language_module.__name__)) - - # If we didn't find it, try english as a fallback. + if role_name: + canonicalname = None + try: + canonicalname = language_module.roles[normname] + except AttributeError, error: + msg_text.append('Problem retrieving role entry from language ' + 'module %r: %s.' % (language_module, error)) + except KeyError: + msg_text.append('No role entry for "%s" in module "%s".' + % (role_name, language_module.__name__)) + else: + canonicalname = DEFAULT_INTERPRETED_ROLE + + # If we didn't find it, try English as a fallback. if not canonicalname: try: canonicalname = _fallback_language_module.roles[normname] @@ -92,17 +97,17 @@ def role(role_name, language_module, lineno, inliner): if msg_text: message = inliner.reporter.info('\n'.join(msg_text), line=lineno) messages.append(message) - + # Look the role up in the registry, and return it. if _roles.has_key(canonicalname): return _roles[canonicalname], messages else: return None, messages # Error message will be generated by caller. - + def register_role(name, role_fn): """ - Register an interpreted role. - + Register an interpreted text role. + :Parameters: - `name`: The canonical name of the interpreted role. - `role_fn`: The role function. See the module docstring for @@ -150,7 +155,7 @@ def pep_reference_role(role, rawtext, text, lineno, inliner): ref = inliner.pep_url % pepnum # [XX] return [nodes.reference(rawtext, 'PEP ' + text, refuri=ref)], [] register_role('pep-reference', pep_reference_role) - + def rfc_reference_role(role, rawtext, text, lineno, inliner): try: rfcnum = int(text) @@ -184,4 +189,5 @@ register_role('footnote-reference', unimplemented_role) register_role('citation-reference', unimplemented_role) register_role('substitution-reference', unimplemented_role) register_role('target', unimplemented_role) +# This one should remain unimplemented, for testing purposes: register_role('restructuredtext-unimplemented-role', unimplemented_role) diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 01075288f..5d7c463dc 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -475,9 +475,6 @@ class Inliner: """ Parse inline markup; call the `parse()` method. """ - default_interpreted_role = 'title-reference' - """The role to use when no explicit role is given. - Override in subclasses.""" def __init__(self, roles=None): """ @@ -834,8 +831,6 @@ class Inliner: return uri def interpreted(self, rawsource, text, role, lineno): - if not role: - role = roles.DEFAULT_INTERPRETED_ROLE role_fn, messages = roles.role(role, self.language, lineno, self) if role_fn: nodes, messages2 = role_fn(role, rawsource, text, lineno, self) @@ -926,7 +921,7 @@ class Inliner: referencename = match.group('refname') refname = normalize_name(referencename) referencenode = nodes.reference( - referencename + match.group('refend'), referencename, + referencename + match.group('refend'), referencename, name=whitespace_normalize_name(referencename)) if anonymous: referencenode['anonymous'] = 1 @@ -1016,6 +1011,7 @@ class Inliner: '_': reference, '__': anonymous_reference} + class Body(RSTState): """ -- cgit v1.2.1 From 93c6daeb478ddb3486dc9b4283582e3d73dca23b Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 16 Apr 2004 15:39:27 +0000 Subject: docstring git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1948 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 23ef04188..a7e434b08 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -193,7 +193,10 @@ def directive(directive_name, language_module, document): return function, messages def register_directive(name, directive): - """Register a nonstandard application-defined directive function.""" + """ + Register a nonstandard application-defined directive function. + Language lookups are not needed for such functions. + """ _directives[name] = directive def flag(argument): -- cgit v1.2.1 From 55963837e360331f7c6f0ef94580e4c1f4f3027c Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 16 Apr 2004 16:41:35 +0000 Subject: implemented local registry git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1950 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/roles.py | 63 ++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 24 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/roles.py b/docutils/parsers/rst/roles.py index 03e4c934b..cd76b58d6 100644 --- a/docutils/parsers/rst/roles.py +++ b/docutils/parsers/rst/roles.py @@ -51,12 +51,14 @@ The canonical name of the default interpreted role. This role is used when no role is specified for a piece of interpreted text. """ +_role_registry = {} +"""Mapping of canonical role names to role functions. Language-dependent role +names are defined in the ``language`` subpackage. """ + _roles = {} -""" -The interpreted role registry. This registry map canonical role names -to role functions. Language-dependent role names are defined in the -``language`` subpackage. -""" +"""Mapping of language-dependent interpreted text role names to already +imported directive functions.""" + def role(role_name, language_module, lineno, inliner): """ @@ -68,6 +70,9 @@ def role(role_name, language_module, lineno, inliner): messages = [] msg_text = [] + if _roles.has_key(normname): + return _roles[normname], messages + if role_name: canonicalname = None try: @@ -99,20 +104,30 @@ def role(role_name, language_module, lineno, inliner): messages.append(message) # Look the role up in the registry, and return it. - if _roles.has_key(canonicalname): - return _roles[canonicalname], messages + if _role_registry.has_key(canonicalname): + role_fn = _role_registry[canonicalname] + register_local_role(normname, role_fn) + return role_fn, messages else: return None, messages # Error message will be generated by caller. -def register_role(name, role_fn): +def register_canonical_role(name, role_fn): """ - Register an interpreted text role. + Register an interpreted text role by its canonical name. :Parameters: - `name`: The canonical name of the interpreted role. - - `role_fn`: The role function. See the module docstring for - `docutils.parsers.rst.roles` for a description of the - signature for `role_fn`. + - `role_fn`: The role function. See the module docstring. + """ + _role_registry[name] = role_fn + +def register_local_role(name, role_fn): + """ + Register an interpreted text role by its local or language-dependent name. + + :Parameters: + - `name`: The local or language-dependent name of the interpreted role. + - `role_fn`: The role function. See the module docstring. """ _roles[name] = role_fn @@ -130,7 +145,7 @@ def make_generic_role(node_class, role, rawtext, text, lineno, inliner): def register_generic_role(name, node_class): def role_fn(role, rawtext, text, lineno, inliner, nc=node_class): return make_generic_role(nc, role, rawtext, text, lineno, inliner) - register_role(name, role_fn) + register_canonical_role(name, role_fn) register_generic_role('abbreviation', nodes.abbreviation) register_generic_role('acronym', nodes.acronym) @@ -154,7 +169,7 @@ def pep_reference_role(role, rawtext, text, lineno, inliner): return [prb], [msg] ref = inliner.pep_url % pepnum # [XX] return [nodes.reference(rawtext, 'PEP ' + text, refuri=ref)], [] -register_role('pep-reference', pep_reference_role) +register_canonical_role('pep-reference', pep_reference_role) def rfc_reference_role(role, rawtext, text, lineno, inliner): try: @@ -169,7 +184,7 @@ def rfc_reference_role(role, rawtext, text, lineno, inliner): return [prb], [msg] ref = inliner.rfc_url % rfcnum # [XX] return [nodes.reference(rawtext, 'RFC ' + text, refuri=ref)], [] -register_role('rfc-reference', rfc_reference_role) +register_canonical_role('rfc-reference', rfc_reference_role) ###################################################################### # Register roles that are currently unimplemented. @@ -181,13 +196,13 @@ def unimplemented_role(role, rawtext, text, lineno, inliner): prb = inliner.problematic(rawtext, rawtext, msg) return [prb], [msg] -register_role('index', unimplemented_role) -register_role('named-reference', unimplemented_role) -register_role('anonymous-reference', unimplemented_role) -register_role('uri-reference', unimplemented_role) -register_role('footnote-reference', unimplemented_role) -register_role('citation-reference', unimplemented_role) -register_role('substitution-reference', unimplemented_role) -register_role('target', unimplemented_role) +register_canonical_role('index', unimplemented_role) +register_canonical_role('named-reference', unimplemented_role) +register_canonical_role('anonymous-reference', unimplemented_role) +register_canonical_role('uri-reference', unimplemented_role) +register_canonical_role('footnote-reference', unimplemented_role) +register_canonical_role('citation-reference', unimplemented_role) +register_canonical_role('substitution-reference', unimplemented_role) +register_canonical_role('target', unimplemented_role) # This one should remain unimplemented, for testing purposes: -register_role('restructuredtext-unimplemented-role', unimplemented_role) +register_canonical_role('restructuredtext-unimplemented-role', unimplemented_role) -- cgit v1.2.1 From 0cf74910395c458d284ad0172097100427b9297e Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 16 Apr 2004 17:14:14 +0000 Subject: docstring fix git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1951 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/roles.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/roles.py b/docutils/parsers/rst/roles.py index cd76b58d6..262abf87a 100644 --- a/docutils/parsers/rst/roles.py +++ b/docutils/parsers/rst/roles.py @@ -53,12 +53,11 @@ when no role is specified for a piece of interpreted text. _role_registry = {} """Mapping of canonical role names to role functions. Language-dependent role -names are defined in the ``language`` subpackage. """ +names are defined in the ``language`` subpackage.""" _roles = {} -"""Mapping of language-dependent interpreted text role names to already -imported directive functions.""" - +"""Mapping of local or language-dependent interpreted text role names to role +functions.""" def role(role_name, language_module, lineno, inliner): """ -- cgit v1.2.1 From 85211ceb10f91f02f40ad54f6936621c8d57f929 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 17 Apr 2004 17:36:18 +0000 Subject: renamed pt-br.py to pt_br.py to conform with Python naming conventions and to allow normal imports git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1954 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/pt-br.py | 96 --------------------------------- docutils/parsers/rst/languages/pt_br.py | 96 +++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 96 deletions(-) delete mode 100644 docutils/parsers/rst/languages/pt-br.py create mode 100644 docutils/parsers/rst/languages/pt_br.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/pt-br.py b/docutils/parsers/rst/languages/pt-br.py deleted file mode 100644 index 6f8e3cf21..000000000 --- a/docutils/parsers/rst/languages/pt-br.py +++ /dev/null @@ -1,96 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Author: David Goodger -# Contact: goodger@users.sourceforge.net -# Revision: $Revision$ -# Date: $Date$ -# Copyright: This module has been placed in the public domain. - -# New language mappings are welcome. Before doing a new translation, please -# read . Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. - -""" -Brazilian Portuguese-language mappings for language-dependent features of -reStructuredText. -""" - -__docformat__ = 'reStructuredText' - - -directives = { - # language-dependent: fixed - u'atenção': 'attention', - 'cuidado': 'caution', - 'perigo': 'danger', - 'erro': 'error', - u'sugestão': 'hint', - 'importante': 'important', - 'nota': 'note', - 'dica': 'tip', - 'aviso': 'warning', - u'exortação': 'admonition', - 'barra-lateral': 'sidebar', - u'tópico': 'topic', - 'bloco-de-linhas': 'line-block', - 'literal-interpretado': 'parsed-literal', - 'rubrica': 'rubric', - u'epígrafo': 'epigraph', - 'destaques': 'highlights', - u'citação-destacada': 'pull-quote', - u'table (translation required)': 'table', - #'perguntas': 'questions', - #'qa': 'questions', - #'faq': 'questions', - 'meta': 'meta', - #'imagemap': 'imagemap', - 'imagem': 'image', - 'figura': 'figure', - u'inclusão': 'include', - 'cru': 'raw', - u'substituição': 'replace', - 'unicode': 'unicode', - 'classe': 'class', - u'índice': 'contents', - 'numsec': 'sectnum', - u'numeração-de-seções': 'sectnum', - #u'notas-de-rorapé': 'footnotes', - #u'citações': 'citations', - u'links-no-rodapé': 'target-notes', - 'restructuredtext-test-directive': 'restructuredtext-test-directive'} -"""English name to registered (in directives/__init__.py) directive name -mapping.""" - -roles = { - # language-dependent: fixed - u'abbreviação': 'abbreviation', - 'ab': 'abbreviation', - u'acrônimo': 'acronym', - 'ac': 'acronym', - u'índice-remissivo': 'index', - 'i': 'index', - 'subscrito': 'subscript', - 'sub': 'subscript', - 'sobrescrito': 'superscript', - 'sob': 'superscript', - u'referência-a-título': 'title-reference', - u'título': 'title-reference', - 't': 'title-reference', - u'referência-a-pep': 'pep-reference', - 'pep': 'pep-reference', - u'referência-a-rfc': 'rfc-reference', - 'rfc': 'rfc-reference', - u'ênfase': 'emphasis', - 'forte': 'strong', - 'literal': 'literal', - u'referência-por-nome': 'named-reference', - u'referência-anônima': 'anonymous-reference', - u'referência-a-nota-de-rodapé': 'footnote-reference', - u'referência-a-citação': 'citation-reference', - u'referência-a-substituição': 'substitution-reference', - 'alvo': 'target', - u'referência-a-uri': 'uri-reference', - 'uri': 'uri-reference', - 'url': 'uri-reference',} -"""Mapping of English role names to canonical role names for interpreted text. -""" diff --git a/docutils/parsers/rst/languages/pt_br.py b/docutils/parsers/rst/languages/pt_br.py new file mode 100644 index 000000000..6f8e3cf21 --- /dev/null +++ b/docutils/parsers/rst/languages/pt_br.py @@ -0,0 +1,96 @@ +# -*- coding: iso-8859-1 -*- +# Author: David Goodger +# Contact: goodger@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +# New language mappings are welcome. Before doing a new translation, please +# read . Two files must be +# translated for each language: one in docutils/languages, the other in +# docutils/parsers/rst/languages. + +""" +Brazilian Portuguese-language mappings for language-dependent features of +reStructuredText. +""" + +__docformat__ = 'reStructuredText' + + +directives = { + # language-dependent: fixed + u'atenção': 'attention', + 'cuidado': 'caution', + 'perigo': 'danger', + 'erro': 'error', + u'sugestão': 'hint', + 'importante': 'important', + 'nota': 'note', + 'dica': 'tip', + 'aviso': 'warning', + u'exortação': 'admonition', + 'barra-lateral': 'sidebar', + u'tópico': 'topic', + 'bloco-de-linhas': 'line-block', + 'literal-interpretado': 'parsed-literal', + 'rubrica': 'rubric', + u'epígrafo': 'epigraph', + 'destaques': 'highlights', + u'citação-destacada': 'pull-quote', + u'table (translation required)': 'table', + #'perguntas': 'questions', + #'qa': 'questions', + #'faq': 'questions', + 'meta': 'meta', + #'imagemap': 'imagemap', + 'imagem': 'image', + 'figura': 'figure', + u'inclusão': 'include', + 'cru': 'raw', + u'substituição': 'replace', + 'unicode': 'unicode', + 'classe': 'class', + u'índice': 'contents', + 'numsec': 'sectnum', + u'numeração-de-seções': 'sectnum', + #u'notas-de-rorapé': 'footnotes', + #u'citações': 'citations', + u'links-no-rodapé': 'target-notes', + 'restructuredtext-test-directive': 'restructuredtext-test-directive'} +"""English name to registered (in directives/__init__.py) directive name +mapping.""" + +roles = { + # language-dependent: fixed + u'abbreviação': 'abbreviation', + 'ab': 'abbreviation', + u'acrônimo': 'acronym', + 'ac': 'acronym', + u'índice-remissivo': 'index', + 'i': 'index', + 'subscrito': 'subscript', + 'sub': 'subscript', + 'sobrescrito': 'superscript', + 'sob': 'superscript', + u'referência-a-título': 'title-reference', + u'título': 'title-reference', + 't': 'title-reference', + u'referência-a-pep': 'pep-reference', + 'pep': 'pep-reference', + u'referência-a-rfc': 'rfc-reference', + 'rfc': 'rfc-reference', + u'ênfase': 'emphasis', + 'forte': 'strong', + 'literal': 'literal', + u'referência-por-nome': 'named-reference', + u'referência-anônima': 'anonymous-reference', + u'referência-a-nota-de-rodapé': 'footnote-reference', + u'referência-a-citação': 'citation-reference', + u'referência-a-substituição': 'substitution-reference', + 'alvo': 'target', + u'referência-a-uri': 'uri-reference', + 'uri': 'uri-reference', + 'url': 'uri-reference',} +"""Mapping of English role names to canonical role names for interpreted text. +""" -- cgit v1.2.1 From 917d7123f53aa0ba69c2ebcfed167acaac9c4931 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 17 Apr 2004 22:47:37 +0000 Subject: added support for custom interpreted text roles git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1958 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/roles.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/roles.py b/docutils/parsers/rst/roles.py index 262abf87a..a7d1333bc 100644 --- a/docutils/parsers/rst/roles.py +++ b/docutils/parsers/rst/roles.py @@ -134,16 +134,17 @@ def register_local_role(name, role_fn): # Create and register the standard roles: ###################################################################### -def make_generic_role(node_class, role, rawtext, text, lineno, inliner): +def generic_role(node_class, role, rawtext, text, lineno, inliner, + attributes={}): # If we wanted to, we could recursively call inliner.nested_parse # to interpret the text contents here (after appropriately # refactoring Inliner.parse). - return [node_class(rawtext, text)], [] + return [node_class(rawtext, text, **attributes)], [] # Helper function: def register_generic_role(name, node_class): def role_fn(role, rawtext, text, lineno, inliner, nc=node_class): - return make_generic_role(nc, role, rawtext, text, lineno, inliner) + return generic_role(nc, role, rawtext, text, lineno, inliner) register_canonical_role(name, role_fn) register_generic_role('abbreviation', nodes.abbreviation) @@ -155,6 +156,12 @@ register_generic_role('subscript', nodes.subscript) register_generic_role('superscript', nodes.superscript) register_generic_role('title-reference', nodes.title_reference) +def register_custom_role(name, attributes): + def role_fn(role, rawtext, text, lineno, inliner, atts=attributes): + return generic_role(nodes.inline, role, rawtext, text, lineno, inliner, + attributes=atts) + register_local_role(name, role_fn) + def pep_reference_role(role, rawtext, text, lineno, inliner): try: pepnum = int(text) -- cgit v1.2.1 From 5de4bec88b62acfa5cd0da03753f96b67603799c Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 17 Apr 2004 22:50:37 +0000 Subject: added "role" directive git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1959 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 6 +++++- docutils/parsers/rst/directives/misc.py | 23 +++++++++++++++++++++-- docutils/parsers/rst/languages/af.py | 1 + docutils/parsers/rst/languages/cs.py | 1 + docutils/parsers/rst/languages/de.py | 3 ++- docutils/parsers/rst/languages/en.py | 1 + docutils/parsers/rst/languages/eo.py | 1 + docutils/parsers/rst/languages/es.py | 1 + docutils/parsers/rst/languages/fr.py | 1 + docutils/parsers/rst/languages/it.py | 3 ++- docutils/parsers/rst/languages/pt_br.py | 1 + docutils/parsers/rst/languages/ru.py | 1 + docutils/parsers/rst/languages/sk.py | 1 + docutils/parsers/rst/languages/sv.py | 1 + 14 files changed, 40 insertions(+), 5 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index a7e434b08..c2a1b5210 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -118,6 +118,7 @@ _directive_registry = { 'replace': ('misc', 'replace'), 'unicode': ('misc', 'unicode_directive'), 'class': ('misc', 'class_directive'), + 'role': ('misc', 'role'), 'restructuredtext-test-directive': ('misc', 'directive_test_function'),} """Mapping of directive name to (module name, function name). The directive name is canonical & must be lowercase. Language-dependent names are defined @@ -272,7 +273,10 @@ def class_option(argument): """ if argument is None: raise ValueError('argument required but none supplied') - return nodes.make_id(argument) + class_name = nodes.make_id(argument) + if not class_name: + raise ValueError('cannot make "%s" into a class name' % argument) + return class_name def format_values(values): return '%s, or "%s"' % (', '.join(['"%s"' % s for s in values[:-1]]), diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 446935831..762d42300 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -12,7 +12,7 @@ import sys import os.path import re from docutils import io, nodes, statemachine, utils -from docutils.parsers.rst import directives, states +from docutils.parsers.rst import directives, roles, states from docutils.transforms import misc try: @@ -220,7 +220,7 @@ def class_directive(name, arguments, options, content, lineno, return [pending] else: error = state_machine.reporter.error( - 'Invalid class attribute value for "%s" directive: %s' + 'Invalid class attribute value for "%s" directive: "%s".' % (name, arguments[0]), nodes.literal_block(block_text, block_text), line=lineno) return [error] @@ -245,3 +245,22 @@ def directive_test_function(name, arguments, options, content, lineno, directive_test_function.arguments = (0, 1, 1) directive_test_function.options = {'option': directives.unchanged_required} directive_test_function.content = 1 + +def role(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + """Dynamically create and register a custom interpreted text role.""" + role_name = arguments[0].lower() + if not options.has_key('class'): + try: + options['class'] = directives.class_option(role_name) + except ValueError, detail: + error = state_machine.reporter.error( + 'Invalid argument for "%s" directive:\n%s.' + % (name, detail), + nodes.literal_block(block_text, block_text), line=lineno) + return [error] + roles.register_custom_role(role_name, options) + return [] + +role.arguments = (1, 0, 0) +role.options = {'class': directives.class_option} diff --git a/docutils/parsers/rst/languages/af.py b/docutils/parsers/rst/languages/af.py index f714ca9b1..ed750a586 100644 --- a/docutils/parsers/rst/languages/af.py +++ b/docutils/parsers/rst/languages/af.py @@ -49,6 +49,7 @@ directives = { 'vervang': 'replace', 'unicode': 'unicode', # should this be translated? unikode 'klas': 'class', + 'role (translation required)': 'role', 'inhoud': 'contents', 'sectnum': 'sectnum', 'section-numbering': 'sectnum', diff --git a/docutils/parsers/rst/languages/cs.py b/docutils/parsers/rst/languages/cs.py index 23c551140..6e836c81b 100644 --- a/docutils/parsers/rst/languages/cs.py +++ b/docutils/parsers/rst/languages/cs.py @@ -50,6 +50,7 @@ directives = { u'replace': 'replace', u'unicode': 'unicode', u't\u0159\u00EDda': 'class', + u'role (translation required)': 'role', u'obsah': 'contents', u'sectnum': 'sectnum', u'section-numbering': 'sectnum', diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index cc3b71138..73ccd90d1 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -50,7 +50,8 @@ directives = { # einfügung would be the noun. 'ersetzung': 'replace', # ersetzen, ersetze 'unicode': 'unicode', - 'klasse': 'class', # offer class too ? + 'klasse': 'class', # offer "class" too ? + 'role (translation required)': 'role', 'inhalt': 'contents', 'sectnum': 'sectnum', 'section-numbering': 'sectnum', diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index d9068ee8e..291404372 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -50,6 +50,7 @@ directives = { 'replace': 'replace', 'unicode': 'unicode', 'class': 'class', + 'role': 'role', 'contents': 'contents', 'sectnum': 'sectnum', 'section-numbering': 'sectnum', diff --git a/docutils/parsers/rst/languages/eo.py b/docutils/parsers/rst/languages/eo.py index dc9f59aa2..08855fa51 100644 --- a/docutils/parsers/rst/languages/eo.py +++ b/docutils/parsers/rst/languages/eo.py @@ -54,6 +54,7 @@ directives = { u'anstata\u016di': 'replace', u'unicode': 'unicode', u'klaso': 'class', + u'role (translation required)': 'role', u'enhavo': 'contents', u'seknum': 'sectnum', u'sekcia-numerado': 'sectnum', diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index f1354778b..2e1da7cfc 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -55,6 +55,7 @@ directives = { u'reemplazar': 'replace', u'unicode': 'unicode', u'clase': 'class', + u'role (translation required)': 'role', u'contenido': 'contents', u'numseccion': 'sectnum', u'numsecci\u00f3n': 'sectnum', diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index 6ed792430..12ab694a0 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -52,6 +52,7 @@ directives = { u'remplace': 'replace', u'unicode': 'unicode', u'classe': 'class', + u'role (translation required)': 'role', u'sommaire': 'contents', u'table-des-mati\u00E8res': 'contents', u'sectnum': 'sectnum', diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index fc08452e1..c794528e0 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -31,7 +31,7 @@ directives = { 'epigrafe': 'epigraph', 'highlights (translation required)': 'highlights', 'pull-quote (translation required)': 'pull-quote', - u'table (translation required)': 'table', + 'table (translation required)': 'table', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', @@ -44,6 +44,7 @@ directives = { 'sostituisci': 'replace', 'unicode': 'unicode', 'classe': 'class', + 'role (translation required)': 'role', 'indice': 'contents', 'seznum': 'sectnum', 'sezioni-autonumerate': 'sectnum', diff --git a/docutils/parsers/rst/languages/pt_br.py b/docutils/parsers/rst/languages/pt_br.py index 6f8e3cf21..de06a74da 100644 --- a/docutils/parsers/rst/languages/pt_br.py +++ b/docutils/parsers/rst/languages/pt_br.py @@ -51,6 +51,7 @@ directives = { u'substituição': 'replace', 'unicode': 'unicode', 'classe': 'class', + 'role (translation required)': 'role', u'índice': 'contents', 'numsec': 'sectnum', u'numeração-de-seções': 'sectnum', diff --git a/docutils/parsers/rst/languages/ru.py b/docutils/parsers/rst/languages/ru.py index 40823dd81..307c55a00 100644 --- a/docutils/parsers/rst/languages/ru.py +++ b/docutils/parsers/rst/languages/ru.py @@ -41,6 +41,7 @@ directives = { u'\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435': u'image', u'\u043a\u043b\u0430\u0441\u0441': u'class', + u'role (translation required)': 'role', u'\u043d\u043e\u043c\u0435\u0440-\u0440\u0430\u0437\u0434\u0435\u043b\u0430': u'sectnum', u'\u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f-\u0440\u0430\u0437' diff --git a/docutils/parsers/rst/languages/sk.py b/docutils/parsers/rst/languages/sk.py index 83f101908..64af4ac1a 100644 --- a/docutils/parsers/rst/languages/sk.py +++ b/docutils/parsers/rst/languages/sk.py @@ -49,6 +49,7 @@ directives = { u'nahradi\x9d': 'replace', u'unicode': 'unicode', u'class (translation required)': 'class', + u'role (translation required)': 'role', u'obsah': 'contents', u'\xe8as\x9d': 'sectnum', u'\xe8as\x9d-\xe8\xedslovanie': 'sectnum', diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index 3409c30f2..9f6e8234c 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -49,6 +49,7 @@ directives = { u'ers\u00e4tt': 'replace', u'unicode': 'unicode', u'class (translation required)': 'class', + u'role (translation required)': 'role', u'inneh\u00e5ll': 'contents', u'sektionsnumrering': 'sectnum', u'target-notes (translation required)': 'target-notes', -- cgit v1.2.1 From 8c9bc8f14cd60ee09168be25c62cb2be4b646d3a Mon Sep 17 00:00:00 2001 From: richieadler Date: Sat, 17 Apr 2004 23:13:20 +0000 Subject: Translation to esperanto and spanish of the "role" directive git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1961 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/eo.py | 2 +- docutils/parsers/rst/languages/es.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/eo.py b/docutils/parsers/rst/languages/eo.py index 08855fa51..7101a082a 100644 --- a/docutils/parsers/rst/languages/eo.py +++ b/docutils/parsers/rst/languages/eo.py @@ -54,7 +54,7 @@ directives = { u'anstata\u016di': 'replace', u'unicode': 'unicode', u'klaso': 'class', - u'role (translation required)': 'role', + u'rolo': 'role', u'enhavo': 'contents', u'seknum': 'sectnum', u'sekcia-numerado': 'sectnum', diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index 2e1da7cfc..08d73e183 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -55,7 +55,7 @@ directives = { u'reemplazar': 'replace', u'unicode': 'unicode', u'clase': 'class', - u'role (translation required)': 'role', + u'rol': 'role', u'contenido': 'contents', u'numseccion': 'sectnum', u'numsecci\u00f3n': 'sectnum', -- cgit v1.2.1 From b4f3a6112f1915b50686c6512be6c491dfb9810f Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 18 Apr 2004 21:58:35 +0000 Subject: moved test directive last git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1966 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 37 +++++++++++++++++---------------- 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 762d42300..4352c846a 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -228,24 +228,6 @@ def class_directive(name, arguments, options, content, lineno, class_directive.arguments = (1, 0, 0) class_directive.content = 1 -def directive_test_function(name, arguments, options, content, lineno, - content_offset, block_text, state, state_machine): - if content: - text = '\n'.join(content) - info = state_machine.reporter.info( - 'Directive processed. Type="%s", arguments=%r, options=%r, ' - 'content:' % (name, arguments, options), - nodes.literal_block(text, text), line=lineno) - else: - info = state_machine.reporter.info( - 'Directive processed. Type="%s", arguments=%r, options=%r, ' - 'content: None' % (name, arguments, options), line=lineno) - return [info] - -directive_test_function.arguments = (0, 1, 1) -directive_test_function.options = {'option': directives.unchanged_required} -directive_test_function.content = 1 - def role(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): """Dynamically create and register a custom interpreted text role.""" @@ -264,3 +246,22 @@ def role(name, arguments, options, content, lineno, role.arguments = (1, 0, 0) role.options = {'class': directives.class_option} + +def directive_test_function(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + """This directive is useful only for testing purposes.""" + if content: + text = '\n'.join(content) + info = state_machine.reporter.info( + 'Directive processed. Type="%s", arguments=%r, options=%r, ' + 'content:' % (name, arguments, options), + nodes.literal_block(text, text), line=lineno) + else: + info = state_machine.reporter.info( + 'Directive processed. Type="%s", arguments=%r, options=%r, ' + 'content: None' % (name, arguments, options), line=lineno) + return [info] + +directive_test_function.arguments = (0, 1, 1) +directive_test_function.options = {'option': directives.unchanged_required} +directive_test_function.content = 1 -- cgit v1.2.1 From 08958ecc17290adb1bc99df3bcfba29d9a30874d Mon Sep 17 00:00:00 2001 From: lele Date: Mon, 19 Apr 2004 00:44:47 +0000 Subject: Added 'role' translation git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1967 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/it.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index c794528e0..cdfd0492c 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -29,9 +29,9 @@ directives = { 'blocco-interpretato': 'parsed-literal', 'rubrica': 'rubric', 'epigrafe': 'epigraph', - 'highlights (translation required)': 'highlights', + 'evidenzia': 'highlights', 'pull-quote (translation required)': 'pull-quote', - 'table (translation required)': 'table', + 'tabella': 'table', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', @@ -44,7 +44,7 @@ directives = { 'sostituisci': 'replace', 'unicode': 'unicode', 'classe': 'class', - 'role (translation required)': 'role', + 'ruolo': 'role', 'indice': 'contents', 'seznum': 'sectnum', 'sezioni-autonumerate': 'sectnum', -- cgit v1.2.1 From 88c2b891564b4b5711743f7d42f96d24f8f23787 Mon Sep 17 00:00:00 2001 From: goodger Date: Mon, 19 Apr 2004 01:23:20 +0000 Subject: code layout & docstrings git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1970 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/roles.py | 48 ++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 21 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/roles.py b/docutils/parsers/rst/roles.py index a7d1333bc..de5f106c6 100644 --- a/docutils/parsers/rst/roles.py +++ b/docutils/parsers/rst/roles.py @@ -11,16 +11,16 @@ registry. The interface for interpreted role functions is as follows:: - def role_fn(name, rawtext, text, lineno, inliner): + def role_fn(name, rawtext, text, lineno, inliner, attributes={}): code... Parameters: -- ``name`` is the interpreted role type or name. +- ``name`` is the local name of the interpreted text role, the role name + actually used in the document. -- ``rawtext`` is a string containing the entire interpreted text. - Include it as the content of a system message if there is a - problem. +- ``rawtext`` is a string containing the entire interpreted text construct. + Include it as a literal block in a system message if there is a problem. - ``text`` is the interpreted text content. @@ -30,6 +30,9 @@ Parameters: It defines the following useful attributes: ``reporter``, ``problematic``, ``memo``, ``parent``, ``document``. +- ``attributes``: A dictionary of additional attributes for the generated + elements, used for customization. + Interpreted role functions return a tuple of two values: - A list of nodes which will be inserted into the document tree at the @@ -130,22 +133,31 @@ def register_local_role(name, role_fn): """ _roles[name] = role_fn -###################################################################### -# Create and register the standard roles: -###################################################################### +def register_generic_role(canonical_name, node_class): + """For roles which simply wrap a given `node_class` around the text.""" + # Dynamically define a role function: + def role_fn(role, rawtext, text, lineno, inliner, nc=node_class): + return generic_role_helper(nc, role, rawtext, text, lineno, inliner) + # Register the role: + register_canonical_role(canonical_name, role_fn) -def generic_role(node_class, role, rawtext, text, lineno, inliner, - attributes={}): +def generic_role_helper(node_class, role, rawtext, text, lineno, inliner, + attributes={}): # If we wanted to, we could recursively call inliner.nested_parse # to interpret the text contents here (after appropriately # refactoring Inliner.parse). return [node_class(rawtext, text, **attributes)], [] -# Helper function: -def register_generic_role(name, node_class): - def role_fn(role, rawtext, text, lineno, inliner, nc=node_class): - return generic_role(nc, role, rawtext, text, lineno, inliner) - register_canonical_role(name, role_fn) +def register_custom_role(local_name, attributes): + """For roles defined in a document.""" + def role_fn(role, rawtext, text, lineno, inliner, atts=attributes): + return generic_role_helper( + nodes.inline, role, rawtext, text, lineno, inliner, attributes=atts) + register_local_role(local_name, role_fn) + +###################################################################### +# Define and register the standard roles: +###################################################################### register_generic_role('abbreviation', nodes.abbreviation) register_generic_role('acronym', nodes.acronym) @@ -156,12 +168,6 @@ register_generic_role('subscript', nodes.subscript) register_generic_role('superscript', nodes.superscript) register_generic_role('title-reference', nodes.title_reference) -def register_custom_role(name, attributes): - def role_fn(role, rawtext, text, lineno, inliner, atts=attributes): - return generic_role(nodes.inline, role, rawtext, text, lineno, inliner, - attributes=atts) - register_local_role(name, role_fn) - def pep_reference_role(role, rawtext, text, lineno, inliner): try: pepnum = int(text) -- cgit v1.2.1 From 080b9ef04d08c4de5c80fd5282bddf950692d546 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 22 Apr 2004 20:08:14 +0000 Subject: comments git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1981 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/roles.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/roles.py b/docutils/parsers/rst/roles.py index de5f106c6..7bf1f96a3 100644 --- a/docutils/parsers/rst/roles.py +++ b/docutils/parsers/rst/roles.py @@ -179,7 +179,8 @@ def pep_reference_role(role, rawtext, text, lineno, inliner): % text, line=lineno) prb = inliner.problematic(text, text, msg) return [prb], [msg] - ref = inliner.pep_url % pepnum # [XX] + # Base URL mainly used by inliner.pep_reference; so this is correct: + ref = inliner.pep_url % pepnum return [nodes.reference(rawtext, 'PEP ' + text, refuri=ref)], [] register_canonical_role('pep-reference', pep_reference_role) @@ -194,7 +195,8 @@ def rfc_reference_role(role, rawtext, text, lineno, inliner): '"%s" is invalid.' % text, line=lineno) prb = inliner.problematic(text, text, msg) return [prb], [msg] - ref = inliner.rfc_url % rfcnum # [XX] + # Base URL mainly used by inliner.rfc_reference, so this is correct: + ref = inliner.rfc_url % rfcnum return [nodes.reference(rawtext, 'RFC ' + text, refuri=ref)], [] register_canonical_role('rfc-reference', rfc_reference_role) -- cgit v1.2.1 From 5f4fc7c0e88fe3f9bdadc52d7ec2906bc02e4839 Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 27 Apr 2004 19:47:28 +0000 Subject: Refactored ``Body.parse_directive`` into ``run_directive`` and ``parse_directive_block``. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2000 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 68 +++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 28 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 5d7c463dc..219b8a790 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -496,6 +496,8 @@ class Inliner: self.rfc_reference)) def parse(self, text, lineno, memo, parent): + # Needs to be refactored for nested inline markup. + # Add nested_parse() method? """ Return 2 lists: nodes (text and inline elements), and system_messages. @@ -831,7 +833,8 @@ class Inliner: return uri def interpreted(self, rawsource, text, role, lineno): - role_fn, messages = roles.role(role, self.language, lineno, self) + role_fn, messages = roles.role(role, self.language, lineno, + self.reporter) if role_fn: nodes, messages2 = role_fn(role, rawsource, text, lineno, self) return nodes, messages + messages2 @@ -1878,17 +1881,18 @@ class Body(RSTState): return [msg], blank_finish def directive(self, match, **option_presets): + """Returns a 2-tuple: list of nodes, and a "blank finish" boolean.""" type_name = match.group(1) directive_function, messages = directives.directive( type_name, self.memo.language, self.document) self.parent += messages if directive_function: - return self.parse_directive( + return self.run_directive( directive_function, match, type_name, option_presets) else: return self.unknown_directive(type_name) - def parse_directive(self, directive_fn, match, type_name, option_presets): + def run_directive(self, directive_fn, match, type_name, option_presets): """ Parse a directive then run its directive function. @@ -1910,13 +1914,6 @@ class Body(RSTState): Returns a 2-tuple: list of nodes, and a "blank finish" boolean. """ - arguments = [] - options = {} - argument_spec = getattr(directive_fn, 'arguments', None) - if argument_spec and argument_spec[:2] == (0, 0): - argument_spec = None - option_spec = getattr(directive_fn, 'options', None) - content_spec = getattr(directive_fn, 'content', None) lineno = self.state_machine.abs_line_number() initial_line_offset = self.state_machine.line_offset indented, indent, line_offset, blank_finish \ @@ -1924,6 +1921,30 @@ class Body(RSTState): strip_top=0) block_text = '\n'.join(self.state_machine.input_lines[ initial_line_offset : self.state_machine.line_offset + 1]) + try: + arguments, options, content, content_offset = ( + self.parse_directive_block(indented, line_offset, + directive_fn, option_presets)) + except MarkupError, detail: + error = self.reporter.error( + 'Error in "%s" directive:\n%s.' % (type_name, detail), + nodes.literal_block(block_text, block_text), line=lineno) + return [error], blank_finish + result = directive_fn(type_name, arguments, options, content, lineno, + content_offset, block_text, self, + self.state_machine) + return (result, + blank_finish or self.state_machine.is_next_line_blank()) + + def parse_directive_block(self, indented, line_offset, directive_fn, + option_presets): + arguments = [] + options = {} + argument_spec = getattr(directive_fn, 'arguments', None) + if argument_spec and argument_spec[:2] == (0, 0): + argument_spec = None + option_spec = getattr(directive_fn, 'options', None) + content_spec = getattr(directive_fn, 'content', None) if indented and not indented[0].strip(): indented.trim_start() line_offset += 1 @@ -1945,24 +1966,15 @@ class Body(RSTState): while content and not content[0].strip(): content.trim_start() content_offset += 1 - try: - if option_spec: - options, arg_block = self.parse_directive_options( - option_presets, option_spec, arg_block) - if argument_spec: - arguments = self.parse_directive_arguments(argument_spec, - arg_block) - if content and not content_spec: - raise MarkupError('no content permitted') - except MarkupError, detail: - error = self.reporter.error( - 'Error in "%s" directive:\n%s.' % (type_name, detail), - nodes.literal_block(block_text, block_text), line=lineno) - return [error], blank_finish - result = directive_fn( - type_name, arguments, options, content, lineno, content_offset, - block_text, self, self.state_machine) - return result, blank_finish or self.state_machine.is_next_line_blank() + if option_spec: + options, arg_block = self.parse_directive_options( + option_presets, option_spec, arg_block) + if argument_spec: + arguments = self.parse_directive_arguments( + argument_spec, arg_block) + if content and not content_spec: + raise MarkupError('no content permitted') + return (arguments, options, content, content_offset) def parse_directive_options(self, option_presets, option_spec, arg_block): options = option_presets.copy() -- cgit v1.2.1 From 60d84454ac6baa935bb8492471cc9a428c0dbd52 Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 27 Apr 2004 19:48:37 +0000 Subject: Reworked role API & "role" directive to allow customization. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2001 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 53 +++++++++-- docutils/parsers/rst/roles.py | 160 +++++++++++++++++++++++++------- 2 files changed, 171 insertions(+), 42 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 4352c846a..d2f65c990 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -228,24 +228,63 @@ def class_directive(name, arguments, options, content, lineno, class_directive.arguments = (1, 0, 0) class_directive.content = 1 +role_arg_pat = re.compile(r'(%s)\s*(\(\s*(%s)\s*\)\s*)?$' + % ((states.Inliner.simplename,) * 2)) def role(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): """Dynamically create and register a custom interpreted text role.""" - role_name = arguments[0].lower() + if content_offset > lineno or not content: + error = state_machine.reporter.error( + '"%s" directive requires arguments on the first line.' + % name, nodes.literal_block(block_text, block_text), line=lineno) + return [error] + args = content[0] + match = role_arg_pat.match(args) + if not match: + error = state_machine.reporter.error( + '"%s" directive arguments not valid role names: "%s".' + % (name, args), nodes.literal_block(block_text, block_text), + line=lineno) + return [error] + new_role_name = match.group(1) + base_role_name = match.group(3) + messages = [] + if base_role_name: + base_role, messages = roles.role( + base_role_name, state_machine.language, lineno, state.reporter) + if base_role is None: + error = state.reporter.error( + 'Unknown interpreted text role "%s".' % base_role_name, + nodes.literal_block(block_text, block_text), line=lineno) + return messages + [error] + else: + base_role = roles.generic_custom_role + assert not hasattr(base_role, 'arguments'), ( + 'Supplemental directive arguments for "%s" directive not supported' + '(specified by "%r" role).' % (name, base_role)) + try: + (arguments, options, content, content_offset) = ( + state.parse_directive_block(content[1:], content_offset, base_role, + option_presets={})) + except states.MarkupError, detail: + error = state_machine.reporter.error( + 'Error in "%s" directive:\n%s.' % (name, detail), + nodes.literal_block(block_text, block_text), line=lineno) + return messages + [error] if not options.has_key('class'): try: - options['class'] = directives.class_option(role_name) + options['class'] = directives.class_option(new_role_name) except ValueError, detail: error = state_machine.reporter.error( 'Invalid argument for "%s" directive:\n%s.' % (name, detail), nodes.literal_block(block_text, block_text), line=lineno) - return [error] - roles.register_custom_role(role_name, options) - return [] + return messages + [error] + role = roles.CustomRole(new_role_name, base_role, options, content) + roles.register_local_role(new_role_name, role) + return messages -role.arguments = (1, 0, 0) -role.options = {'class': directives.class_option} +role.content = 1 def directive_test_function(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): diff --git a/docutils/parsers/rst/roles.py b/docutils/parsers/rst/roles.py index 7bf1f96a3..2af000d6c 100644 --- a/docutils/parsers/rst/roles.py +++ b/docutils/parsers/rst/roles.py @@ -11,16 +11,22 @@ registry. The interface for interpreted role functions is as follows:: - def role_fn(name, rawtext, text, lineno, inliner, attributes={}): + def role_fn(name, rawtext, text, lineno, inliner, + options={}, content=[]): code... + # Set function attributes for customization: + role_fn.options = ... + role_fn.content = ... + Parameters: - ``name`` is the local name of the interpreted text role, the role name actually used in the document. - ``rawtext`` is a string containing the entire interpreted text construct. - Include it as a literal block in a system message if there is a problem. + Return it as a ``problematic`` node linked to a system message if there is a + problem. - ``text`` is the interpreted text content. @@ -30,8 +36,30 @@ Parameters: It defines the following useful attributes: ``reporter``, ``problematic``, ``memo``, ``parent``, ``document``. -- ``attributes``: A dictionary of additional attributes for the generated - elements, used for customization. +- ``options``: A dictionary of directive options for customization, to be + interpreted by the role function. Used for additional attributes for the + generated elements and other functionality. + +- ``content``: A list of strings, the directive content for customization + ("role" directive). To be interpreted by the role function. + +Function attributes for customization, interpreted by the "role" directive: + +- ``options``: A dictionary, mapping known option names to conversion + functions such as `int` or `float`. ``None`` or an empty dict implies no + options to parse. Several directive option conversion functions are defined + in the `directives` module. + + All role functions implicitly support the "class" option, unless disabled + with an explicit ``{'class': None}``. + +- ``content``: A boolean; true if content is allowed. Client code must handle + the case where content is required but not supplied (an empty content list + will be supplied). + +Note that unlike directives, the "arguments" function attribute is not +supported for role customization. Directive arguments are handled by the +"role" directive itself. Interpreted role functions return a tuple of two values: @@ -46,6 +74,7 @@ Interpreted role functions return a tuple of two values: __docformat__ = 'reStructuredText' from docutils import nodes +from docutils.parsers.rst import directives from docutils.parsers.rst.languages import en as _fallback_language_module DEFAULT_INTERPRETED_ROLE = 'title-reference' @@ -62,11 +91,12 @@ _roles = {} """Mapping of local or language-dependent interpreted text role names to role functions.""" -def role(role_name, language_module, lineno, inliner): +def role(role_name, language_module, lineno, reporter): """ Locate and return a role function from its language-dependent name, along with a list of system messages. If the role is not found in the current - language, check English. Return None if the named role cannot be found. + language, check English. Return a 2-tuple: role function (``None`` if the + named role cannot be found) and a list of system messages. """ normname = role_name.lower() messages = [] @@ -102,7 +132,7 @@ def role(role_name, language_module, lineno, inliner): # Collect any messages that we generated. if msg_text: - message = inliner.reporter.info('\n'.join(msg_text), line=lineno) + message = reporter.info('\n'.join(msg_text), line=lineno) messages.append(message) # Look the role up in the registry, and return it. @@ -121,6 +151,7 @@ def register_canonical_role(name, role_fn): - `name`: The canonical name of the interpreted role. - `role_fn`: The role function. See the module docstring. """ + set_implicit_options(role_fn) _role_registry[name] = role_fn def register_local_role(name, role_fn): @@ -131,29 +162,80 @@ def register_local_role(name, role_fn): - `name`: The local or language-dependent name of the interpreted role. - `role_fn`: The role function. See the module docstring. """ + set_implicit_options(role_fn) _roles[name] = role_fn +def set_implicit_options(role_fn): + """ + Add customization options to role functions, unless explicitly set or + disabled. + """ + if not hasattr(role_fn, 'options') or role_fn.options is None: + role_fn.options = {'class': directives.class_option} + elif not role_fn.options.has_key('class'): + role_fn.options['class'] = directives.class_option + def register_generic_role(canonical_name, node_class): """For roles which simply wrap a given `node_class` around the text.""" - # Dynamically define a role function: - def role_fn(role, rawtext, text, lineno, inliner, nc=node_class): - return generic_role_helper(nc, role, rawtext, text, lineno, inliner) - # Register the role: - register_canonical_role(canonical_name, role_fn) - -def generic_role_helper(node_class, role, rawtext, text, lineno, inliner, - attributes={}): - # If we wanted to, we could recursively call inliner.nested_parse - # to interpret the text contents here (after appropriately - # refactoring Inliner.parse). - return [node_class(rawtext, text, **attributes)], [] - -def register_custom_role(local_name, attributes): - """For roles defined in a document.""" - def role_fn(role, rawtext, text, lineno, inliner, atts=attributes): - return generic_role_helper( - nodes.inline, role, rawtext, text, lineno, inliner, attributes=atts) - register_local_role(local_name, role_fn) + role = GenericRole(canonical_name, node_class) + register_canonical_role(canonical_name, role) + + +class GenericRole: + + """ + Generic interpreted text role, where the interpreted text is simply + wrapped with the provided node class. + """ + + def __init__(self, role_name, node_class): + self.name = role_name + self.node_class = node_class + + def __call__(self, role, rawtext, text, lineno, inliner, + options={}, content=[]): + return [self.node_class(rawtext, text, **options)], [] + + +class CustomRole: + + """ + Wrapper for custom interpreted text roles. + """ + + def __init__(self, role_name, base_role, options={}, content=[]): + self.name = role_name + self.base_role = base_role + self.options = None + if hasattr(base_role, 'options'): + self.options = base_role.options + self.content = None + if hasattr(base_role, 'content'): + self.content = base_role.content + self.supplied_options = options + self.supplied_content = content + + def __call__(self, role, rawtext, text, lineno, inliner, + options={}, content=[]): + opts = self.supplied_options.copy() + opts.update(options) + cont = list(self.supplied_content) + if cont and content: + cont += '\n' + cont.extend(content) + return self.base_role(role, rawtext, text, lineno, inliner, + options=opts, content=cont) + + +def generic_custom_role(role, rawtext, text, lineno, inliner, + options={}, content=[]): + """""" + # Once nested inline markup is implemented, this and other methods should + # recursively call inliner.nested_parse(). + return [nodes.inline(rawtext, text, **options)], [] + +generic_custom_role.options = {'class': directives.class_option} + ###################################################################### # Define and register the standard roles: @@ -168,7 +250,8 @@ register_generic_role('subscript', nodes.subscript) register_generic_role('superscript', nodes.superscript) register_generic_role('title-reference', nodes.title_reference) -def pep_reference_role(role, rawtext, text, lineno, inliner): +def pep_reference_role(role, rawtext, text, lineno, inliner, + options={}, content=[]): try: pepnum = int(text) if pepnum < 0 or pepnum > 9999: @@ -177,14 +260,16 @@ def pep_reference_role(role, rawtext, text, lineno, inliner): msg = inliner.reporter.error( 'PEP number must be a number from 0 to 9999; "%s" is invalid.' % text, line=lineno) - prb = inliner.problematic(text, text, msg) + prb = inliner.problematic(rawtext, rawtext, msg) return [prb], [msg] # Base URL mainly used by inliner.pep_reference; so this is correct: ref = inliner.pep_url % pepnum - return [nodes.reference(rawtext, 'PEP ' + text, refuri=ref)], [] + return [nodes.reference(rawtext, 'PEP ' + text, refuri=ref, **options)], [] + register_canonical_role('pep-reference', pep_reference_role) -def rfc_reference_role(role, rawtext, text, lineno, inliner): +def rfc_reference_role(role, rawtext, text, lineno, inliner, + options={}, content=[]): try: rfcnum = int(text) if rfcnum <= 0: @@ -193,18 +278,21 @@ def rfc_reference_role(role, rawtext, text, lineno, inliner): msg = inliner.reporter.error( 'RFC number must be a number greater than or equal to 1; ' '"%s" is invalid.' % text, line=lineno) - prb = inliner.problematic(text, text, msg) + prb = inliner.problematic(rawtext, rawtext, msg) return [prb], [msg] # Base URL mainly used by inliner.rfc_reference, so this is correct: ref = inliner.rfc_url % rfcnum - return [nodes.reference(rawtext, 'RFC ' + text, refuri=ref)], [] + node = nodes.reference(rawtext, 'RFC ' + text, refuri=ref, **options) + return [node], [] + register_canonical_role('rfc-reference', rfc_reference_role) + ###################################################################### # Register roles that are currently unimplemented. ###################################################################### -def unimplemented_role(role, rawtext, text, lineno, inliner): +def unimplemented_role(role, rawtext, text, lineno, inliner, attributes={}): msg = inliner.reporter.error( 'Interpreted text role "%s" not implemented.' % role, line=lineno) prb = inliner.problematic(rawtext, rawtext, msg) @@ -218,5 +306,7 @@ register_canonical_role('footnote-reference', unimplemented_role) register_canonical_role('citation-reference', unimplemented_role) register_canonical_role('substitution-reference', unimplemented_role) register_canonical_role('target', unimplemented_role) -# This one should remain unimplemented, for testing purposes: -register_canonical_role('restructuredtext-unimplemented-role', unimplemented_role) + +# This should remain unimplemented, for testing purposes: +register_canonical_role('restructuredtext-unimplemented-role', + unimplemented_role) -- cgit v1.2.1 From 6c18a0548558d3eefb532ef613a49533328dd357 Mon Sep 17 00:00:00 2001 From: wiemann Date: Sat, 5 Jun 2004 19:32:15 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2223 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index c2a1b5210..74ecc9984 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -74,7 +74,7 @@ empty list). See `Creating reStructuredText Directives`_ for more information. .. _Creating reStructuredText Directives: - http://docutils.sourceforge.net/spec/howto/rst-directives.html + http://docutils.sourceforge.net/docs/howto/rst-directives.html """ __docformat__ = 'reStructuredText' -- cgit v1.2.1 From a3eedc4e04eea5aa5723ea42ebb293f87fc4c33c Mon Sep 17 00:00:00 2001 From: wiemann Date: Sat, 5 Jun 2004 19:40:46 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2224 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/__init__.py | 2 +- docutils/parsers/rst/languages/af.py | 2 +- docutils/parsers/rst/languages/cs.py | 2 +- docutils/parsers/rst/languages/de.py | 2 +- docutils/parsers/rst/languages/en.py | 2 +- docutils/parsers/rst/languages/eo.py | 2 +- docutils/parsers/rst/languages/es.py | 2 +- docutils/parsers/rst/languages/fr.py | 2 +- docutils/parsers/rst/languages/it.py | 5 +++++ docutils/parsers/rst/languages/pt_br.py | 2 +- docutils/parsers/rst/languages/ru.py | 2 +- docutils/parsers/rst/languages/sk.py | 2 +- docutils/parsers/rst/languages/sv.py | 2 +- 13 files changed, 17 insertions(+), 12 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/__init__.py b/docutils/parsers/rst/languages/__init__.py index ea4218657..be6feb644 100644 --- a/docutils/parsers/rst/languages/__init__.py +++ b/docutils/parsers/rst/languages/__init__.py @@ -5,7 +5,7 @@ # Copyright: This module has been placed in the public domain. # Internationalization details are documented in -# . +# . """ This package contains modules for language-dependent features of diff --git a/docutils/parsers/rst/languages/af.py b/docutils/parsers/rst/languages/af.py index ed750a586..3fc6c6a9a 100644 --- a/docutils/parsers/rst/languages/af.py +++ b/docutils/parsers/rst/languages/af.py @@ -5,7 +5,7 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read . Two files must be +# read . Two files must be # translated for each language: one in docutils/languages, the other in # docutils/parsers/rst/languages. diff --git a/docutils/parsers/rst/languages/cs.py b/docutils/parsers/rst/languages/cs.py index 6e836c81b..7897b90a9 100644 --- a/docutils/parsers/rst/languages/cs.py +++ b/docutils/parsers/rst/languages/cs.py @@ -5,7 +5,7 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read . Two files must be +# read . Two files must be # translated for each language: one in docutils/languages, the other in # docutils/parsers/rst/languages. diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index 73ccd90d1..cc9465cb1 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -6,7 +6,7 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read . Two files must be +# read . Two files must be # translated for each language: one in docutils/languages, the other in # docutils/parsers/rst/languages. diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index 291404372..d6a70f564 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -5,7 +5,7 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read . Two files must be +# read . Two files must be # translated for each language: one in docutils/languages, the other in # docutils/parsers/rst/languages. diff --git a/docutils/parsers/rst/languages/eo.py b/docutils/parsers/rst/languages/eo.py index 7101a082a..0abcc0390 100644 --- a/docutils/parsers/rst/languages/eo.py +++ b/docutils/parsers/rst/languages/eo.py @@ -5,7 +5,7 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read . Two files must be +# read . Two files must be # translated for each language: one in docutils/languages, the other in # docutils/parsers/rst/languages. diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index 08d73e183..1535b4a00 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -6,7 +6,7 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read . Two files must be +# read . Two files must be # translated for each language: one in docutils/languages, the other in # docutils/parsers/rst/languages. diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index 12ab694a0..3afdf942c 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -5,7 +5,7 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read . Two files must be +# read . Two files must be # translated for each language: one in docutils/languages, the other in # docutils/parsers/rst/languages. diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index cdfd0492c..db2c81d5f 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -4,6 +4,11 @@ # Date: $Date$ # Copyright: This module has been placed in the public domain. +# New language mappings are welcome. Before doing a new translation, please +# read . Two files must be +# translated for each language: one in docutils/languages, the other in +# docutils/parsers/rst/languages. + """ Italian-language mappings for language-dependent features of reStructuredText. diff --git a/docutils/parsers/rst/languages/pt_br.py b/docutils/parsers/rst/languages/pt_br.py index de06a74da..5424aa24c 100644 --- a/docutils/parsers/rst/languages/pt_br.py +++ b/docutils/parsers/rst/languages/pt_br.py @@ -6,7 +6,7 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read . Two files must be +# read . Two files must be # translated for each language: one in docutils/languages, the other in # docutils/parsers/rst/languages. diff --git a/docutils/parsers/rst/languages/ru.py b/docutils/parsers/rst/languages/ru.py index 307c55a00..49420b3c3 100644 --- a/docutils/parsers/rst/languages/ru.py +++ b/docutils/parsers/rst/languages/ru.py @@ -5,7 +5,7 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read . Two files must be +# read . Two files must be # translated for each language: one in docutils/languages, the other in # docutils/parsers/rst/languages. diff --git a/docutils/parsers/rst/languages/sk.py b/docutils/parsers/rst/languages/sk.py index 64af4ac1a..c4b8e635c 100644 --- a/docutils/parsers/rst/languages/sk.py +++ b/docutils/parsers/rst/languages/sk.py @@ -5,7 +5,7 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read . Two files must be +# read . Two files must be # translated for each language: one in docutils/languages, the other in # docutils/parsers/rst/languages. diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index 9f6e8234c..a5579be25 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -5,7 +5,7 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read . Two files must be +# read . Two files must be # translated for each language: one in docutils/languages, the other in # docutils/parsers/rst/languages. -- cgit v1.2.1 From c48260665ecf74131830f99949da7b99b7579348 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 16 Jun 2004 17:21:57 +0000 Subject: added pep_base_url & rfc_base_url settings & support git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2287 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/__init__.py | 13 +++++++++++-- docutils/parsers/rst/roles.py | 4 ++-- docutils/parsers/rst/states.py | 10 ++++------ 3 files changed, 17 insertions(+), 10 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/__init__.py b/docutils/parsers/rst/__init__.py index 679539fb9..33ad99829 100644 --- a/docutils/parsers/rst/__init__.py +++ b/docutils/parsers/rst/__init__.py @@ -88,12 +88,21 @@ class Parser(docutils.parsers.Parser): settings_spec = ( 'reStructuredText Parser Options', None, - (('Recognize and link to PEP references (like "PEP 258").', + (('Recognize and link to standalone PEP references (like "PEP 258").', ['--pep-references'], {'action': 'store_true', 'validator': frontend.validate_boolean}), - ('Recognize and link to RFC references (like "RFC 822").', + ('Base URL for PEP references ' + '(default "http://www.python.org/peps/").', + ['--pep-base-url'], + {'metavar': '', 'default': 'http://www.python.org/peps/', + 'validator': frontend.validate_url_trailing_slash}), + ('Recognize and link to standalone RFC references (like "RFC 822").', ['--rfc-references'], {'action': 'store_true', 'validator': frontend.validate_boolean}), + ('Base URL for RFC references (default "http://www.faqs.org/rfcs/").', + ['--rfc-base-url'], + {'metavar': '', 'default': 'http://www.faqs.org/rfcs/', + 'validator': frontend.validate_url_trailing_slash}), ('Set number of spaces for tab expansion (default 8).', ['--tab-width'], {'metavar': '', 'type': 'int', 'default': 8}), diff --git a/docutils/parsers/rst/roles.py b/docutils/parsers/rst/roles.py index 2af000d6c..aff19f30c 100644 --- a/docutils/parsers/rst/roles.py +++ b/docutils/parsers/rst/roles.py @@ -263,7 +263,7 @@ def pep_reference_role(role, rawtext, text, lineno, inliner, prb = inliner.problematic(rawtext, rawtext, msg) return [prb], [msg] # Base URL mainly used by inliner.pep_reference; so this is correct: - ref = inliner.pep_url % pepnum + ref = inliner.document.settings.pep_base_url + inliner.pep_url % pepnum return [nodes.reference(rawtext, 'PEP ' + text, refuri=ref, **options)], [] register_canonical_role('pep-reference', pep_reference_role) @@ -281,7 +281,7 @@ def rfc_reference_role(role, rawtext, text, lineno, inliner, prb = inliner.problematic(rawtext, rawtext, msg) return [prb], [msg] # Base URL mainly used by inliner.rfc_reference, so this is correct: - ref = inliner.rfc_url % rfcnum + ref = inliner.document.settings.rfc_base_url + inliner.rfc_url % rfcnum node = nodes.reference(rawtext, 'RFC ' + text, refuri=ref, **options) return [node], [] diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 219b8a790..4025c7e72 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -954,9 +954,7 @@ class Inliner: else: # not a valid scheme raise MarkupMismatch - pep_url_local = 'pep-%04d.html' - pep_url_absolute = 'http://www.python.org/peps/pep-%04d.html' - pep_url = pep_url_absolute + pep_url = 'pep-%04d.html' def pep_reference(self, match, lineno): text = match.group(0) @@ -966,17 +964,17 @@ class Inliner: pepnum = int(match.group('pepnum2')) else: raise MarkupMismatch - ref = self.pep_url % pepnum + ref = self.document.settings.pep_base_url + self.pep_url % pepnum unescaped = unescape(text, 0) return [nodes.reference(unescape(text, 1), unescaped, refuri=ref)] - rfc_url = 'http://www.faqs.org/rfcs/rfc%d.html' + rfc_url = 'rfc%d.html' def rfc_reference(self, match, lineno): text = match.group(0) if text.startswith('RFC'): rfcnum = int(match.group('rfcnum')) - ref = self.rfc_url % rfcnum + ref = self.document.settings.rfc_base_url + self.rfc_url % rfcnum else: raise MarkupMismatch unescaped = unescape(text, 0) -- cgit v1.2.1 From dea94526d6cba0d4538178fc7a8377697997dbe6 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 17 Jun 2004 02:08:48 +0000 Subject: docstrings git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2290 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 74ecc9984..4eacafe9e 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -63,6 +63,10 @@ directive function): options to parse. Several directive option conversion functions are defined in this module. + Option conversion functions take a single parameter, the option argument (a + string or ``None``), validate it and/or convert it to the appropriate form. + Conversion functions may raise ``ValueError`` and ``TypeError`` exceptions. + - ``content``: A boolean; true if content is allowed. Client code must handle the case where content is required but not supplied (an empty content list will be supplied). @@ -193,12 +197,12 @@ def directive(directive_name, language_module, document): return None, messages return function, messages -def register_directive(name, directive): +def register_directive(name, directive_function): """ Register a nonstandard application-defined directive function. Language lookups are not needed for such functions. """ - _directives[name] = directive + _directives[name] = directive_function def flag(argument): """ -- cgit v1.2.1 From 461ca3f5083d8f4a86755b583797616460e34011 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 17 Jun 2004 02:52:54 +0000 Subject: extracted unicode code conversion git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2292 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 25 +++++++++++++++++++++++++ docutils/parsers/rst/directives/misc.py | 20 +++++--------------- 2 files changed, 30 insertions(+), 15 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 4eacafe9e..6f88e3638 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -83,6 +83,7 @@ See `Creating reStructuredText Directives`_ for more information. __docformat__ = 'reStructuredText' +import re from docutils import nodes from docutils.parsers.rst.languages import en as _fallback_language_module @@ -282,6 +283,30 @@ def class_option(argument): raise ValueError('cannot make "%s" into a class name' % argument) return class_name +unicode_pattern = re.compile( + r'(?:0x|x|\\x|U\+?|\\u)([0-9a-f]+)$|&#x([0-9a-f]+);$', re.IGNORECASE) + +def unicode_code(code): + r""" + Convert a Unicode character code to a Unicode character. + + Codes may be decimal numbers, hexadecimal numbers (prefixed by ``0x``, + ``x``, ``\x``, ``U+``, ``u``, or ``\u``; e.g. ``U+262E``), or XML-style + numeric character entities (e.g. ``☮``). Other text remains as-is. + """ + try: + if code.isdigit(): # decimal number + return unichr(int(code)) + else: + match = unicode_pattern.match(code) + if match: # hex number + value = match.group(1) or match.group(2) + return unichr(int(value, 16)) + else: # other text + return code + except OverflowError, detail: + raise ValueError('code too large (%s)' % detail) + def format_values(values): return '%s, or "%s"' % (', '.join(['"%s"' % s for s in values[:-1]]), values[-1]) diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index d2f65c990..a91719f6d 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -117,7 +117,7 @@ def raw(name, arguments, options, content, lineno, nodes.literal_block(block_text, block_text), line=lineno) return [severe] text = raw_file.read() - raw_file.close() + raw_file.close() attributes['source'] = options['file'] else: error = state_machine.reporter.warning( @@ -185,29 +185,19 @@ def unicode_directive(name, arguments, options, content, lineno, element = nodes.Element() for code in codes: try: - if code.isdigit(): - element += nodes.Text(unichr(int(code))) - else: - match = unicode_pattern.match(code) - if match: - value = match.group(1) or match.group(2) - element += nodes.Text(unichr(int(value, 16))) - else: - element += nodes.Text(code) - except (ValueError, OverflowError), err: + decoded = directives.unicode_code(code) + except ValueError, err: error = state_machine.reporter.error( 'Invalid character code: %s\n%s: %s' % (code, err.__class__.__name__, err), nodes.literal_block(block_text, block_text), line=lineno) return [error] + element += nodes.Text(decoded) return element.children unicode_directive.arguments = (1, 0, 1) -unicode_pattern = re.compile( - r'(?:0x|x|\\x|U\+?|\\u)([0-9a-f]+)$|&#x([0-9a-f]+);$', re.IGNORECASE) unicode_comment_pattern = re.compile(r'( |\n|^).. ') - def class_directive(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): """""" @@ -259,7 +249,7 @@ def role(name, arguments, options, content, lineno, return messages + [error] else: base_role = roles.generic_custom_role - assert not hasattr(base_role, 'arguments'), ( + assert not hasattr(base_role, 'arguments'), ( 'Supplemental directive arguments for "%s" directive not supported' '(specified by "%r" role).' % (name, base_role)) try: -- cgit v1.2.1 From 16bbd9314c3d45a98742ce519ddd160516334c5a Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 17 Jun 2004 16:08:46 +0000 Subject: fixed omission git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2296 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/body.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index 6c29d037e..4fc015b21 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -136,6 +136,7 @@ def table(name, arguments, options, content, lineno, title = nodes.title(title_text, '', *text_nodes) else: title = None + messages = [] node = nodes.Element() # anonymous container for parsing text = '\n'.join(content) state.nested_parse(content, content_offset, node) @@ -151,7 +152,7 @@ def table(name, arguments, options, content, lineno, table_node.set_class(options['class']) if title: table_node.insert(0, title) - return [table_node] + return [table_node] + messages table.arguments = (0, 1, 1) table.options = {'class': directives.class_option} -- cgit v1.2.1 From c059e577bf3d4e3a261faee5d824f76a06a942a2 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 18 Jun 2004 21:35:35 +0000 Subject: moved "table" directive to tables.py git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2305 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/body.py | 38 +-------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index 4fc015b21..c63ac8aef 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -1,5 +1,5 @@ # Author: David Goodger -# Contact: goodger@users.sourceforge.net +# Contact: goodger@python.org # Revision: $Revision$ # Date: $Date$ # Copyright: This module has been placed in the public domain. @@ -121,39 +121,3 @@ def pull_quote(name, arguments, options, content, lineno, return [block_quote] + messages pull_quote.content = 1 - -def table(name, arguments, options, content, lineno, - content_offset, block_text, state, state_machine): - if not content: - warning = state_machine.reporter.warning( - 'Content block expected for the "%s" directive; none found.' - % name, nodes.literal_block(block_text, block_text), - line=lineno) - return [warning] - if arguments: - title_text = arguments[0] - text_nodes, messages = state.inline_text(title_text, lineno) - title = nodes.title(title_text, '', *text_nodes) - else: - title = None - messages = [] - node = nodes.Element() # anonymous container for parsing - text = '\n'.join(content) - state.nested_parse(content, content_offset, node) - if len(node) != 1 or not isinstance(node[0], nodes.table): - error = state_machine.reporter.error( - 'Error parsing content block for the "%s" directive: ' - 'exactly one table expected.' - % name, nodes.literal_block(block_text, block_text), - line=lineno) - return [error] - table_node = node[0] - if options.has_key('class'): - table_node.set_class(options['class']) - if title: - table_node.insert(0, title) - return [table_node] + messages - -table.arguments = (0, 1, 1) -table.options = {'class': directives.class_option} -table.content = 1 -- cgit v1.2.1 From 55d9840df5e7f33f12257081f425ef57f1374042 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 18 Jun 2004 21:36:30 +0000 Subject: added several directive option conversion functions git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2307 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 35 +++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 6f88e3638..6ef7c752f 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -1,5 +1,5 @@ # Author: David Goodger -# Contact: goodger@users.sourceforge.net +# Contact: goodger@python.org # Revision: $Revision$ # Date: $Date$ # Copyright: This module has been placed in the public domain. @@ -107,8 +107,9 @@ _directive_registry = { 'epigraph': ('body', 'epigraph'), 'highlights': ('body', 'highlights'), 'pull-quote': ('body', 'pull_quote'), - 'table': ('body', 'table'), #'questions': ('body', 'question_list'), + 'table': ('tables', 'table'), + 'csv-table': ('tables', 'csv_table'), 'image': ('images', 'image'), 'figure': ('images', 'figure'), 'contents': ('parts', 'contents'), @@ -307,6 +308,36 @@ def unicode_code(code): except OverflowError, detail: raise ValueError('code too large (%s)' % detail) + +def single_char_or_unicode(argument): + char = unicode_code(argument) + if len(char) > 1: + raise ValueError('%r invalid; must be a single character or ' + 'a Unicode code' % char) + return char + +def single_char_or_whitespace_or_unicode(argument): + if argument == 'tab': + char = '\t' + elif argument == 'space': + char = ' ' + else: + char = single_char_or_unicode(argument) + return char + +def positive_int(argument): + value = int(argument) + if value < 1: + raise ValueError('negative or zero value; must be positive') + return value + +def positive_int_list(argument): + if ',' in argument: + entries = argument.split(',') + else: + entries = argument.split() + return [positive_int(entry) for entry in entries] + def format_values(values): return '%s, or "%s"' % (', '.join(['"%s"' % s for s in values[:-1]]), values[-1]) -- cgit v1.2.1 From d2efa0442ee4ca7ecc5b6e68d209434eae946f74 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 18 Jun 2004 21:36:55 +0000 Subject: added "csv-table" directive git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2308 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/af.py | 3 ++- docutils/parsers/rst/languages/cs.py | 3 ++- docutils/parsers/rst/languages/de.py | 3 ++- docutils/parsers/rst/languages/en.py | 3 ++- docutils/parsers/rst/languages/eo.py | 3 ++- docutils/parsers/rst/languages/es.py | 3 ++- docutils/parsers/rst/languages/fr.py | 3 ++- docutils/parsers/rst/languages/it.py | 3 ++- docutils/parsers/rst/languages/pt_br.py | 3 ++- docutils/parsers/rst/languages/ru.py | 1 + docutils/parsers/rst/languages/sk.py | 3 ++- docutils/parsers/rst/languages/sv.py | 3 ++- 12 files changed, 23 insertions(+), 11 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/af.py b/docutils/parsers/rst/languages/af.py index 3fc6c6a9a..1c799127f 100644 --- a/docutils/parsers/rst/languages/af.py +++ b/docutils/parsers/rst/languages/af.py @@ -36,10 +36,11 @@ directives = { 'epigraaf': 'epigraph', 'hoogtepunte': 'highlights', 'pull-quote (translation required)': 'pull-quote', - 'table (translation required)': 'table', #'vrae': 'questions', #'qa': 'questions', #'faq': 'questions', + 'table (translation required)': 'table', + 'csv-table (translation required)': 'csv-table', 'meta': 'meta', #'beeldkaart': 'imagemap', 'beeld': 'image', diff --git a/docutils/parsers/rst/languages/cs.py b/docutils/parsers/rst/languages/cs.py index 7897b90a9..111a476eb 100644 --- a/docutils/parsers/rst/languages/cs.py +++ b/docutils/parsers/rst/languages/cs.py @@ -37,10 +37,11 @@ directives = { u'moto': 'epigraph', u'highlights': 'highlights', u'pull-quote': 'pull-quote', - u'table (translation required)': 'table', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', + u'table (translation required)': 'table', + u'csv-table (translation required)': 'csv-table', u'meta': 'meta', #'imagemap': 'imagemap', u'image': 'image', # obrazek diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index cc9465cb1..90eb77bdb 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -37,10 +37,11 @@ directives = { 'epigraph (translation required)': 'epigraph', 'highlights (translation required)': 'highlights', 'pull-quote (translation required)': 'pull-quote', # kasten too ? - 'table (translation required)': 'table', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', + 'table (translation required)': 'table', + 'csv-table (translation required)': 'csv-table', 'meta': 'meta', #'imagemap': 'imagemap', 'bild': 'image', diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index d6a70f564..f45e104f9 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -37,8 +37,9 @@ directives = { 'epigraph': 'epigraph', 'highlights': 'highlights', 'pull-quote': 'pull-quote', - 'table': 'table', #'questions': 'questions', + 'table': 'table', + 'csv-table': 'csv-table', #'qa': 'questions', #'faq': 'questions', 'meta': 'meta', diff --git a/docutils/parsers/rst/languages/eo.py b/docutils/parsers/rst/languages/eo.py index 0abcc0390..2e4f515e9 100644 --- a/docutils/parsers/rst/languages/eo.py +++ b/docutils/parsers/rst/languages/eo.py @@ -40,10 +40,11 @@ directives = { u'elstara\u0135oj': 'highlights', u'ekstera-citajxo': 'pull-quote', u'ekstera-cita\u0135o': 'pull-quote', - u'tabelo': 'table', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', + u'tabelo': 'table', + u'csv-tabelo (translation required)': 'csv-table', u'meta': 'meta', #'imagemap': 'imagemap', u'bildo': 'image', diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index 1535b4a00..537800961 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -42,10 +42,11 @@ directives = { u'epigrafe': 'epigraph', u'destacado': 'highlights', u'cita-destacada': 'pull-quote', - u'tabla': 'table', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', + u'tabla': 'table', + u'csv-table (translation required)': 'csv-table', u'meta': 'meta', #'imagemap': 'imagemap', u'imagen': 'image', diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index 3afdf942c..a104ae111 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -38,10 +38,11 @@ directives = { u'\u00E9pigraphe': 'epigraph', u'chapeau': 'highlights', u'accroche': 'pull-quote', - u'tableau': 'table', #u'questions': 'questions', #u'qr': 'questions', #u'faq': 'questions', + u'tableau': 'table', + u'csv-table (translation required)': 'csv-table', u'm\u00E9ta': 'meta', #u'imagemap (translation required)': 'imagemap', u'image': 'image', diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index db2c81d5f..1f80e3bc8 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -36,10 +36,11 @@ directives = { 'epigrafe': 'epigraph', 'evidenzia': 'highlights', 'pull-quote (translation required)': 'pull-quote', - 'tabella': 'table', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', + 'tabella': 'table', + 'csv-table (translation required)': 'csv-table', 'meta': 'meta', #'imagemap': 'imagemap', 'immagine': 'image', diff --git a/docutils/parsers/rst/languages/pt_br.py b/docutils/parsers/rst/languages/pt_br.py index 5424aa24c..4834e8f25 100644 --- a/docutils/parsers/rst/languages/pt_br.py +++ b/docutils/parsers/rst/languages/pt_br.py @@ -38,10 +38,11 @@ directives = { u'epígrafo': 'epigraph', 'destaques': 'highlights', u'citação-destacada': 'pull-quote', - u'table (translation required)': 'table', #'perguntas': 'questions', #'qa': 'questions', #'faq': 'questions', + u'table (translation required)': 'table', + u'csv-table (translation required)': 'csv-table', 'meta': 'meta', #'imagemap': 'imagemap', 'imagem': 'image', diff --git a/docutils/parsers/rst/languages/ru.py b/docutils/parsers/rst/languages/ru.py index 49420b3c3..ce0dc2b76 100644 --- a/docutils/parsers/rst/languages/ru.py +++ b/docutils/parsers/rst/languages/ru.py @@ -24,6 +24,7 @@ directives = { u'\u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u0430\u044f-\u0446\u0438\u0442\u0430\u0442\u0430': u'pull-quote', u'table (translation required)': 'table', + u'csv-table (translation required)': 'csv-table', u'\u0441\u044b\u0440\u043e\u0439': u'raw', u'\u0437\u0430\u043c\u0435\u043d\u0430': u'replace', u'\u0442\u0435\u0441\u0442\u043e\u0432\u0430\u044f-\u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430-restructuredtext': diff --git a/docutils/parsers/rst/languages/sk.py b/docutils/parsers/rst/languages/sk.py index c4b8e635c..1a508a851 100644 --- a/docutils/parsers/rst/languages/sk.py +++ b/docutils/parsers/rst/languages/sk.py @@ -36,10 +36,11 @@ directives = { u'epigraph (translation required)': 'epigraph', u'highlights (translation required)': 'highlights', u'pull-quote (translation required)': 'pull-quote', - u'table (translation required)': 'table', #u'questions': 'questions', #u'qa': 'questions', #u'faq': 'questions', + u'table (translation required)': 'table', + u'csv-table (translation required)': 'csv-table', u'meta': 'meta', #u'imagemap': 'imagemap', u'obr\xe1zok': 'image', diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index a5579be25..f4f8ee6a7 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -35,11 +35,12 @@ directives = { u'epigraph (translation required)': 'epigraph', u'highlights (translation required)': 'highlights', u'pull-quote (translation required)': 'pull-quote', - u'table (translation required)': 'table', # u'fr\u00e5gor': 'questions', # NOTE: A bit long, but recommended by http://www.nada.kth.se/dataterm/: # u'fr\u00e5gor-och-svar': 'questions', # u'vanliga-fr\u00e5gor': 'questions', + u'table (translation required)': 'table', + u'csv-table (translation required)': 'csv-table', u'meta': 'meta', # u'bildkarta': 'imagemap', # FIXME: Translation might be too literal. u'bild': 'image', -- cgit v1.2.1 From b514245823ade13164c47f8cdc769d5a358611c7 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 18 Jun 2004 21:41:31 +0000 Subject: table-related directives git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2309 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/tables.py | 269 ++++++++++++++++++++++++++++++ 1 file changed, 269 insertions(+) create mode 100644 docutils/parsers/rst/directives/tables.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/tables.py b/docutils/parsers/rst/directives/tables.py new file mode 100644 index 000000000..90c392117 --- /dev/null +++ b/docutils/parsers/rst/directives/tables.py @@ -0,0 +1,269 @@ +# Authors: David Goodger, David Priest +# Contact: goodger@python.org +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +""" +Directives for table elements. +""" + +__docformat__ = 'reStructuredText' + + +import sys +import os.path +import csv +from docutils import nodes, statemachine, utils +from docutils.utils import SystemMessagePropagation +from docutils.parsers.rst import directives + +try: + import urllib2 +except ImportError: + urllib2 = None + +try: + True +except NameError: # Python 2.2 & 2.1 compatibility + True = not 0 + False = not 1 + + +def table(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + if not content: + warning = state_machine.reporter.warning( + 'Content block expected for the "%s" directive; none found.' + % name, nodes.literal_block(block_text, block_text), + line=lineno) + return [warning] + title, messages = make_title(arguments, state, lineno) + node = nodes.Element() # anonymous container for parsing + text = '\n'.join(content) + state.nested_parse(content, content_offset, node) + if len(node) != 1 or not isinstance(node[0], nodes.table): + error = state_machine.reporter.error( + 'Error parsing content block for the "%s" directive: ' + 'exactly one table expected.' + % name, nodes.literal_block(block_text, block_text), + line=lineno) + return [error] + table_node = node[0] + if options.has_key('class'): + table_node.set_class(options['class']) + if title: + table_node.insert(0, title) + return [table_node] + messages + +table.arguments = (0, 1, 1) +table.options = {'class': directives.class_option} +table.content = 1 + +def make_title(arguments, state, lineno): + if arguments: + title_text = arguments[0] + text_nodes, messages = state.inline_text(title_text, lineno) + title = nodes.title(title_text, '', *text_nodes) + else: + title = None + messages = [] + return title, messages + + +class DocutilsDialect(csv.Dialect): + + """CSV dialect for `csv_table` directive function.""" + + delimiter = ',' + quotechar = '"' + doublequote = True + skipinitialspace = True + lineterminator = '\n' + quoting = csv.QUOTE_MINIMAL + + def __init__(self, options): + if options.has_key('delim'): + self.delimiter = str(options['delim']) + if options.has_key('keepspace'): + self.skipinitialspace = False + if options.has_key('quote'): + self.quotechar = str(options['quote']) + if options.has_key('escape'): + self.doublequote = False + self.escapechar = str(options['escape']) + csv.Dialect.__init__(self) + + +class HeaderDialect(csv.Dialect): + + """CSV dialect to use for the "header" option data.""" + + delimiter = ',' + quotechar = '"' + escapechar = '\\' + doublequote = False + skipinitialspace = True + lineterminator = '\n' + quoting = csv.QUOTE_MINIMAL + + +def csv_table(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + + title, messages = make_title(arguments, state, lineno) + try: + csv_data, source = get_csv_data( + name, options, content, lineno, block_text, state, state_machine) + table_head, max_header_cols = process_header_option( + options, state_machine, lineno) + rows, max_cols = parse_csv_data_into_rows( + csv_data, DocutilsDialect(options), source, options) + max_cols = max(max_cols, max_header_cols) + header_rows = options.get('header-rows', 0) # default 0 + table_head.extend(rows[:header_rows]) + table_body = rows[header_rows:] + if not table_body: + error = state_machine.reporter.error( + '"%s" directive requires table body content.' % name, + nodes.literal_block(block_text, block_text), line=lineno) + return [error] + col_widths = get_column_widths( + max_cols, name, options, lineno, block_text, state_machine) + extend_short_rows_with_empty_cells(max_cols, (table_head, table_body)) + except SystemMessagePropagation, detail: + return [detail.args[0]] + except csv.Error, detail: + error = state_machine.reporter.error( + 'Error with CSV data in "%s" directive:\n%s' % (name, detail), + nodes.literal_block(block_text, block_text), line=lineno) + return [error] + table = (col_widths, table_head, table_body) + table_node = state.build_table(table, content_offset) + if options.has_key('class'): + table_node.set_class(options['class']) + if title: + table_node.insert(0, title) + return [table_node] + messages + +csv_table.arguments = (0, 1, 1) +csv_table.options = {'header-rows': directives.nonnegative_int, + 'header': directives.unchanged, + 'widths': directives.positive_int_list, + 'file': directives.path, + 'url': directives.path, + 'class': directives.class_option, + # field delimiter char + 'delim': directives.single_char_or_whitespace_or_unicode, + # treat whitespace after delimiter as significant + 'keepspace': directives.flag, + # text field quote/unquote char: + 'quote': directives.single_char_or_unicode, + # char used to escape delim & quote as-needed: + 'escape': directives.single_char_or_unicode,} +csv_table.content = 1 + +def get_csv_data(name, options, content, lineno, block_text, + state, state_machine): + """ + CSV data can come from the directive content, from an external file, or + from a URL reference. + """ + if content: # CSV data is from directive content + if options.has_key('file') or options.has_key('url'): + error = state_machine.reporter.error( + '"%s" directive may not both specify an external file and ' + 'have content.' % name, + nodes.literal_block(block_text, block_text), line=lineno) + raise SystemMessagePropagation(error) + source = content.source(0) + csv_data = content + elif options.has_key('file'): # CSV data is from an external file + if options.has_key('url'): + error = state_machine.reporter.error( + 'The "file" and "url" options may not be simultaneously ' + 'specified for the "%s" directive.' % name, + nodes.literal_block(block_text, block_text), line=lineno) + raise SystemMessagePropagation(error) + source_dir = os.path.dirname( + os.path.abspath(state.document.current_source)) + source = os.path.normpath(os.path.join(source_dir, options['file'])) + source = utils.relative_path(None, source) + try: + csv_file = open(source, 'rb') + try: + csv_data = csv_file.read().splitlines() + finally: + csv_file.close() + except IOError, error: + severe = state_machine.reporter.severe( + 'Problems with "%s" directive path:\n%s.' % (name, error), + nodes.literal_block(block_text, block_text), line=lineno) + raise SystemMessagePropagation(severe) + elif options.has_key('url'): # CSV data is from a URL + if not urllib2: + severe = state_machine.reporter.severe( + 'Problems with the "%s" directive and its "url" option: ' + 'unable to access the required functionality (from the ' + '"urllib2" module).' % name, + nodes.literal_block(block_text, block_text), line=lineno) + raise SystemMessagePropagation(severe) + source = options['url'] + try: + csv_data = urllib2.urlopen(source).read().splitlines() + except (urllib2.URLError, IOError, OSError, ValueError), error: + severe = state_machine.reporter.severe( + 'Problems with "%s" directive URL "%s":\n%s.' + % (name, options['url'], error), + nodes.literal_block(block_text, block_text), line=lineno) + raise SystemMessagePropagation(severe) + else: + error = state_machine.reporter.warning( + 'The "%s" directive requires content; none supplied.' % (name), + nodes.literal_block(block_text, block_text), line=lineno) + raise SystemMessagePropagation(error) + return csv_data, source + +def process_header_option(options, state_machine, lineno): + source = state_machine.get_source(lineno - 1) + table_head = [] + max_header_cols = 0 + if options.has_key('header'): # separate table header in option + rows, max_header_cols = parse_csv_data_into_rows( + options['header'].split('\n'), HeaderDialect(), source, options) + table_head.extend(rows) + return table_head, max_header_cols + +def parse_csv_data_into_rows(csv_data, dialect, source, options): + csv_reader = csv.reader(csv_data, dialect=dialect) + rows = [] + max_cols = 0 + for row in csv_reader: + row_data = [] + for cell in row: + cell_data = (0, 0, 0, statemachine.StringList(cell.splitlines(), + source=source)) + row_data.append(cell_data) + rows.append(row_data) + max_cols = max(max_cols, len(row)) + return rows, max_cols + +def get_column_widths(max_cols, name, options, lineno, block_text, + state_machine): + if options.has_key('widths'): + col_widths = options['widths'] + if len(col_widths) != max_cols: + error = state_machine.reporter.error( + '"%s" widths do not match the number of columns in table (%s).' + % (name, max_cols), + nodes.literal_block(block_text, block_text), line=lineno) + raise SystemMessagePropagation(error) + else: + col_widths = [100 / max_cols] * max_cols + return col_widths + +def extend_short_rows_with_empty_cells(columns, parts): + for part in parts: + for row in part: + if len(row) < columns: + row.extend([(0, 0, 0, [])] * (columns - len(row))) -- cgit v1.2.1 From 9afb2c5adc84beeabf5ec16e55200249a0dc1717 Mon Sep 17 00:00:00 2001 From: richieadler Date: Sat, 19 Jun 2004 01:44:07 +0000 Subject: Translation of new "csv-table" directive. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2312 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/eo.py | 3 ++- docutils/parsers/rst/languages/es.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/eo.py b/docutils/parsers/rst/languages/eo.py index 2e4f515e9..9f269decb 100644 --- a/docutils/parsers/rst/languages/eo.py +++ b/docutils/parsers/rst/languages/eo.py @@ -44,7 +44,8 @@ directives = { #'qa': 'questions', #'faq': 'questions', u'tabelo': 'table', - u'csv-tabelo (translation required)': 'csv-table', + u'tabelo-vdk': 'csv-table', # "valoroj disigitaj per komoj" + u'tabelo-csv': 'csv-table', u'meta': 'meta', #'imagemap': 'imagemap', u'bildo': 'image', diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index 537800961..ce5a92a28 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -1,6 +1,6 @@ # -*- coding: iso-8859-1 -*- # Author: Marcelo Huerta San Martín -# Contact: mghsm@uol.com.ar +# Contact: richieadler@users.sourceforge.net # Revision: $Revision$ # Date: $Date$ # Copyright: This module has been placed in the public domain. @@ -46,7 +46,8 @@ directives = { #'qa': 'questions', #'faq': 'questions', u'tabla': 'table', - u'csv-table (translation required)': 'csv-table', + u'tabla-vsc': 'csv-table', + u'tabla-csv': 'csv-table', u'meta': 'meta', #'imagemap': 'imagemap', u'imagen': 'image', -- cgit v1.2.1 From f2b64c0ff06f8682e71bc5bd12098b2f4a5d53b8 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 19 Jun 2004 22:53:32 +0000 Subject: added checks for cvs.py module (Python 2.3+), and table dimensions; added guarding for Python 2.1/2.2 (no CSV support) git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2314 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/tables.py | 98 +++++++++++++++++++------------ 1 file changed, 62 insertions(+), 36 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/tables.py b/docutils/parsers/rst/directives/tables.py index 90c392117..e34e54b20 100644 --- a/docutils/parsers/rst/directives/tables.py +++ b/docutils/parsers/rst/directives/tables.py @@ -13,11 +13,15 @@ __docformat__ = 'reStructuredText' import sys import os.path -import csv from docutils import nodes, statemachine, utils from docutils.utils import SystemMessagePropagation from docutils.parsers.rst import directives +try: + import csv # new in Python 2.3 +except ImportError: + csv = None + try: import urllib2 except ImportError: @@ -71,48 +75,49 @@ def make_title(arguments, state, lineno): return title, messages -class DocutilsDialect(csv.Dialect): +if csv: + class DocutilsDialect(csv.Dialect): - """CSV dialect for `csv_table` directive function.""" + """CSV dialect for `csv_table` directive function.""" - delimiter = ',' - quotechar = '"' - doublequote = True - skipinitialspace = True - lineterminator = '\n' - quoting = csv.QUOTE_MINIMAL + delimiter = ',' + quotechar = '"' + doublequote = True + skipinitialspace = True + lineterminator = '\n' + quoting = csv.QUOTE_MINIMAL - def __init__(self, options): - if options.has_key('delim'): - self.delimiter = str(options['delim']) - if options.has_key('keepspace'): - self.skipinitialspace = False - if options.has_key('quote'): - self.quotechar = str(options['quote']) - if options.has_key('escape'): - self.doublequote = False - self.escapechar = str(options['escape']) - csv.Dialect.__init__(self) + def __init__(self, options): + if options.has_key('delim'): + self.delimiter = str(options['delim']) + if options.has_key('keepspace'): + self.skipinitialspace = False + if options.has_key('quote'): + self.quotechar = str(options['quote']) + if options.has_key('escape'): + self.doublequote = False + self.escapechar = str(options['escape']) + csv.Dialect.__init__(self) -class HeaderDialect(csv.Dialect): + class HeaderDialect(csv.Dialect): - """CSV dialect to use for the "header" option data.""" + """CSV dialect to use for the "header" option data.""" - delimiter = ',' - quotechar = '"' - escapechar = '\\' - doublequote = False - skipinitialspace = True - lineterminator = '\n' - quoting = csv.QUOTE_MINIMAL + delimiter = ',' + quotechar = '"' + escapechar = '\\' + doublequote = False + skipinitialspace = True + lineterminator = '\n' + quoting = csv.QUOTE_MINIMAL def csv_table(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): - - title, messages = make_title(arguments, state, lineno) try: + check_requirements(name, lineno, block_text, state_machine) + title, messages = make_title(arguments, state, lineno) csv_data, source = get_csv_data( name, options, content, lineno, block_text, state, state_machine) table_head, max_header_cols = process_header_option( @@ -121,13 +126,10 @@ def csv_table(name, arguments, options, content, lineno, csv_data, DocutilsDialect(options), source, options) max_cols = max(max_cols, max_header_cols) header_rows = options.get('header-rows', 0) # default 0 + check_table_dimensions( + rows, header_rows, name, lineno, block_text, state_machine) table_head.extend(rows[:header_rows]) table_body = rows[header_rows:] - if not table_body: - error = state_machine.reporter.error( - '"%s" directive requires table body content.' % name, - nodes.literal_block(block_text, block_text), line=lineno) - return [error] col_widths = get_column_widths( max_cols, name, options, lineno, block_text, state_machine) extend_short_rows_with_empty_cells(max_cols, (table_head, table_body)) @@ -163,6 +165,15 @@ csv_table.options = {'header-rows': directives.nonnegative_int, 'escape': directives.single_char_or_unicode,} csv_table.content = 1 +def check_requirements(name, lineno, block_text, state_machine): + if not csv: + error = state_machine.reporter.error( + 'The "%s" directive is not compatible with this version of ' + 'Python (%s). Requires the "csv" module, new in Python 2.3.' + % (name, sys.version.split()[0]), + nodes.literal_block(block_text, block_text), line=lineno) + raise SystemMessagePropagation(error) + def get_csv_data(name, options, content, lineno, block_text, state, state_machine): """ @@ -248,6 +259,21 @@ def parse_csv_data_into_rows(csv_data, dialect, source, options): max_cols = max(max_cols, len(row)) return rows, max_cols +def check_table_dimensions(rows, header_rows, name, lineno, block_text, + state_machine): + if len(rows) < header_rows: + error = state_machine.reporter.error( + '%s header row(s) specified but only %s row(s) of data supplied ' + '("%s" directive).' % (header_rows, len(rows), name), + nodes.literal_block(block_text, block_text), line=lineno) + raise SystemMessagePropagation(error) + elif len(rows) == header_rows > 0: + error = state_machine.reporter.error( + 'Insufficient data supplied (%s row(s)); no data remaining for ' + 'table body, required by "%s" directive.' % (len(rows), name), + nodes.literal_block(block_text, block_text), line=lineno) + raise SystemMessagePropagation(error) + def get_column_widths(max_cols, name, options, lineno, block_text, state_machine): if options.has_key('widths'): -- cgit v1.2.1 From dfa3a35a0946731e59954fbfdd0ee72bf3abd25d Mon Sep 17 00:00:00 2001 From: wiemann Date: Sun, 20 Jun 2004 20:46:21 +0000 Subject: encoding fix git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2332 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/pt_br.py | 63 ++++++++++++++++----------------- 1 file changed, 31 insertions(+), 32 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/pt_br.py b/docutils/parsers/rst/languages/pt_br.py index 4834e8f25..36005f344 100644 --- a/docutils/parsers/rst/languages/pt_br.py +++ b/docutils/parsers/rst/languages/pt_br.py @@ -1,4 +1,3 @@ -# -*- coding: iso-8859-1 -*- # Author: David Goodger # Contact: goodger@users.sourceforge.net # Revision: $Revision$ @@ -20,24 +19,24 @@ __docformat__ = 'reStructuredText' directives = { # language-dependent: fixed - u'atenção': 'attention', + u'aten\u00E7\u00E3o': 'attention', 'cuidado': 'caution', 'perigo': 'danger', 'erro': 'error', - u'sugestão': 'hint', + u'sugest\u00E3o': 'hint', 'importante': 'important', 'nota': 'note', 'dica': 'tip', 'aviso': 'warning', - u'exortação': 'admonition', + u'exorta\u00E7\u00E3o': 'admonition', 'barra-lateral': 'sidebar', - u'tópico': 'topic', + u't\u00F3pico': 'topic', 'bloco-de-linhas': 'line-block', 'literal-interpretado': 'parsed-literal', 'rubrica': 'rubric', - u'epígrafo': 'epigraph', + u'ep\u00EDgrafo': 'epigraph', 'destaques': 'highlights', - u'citação-destacada': 'pull-quote', + u'cita\u00E7\u00E3o-destacada': 'pull-quote', #'perguntas': 'questions', #'qa': 'questions', #'faq': 'questions', @@ -47,52 +46,52 @@ directives = { #'imagemap': 'imagemap', 'imagem': 'image', 'figura': 'figure', - u'inclusão': 'include', + u'inclus\u00E3o': 'include', 'cru': 'raw', - u'substituição': 'replace', + u'substitui\u00E7\u00E3o': 'replace', 'unicode': 'unicode', 'classe': 'class', 'role (translation required)': 'role', - u'índice': 'contents', + u'\u00EDndice': 'contents', 'numsec': 'sectnum', - u'numeração-de-seções': 'sectnum', - #u'notas-de-rorapé': 'footnotes', - #u'citações': 'citations', - u'links-no-rodapé': 'target-notes', + u'numera\u00E7\u00E3o-de-se\u00E7\u00F5es': 'sectnum', + #u'notas-de-rorap\u00E9': 'footnotes', + #u'cita\u00E7\u00F5es': 'citations', + u'links-no-rodap\u00E9': 'target-notes', 'restructuredtext-test-directive': 'restructuredtext-test-directive'} -"""English name to registered (in directives/__init__.py) directive name -mapping.""" +"""Brazilian Portuguese name to registered (in directives/__init__.py) +directive name mapping.""" roles = { # language-dependent: fixed - u'abbreviação': 'abbreviation', + u'abbrevia\u00E7\u00E3o': 'abbreviation', 'ab': 'abbreviation', - u'acrônimo': 'acronym', + u'acr\u00F4nimo': 'acronym', 'ac': 'acronym', - u'índice-remissivo': 'index', + u'\u00EDndice-remissivo': 'index', 'i': 'index', 'subscrito': 'subscript', 'sub': 'subscript', 'sobrescrito': 'superscript', 'sob': 'superscript', - u'referência-a-título': 'title-reference', - u'título': 'title-reference', + u'refer\u00EAncia-a-t\u00EDtulo': 'title-reference', + u't\u00EDtulo': 'title-reference', 't': 'title-reference', - u'referência-a-pep': 'pep-reference', + u'refer\u00EAncia-a-pep': 'pep-reference', 'pep': 'pep-reference', - u'referência-a-rfc': 'rfc-reference', + u'refer\u00EAncia-a-rfc': 'rfc-reference', 'rfc': 'rfc-reference', - u'ênfase': 'emphasis', + u'\u00EAnfase': 'emphasis', 'forte': 'strong', 'literal': 'literal', - u'referência-por-nome': 'named-reference', - u'referência-anônima': 'anonymous-reference', - u'referência-a-nota-de-rodapé': 'footnote-reference', - u'referência-a-citação': 'citation-reference', - u'referência-a-substituição': 'substitution-reference', + u'refer\u00EAncia-por-nome': 'named-reference', + u'refer\u00EAncia-an\u00F4nima': 'anonymous-reference', + u'refer\u00EAncia-a-nota-de-rodap\u00E9': 'footnote-reference', + u'refer\u00EAncia-a-cita\u00E7\u00E3o': 'citation-reference', + u'refer\u00EAncia-a-substitui\u00E7\u00E3o': 'substitution-reference', 'alvo': 'target', - u'referência-a-uri': 'uri-reference', + u'refer\u00EAncia-a-uri': 'uri-reference', 'uri': 'uri-reference', 'url': 'uri-reference',} -"""Mapping of English role names to canonical role names for interpreted text. -""" +"""Mapping of Brazilian Portuguese role names to canonical role names +for interpreted text.""" -- cgit v1.2.1 From 9d0496b115ec1e25eecd5a3d34fba4857d9f53bd Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 20 Jun 2004 21:31:56 +0000 Subject: fixed line number for literal blocks git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2334 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 4025c7e72..a786abbda 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -2540,9 +2540,10 @@ class Text(RSTState): indented.trim_end() if not indented: return self.quoted_literal_block() - nodelist = [] data = '\n'.join(indented) - nodelist.append(nodes.literal_block(data, data)) + literal_block = nodes.literal_block(data, data) + literal_block.line = offset + 1 + nodelist = [literal_block] if not blank_finish: nodelist.append(self.unindent_warning('Literal block')) return nodelist -- cgit v1.2.1 From 65e2e0206fa2d221870703a563471330d47d5b9d Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 20 Jun 2004 22:13:00 +0000 Subject: fixed "target" option for figure git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2336 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index ab96a0a4e..67cf6b4a6 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -40,18 +40,22 @@ def image(name, arguments, options, content, lineno, block = [line for line in block] target_type, data = state.parse_target(block, block_text, lineno) if target_type == 'refuri': - node_list = nodes.reference(refuri=data) + reference = nodes.reference(refuri=data) elif target_type == 'refname': - node_list = nodes.reference( + reference = nodes.reference( refname=data, name=whitespace_normalize_name(options['target'])) - state.document.note_refname(node_list) + state.document.note_refname(reference) else: # malformed target - node_list = [data] # data is a system message + reference = [data] # data is a system message del options['target'] else: - node_list = [] - node_list.append(nodes.image(block_text, **options)) - return node_list + reference = None + image_node = nodes.image(block_text, **options) + if reference: + reference += image_node + return [reference] + else: + return [image_node] image.arguments = (1, 0, 1) image.options = {'alt': directives.unchanged, -- cgit v1.2.1 From e107070ca2dd791cde875463616d249d03eb8ada Mon Sep 17 00:00:00 2001 From: goodger Date: Mon, 21 Jun 2004 12:40:33 +0000 Subject: fixed bug introduced in last change git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2341 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index 67cf6b4a6..ddbdb96c6 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -28,6 +28,7 @@ def align(argument): def image(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): + messages = [] reference = ''.join(arguments[0].split('\n')) if reference.find(' ') != -1: error = state_machine.reporter.error( @@ -35,27 +36,26 @@ def image(name, arguments, options, content, lineno, nodes.literal_block(block_text, block_text), line=lineno) return [error] options['uri'] = reference + reference_node = None if options.has_key('target'): block = states.escape2null(options['target']).splitlines() block = [line for line in block] target_type, data = state.parse_target(block, block_text, lineno) if target_type == 'refuri': - reference = nodes.reference(refuri=data) + reference_node = nodes.reference(refuri=data) elif target_type == 'refname': - reference = nodes.reference( + reference_node = nodes.reference( refname=data, name=whitespace_normalize_name(options['target'])) - state.document.note_refname(reference) + state.document.note_refname(reference_node) else: # malformed target - reference = [data] # data is a system message + messages.append(data) # data is a system message del options['target'] - else: - reference = None image_node = nodes.image(block_text, **options) - if reference: - reference += image_node - return [reference] + if reference_node: + reference_node += image_node + return messages + [reference_node] else: - return [image_node] + return messages + [image_node] image.arguments = (1, 0, 1) image.options = {'alt': directives.unchanged, -- cgit v1.2.1 From e9392a97370514aa39851a14552563be3b5c8584 Mon Sep 17 00:00:00 2001 From: david_abrahams Date: Wed, 23 Jun 2004 02:17:11 +0000 Subject: Fix the line numbering of nodes produced by line_block directives. This is a total shot-in-the-dark, since it's unclear why lineno is 97 and content_offset is the right line number. Without some description of the protocol I can't really know, but it seems to be working... for now. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2361 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/body.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index c63ac8aef..bfe2e695f 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -15,7 +15,25 @@ import sys from docutils import nodes from docutils.parsers.rst import directives - +# Directive Handler Functions +# +# What they do is blah blah +# +# They are called by blah blah after being looked up blah blah +# +# Parameter Required Type Role +# ============== ============= ============================= +# name str ??? +# arguments ??? ??? +# options ??? ??? +# content ??? ??? +# lineno ??? ??? +# content_offset ??? ??? +# block_text ??? ??? +# state ??? ??? +# state_machine ??? ??? +# node_class ??? ??? + def topic(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine, node_class=nodes.topic): @@ -74,6 +92,7 @@ def line_block(name, arguments, options, content, lineno, text = '\n'.join(content) text_nodes, messages = state.inline_text(text, lineno) node = node_class(text, '', *text_nodes, **options) + node.line = content_offset return [node] + messages line_block.options = {'class': directives.class_option} -- cgit v1.2.1 From 5522058d7b68c055e68752ff4a5f3ff2138238af Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 23 Jun 2004 02:29:02 +0000 Subject: line number == (line offset + 1); check module docstring of directives/__init__.py for detailed instructions git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2363 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/body.py | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index bfe2e695f..9e93b3aff 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -15,24 +15,6 @@ import sys from docutils import nodes from docutils.parsers.rst import directives -# Directive Handler Functions -# -# What they do is blah blah -# -# They are called by blah blah after being looked up blah blah -# -# Parameter Required Type Role -# ============== ============= ============================= -# name str ??? -# arguments ??? ??? -# options ??? ??? -# content ??? ??? -# lineno ??? ??? -# content_offset ??? ??? -# block_text ??? ??? -# state ??? ??? -# state_machine ??? ??? -# node_class ??? ??? def topic(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine, @@ -92,7 +74,7 @@ def line_block(name, arguments, options, content, lineno, text = '\n'.join(content) text_nodes, messages = state.inline_text(text, lineno) node = node_class(text, '', *text_nodes, **options) - node.line = content_offset + node.line = content_offset + 1 return [node] + messages line_block.options = {'class': directives.class_option} -- cgit v1.2.1 From ea6bc82584ed1a16423aadc5d88af6baca1cda47 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 23 Jun 2004 02:35:59 +0000 Subject: docstrings git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2364 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/body.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index 9e93b3aff..85adda981 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -6,6 +6,8 @@ """ Directives for additional body elements. + +See `docutils.parsers.rst.directives` for API details. """ __docformat__ = 'reStructuredText' -- cgit v1.2.1 From 6809090a4197bff7bde6f08243383783e24fd43c Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 23 Jun 2004 03:44:06 +0000 Subject: docstrings git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2365 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 6ef7c752f..f10d42cec 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -20,11 +20,12 @@ The interface for directive functions is as follows:: Parameters: -- ``name`` is the directive type or name. +- ``name`` is the directive type or name (string). -- ``arguments`` is a list of positional arguments. +- ``arguments`` is a list of positional arguments (strings). -- ``options`` is a dictionary mapping option names to values. +- ``options`` is a dictionary mapping option names (strings) to values (type + depends on option conversion functions; see below). - ``content`` is a list of strings, the directive content. -- cgit v1.2.1 From 80fce2bdf1c90e564c0f4b8d062d5349277e33b2 Mon Sep 17 00:00:00 2001 From: wiemann Date: Mon, 28 Jun 2004 19:06:02 +0000 Subject: made URI recognition slightly more aggressive and intelligent git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2407 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index a786abbda..43caa9711 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -556,14 +556,19 @@ class Inliner: # Valid URI characters (see RFC 2396 & RFC 2732); # final \x00 allows backslash escapes in URIs: uric = r"""[-_.!~*'()[\];/:@&=+$,%a-zA-Z0-9\x00]""" + # Delimiter indicating the end of a URI (not part of the URI): + uri_end_delim = r"""[>]""" # Last URI character; same as uric but no punctuation: - urilast = r"""[_~/a-zA-Z0-9]""" + urilast = r"""[_~*/=+a-zA-Z0-9]""" + # End of a URI (either 'urilast' or 'uric followed by a + # uri_end_delim'): + uri_end = r"""(?:%(urilast)s|%(uric)s(?=%(uri_end_delim)s))""" % locals() emailc = r"""[-_!~*'{|}/#?^`&=+$%a-zA-Z0-9\x00]""" email_pattern = r""" %(emailc)s+(?:\.%(emailc)s+)* # name @ # at %(emailc)s+(?:\.%(emailc)s*)* # host - %(urilast)s # final URI char + %(uri_end)s # final URI char """ parts = ('initial_inline', start_string_prefix, '', [('start', '', non_whitespace_after, # simple start-strings @@ -642,15 +647,15 @@ class Inliner: ( # either: (//?)? # hierarchical URI %(uric)s* # URI characters - %(urilast)s # final URI char + %(uri_end)s # final URI char ) ( # optional query \?%(uric)s* - %(urilast)s + %(uri_end)s )? ( # optional fragment \#%(uric)s* - %(urilast)s + %(uri_end)s )? ) ) -- cgit v1.2.1 From 96ef87cb0b150a32a4a318cb897c67cf51bcfcae Mon Sep 17 00:00:00 2001 From: wiemann Date: Mon, 26 Jul 2004 22:32:24 +0000 Subject: fixed bug with ".." recognition in unicode directive git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2460 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index a91719f6d..882d6acd9 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -196,7 +196,7 @@ def unicode_directive(name, arguments, options, content, lineno, return element.children unicode_directive.arguments = (1, 0, 1) -unicode_comment_pattern = re.compile(r'( |\n|^).. ') +unicode_comment_pattern = re.compile(r'( |\n|^)\.\. ') def class_directive(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): -- cgit v1.2.1 From 14d88a0e6bc1921b02952fc27b847121ea9ff2b1 Mon Sep 17 00:00:00 2001 From: lele Date: Fri, 20 Aug 2004 08:00:43 +0000 Subject: The directive now accepts a prefix option, a string that will be prepended to the generated section enumeration, and a start value, an integer used as the starting value for auto-numbering the sections. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2533 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/parts.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py index 5e6809142..98d2931f7 100644 --- a/docutils/parsers/rst/directives/parts.py +++ b/docutils/parsers/rst/directives/parts.py @@ -78,4 +78,6 @@ def sectnum(name, arguments, options, content, lineno, state_machine.document.note_pending(pending) return [pending] -sectnum.options = {'depth': int} +sectnum.options = {'depth': int, + 'start': int, + 'prefix': directives.unchanged_required} -- cgit v1.2.1 From 96cef63ca0e73f97052a3286d8480b7ea870313e Mon Sep 17 00:00:00 2001 From: goodger Date: Mon, 23 Aug 2004 17:35:50 +0000 Subject: added "suffix" option to "sectnum" directive; require separating punctuation git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2539 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/parts.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py index 98d2931f7..c182ad0fd 100644 --- a/docutils/parsers/rst/directives/parts.py +++ b/docutils/parsers/rst/directives/parts.py @@ -80,4 +80,5 @@ def sectnum(name, arguments, options, content, lineno, sectnum.options = {'depth': int, 'start': int, - 'prefix': directives.unchanged_required} + 'prefix': directives.unchanged_required, + 'suffix': directives.unchanged_required} -- cgit v1.2.1 From f3aa787d95ca9355050f76b4a849610bbeeace5c Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 8 Sep 2004 19:49:33 +0000 Subject: updated git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2562 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 882d6acd9..d6aa39ae7 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -200,7 +200,10 @@ unicode_comment_pattern = re.compile(r'( |\n|^)\.\. ') def class_directive(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): - """""" + """ + Set a "class" attribute on the next element. + A "pending" element is inserted, and a transform does the work later. + """ class_value = nodes.make_id(arguments[0]) if class_value: pending = nodes.pending(misc.ClassAttribute, -- cgit v1.2.1 From 144f2976e1b8ac8619acfbb2bf333771b33d2e86 Mon Sep 17 00:00:00 2001 From: wiemann Date: Sat, 11 Sep 2004 13:27:03 +0000 Subject: fixed non-ASCII-character bug with csv-table directive git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2568 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/tables.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/tables.py b/docutils/parsers/rst/directives/tables.py index e34e54b20..787278b3e 100644 --- a/docutils/parsers/rst/directives/tables.py +++ b/docutils/parsers/rst/directives/tables.py @@ -13,6 +13,7 @@ __docformat__ = 'reStructuredText' import sys import os.path +from types import UnicodeType from docutils import nodes, statemachine, utils from docutils.utils import SystemMessagePropagation from docutils.parsers.rst import directives @@ -246,10 +247,18 @@ def process_header_option(options, state_machine, lineno): return table_head, max_header_cols def parse_csv_data_into_rows(csv_data, dialect, source, options): + isunicode = (csv_data and type(csv_data[0]) == UnicodeType) + if isunicode: + # Encode unicode in UTF-8, because the csv module doesn't + # support unicode strings. + csv_data = [item.encode('utf-8') for item in csv_data] csv_reader = csv.reader(csv_data, dialect=dialect) rows = [] max_cols = 0 for row in csv_reader: + if isunicode: + # Decode UTF-8 back to unicode + row = [item.decode('utf-8') for item in row] row_data = [] for cell in row: cell_data = (0, 0, 0, statemachine.StringList(cell.splitlines(), -- cgit v1.2.1 From 8f5b572efecb175fb4a07bd40f7bd6e3a275128d Mon Sep 17 00:00:00 2001 From: wiemann Date: Sat, 11 Sep 2004 15:35:05 +0000 Subject: acceptet patch from http://sourceforge.net/tracker/index.php?func=detail&aid=1009676&group_id=38414&atid=422032 (finnish translation) git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2570 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/fi.py | 91 ++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 docutils/parsers/rst/languages/fi.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/fi.py b/docutils/parsers/rst/languages/fi.py new file mode 100644 index 000000000..fda7b5af1 --- /dev/null +++ b/docutils/parsers/rst/languages/fi.py @@ -0,0 +1,91 @@ +# Author: Asko Soukka +# Contact: asko.soukka@iki.fi +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +# New language mappings are welcome. Before doing a new translation, please +# read . Two files must be +# translated for each language: one in docutils/languages, the other in +# docutils/parsers/rst/languages. + +""" +Finnish-language mappings for language-dependent features of +reStructuredText. +""" + +__docformat__ = 'reStructuredText' + + +directives = { + # language-dependent: fixed + u'huomio': u'attention', + u'varo': u'caution', + u'vaara': u'danger', + u'virhe': u'error', + u'vihje': u'hint', + u't\u00e4rke\u00e4\u00e4': u'important', + u'huomautus': u'note', + u'neuvo': u'tip', + u'varoitus': u'warning', + u'kehotus': u'admonition', + u'sivupalkki': u'sidebar', + u'aihe': u'topic', + u'rivi': u'line-block', + u'tasalevyinen': u'parsed-literal', + u'ohje': u'rubric', + u'epigraafi': u'epigraph', + u'kohokohdat': u'highlights', + u'lainaus': u'pull-quote', + u'taulukko': u'table', + u'csv-taulukko': u'csv-table', + #u'kysymykset': u'questions', + u'meta': u'meta', + #u'kuvakartta': u'imagemap', + u'kuva': u'image', + u'kaavio': u'figure', + u'sis\u00e4llyt\u00e4': u'include', + u'raaka': u'raw', + u'korvaa': u'replace', + u'unicode': u'unicode', + u'luokka': u'class', + u'rooli': u'role', + u'sis\u00e4llys': u'contents', + u'kappale': u'sectnum', + #u'alaviitteet': u'footnotes', + #u'viitaukset': u'citations', + u'target-notes': u'target-notes', + u'restructuredtext-test-directive': u'restructuredtext-test-directive'} +"""Finnish name to registered (in directives/__init__.py) directive name +mapping.""" + +roles = { + # language-dependent: fixed + u'lyhennys': u'abbreviation', + u'akronyymi': u'acronym', + u'kirjainsana': u'acronym', + u'hakemisto': u'index', + u'luettelo': u'index', + u'alaindeksi': u'subscript', + u'indeksi': u'subscript', + u'yl\u00e4indeksi': u'superscript', + u'title-reference': u'title-reference', + u'title': u'title-reference', + u'pep-reference': u'pep-reference', + u'pep': u'pep-reference', + u'rfc-reference': u'rfc-reference', + u'rfc': u'rfc-reference', + u'korostus': u'emphasis', + u'vahvistus': u'strong', + u'tasalevyinen': u'literal', + u'named-reference': u'named-reference', + u'anonymous-reference': u'anonymous-reference', + u'footnote-reference': u'footnote-reference', + u'citation-reference': u'citation-reference', + u'substitution-reference': u'substitution-reference', + u'kohde': u'target', + u'uri-reference': u'uri-reference', + u'uri': u'uri-reference', + u'url': u'uri-reference',} +"""Mapping of Finnish role names to canonical role names for interpreted text. +""" -- cgit v1.2.1 From 051f028f8d263ef3db69ffe83a689e92bf9408d1 Mon Sep 17 00:00:00 2001 From: wiemann Date: Sat, 11 Sep 2004 16:05:04 +0000 Subject: ripped out unnecessary stuff, added "(translation required)" git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2571 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/fi.py | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/fi.py b/docutils/parsers/rst/languages/fi.py index fda7b5af1..0eeefff19 100644 --- a/docutils/parsers/rst/languages/fi.py +++ b/docutils/parsers/rst/languages/fi.py @@ -54,8 +54,7 @@ directives = { u'kappale': u'sectnum', #u'alaviitteet': u'footnotes', #u'viitaukset': u'citations', - u'target-notes': u'target-notes', - u'restructuredtext-test-directive': u'restructuredtext-test-directive'} + u'target-notes (translation required)': u'target-notes'} """Finnish name to registered (in directives/__init__.py) directive name mapping.""" @@ -69,23 +68,19 @@ roles = { u'alaindeksi': u'subscript', u'indeksi': u'subscript', u'yl\u00e4indeksi': u'superscript', - u'title-reference': u'title-reference', - u'title': u'title-reference', - u'pep-reference': u'pep-reference', - u'pep': u'pep-reference', - u'rfc-reference': u'rfc-reference', - u'rfc': u'rfc-reference', + u'title-reference (translation required)': u'title-reference', + u'title (translation required)': u'title-reference', + u'pep-reference (translation required)': u'pep-reference', + u'rfc-reference (translation required)': u'rfc-reference', u'korostus': u'emphasis', u'vahvistus': u'strong', u'tasalevyinen': u'literal', - u'named-reference': u'named-reference', - u'anonymous-reference': u'anonymous-reference', - u'footnote-reference': u'footnote-reference', - u'citation-reference': u'citation-reference', - u'substitution-reference': u'substitution-reference', + u'named-reference (translation required)': u'named-reference', + u'anonymous-reference (translation required)': u'anonymous-reference', + u'footnote-reference (translation required)': u'footnote-reference', + u'citation-reference (translation required)': u'citation-reference', + u'substitution-reference (translation required)': u'substitution-reference', u'kohde': u'target', - u'uri-reference': u'uri-reference', - u'uri': u'uri-reference', - u'url': u'uri-reference',} + u'uri-reference (translation required)': u'uri-reference', """Mapping of Finnish role names to canonical role names for interpreted text. """ -- cgit v1.2.1 From 74e3459ee5404626d2f5267d4d1e6da939df0dcb Mon Sep 17 00:00:00 2001 From: wiemann Date: Sat, 11 Sep 2004 17:11:02 +0000 Subject: typo git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2572 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/de.py | 82 ++++++++++++++++++------------------ docutils/parsers/rst/languages/fi.py | 2 +- 2 files changed, 41 insertions(+), 43 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index 90eb77bdb..e6fcaaa1f 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -1,5 +1,4 @@ -# -*- coding: iso-8859-1 -*- -# Author: Engelbert Gruber +# Authors: Engelbert Gruber; Felix Wiemann # Contact: grubert@users.sourceforge.net # Revision: $Revision$ # Date: $Date$ @@ -26,61 +25,60 @@ directives = { 'hinweis': 'hint', 'wichtig': 'important', 'notiz': 'note', - 'tip': 'tip', + 'tipp': 'tip', 'warnung': 'warning', 'ermahnung': 'admonition', - 'kasten': 'sidebar', # seitenkasten ? - 'thema': 'topic', - 'line-block': 'line-block', - 'parsed-literal': 'parsed-literal', + 'kasten': 'sidebar', + 'seitenkasten': 'sidebar', + 'thema': 'topic', + 'zeilen-block': 'line-block', + 'parsed-literal (translation required)': 'parsed-literal', 'rubrik': 'rubric', - 'epigraph (translation required)': 'epigraph', + 'epigraph': 'epigraph', 'highlights (translation required)': 'highlights', 'pull-quote (translation required)': 'pull-quote', # kasten too ? - #'questions': 'questions', - #'qa': 'questions', - #'faq': 'questions', - 'table (translation required)': 'table', - 'csv-table (translation required)': 'csv-table', + #'fragen': 'questions', + 'tabelle': 'table', + 'csv-tabelle': 'csv-table', 'meta': 'meta', #'imagemap': 'imagemap', 'bild': 'image', 'abbildung': 'figure', - 'raw': 'raw', # unbearbeitet - 'include': 'include', # einfügen, "füge ein" would be more like a command. - # einfügung would be the noun. - 'ersetzung': 'replace', # ersetzen, ersetze + u'unver\xe4ndert': 'raw', + u'einf\xfcgen': 'include', + 'ersetzen': 'replace', + 'ersetze': 'replace', 'unicode': 'unicode', - 'klasse': 'class', # offer "class" too ? - 'role (translation required)': 'role', + 'klasse': 'class', + 'rolle': 'role', 'inhalt': 'contents', - 'sectnum': 'sectnum', - 'section-numbering': 'sectnum', - 'target-notes': 'target-notes', - #'footnotes': 'footnotes', - #'citations': 'citations', - 'restructuredtext-test-directive': 'restructuredtext-test-directive'} + 'kapitel-nummerierung': 'sectnum', + 'abschnitts-nummerierung': 'sectnum', + u'linkziel-fu\xdfnoten': 'target-notes', + #u'fu\xdfnoten': 'footnotes', + #'zitate': 'citations', + } """German name to registered (in directives/__init__.py) directive name mapping.""" roles = { - 'abbreviation (translation required)': 'abbreviation', - 'acronym (translation required)': 'acronym', - 'index (translation required)': 'index', - 'subscript (translation required)': 'subscript', - 'superscript (translation required)': 'superscript', - 'title-reference (translation required)': 'title-reference', - 'pep-reference (translation required)': 'pep-reference', - 'rfc-reference (translation required)': 'rfc-reference', - 'emphasis (translation required)': 'emphasis', - 'strong (translation required)': 'strong', + u'abk\xfcrzung': 'abbreviation', + 'akronym': 'acronym', + 'index': 'index', + 'tiefgestellt': 'subscript', + 'hochgestellt': 'superscript', + 'titel-referenz': 'title-reference', + 'pep-referenz': 'pep-reference', + 'rfc-referenz': 'rfc-reference', + 'betonung': 'emphasis', + 'fett': 'strong', 'literal (translation required)': 'literal', - 'named-reference (translation required)': 'named-reference', - 'anonymous-reference (translation required)': 'anonymous-reference', - 'footnote-reference (translation required)': 'footnote-reference', - 'citation-reference (translation required)': 'citation-reference', - 'substitution-reference (translation required)': 'substitution-reference', - 'target (translation required)': 'target', - 'uri-reference (translation required)': 'uri-reference',} + 'benannte-referenz': 'named-reference', + 'unbenannte-referenz': 'anonymous-reference', + u'fu\xdfnoten-referenz': 'footnote-reference', + 'zitat-referenz': 'citation-reference', + 'ersetzungs-referenz': 'substitution-reference', + 'ziel': 'target', + 'uri-referenz': 'uri-reference',} """Mapping of German role names to canonical role names for interpreted text. """ diff --git a/docutils/parsers/rst/languages/fi.py b/docutils/parsers/rst/languages/fi.py index 0eeefff19..269a41d1e 100644 --- a/docutils/parsers/rst/languages/fi.py +++ b/docutils/parsers/rst/languages/fi.py @@ -81,6 +81,6 @@ roles = { u'citation-reference (translation required)': u'citation-reference', u'substitution-reference (translation required)': u'substitution-reference', u'kohde': u'target', - u'uri-reference (translation required)': u'uri-reference', + u'uri-reference (translation required)': u'uri-reference'} """Mapping of Finnish role names to canonical role names for interpreted text. """ -- cgit v1.2.1 From 2098f68d0d25262d21a2db2c7c91164052cdd004 Mon Sep 17 00:00:00 2001 From: wiemann Date: Sat, 11 Sep 2004 17:41:18 +0000 Subject: don't delete anything without a good reason git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2574 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/de.py | 1 + 1 file changed, 1 insertion(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index e6fcaaa1f..d8dedffd2 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -46,6 +46,7 @@ directives = { 'abbildung': 'figure', u'unver\xe4ndert': 'raw', u'einf\xfcgen': 'include', + 'ersetzung': 'replace', 'ersetzen': 'replace', 'ersetze': 'replace', 'unicode': 'unicode', -- cgit v1.2.1 From dabc9aa76be60ffea41afc00b33103307d54d59a Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 12 Sep 2004 20:43:32 +0000 Subject: reverted rev1.3 (Unicode check for CSV table) git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2587 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/tables.py | 9 --------- 1 file changed, 9 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/tables.py b/docutils/parsers/rst/directives/tables.py index 787278b3e..e34e54b20 100644 --- a/docutils/parsers/rst/directives/tables.py +++ b/docutils/parsers/rst/directives/tables.py @@ -13,7 +13,6 @@ __docformat__ = 'reStructuredText' import sys import os.path -from types import UnicodeType from docutils import nodes, statemachine, utils from docutils.utils import SystemMessagePropagation from docutils.parsers.rst import directives @@ -247,18 +246,10 @@ def process_header_option(options, state_machine, lineno): return table_head, max_header_cols def parse_csv_data_into_rows(csv_data, dialect, source, options): - isunicode = (csv_data and type(csv_data[0]) == UnicodeType) - if isunicode: - # Encode unicode in UTF-8, because the csv module doesn't - # support unicode strings. - csv_data = [item.encode('utf-8') for item in csv_data] csv_reader = csv.reader(csv_data, dialect=dialect) rows = [] max_cols = 0 for row in csv_reader: - if isunicode: - # Decode UTF-8 back to unicode - row = [item.decode('utf-8') for item in row] row_data = [] for cell in row: cell_data = (0, 0, 0, statemachine.StringList(cell.splitlines(), -- cgit v1.2.1 From 82924f762267c60ed71fd26c87e1fa533a2f1882 Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 12 Sep 2004 21:13:54 +0000 Subject: Added "encoding" directive to "csv-table" directive. Added workaround for lack of Unicode support in csv.py, for non-ASCII CSV input. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2588 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/tables.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/tables.py b/docutils/parsers/rst/directives/tables.py index e34e54b20..1966d2ab2 100644 --- a/docutils/parsers/rst/directives/tables.py +++ b/docutils/parsers/rst/directives/tables.py @@ -13,7 +13,7 @@ __docformat__ = 'reStructuredText' import sys import os.path -from docutils import nodes, statemachine, utils +from docutils import io, nodes, statemachine, utils from docutils.utils import SystemMessagePropagation from docutils.parsers.rst import directives @@ -154,6 +154,7 @@ csv_table.options = {'header-rows': directives.nonnegative_int, 'widths': directives.positive_int_list, 'file': directives.path, 'url': directives.path, + 'encoding': directives.encoding, 'class': directives.class_option, # field delimiter char 'delim': directives.single_char_or_whitespace_or_unicode, @@ -180,6 +181,7 @@ def get_csv_data(name, options, content, lineno, block_text, CSV data can come from the directive content, from an external file, or from a URL reference. """ + encoding = options.get('encoding', state.document.settings.input_encoding) if content: # CSV data is from directive content if options.has_key('file') or options.has_key('url'): error = state_machine.reporter.error( @@ -201,11 +203,9 @@ def get_csv_data(name, options, content, lineno, block_text, source = os.path.normpath(os.path.join(source_dir, options['file'])) source = utils.relative_path(None, source) try: - csv_file = open(source, 'rb') - try: - csv_data = csv_file.read().splitlines() - finally: - csv_file.close() + csv_file = io.FileInput(source_path=source, encoding=encoding, + handle_io_errors=None) + csv_data = csv_file.read().splitlines() except IOError, error: severe = state_machine.reporter.severe( 'Problems with "%s" directive path:\n%s.' % (name, error), @@ -221,13 +221,16 @@ def get_csv_data(name, options, content, lineno, block_text, raise SystemMessagePropagation(severe) source = options['url'] try: - csv_data = urllib2.urlopen(source).read().splitlines() + csv_text = urllib2.urlopen(source).read() except (urllib2.URLError, IOError, OSError, ValueError), error: severe = state_machine.reporter.severe( 'Problems with "%s" directive URL "%s":\n%s.' % (name, options['url'], error), nodes.literal_block(block_text, block_text), line=lineno) raise SystemMessagePropagation(severe) + csv_file = io.StringInput(source=csv_text, source_path=source, + encoding=encoding) + csv_data = csv_file.read().splitlines() else: error = state_machine.reporter.warning( 'The "%s" directive requires content; none supplied.' % (name), @@ -246,14 +249,18 @@ def process_header_option(options, state_machine, lineno): return table_head, max_header_cols def parse_csv_data_into_rows(csv_data, dialect, source, options): - csv_reader = csv.reader(csv_data, dialect=dialect) + # csv.py doesn't do Unicode; encode temporarily as UTF-8 + csv_reader = csv.reader([line.encode('utf-8') for line in csv_data], + dialect=dialect) rows = [] max_cols = 0 for row in csv_reader: row_data = [] for cell in row: - cell_data = (0, 0, 0, statemachine.StringList(cell.splitlines(), - source=source)) + # decode UTF-8 back to Unicode + cell_text = unicode(cell, 'utf-8') + cell_data = (0, 0, 0, statemachine.StringList( + cell_text.splitlines(), source=source)) row_data.append(cell_data) rows.append(row_data) max_cols = max(max_cols, len(row)) -- cgit v1.2.1 From 5cf52a0232f6f46fee60577e205a273082efea85 Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 12 Sep 2004 21:16:37 +0000 Subject: Added ``encoding`` directive option conversion function. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2592 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index f10d42cec..bd8f84e8a 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -85,6 +85,7 @@ See `Creating reStructuredText Directives`_ for more information. __docformat__ = 'reStructuredText' import re +import codecs from docutils import nodes from docutils.parsers.rst.languages import en as _fallback_language_module @@ -339,9 +340,12 @@ def positive_int_list(argument): entries = argument.split() return [positive_int(entry) for entry in entries] -def format_values(values): - return '%s, or "%s"' % (', '.join(['"%s"' % s for s in values[:-1]]), - values[-1]) +def encoding(argument): + try: + codecs.lookup(argument) + except LookupError: + raise ValueError('unknown encoding: "%s"' % argument) + return argument def choice(argument, values): """ @@ -368,3 +372,7 @@ def choice(argument, values): else: raise ValueError('"%s" unknown; choose from %s' % (argument, format_values(values))) + +def format_values(values): + return '%s, or "%s"' % (', '.join(['"%s"' % s for s in values[:-1]]), + values[-1]) -- cgit v1.2.1 From 1a6a5138cc6fe3ede8e5ef7f6ff62cbb9e064128 Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 12 Sep 2004 21:17:03 +0000 Subject: Added "encoding" option to "include" and "raw" directives. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2593 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index d6aa39ae7..8411f36c8 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -35,10 +35,10 @@ def include(name, arguments, options, content, lineno, return [error] path = os.path.normpath(os.path.join(source_dir, path)) path = utils.relative_path(None, path) + encoding = options.get('encoding', state.document.settings.input_encoding) try: include_file = io.FileInput( - source_path=path, encoding=state.document.settings.input_encoding, - handle_io_errors=None) + source_path=path, encoding=encoding, handle_io_errors=None) except IOError, error: severe = state_machine.reporter.severe( 'Problems with "%s" directive path:\n%s: %s.' @@ -71,6 +71,7 @@ def raw(name, arguments, options, content, lineno, imported from a file or url. """ attributes = {'format': arguments[0]} + encoding = options.get('encoding', state.document.settings.input_encoding) if content: if options.has_key('file') or options.has_key('url'): error = state_machine.reporter.error( @@ -91,14 +92,13 @@ def raw(name, arguments, options, content, lineno, path = os.path.normpath(os.path.join(source_dir, options['file'])) path = utils.relative_path(None, path) try: - raw_file = open(path) + raw_file = io.FileInput(source_path=path, encoding=encoding) except IOError, error: severe = state_machine.reporter.severe( 'Problems with "%s" directive path:\n%s.' % (name, error), nodes.literal_block(block_text, block_text), line=lineno) return [severe] text = raw_file.read() - raw_file.close() attributes['source'] = path elif options.has_key('url'): if not urllib2: @@ -108,17 +108,19 @@ def raw(name, arguments, options, content, lineno, '"urllib2" module).' % name, nodes.literal_block(block_text, block_text), line=lineno) return [severe] + source = options['url'] try: - raw_file = urllib2.urlopen(options['url']) + raw_text = urllib2.urlopen(source).read() except (urllib2.URLError, IOError, OSError), error: severe = state_machine.reporter.severe( 'Problems with "%s" directive URL "%s":\n%s.' % (name, options['url'], error), nodes.literal_block(block_text, block_text), line=lineno) return [severe] + raw_file = io.StringInput(source=raw_text, source_path=source, + encoding=encoding) text = raw_file.read() - raw_file.close() - attributes['source'] = options['file'] + attributes['source'] = source else: error = state_machine.reporter.warning( 'The "%s" directive requires content; none supplied.' % (name), -- cgit v1.2.1 From 09522775bb77029bc2a4cbfbbde5ebe5e43fabe1 Mon Sep 17 00:00:00 2001 From: goodger Date: Mon, 13 Sep 2004 00:18:57 +0000 Subject: added input_encoding_error_handler to external file processing (include, raw, csv-table directives) git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2598 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 15 +++++++++++---- docutils/parsers/rst/directives/tables.py | 11 +++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 8411f36c8..599582acd 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -38,7 +38,9 @@ def include(name, arguments, options, content, lineno, encoding = options.get('encoding', state.document.settings.input_encoding) try: include_file = io.FileInput( - source_path=path, encoding=encoding, handle_io_errors=None) + source_path=path, encoding=encoding, + error_handler=state.document.settings.input_encoding_error_handler, + handle_io_errors=None) except IOError, error: severe = state_machine.reporter.severe( 'Problems with "%s" directive path:\n%s: %s.' @@ -72,6 +74,7 @@ def raw(name, arguments, options, content, lineno, """ attributes = {'format': arguments[0]} encoding = options.get('encoding', state.document.settings.input_encoding) + error_handler = state.document.settings.input_encoding_error_handler if content: if options.has_key('file') or options.has_key('url'): error = state_machine.reporter.error( @@ -92,7 +95,10 @@ def raw(name, arguments, options, content, lineno, path = os.path.normpath(os.path.join(source_dir, options['file'])) path = utils.relative_path(None, path) try: - raw_file = io.FileInput(source_path=path, encoding=encoding) + raw_file = io.FileInput( + source_path=path, encoding=encoding, + error_handler=state.document.settings.input_encoding_error_handler, + handle_io_errors=None) except IOError, error: severe = state_machine.reporter.severe( 'Problems with "%s" directive path:\n%s.' % (name, error), @@ -117,8 +123,9 @@ def raw(name, arguments, options, content, lineno, % (name, options['url'], error), nodes.literal_block(block_text, block_text), line=lineno) return [severe] - raw_file = io.StringInput(source=raw_text, source_path=source, - encoding=encoding) + raw_file = io.StringInput( + source=raw_text, source_path=source, encoding=encoding, + error_handler=state.document.settings.input_encoding_error_handler) text = raw_file.read() attributes['source'] = source else: diff --git a/docutils/parsers/rst/directives/tables.py b/docutils/parsers/rst/directives/tables.py index 1966d2ab2..104a99480 100644 --- a/docutils/parsers/rst/directives/tables.py +++ b/docutils/parsers/rst/directives/tables.py @@ -203,8 +203,10 @@ def get_csv_data(name, options, content, lineno, block_text, source = os.path.normpath(os.path.join(source_dir, options['file'])) source = utils.relative_path(None, source) try: - csv_file = io.FileInput(source_path=source, encoding=encoding, - handle_io_errors=None) + csv_file = io.FileInput( + source_path=source, encoding=encoding, + error_handler=state.document.settings.input_encoding_error_handler, + handle_io_errors=None) csv_data = csv_file.read().splitlines() except IOError, error: severe = state_machine.reporter.severe( @@ -228,8 +230,9 @@ def get_csv_data(name, options, content, lineno, block_text, % (name, options['url'], error), nodes.literal_block(block_text, block_text), line=lineno) raise SystemMessagePropagation(severe) - csv_file = io.StringInput(source=csv_text, source_path=source, - encoding=encoding) + csv_file = io.StringInput( + source=csv_text, source_path=source, encoding=encoding, + error_handler=state.document.settings.input_encoding_error_handler) csv_data = csv_file.read().splitlines() else: error = state_machine.reporter.warning( -- cgit v1.2.1 From 7531dff9a666b4291d8707d37954b1768b49e607 Mon Sep 17 00:00:00 2001 From: goodger Date: Mon, 13 Sep 2004 00:24:38 +0000 Subject: removed unnecessary line git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2599 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 1 - 1 file changed, 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 599582acd..243340ea9 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -74,7 +74,6 @@ def raw(name, arguments, options, content, lineno, """ attributes = {'format': arguments[0]} encoding = options.get('encoding', state.document.settings.input_encoding) - error_handler = state.document.settings.input_encoding_error_handler if content: if options.has_key('file') or options.has_key('url'): error = state_machine.reporter.error( -- cgit v1.2.1 From fc086c0355a08866685ee9a058d29e391e778425 Mon Sep 17 00:00:00 2001 From: wiemann Date: Mon, 13 Sep 2004 18:50:33 +0000 Subject: added Traditional Chinese language files; thanks to Joe YS Jaw git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2607 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/zh_tw.py | 97 +++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 docutils/parsers/rst/languages/zh_tw.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/zh_tw.py b/docutils/parsers/rst/languages/zh_tw.py new file mode 100644 index 000000000..faeeac54d --- /dev/null +++ b/docutils/parsers/rst/languages/zh_tw.py @@ -0,0 +1,97 @@ +# Author: David Goodger +# Contact: goodger@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +# New language mappings are welcome. Before doing a new translation, please +# read . Two files must be +# translated for each language: one in docutils/languages, the other in +# docutils/parsers/rst/languages. + +""" +Traditional Chinese language mappings for language-dependent features of +reStructuredText. +""" + +__docformat__ = 'reStructuredText' + + +directives = { + # language-dependent: fixed + 'attention': 'attention', + 'caution': 'caution', + 'danger': 'danger', + 'error': 'error', + 'hint': 'hint', + 'important': 'important', + 'note': 'note', + 'tip': 'tip', + 'warning': 'warning', + 'admonition': 'admonition', + 'sidebar': 'sidebar', + 'topic': 'topic', + 'line-block': 'line-block', + 'parsed-literal': 'parsed-literal', + 'rubric': 'rubric', + 'epigraph': 'epigraph', + 'highlights': 'highlights', + 'pull-quote': 'pull-quote', + #'questions': 'questions', + 'table': 'table', + 'csv-table': 'csv-table', + #'qa': 'questions', + #'faq': 'questions', + 'meta': 'meta', + #'imagemap': 'imagemap', + 'image': 'image', + 'figure': 'figure', + 'include': 'include', + 'raw': 'raw', + 'replace': 'replace', + 'unicode': 'unicode', + 'class': 'class', + 'role': 'role', + 'contents': 'contents', + 'sectnum': 'sectnum', + 'section-numbering': 'sectnum', + #'footnotes': 'footnotes', + #'citations': 'citations', + 'target-notes': 'target-notes', + 'restructuredtext-test-directive': 'restructuredtext-test-directive'} +"""English name to registered (in directives/__init__.py) directive name +mapping.""" + +roles = { + # language-dependent: fixed + 'abbreviation': 'abbreviation', + 'ab': 'abbreviation', + 'acronym': 'acronym', + 'ac': 'acronym', + 'index': 'index', + 'i': 'index', + 'subscript': 'subscript', + 'sub': 'subscript', + 'superscript': 'superscript', + 'sup': 'superscript', + 'title-reference': 'title-reference', + 'title': 'title-reference', + 't': 'title-reference', + 'pep-reference': 'pep-reference', + 'pep': 'pep-reference', + 'rfc-reference': 'rfc-reference', + 'rfc': 'rfc-reference', + 'emphasis': 'emphasis', + 'strong': 'strong', + 'literal': 'literal', + 'named-reference': 'named-reference', + 'anonymous-reference': 'anonymous-reference', + 'footnote-reference': 'footnote-reference', + 'citation-reference': 'citation-reference', + 'substitution-reference': 'substitution-reference', + 'target': 'target', + 'uri-reference': 'uri-reference', + 'uri': 'uri-reference', + 'url': 'uri-reference',} +"""Mapping of Traditional Chinese role names to canonical role names for interpreted text. +""" -- cgit v1.2.1 From e2477e304e4417a049215d78485c8c2e9627f884 Mon Sep 17 00:00:00 2001 From: wiemann Date: Mon, 13 Sep 2004 19:25:33 +0000 Subject: fixed links git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2609 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/fi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/fi.py b/docutils/parsers/rst/languages/fi.py index 269a41d1e..4ccdee84a 100644 --- a/docutils/parsers/rst/languages/fi.py +++ b/docutils/parsers/rst/languages/fi.py @@ -5,7 +5,7 @@ # Copyright: This module has been placed in the public domain. # New language mappings are welcome. Before doing a new translation, please -# read . Two files must be +# read . Two files must be # translated for each language: one in docutils/languages, the other in # docutils/parsers/rst/languages. -- cgit v1.2.1 From 26e823e026f5b9be93d71437039d9b7eb3e0c76d Mon Sep 17 00:00:00 2001 From: wiemann Date: Sun, 19 Sep 2004 00:34:03 +0000 Subject: added --dependency-file option git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2622 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 10 +++++++++- docutils/parsers/rst/directives/misc.py | 6 ++++-- docutils/parsers/rst/directives/tables.py | 3 ++- 3 files changed, 15 insertions(+), 4 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index ddbdb96c6..5c142d32d 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -12,7 +12,7 @@ __docformat__ = 'reStructuredText' import sys -from docutils import nodes, utils +from docutils import nodes, utils, io from docutils.parsers.rst import directives, states from docutils.nodes import whitespace_normalize_name @@ -35,6 +35,14 @@ def image(name, arguments, options, content, lineno, 'Image URI contains whitespace.', nodes.literal_block(block_text, block_text), line=lineno) return [error] + try: + open(reference) + # If this didn't cause an exception, the image URI is an + # existent file and can be added to the dependency list. + io.add_dependency(reference, + state.document.settings.dependency_file) + except (IOError, UnicodeError): + pass options['uri'] = reference reference_node = None if options.has_key('target'): diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 243340ea9..e04d9ac53 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -40,7 +40,8 @@ def include(name, arguments, options, content, lineno, include_file = io.FileInput( source_path=path, encoding=encoding, error_handler=state.document.settings.input_encoding_error_handler, - handle_io_errors=None) + handle_io_errors=None, + dep_file=state.document.settings.dependency_file) except IOError, error: severe = state_machine.reporter.severe( 'Problems with "%s" directive path:\n%s: %s.' @@ -97,7 +98,8 @@ def raw(name, arguments, options, content, lineno, raw_file = io.FileInput( source_path=path, encoding=encoding, error_handler=state.document.settings.input_encoding_error_handler, - handle_io_errors=None) + handle_io_errors=None, + dep_file=state.document.settings.dependency_file) except IOError, error: severe = state_machine.reporter.severe( 'Problems with "%s" directive path:\n%s.' % (name, error), diff --git a/docutils/parsers/rst/directives/tables.py b/docutils/parsers/rst/directives/tables.py index 104a99480..5e90e7d3c 100644 --- a/docutils/parsers/rst/directives/tables.py +++ b/docutils/parsers/rst/directives/tables.py @@ -206,7 +206,8 @@ def get_csv_data(name, options, content, lineno, block_text, csv_file = io.FileInput( source_path=source, encoding=encoding, error_handler=state.document.settings.input_encoding_error_handler, - handle_io_errors=None) + handle_io_errors=None, + dep_file=state.document.settings.dependency_file) csv_data = csv_file.read().splitlines() except IOError, error: severe = state_machine.reporter.severe( -- cgit v1.2.1 From 965d763d192aabd0d71ed3a088b994170bc8219f Mon Sep 17 00:00:00 2001 From: wiemann Date: Sat, 25 Sep 2004 23:44:06 +0000 Subject: use new DependencyList (in settings.record_dependencies) git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2647 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 11 ++--------- docutils/parsers/rst/directives/misc.py | 8 ++++---- docutils/parsers/rst/directives/tables.py | 4 ++-- 3 files changed, 8 insertions(+), 15 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index 5c142d32d..bf13b93e1 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -12,7 +12,7 @@ __docformat__ = 'reStructuredText' import sys -from docutils import nodes, utils, io +from docutils import nodes, utils from docutils.parsers.rst import directives, states from docutils.nodes import whitespace_normalize_name @@ -35,14 +35,6 @@ def image(name, arguments, options, content, lineno, 'Image URI contains whitespace.', nodes.literal_block(block_text, block_text), line=lineno) return [error] - try: - open(reference) - # If this didn't cause an exception, the image URI is an - # existent file and can be added to the dependency list. - io.add_dependency(reference, - state.document.settings.dependency_file) - except (IOError, UnicodeError): - pass options['uri'] = reference reference_node = None if options.has_key('target'): @@ -93,6 +85,7 @@ def figure(name, arguments, options, content, lineno, except (IOError, UnicodeError): pass else: + state.document.settings.record_dependencies.add(reference) figure_node['width'] = i.size[0] elif figwidth is not None: figure_node['width'] = figwidth diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index e04d9ac53..fc797e1eb 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -37,11 +37,11 @@ def include(name, arguments, options, content, lineno, path = utils.relative_path(None, path) encoding = options.get('encoding', state.document.settings.input_encoding) try: + state.document.settings.record_dependencies.add(path) include_file = io.FileInput( source_path=path, encoding=encoding, error_handler=state.document.settings.input_encoding_error_handler, - handle_io_errors=None, - dep_file=state.document.settings.dependency_file) + handle_io_errors=None) except IOError, error: severe = state_machine.reporter.severe( 'Problems with "%s" directive path:\n%s: %s.' @@ -95,11 +95,11 @@ def raw(name, arguments, options, content, lineno, path = os.path.normpath(os.path.join(source_dir, options['file'])) path = utils.relative_path(None, path) try: + state.document.settings.record_dependencies.add(path) raw_file = io.FileInput( source_path=path, encoding=encoding, error_handler=state.document.settings.input_encoding_error_handler, - handle_io_errors=None, - dep_file=state.document.settings.dependency_file) + handle_io_errors=None) except IOError, error: severe = state_machine.reporter.severe( 'Problems with "%s" directive path:\n%s.' % (name, error), diff --git a/docutils/parsers/rst/directives/tables.py b/docutils/parsers/rst/directives/tables.py index 5e90e7d3c..5b4cf8313 100644 --- a/docutils/parsers/rst/directives/tables.py +++ b/docutils/parsers/rst/directives/tables.py @@ -203,11 +203,11 @@ def get_csv_data(name, options, content, lineno, block_text, source = os.path.normpath(os.path.join(source_dir, options['file'])) source = utils.relative_path(None, source) try: + state.document.settings.record_dependencies.add(source) csv_file = io.FileInput( source_path=source, encoding=encoding, error_handler=state.document.settings.input_encoding_error_handler, - handle_io_errors=None, - dep_file=state.document.settings.dependency_file) + handle_io_errors=None) csv_data = csv_file.read().splitlines() except IOError, error: severe = state_machine.reporter.severe( -- cgit v1.2.1 From 7e01e55a123cbcb5ba89d7cc435ec97e2269f57e Mon Sep 17 00:00:00 2001 From: goodger Date: Mon, 27 Sep 2004 15:28:33 +0000 Subject: Fixed bug where a "role" directive in a nested parse would crash the parser; the "language" attribute was not being copied over to the new state machine. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2654 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 1 + 1 file changed, 1 insertion(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 43caa9711..f6a25465f 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -199,6 +199,7 @@ class NestedStateMachine(StateMachineWS): self.document = memo.document self.attach_observer(self.document.note_source) self.reporter = memo.reporter + self.language = memo.language self.node = node results = StateMachineWS.run(self, input_lines, input_offset) assert results == [], ('NestedStateMachine.run() results should be ' -- cgit v1.2.1 From cae2ee1daa3debebadffe965580cd15af2712331 Mon Sep 17 00:00:00 2001 From: wiemann Date: Thu, 30 Sep 2004 13:43:40 +0000 Subject: added --leave-footnote-reference-space git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2680 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/__init__.py b/docutils/parsers/rst/__init__.py index 33ad99829..88795a830 100644 --- a/docutils/parsers/rst/__init__.py +++ b/docutils/parsers/rst/__init__.py @@ -108,7 +108,11 @@ class Parser(docutils.parsers.Parser): {'metavar': '', 'type': 'int', 'default': 8}), ('Remove spaces before footnote references.', ['--trim-footnote-reference-space'], - {'action': 'store_true', 'validator': frontend.validate_boolean}),)) + {'action': 'store_true', 'validator': frontend.validate_boolean}), + ('Leave spaces before footnote references.', + ['--leave-footnote-reference-space'], + {'action': 'store_false', 'dest': 'trim_footnote_reference_space', + 'validator': frontend.validate_boolean}),)) config_section = 'restructuredtext parser' config_section_dependencies = ('parsers',) -- cgit v1.2.1 From 124f37c038f86eb6c3b1344150840b5fd2a1cdbd Mon Sep 17 00:00:00 2001 From: wiemann Date: Thu, 30 Sep 2004 13:47:59 +0000 Subject: setting footnote_references to "superscript" or "brackets" now causes footnote-reference-space to be trimmed or not, resp. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2681 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index f6a25465f..60e0bcafd 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -922,7 +922,7 @@ class Inliner: if refname: refnode['refname'] = refname self.document.note_footnote_ref(refnode) - if self.document.settings.trim_footnote_reference_space: + if utils.get_trim_footnote_ref_space(self.document.settings): before = before.rstrip() return (before, [refnode], remaining, []) -- cgit v1.2.1 From 81cbe9fdf4f4d5b57902ddc6d7b764b1250b9c96 Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 5 Oct 2004 01:21:26 +0000 Subject: Added support for line block syntax. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2686 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 90 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 86 insertions(+), 4 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 60e0bcafd..cdc4258d1 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1090,6 +1090,7 @@ class Body(RSTState): 'field_marker': r':[^: ]([^:]*[^: ])?:( +|$)', 'option_marker': r'%(option)s(, %(option)s)*( +| ?$)' % pats, 'doctest': r'>>>( +|$)', + 'line_block': r'\|( +|$)', 'grid_table_top': grid_table_top_pat, 'simple_table_top': simple_table_top_pat, 'explicit_markup': r'\.\.( +|$)', @@ -1102,6 +1103,7 @@ class Body(RSTState): 'field_marker', 'option_marker', 'doctest', + 'line_block', 'grid_table_top', 'simple_table_top', 'explicit_markup', @@ -1189,12 +1191,12 @@ class Body(RSTState): i, blank_finish = self.list_item(match.end()) bulletlist += i offset = self.state_machine.line_offset + 1 # next line - newline_offset, blank_finish = self.nested_list_parse( + new_line_offset, blank_finish = self.nested_list_parse( self.state_machine.input_lines[offset:], input_offset=self.state_machine.abs_line_offset() + 1, node=bulletlist, initial_state='BulletList', blank_finish=blank_finish) - self.goto_line(newline_offset) + self.goto_line(new_line_offset) if not blank_finish: self.parent += self.unindent_warning('Bullet list') return [], next_state, [] @@ -1476,6 +1478,69 @@ class Body(RSTState): self.parent += nodes.doctest_block(data, data) return [], next_state, [] + def line_block(self, match, context, next_state): + """First line of a line block.""" + block = nodes.line_block() + self.parent += block + lineno = self.state_machine.abs_line_number() + line, messages, blank_finish = self.line_block_line(match, lineno) + block += line + self.parent += messages + if not blank_finish: + offset = self.state_machine.line_offset + 1 # next line + new_line_offset, blank_finish = self.nested_list_parse( + self.state_machine.input_lines[offset:], + input_offset=self.state_machine.abs_line_offset() + 1, + node=block, initial_state='LineBlock', + blank_finish=0) + self.goto_line(new_line_offset) + if not blank_finish: + self.parent += self.reporter.warning( + 'Line block ends without a blank line.', + line=(self.state_machine.abs_line_number() + 1)) + if len(block): + if block[0].indent is None: + block[0].indent = 0 + self.nest_line_block_lines(block) + return [], next_state, [] + + def line_block_line(self, match, lineno): + """Return one line element of a line_block.""" + indented, indent, line_offset, blank_finish = \ + self.state_machine.get_first_known_indented(match.end(), + until_blank=1) + text = u'\n'.join(indented) + text_nodes, messages = self.inline_text(text, lineno) + line = nodes.line(text, '', *text_nodes) + if match.string.rstrip() != '|': # not empty + line.indent = len(match.group(1)) - 1 + return line, messages, blank_finish + + def nest_line_block_lines(self, block): + for index in range(1, len(block)): + if block[index].indent is None: + block[index].indent = block[index - 1].indent + self.nest_line_block_segment(block) + + def nest_line_block_segment(self, block): + indents = [item.indent for item in block] + least = min(indents) + new_items = [] + new_block = nodes.line_block() + for item in block: + if item.indent > least: + new_block.append(item) + else: + if len(new_block): + self.nest_line_block_segment(new_block) + new_items.append(new_block) + new_block = nodes.line_block() + new_items.append(item) + if len(new_block): + self.nest_line_block_segment(new_block) + new_items.append(new_block) + block[:] = new_items + def grid_table_top(self, match, context, next_state): """Top border of a full table.""" return self.table_top(match, context, next_state, @@ -2274,6 +2339,7 @@ class SpecializedBody(Body): field_marker = invalid_input option_marker = invalid_input doctest = invalid_input + line_block = invalid_input grid_table_top = invalid_input simple_table_top = invalid_input explicit_markup = invalid_input @@ -2391,6 +2457,22 @@ class ExtensionOptions(FieldList): lines = [] +class LineBlock(SpecializedBody): + + """Second and subsequent lines of a line_block.""" + + blank = SpecializedBody.invalid_input + + def line_block(self, match, context, next_state): + """New line of line block.""" + lineno = self.state_machine.abs_line_number() + line, messages, blank_finish = self.line_block_line(match, lineno) + self.parent += line + self.parent.parent += messages + self.blank_finish = blank_finish + return [], next_state, [] + + class Explicit(SpecializedBody): """Second and subsequent explicit markup construct.""" @@ -2854,8 +2936,8 @@ class QuotedLiteralBlock(RSTState): state_classes = (Body, BulletList, DefinitionList, EnumeratedList, FieldList, - OptionList, ExtensionOptions, Explicit, Text, Definition, - Line, SubstitutionDef, RFC2822Body, RFC2822List) + OptionList, LineBlock, ExtensionOptions, Explicit, Text, + Definition, Line, SubstitutionDef, RFC2822Body, RFC2822List) """Standard set of State classes used to start `RSTStateMachine`.""" -- cgit v1.2.1 From ef553a1fe8a6033a97e97a4c72d07632de6fbd7c Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 5 Oct 2004 01:21:47 +0000 Subject: Converted the line-block directive to use the new structure. Extracted the old line-block functionality to the ``block`` function (still used). git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2689 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/body.py | 40 ++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index 85adda981..9d40331ca 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -66,31 +66,51 @@ sidebar.options = {'subtitle': directives.unchanged_required, sidebar.content = 1 def line_block(name, arguments, options, content, lineno, - content_offset, block_text, state, state_machine, - node_class=nodes.line_block): + content_offset, block_text, state, state_machine): if not content: warning = state_machine.reporter.warning( 'Content block expected for the "%s" directive; none found.' % name, nodes.literal_block(block_text, block_text), line=lineno) return [warning] - text = '\n'.join(content) - text_nodes, messages = state.inline_text(text, lineno) - node = node_class(text, '', *text_nodes, **options) - node.line = content_offset + 1 - return [node] + messages + block = nodes.line_block() + node_list = [block] + for line_text in content: + text_nodes, messages = state.inline_text(line_text.strip(), + lineno + content_offset) + line = nodes.line(line_text, '', *text_nodes) + if line_text.strip(): + line.indent = len(line_text) - len(line_text.lstrip()) + block += line + node_list.extend(messages) + content_offset += 1 + state.nest_line_block_lines(block) + return node_list line_block.options = {'class': directives.class_option} line_block.content = 1 def parsed_literal(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): - return line_block(name, arguments, options, content, lineno, - content_offset, block_text, state, state_machine, - node_class=nodes.literal_block) + return block(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine, + node_class=nodes.literal_block) parsed_literal.options = {'class': directives.class_option} parsed_literal.content = 1 +def block(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine, node_class): + if not content: + warning = state_machine.reporter.warning( + 'Content block expected for the "%s" directive; none found.' + % name, nodes.literal_block(block_text, block_text), line=lineno) + return [warning] + text = '\n'.join(content) + text_nodes, messages = state.inline_text(text, lineno) + node = node_class(text, '', *text_nodes, **options) + node.line = content_offset + 1 + return [node] + messages + def rubric(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): rubric_text = arguments[0] -- cgit v1.2.1 From aa44e1902eb28a2ddabc3b9f54fe62e1eb164c52 Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 19 Oct 2004 23:32:05 +0000 Subject: marked untranslated entries (all!) git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2724 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/zh_tw.py | 137 ++++++++++++++++---------------- 1 file changed, 69 insertions(+), 68 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/zh_tw.py b/docutils/parsers/rst/languages/zh_tw.py index faeeac54d..acddae237 100644 --- a/docutils/parsers/rst/languages/zh_tw.py +++ b/docutils/parsers/rst/languages/zh_tw.py @@ -19,79 +19,80 @@ __docformat__ = 'reStructuredText' directives = { # language-dependent: fixed - 'attention': 'attention', - 'caution': 'caution', - 'danger': 'danger', - 'error': 'error', - 'hint': 'hint', - 'important': 'important', - 'note': 'note', - 'tip': 'tip', - 'warning': 'warning', - 'admonition': 'admonition', - 'sidebar': 'sidebar', - 'topic': 'topic', - 'line-block': 'line-block', - 'parsed-literal': 'parsed-literal', - 'rubric': 'rubric', - 'epigraph': 'epigraph', - 'highlights': 'highlights', - 'pull-quote': 'pull-quote', - #'questions': 'questions', - 'table': 'table', - 'csv-table': 'csv-table', - #'qa': 'questions', - #'faq': 'questions', - 'meta': 'meta', - #'imagemap': 'imagemap', - 'image': 'image', - 'figure': 'figure', - 'include': 'include', - 'raw': 'raw', - 'replace': 'replace', - 'unicode': 'unicode', - 'class': 'class', - 'role': 'role', - 'contents': 'contents', - 'sectnum': 'sectnum', - 'section-numbering': 'sectnum', - #'footnotes': 'footnotes', - #'citations': 'citations', - 'target-notes': 'target-notes', + 'attention (translation required)': 'attention', + 'caution (translation required)': 'caution', + 'danger (translation required)': 'danger', + 'error (translation required)': 'error', + 'hint (translation required)': 'hint', + 'important (translation required)': 'important', + 'note (translation required)': 'note', + 'tip (translation required)': 'tip', + 'warning (translation required)': 'warning', + 'admonition (translation required)': 'admonition', + 'sidebar (translation required)': 'sidebar', + 'topic (translation required)': 'topic', + 'line-block (translation required)': 'line-block', + 'parsed-literal (translation required)': 'parsed-literal', + 'rubric (translation required)': 'rubric', + 'epigraph (translation required)': 'epigraph', + 'highlights (translation required)': 'highlights', + 'pull-quote (translation required)': 'pull-quote', + 'compound (translation required)': 'compound', + #'questions (translation required)': 'questions', + 'table (translation required)': 'table', + 'csv-table (translation required)': 'csv-table', + #'qa (translation required)': 'questions', + #'faq (translation required)': 'questions', + 'meta (translation required)': 'meta', + #'imagemap (translation required)': 'imagemap', + 'image (translation required)': 'image', + 'figure (translation required)': 'figure', + 'include (translation required)': 'include', + 'raw (translation required)': 'raw', + 'replace (translation required)': 'replace', + 'unicode (translation required)': 'unicode', + 'class (translation required)': 'class', + 'role (translation required)': 'role', + 'contents (translation required)': 'contents', + 'sectnum (translation required)': 'sectnum', + 'section-numbering (translation required)': 'sectnum', + #'footnotes (translation required)': 'footnotes', + #'citations (translation required)': 'citations', + 'target-notes (translation required)': 'target-notes', 'restructuredtext-test-directive': 'restructuredtext-test-directive'} """English name to registered (in directives/__init__.py) directive name mapping.""" roles = { # language-dependent: fixed - 'abbreviation': 'abbreviation', - 'ab': 'abbreviation', - 'acronym': 'acronym', - 'ac': 'acronym', - 'index': 'index', - 'i': 'index', - 'subscript': 'subscript', - 'sub': 'subscript', - 'superscript': 'superscript', - 'sup': 'superscript', - 'title-reference': 'title-reference', - 'title': 'title-reference', - 't': 'title-reference', - 'pep-reference': 'pep-reference', - 'pep': 'pep-reference', - 'rfc-reference': 'rfc-reference', - 'rfc': 'rfc-reference', - 'emphasis': 'emphasis', - 'strong': 'strong', - 'literal': 'literal', - 'named-reference': 'named-reference', - 'anonymous-reference': 'anonymous-reference', - 'footnote-reference': 'footnote-reference', - 'citation-reference': 'citation-reference', - 'substitution-reference': 'substitution-reference', - 'target': 'target', - 'uri-reference': 'uri-reference', - 'uri': 'uri-reference', - 'url': 'uri-reference',} + 'abbreviation (translation required)': 'abbreviation', + 'ab (translation required)': 'abbreviation', + 'acronym (translation required)': 'acronym', + 'ac (translation required)': 'acronym', + 'index (translation required)': 'index', + 'i (translation required)': 'index', + 'subscript (translation required)': 'subscript', + 'sub (translation required)': 'subscript', + 'superscript (translation required)': 'superscript', + 'sup (translation required)': 'superscript', + 'title-reference (translation required)': 'title-reference', + 'title (translation required)': 'title-reference', + 't (translation required)': 'title-reference', + 'pep-reference (translation required)': 'pep-reference', + 'pep (translation required)': 'pep-reference', + 'rfc-reference (translation required)': 'rfc-reference', + 'rfc (translation required)': 'rfc-reference', + 'emphasis (translation required)': 'emphasis', + 'strong (translation required)': 'strong', + 'literal (translation required)': 'literal', + 'named-reference (translation required)': 'named-reference', + 'anonymous-reference (translation required)': 'anonymous-reference', + 'footnote-reference (translation required)': 'footnote-reference', + 'citation-reference (translation required)': 'citation-reference', + 'substitution-reference (translation required)': 'substitution-reference', + 'target (translation required)': 'target', + 'uri-reference (translation required)': 'uri-reference', + 'uri (translation required)': 'uri-reference', + 'url (translation required)': 'uri-reference',} """Mapping of Traditional Chinese role names to canonical role names for interpreted text. """ -- cgit v1.2.1 From 3060e6fbba970093521688e7f665a2ef8e9214d6 Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 19 Oct 2004 23:36:31 +0000 Subject: Fixed directive parsing bug: argument-less directives didn't notice that arguments were present. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2725 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index cdc4258d1..0d6362b51 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -2038,6 +2038,9 @@ class Body(RSTState): if option_spec: options, arg_block = self.parse_directive_options( option_presets, option_spec, arg_block) + if arg_block and not argument_spec: + raise MarkupError('no arguments permitted; blank line ' + 'required before content block') if argument_spec: arguments = self.parse_directive_arguments( argument_spec, arg_block) -- cgit v1.2.1 From a5b30fef88ce1820207ff83afb790d71612573ca Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 19 Oct 2004 23:37:23 +0000 Subject: added "compound" directive git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2726 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/af.py | 1 + docutils/parsers/rst/languages/cs.py | 1 + docutils/parsers/rst/languages/de.py | 1 + docutils/parsers/rst/languages/en.py | 1 + docutils/parsers/rst/languages/eo.py | 1 + docutils/parsers/rst/languages/es.py | 1 + docutils/parsers/rst/languages/fi.py | 1 + docutils/parsers/rst/languages/fr.py | 1 + docutils/parsers/rst/languages/it.py | 1 + docutils/parsers/rst/languages/pt_br.py | 1 + docutils/parsers/rst/languages/ru.py | 1 + docutils/parsers/rst/languages/sk.py | 1 + docutils/parsers/rst/languages/sv.py | 1 + 13 files changed, 13 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/af.py b/docutils/parsers/rst/languages/af.py index 1c799127f..fda16ccba 100644 --- a/docutils/parsers/rst/languages/af.py +++ b/docutils/parsers/rst/languages/af.py @@ -36,6 +36,7 @@ directives = { 'epigraaf': 'epigraph', 'hoogtepunte': 'highlights', 'pull-quote (translation required)': 'pull-quote', + u'compound (translation required)': 'compound', #'vrae': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/cs.py b/docutils/parsers/rst/languages/cs.py index 111a476eb..1dbd0ca2b 100644 --- a/docutils/parsers/rst/languages/cs.py +++ b/docutils/parsers/rst/languages/cs.py @@ -37,6 +37,7 @@ directives = { u'moto': 'epigraph', u'highlights': 'highlights', u'pull-quote': 'pull-quote', + u'compound (translation required)': 'compound', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index d8dedffd2..8e6df7e92 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -37,6 +37,7 @@ directives = { 'epigraph': 'epigraph', 'highlights (translation required)': 'highlights', 'pull-quote (translation required)': 'pull-quote', # kasten too ? + 'compound (translation required)': 'compound', #'fragen': 'questions', 'tabelle': 'table', 'csv-tabelle': 'csv-table', diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index f45e104f9..cd69becad 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -37,6 +37,7 @@ directives = { 'epigraph': 'epigraph', 'highlights': 'highlights', 'pull-quote': 'pull-quote', + 'compound': 'compound', #'questions': 'questions', 'table': 'table', 'csv-table': 'csv-table', diff --git a/docutils/parsers/rst/languages/eo.py b/docutils/parsers/rst/languages/eo.py index 9f269decb..8c0f65d6e 100644 --- a/docutils/parsers/rst/languages/eo.py +++ b/docutils/parsers/rst/languages/eo.py @@ -40,6 +40,7 @@ directives = { u'elstara\u0135oj': 'highlights', u'ekstera-citajxo': 'pull-quote', u'ekstera-cita\u0135o': 'pull-quote', + u'compound (translation required)': 'compound', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index ce5a92a28..076efaa01 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -42,6 +42,7 @@ directives = { u'epigrafe': 'epigraph', u'destacado': 'highlights', u'cita-destacada': 'pull-quote', + u'compound (translation required)': 'compound', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/fi.py b/docutils/parsers/rst/languages/fi.py index 4ccdee84a..72530600c 100644 --- a/docutils/parsers/rst/languages/fi.py +++ b/docutils/parsers/rst/languages/fi.py @@ -39,6 +39,7 @@ directives = { u'lainaus': u'pull-quote', u'taulukko': u'table', u'csv-taulukko': u'csv-table', + u'compound (translation required)': 'compound', #u'kysymykset': u'questions', u'meta': u'meta', #u'kuvakartta': u'imagemap', diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index a104ae111..9518fb3d2 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -38,6 +38,7 @@ directives = { u'\u00E9pigraphe': 'epigraph', u'chapeau': 'highlights', u'accroche': 'pull-quote', + u'compound (translation required)': 'compound', #u'questions': 'questions', #u'qr': 'questions', #u'faq': 'questions', diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index 1f80e3bc8..e4aa04261 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -36,6 +36,7 @@ directives = { 'epigrafe': 'epigraph', 'evidenzia': 'highlights', 'pull-quote (translation required)': 'pull-quote', + 'compound (translation required)': 'compound', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/pt_br.py b/docutils/parsers/rst/languages/pt_br.py index 36005f344..66aa143c3 100644 --- a/docutils/parsers/rst/languages/pt_br.py +++ b/docutils/parsers/rst/languages/pt_br.py @@ -37,6 +37,7 @@ directives = { u'ep\u00EDgrafo': 'epigraph', 'destaques': 'highlights', u'cita\u00E7\u00E3o-destacada': 'pull-quote', + u'compound (translation required)': 'compound', #'perguntas': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/ru.py b/docutils/parsers/rst/languages/ru.py index ce0dc2b76..87deeebad 100644 --- a/docutils/parsers/rst/languages/ru.py +++ b/docutils/parsers/rst/languages/ru.py @@ -23,6 +23,7 @@ directives = { u'parsed-literal', u'\u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u0430\u044f-\u0446\u0438\u0442\u0430\u0442\u0430': u'pull-quote', + u'compound (translation required)': 'compound', u'table (translation required)': 'table', u'csv-table (translation required)': 'csv-table', u'\u0441\u044b\u0440\u043e\u0439': u'raw', diff --git a/docutils/parsers/rst/languages/sk.py b/docutils/parsers/rst/languages/sk.py index 1a508a851..2d637d984 100644 --- a/docutils/parsers/rst/languages/sk.py +++ b/docutils/parsers/rst/languages/sk.py @@ -36,6 +36,7 @@ directives = { u'epigraph (translation required)': 'epigraph', u'highlights (translation required)': 'highlights', u'pull-quote (translation required)': 'pull-quote', + u'compound (translation required)': 'compound', #u'questions': 'questions', #u'qa': 'questions', #u'faq': 'questions', diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index f4f8ee6a7..e014bc612 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -35,6 +35,7 @@ directives = { u'epigraph (translation required)': 'epigraph', u'highlights (translation required)': 'highlights', u'pull-quote (translation required)': 'pull-quote', + u'compound (translation required)': 'compound', # u'fr\u00e5gor': 'questions', # NOTE: A bit long, but recommended by http://www.nada.kth.se/dataterm/: # u'fr\u00e5gor-och-svar': 'questions', -- cgit v1.2.1 From 90c7498f0650fbbc5b375773a326e33e856d35cd Mon Sep 17 00:00:00 2001 From: richieadler Date: Wed, 20 Oct 2004 00:47:01 +0000 Subject: translation for the new "compound" directive git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2730 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/eo.py | 3 ++- docutils/parsers/rst/languages/es.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/eo.py b/docutils/parsers/rst/languages/eo.py index 8c0f65d6e..3e3c77c41 100644 --- a/docutils/parsers/rst/languages/eo.py +++ b/docutils/parsers/rst/languages/eo.py @@ -40,7 +40,8 @@ directives = { u'elstara\u0135oj': 'highlights', u'ekstera-citajxo': 'pull-quote', u'ekstera-cita\u0135o': 'pull-quote', - u'compound (translation required)': 'compound', + u'kombinajxo': 'compound', + u'kombina\u0135o': 'compound', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index 076efaa01..363e13516 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -42,7 +42,8 @@ directives = { u'epigrafe': 'epigraph', u'destacado': 'highlights', u'cita-destacada': 'pull-quote', - u'compound (translation required)': 'compound', + u'combinacion': 'compound', + u'combinaci\u00f3n': 'compound', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', -- cgit v1.2.1 From 54ce70ca93e577ba2bdddfb18bbae692cfdb57aa Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 20 Oct 2004 13:46:31 +0000 Subject: Added ``compound`` directive. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2732 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 1 + docutils/parsers/rst/directives/body.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index bd8f84e8a..828a830de 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -109,6 +109,7 @@ _directive_registry = { 'epigraph': ('body', 'epigraph'), 'highlights': ('body', 'highlights'), 'pull-quote': ('body', 'pull_quote'), + 'compound': ('body', 'compound'), #'questions': ('body', 'question_list'), 'table': ('tables', 'table'), 'csv-table': ('tables', 'csv_table'), diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index 9d40331ca..cfc3c04f4 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -144,3 +144,20 @@ def pull_quote(name, arguments, options, content, lineno, return [block_quote] + messages pull_quote.content = 1 + +def compound(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + text = '\n'.join(content) + if not text: + error = state_machine.reporter.error( + 'The "%s" directive is empty; content required.' % name, + nodes.literal_block(block_text, block_text), line=lineno) + return [error] + node = nodes.compound(text) + if options.has_key('class'): + node.set_class(options['class']) + state.nested_parse(content, content_offset, node) + return [node] + +compound.options = {'class': directives.class_option} +compound.content = 1 -- cgit v1.2.1 From 86949c4728d404a74dfdf0fedabde32ff9d751de Mon Sep 17 00:00:00 2001 From: wiemann Date: Wed, 20 Oct 2004 16:19:33 +0000 Subject: added German translation for "compound" git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2738 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/de.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index 8e6df7e92..5d7e6a006 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -37,7 +37,8 @@ directives = { 'epigraph': 'epigraph', 'highlights (translation required)': 'highlights', 'pull-quote (translation required)': 'pull-quote', # kasten too ? - 'compound (translation required)': 'compound', + 'zusammengesetzt': 'compound', + 'verbund': 'compound', #'fragen': 'questions', 'tabelle': 'table', 'csv-tabelle': 'csv-table', -- cgit v1.2.1 From d2995e5fff30d16439cae71a4f6aa3d173a92b7b Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 22 Oct 2004 01:51:28 +0000 Subject: fixed unwanted interaction of "class" directive and enumerated lists (start != 1) git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2761 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 0d6362b51..0f8bdcf83 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1215,13 +1215,13 @@ class Body(RSTState): format, sequence, text, ordinal = self.parse_enumerator(match) if not self.is_enumerated_list_item(ordinal, sequence, format): raise statemachine.TransitionCorrection('text') + enumlist = nodes.enumerated_list() + self.parent += enumlist if ordinal != 1: msg = self.reporter.info( 'Enumerated list start value not ordinal-1: "%s" (ordinal %s)' % (text, ordinal), line=self.state_machine.abs_line_number()) self.parent += msg - enumlist = nodes.enumerated_list() - self.parent += enumlist enumlist['enumtype'] = sequence if ordinal != 1: enumlist['start'] = ordinal -- cgit v1.2.1 From 51768bcfb012ab6819afb5f726043f29386e739f Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 22 Oct 2004 02:10:43 +0000 Subject: small simplification git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2762 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 0f8bdcf83..a1e34d5d1 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1217,16 +1217,15 @@ class Body(RSTState): raise statemachine.TransitionCorrection('text') enumlist = nodes.enumerated_list() self.parent += enumlist + enumlist['enumtype'] = sequence + enumlist['prefix'] = self.enum.formatinfo[format].prefix + enumlist['suffix'] = self.enum.formatinfo[format].suffix if ordinal != 1: + enumlist['start'] = ordinal msg = self.reporter.info( 'Enumerated list start value not ordinal-1: "%s" (ordinal %s)' % (text, ordinal), line=self.state_machine.abs_line_number()) self.parent += msg - enumlist['enumtype'] = sequence - if ordinal != 1: - enumlist['start'] = ordinal - enumlist['prefix'] = self.enum.formatinfo[format].prefix - enumlist['suffix'] = self.enum.formatinfo[format].suffix listitem, blank_finish = self.list_item(match.end()) enumlist += listitem offset = self.state_machine.line_offset + 1 # next line -- cgit v1.2.1 From 4513833b27e558a8837877231abb4ce8b886b37b Mon Sep 17 00:00:00 2001 From: wiemann Date: Mon, 25 Oct 2004 13:05:43 +0000 Subject: fixed documentation of RSTStateMachine.run() git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2768 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index a1e34d5d1..2c33cb081 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -144,11 +144,10 @@ class RSTStateMachine(StateMachineWS): def run(self, input_lines, document, input_offset=0, match_titles=1, inliner=None): """ - Parse `input_lines` and return a `docutils.nodes.document` instance. + Parse `input_lines` and modify the `document` node in place. - Extend `StateMachineWS.run()`: set up parse-global data, run the - StateMachine, and return the resulting - document. + Extend `StateMachineWS.run()`: set up parse-global data and + run the StateMachine. """ self.language = languages.get_language( document.settings.language_code) @@ -290,7 +289,7 @@ class RSTState(StateWS): state_machine_kwargs=None): """ Create a new StateMachine rooted at `node` and run it over the input - `block`. Also keep track of optional intermdediate blank lines and the + `block`. Also keep track of optional intermediate blank lines and the required final one. """ if state_machine_class is None: -- cgit v1.2.1 From 88a4789f802608b293da9f7be6af821103ab4222 Mon Sep 17 00:00:00 2001 From: wiemann Date: Sat, 30 Oct 2004 13:53:50 +0000 Subject: insert pending transition instead of real transition; removed error checking code git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2772 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 2c33cb081..b99687505 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -116,6 +116,7 @@ from docutils.nodes import fully_normalize_name as normalize_name from docutils.nodes import whitespace_normalize_name from docutils.parsers.rst import directives, languages, tableparser, roles from docutils.parsers.rst.languages import en as _fallback_language_module +from docutils.transforms.structural import Transition as TransitionTransform class MarkupError(DataError): pass @@ -403,16 +404,6 @@ class RSTState(StateWS): error = self.reporter.error( 'First element of section must be a title.', line=lineno) section.insert(0, error) - if isinstance(section[1], nodes.transition): - error = self.reporter.error( - 'Section may not begin with a transition.', - line=section[1].line) - section.insert(1, error) - if len(section) > 2 and isinstance(section[-1], nodes.transition): - error = self.reporter.error( - 'Section may not end with a transition.', - line=section[-1].line) - section += error def paragraph(self, lines, lineno): """ @@ -2748,13 +2739,11 @@ class Line(SpecializedText): self.state_correction(context) if self.eofcheck: # ignore EOFError with sections lineno = self.state_machine.abs_line_number() - 1 - transition = nodes.transition(context[0]) + transition = nodes.pending(TransitionTransform, + rawsource=context[0]) transition.line = lineno + self.document.note_pending(transition) self.parent += transition - msg = self.reporter.error( - 'Document or section may not end with a transition.', - line=lineno) - self.parent += msg self.eofcheck = 1 return [] @@ -2764,19 +2753,9 @@ class Line(SpecializedText): marker = context[0].strip() if len(marker) < 4: self.state_correction(context) - transition = nodes.transition(marker) + transition = nodes.pending(TransitionTransform, rawsource=marker) transition.line = lineno - if len(self.parent) == 0: - msg = self.reporter.error( - 'Document or section may not begin with a transition.', - line=lineno) - self.parent += msg - elif isinstance(self.parent[-1], nodes.transition): - msg = self.reporter.error( - 'At least one body element must separate transitions; ' - 'adjacent transitions not allowed.', - line=lineno) - self.parent += msg + self.document.note_pending(transition) self.parent += transition return [], 'Body', [] -- cgit v1.2.1 From 54bea9c700c038c02df30a191545eb1e4c686ebe Mon Sep 17 00:00:00 2001 From: wiemann Date: Sat, 30 Oct 2004 15:56:50 +0000 Subject: insert real transitions git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2780 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index b99687505..7d0b1bca2 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -116,7 +116,6 @@ from docutils.nodes import fully_normalize_name as normalize_name from docutils.nodes import whitespace_normalize_name from docutils.parsers.rst import directives, languages, tableparser, roles from docutils.parsers.rst.languages import en as _fallback_language_module -from docutils.transforms.structural import Transition as TransitionTransform class MarkupError(DataError): pass @@ -2739,10 +2738,8 @@ class Line(SpecializedText): self.state_correction(context) if self.eofcheck: # ignore EOFError with sections lineno = self.state_machine.abs_line_number() - 1 - transition = nodes.pending(TransitionTransform, - rawsource=context[0]) + transition = nodes.transition(rawsource=context[0]) transition.line = lineno - self.document.note_pending(transition) self.parent += transition self.eofcheck = 1 return [] @@ -2753,9 +2750,8 @@ class Line(SpecializedText): marker = context[0].strip() if len(marker) < 4: self.state_correction(context) - transition = nodes.pending(TransitionTransform, rawsource=marker) + transition = nodes.transition(rawsource=marker) transition.line = lineno - self.document.note_pending(transition) self.parent += transition return [], 'Body', [] -- cgit v1.2.1 From b3e9a23e50a601b58933870569c83a8aff859c5e Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 2 Nov 2004 22:14:14 +0000 Subject: Added "trim", "ltrim", and "rtrim" options to "unicode" directive. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2795 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index fc797e1eb..ee62f791b 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -177,7 +177,7 @@ def replace(name, arguments, options, content, lineno, replace.content = 1 def unicode_directive(name, arguments, options, content, lineno, - content_offset, block_text, state, state_machine): + content_offset, block_text, state, state_machine): r""" Convert Unicode character codes (numbers) to characters. Codes may be decimal numbers, hexadecimal numbers (prefixed by ``0x``, ``x``, ``\x``, @@ -191,6 +191,14 @@ def unicode_directive(name, arguments, options, content, lineno, 'substitution definition.' % (name), nodes.literal_block(block_text, block_text), line=lineno) return [error] + substitution_definition = state_machine.node + if options.has_key('trim'): + substitution_definition.attributes['ltrim'] = 1 + substitution_definition.attributes['rtrim'] = 1 + if options.has_key('ltrim'): + substitution_definition.attributes['ltrim'] = 1 + if options.has_key('rtrim'): + substitution_definition.attributes['rtrim'] = 1 codes = unicode_comment_pattern.split(arguments[0])[0].split() element = nodes.Element() for code in codes: @@ -206,6 +214,9 @@ def unicode_directive(name, arguments, options, content, lineno, return element.children unicode_directive.arguments = (1, 0, 1) +unicode_directive.options = {'trim': directives.flag, + 'ltrim': directives.flag, + 'rtrim': directives.flag} unicode_comment_pattern = re.compile(r'( |\n|^)\.\. ') def class_directive(name, arguments, options, content, lineno, -- cgit v1.2.1 From a6a2dd50bbaaea7412ef021329d7b3b518636583 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 3 Nov 2004 14:31:26 +0000 Subject: Enabled multiple format names for "raw" directive. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2799 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index ee62f791b..49f3fb498 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -73,7 +73,7 @@ def raw(name, arguments, options, content, lineno, Content may be included inline (content section of directive) or imported from a file or url. """ - attributes = {'format': arguments[0]} + attributes = {'format': ' '.join(arguments[0].lower().split())} encoding = options.get('encoding', state.document.settings.input_encoding) if content: if options.has_key('file') or options.has_key('url'): @@ -82,7 +82,7 @@ def raw(name, arguments, options, content, lineno, 'have content.' % name, nodes.literal_block(block_text, block_text), line=lineno) return [error] - text = '\n'.join(content) + text = '\n'.join(content) + '\n' elif options.has_key('file'): if options.has_key('url'): error = state_machine.reporter.error( -- cgit v1.2.1 From 097815228a511d2c7da47cf4c4d2141893556dcd Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 3 Nov 2004 20:11:11 +0000 Subject: Added support for multiple classifiers in definition list items. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2802 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 7d0b1bca2..874110a30 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -2657,8 +2657,10 @@ class Text(RSTState): self.nested_parse(indented, input_offset=line_offset, node=definition) return definitionlistitem, blank_finish + classifier_delimiter = re.compile(' +: +') + def term(self, lines, lineno): - """Return a definition_list's term and optional classifier.""" + """Return a definition_list's term and optional classifiers.""" assert len(lines) == 1 text_nodes, messages = self.inline_text(lines[0], lineno) term_node = nodes.term() @@ -2666,17 +2668,17 @@ class Text(RSTState): for i in range(len(text_nodes)): node = text_nodes[i] if isinstance(node, nodes.Text): - parts = node.rawsource.split(' : ', 1) + parts = self.classifier_delimiter.split(node.rawsource) if len(parts) == 1: - term_node += node + node_list[-1] += node else: - term_node += nodes.Text(parts[0].rstrip()) - classifier_node = nodes.classifier('', parts[1]) - classifier_node += text_nodes[i+1:] - node_list.append(classifier_node) - break + + node_list[-1] += nodes.Text(parts[0].rstrip()) + for part in parts[1:]: + classifier_node = nodes.classifier('', part) + node_list.append(classifier_node) else: - term_node += node + node_list[-1] += node return node_list, messages -- cgit v1.2.1 From ca40d84eba8e1ccfa232ea08c5d38d108d7238d9 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 6 Nov 2004 17:13:39 +0000 Subject: Allow multiple class names in the "class" directive. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2808 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 49f3fb498..ee718063c 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -225,21 +225,21 @@ def class_directive(name, arguments, options, content, lineno, Set a "class" attribute on the next element. A "pending" element is inserted, and a transform does the work later. """ - class_value = nodes.make_id(arguments[0]) - if class_value: - pending = nodes.pending(misc.ClassAttribute, - {'class': class_value, 'directive': name}, - block_text) - state_machine.document.note_pending(pending) - return [pending] - else: + try: + class_value = directives.class_option(arguments[0]) + except ValueError: error = state_machine.reporter.error( 'Invalid class attribute value for "%s" directive: "%s".' % (name, arguments[0]), nodes.literal_block(block_text, block_text), line=lineno) return [error] + pending = nodes.pending(misc.ClassAttribute, + {'class': class_value, 'directive': name}, + block_text) + state_machine.document.note_pending(pending) + return [pending] -class_directive.arguments = (1, 0, 0) +class_directive.arguments = (1, 0, 1) class_directive.content = 1 role_arg_pat = re.compile(r'(%s)\s*(\(\s*(%s)\s*\)\s*)?$' -- cgit v1.2.1 From b79ad0ee0ada6563707ed122aaea57c5e6a645d0 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 6 Nov 2004 17:13:58 +0000 Subject: Allow multiple class names in class_option conversion function git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2810 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 828a830de..7ef052053 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -272,7 +272,6 @@ def nonnegative_int(argument): raise ValueError('negative value; must be positive or zero') return value - def class_option(argument): """ Convert the argument into an ID-compatible string and return it. @@ -282,10 +281,14 @@ def class_option(argument): """ if argument is None: raise ValueError('argument required but none supplied') - class_name = nodes.make_id(argument) - if not class_name: - raise ValueError('cannot make "%s" into a class name' % argument) - return class_name + names = argument.split() + class_names = [] + for name in names: + class_name = nodes.make_id(name) + if not class_name: + raise ValueError('cannot make "%s" into a class name' % name) + class_names.append(class_name) + return ' '.join(class_names) unicode_pattern = re.compile( r'(?:0x|x|\\x|U\+?|\\u)([0-9a-f]+)$|&#x([0-9a-f]+);$', re.IGNORECASE) @@ -311,7 +314,6 @@ def unicode_code(code): except OverflowError, detail: raise ValueError('code too large (%s)' % detail) - def single_char_or_unicode(argument): char = unicode_code(argument) if len(char) > 1: -- cgit v1.2.1 From d74ca66c1c0d32c7447bfcd10c3c02ad9ea40123 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 6 Nov 2004 19:51:39 +0000 Subject: Added "raw" role git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2814 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/af.py | 3 +- docutils/parsers/rst/languages/cs.py | 59 +++++++++++++++++---------------- docutils/parsers/rst/languages/de.py | 3 +- docutils/parsers/rst/languages/en.py | 3 +- docutils/parsers/rst/languages/eo.py | 3 +- docutils/parsers/rst/languages/es.py | 4 +-- docutils/parsers/rst/languages/fi.py | 3 +- docutils/parsers/rst/languages/fr.py | 3 +- docutils/parsers/rst/languages/it.py | 3 +- docutils/parsers/rst/languages/pt_br.py | 5 +-- docutils/parsers/rst/languages/ru.py | 3 +- docutils/parsers/rst/languages/sk.py | 3 +- docutils/parsers/rst/languages/sv.py | 3 +- docutils/parsers/rst/languages/zh_tw.py | 3 +- 14 files changed, 57 insertions(+), 44 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/af.py b/docutils/parsers/rst/languages/af.py index fda16ccba..9c3b05633 100644 --- a/docutils/parsers/rst/languages/af.py +++ b/docutils/parsers/rst/languages/af.py @@ -91,6 +91,7 @@ roles = { 'teiken': 'target', 'uri-verwysing': 'uri-reference', 'uri': 'uri-reference', - 'url': 'uri-reference',} + 'url': 'uri-reference', + 'raw (translation required)': 'raw',} """Mapping of Afrikaans role names to canonical role names for interpreted text. """ diff --git a/docutils/parsers/rst/languages/cs.py b/docutils/parsers/rst/languages/cs.py index 1dbd0ca2b..61ab1a79a 100644 --- a/docutils/parsers/rst/languages/cs.py +++ b/docutils/parsers/rst/languages/cs.py @@ -65,34 +65,35 @@ mapping.""" roles = { # language-dependent: fixed - u'abbreviation': 'abbreviation', - u'ab': 'abbreviation', - u'acronym': 'acronym', - u'ac': 'acronym', - u'index': 'index', - u'i': 'index', - u'subscript': 'subscript', - u'sub': 'subscript', - u'superscript': 'superscript', - u'sup': 'superscript', - u'title-reference': 'title-reference', - u'title': 'title-reference', - u't': 'title-reference', - u'pep-reference': 'pep-reference', - u'pep': 'pep-reference', - u'rfc-reference': 'rfc-reference', - u'rfc': 'rfc-reference', - u'emphasis': 'emphasis', - u'strong': 'strong', - u'literal': 'literal', - u'named-reference': 'named-reference', - u'anonymous-reference': 'anonymous-reference', - u'footnote-reference': 'footnote-reference', - u'citation-reference': 'citation-reference', - u'substitution-reference': 'substitution-reference', - u'target': 'target', - u'uri-reference': 'uri-reference', - u'uri': 'uri-reference', - u'url': 'uri-reference',} + u'abbreviation (translation required)': 'abbreviation', + u'ab (translation required)': 'abbreviation', + u'acronym (translation required)': 'acronym', + u'ac (translation required)': 'acronym', + u'index (translation required)': 'index', + u'i (translation required)': 'index', + u'subscript (translation required)': 'subscript', + u'sub (translation required)': 'subscript', + u'superscript (translation required)': 'superscript', + u'sup (translation required)': 'superscript', + u'title-reference (translation required)': 'title-reference', + u'title (translation required)': 'title-reference', + u't (translation required)': 'title-reference', + u'pep-reference (translation required)': 'pep-reference', + u'pep (translation required)': 'pep-reference', + u'rfc-reference (translation required)': 'rfc-reference', + u'rfc (translation required)': 'rfc-reference', + u'emphasis (translation required)': 'emphasis', + u'strong (translation required)': 'strong', + u'literal (translation required)': 'literal', + u'named-reference (translation required)': 'named-reference', + u'anonymous-reference (translation required)': 'anonymous-reference', + u'footnote-reference (translation required)': 'footnote-reference', + u'citation-reference (translation required)': 'citation-reference', + u'substitution-reference (translation required)': 'substitution-reference', + u'target (translation required)': 'target', + u'uri-reference (translation required)': 'uri-reference', + u'uri (translation required)': 'uri-reference', + u'url (translation required)': 'uri-reference', + u'raw (translation required)': 'raw',} """Mapping of Czech role names to canonical role names for interpreted text. """ diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index 5d7e6a006..a8c215b3a 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -82,6 +82,7 @@ roles = { 'zitat-referenz': 'citation-reference', 'ersetzungs-referenz': 'substitution-reference', 'ziel': 'target', - 'uri-referenz': 'uri-reference',} + 'uri-referenz': 'uri-reference', + 'raw (translation required)': 'raw',} """Mapping of German role names to canonical role names for interpreted text. """ diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index cd69becad..5f83cd764 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -93,6 +93,7 @@ roles = { 'target': 'target', 'uri-reference': 'uri-reference', 'uri': 'uri-reference', - 'url': 'uri-reference',} + 'url': 'uri-reference', + 'raw': 'raw',} """Mapping of English role names to canonical role names for interpreted text. """ diff --git a/docutils/parsers/rst/languages/eo.py b/docutils/parsers/rst/languages/eo.py index 3e3c77c41..14a01d5f6 100644 --- a/docutils/parsers/rst/languages/eo.py +++ b/docutils/parsers/rst/languages/eo.py @@ -101,6 +101,7 @@ roles = { u'celo': 'target', u'uri-referenco': 'uri-reference', u'uri': 'uri-reference', - u'url': 'uri-reference',} + u'url': 'uri-reference', + u'raw (translation required)': 'raw',} """Mapping of Esperanto role names to canonical role names for interpreted text. """ diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index 363e13516..35fe17044 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -94,7 +94,7 @@ roles = { u'enfasis': 'emphasis', u'\u00e9nfasis': 'emphasis', u'destacado': 'strong', - u'literal': 'literal', + u'literal': 'literal', # translation required? u'referencia-con-nombre': 'named-reference', u'referencia-anonima': 'anonymous-reference', u'referencia-an\u00f3nima': 'anonymous-reference', @@ -106,6 +106,6 @@ roles = { u'referencia-uri': 'uri-reference', u'uri': 'uri-reference', u'url': 'uri-reference', - } + u'raw (translation required)': 'raw',} """Mapping of Spanish role names to canonical role names for interpreted text. """ diff --git a/docutils/parsers/rst/languages/fi.py b/docutils/parsers/rst/languages/fi.py index 72530600c..c03618fc3 100644 --- a/docutils/parsers/rst/languages/fi.py +++ b/docutils/parsers/rst/languages/fi.py @@ -82,6 +82,7 @@ roles = { u'citation-reference (translation required)': u'citation-reference', u'substitution-reference (translation required)': u'substitution-reference', u'kohde': u'target', - u'uri-reference (translation required)': u'uri-reference'} + u'uri-reference (translation required)': u'uri-reference', + u'raw (translation required)': 'raw',} """Mapping of Finnish role names to canonical role names for interpreted text. """ diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index 9518fb3d2..c43781179 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -88,6 +88,7 @@ roles = { u'citation-r\u00E9f\u00E9rence': 'citation-reference', u'substitution-r\u00E9f\u00E9rence': 'substitution-reference', u'lien': 'target', - u'uri-r\u00E9f\u00E9rence': 'uri-reference',} + u'uri-r\u00E9f\u00E9rence': 'uri-reference', + u'raw (translation required)': 'raw',} """Mapping of French role names to canonical role names for interpreted text. """ diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index e4aa04261..87a615e07 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -80,6 +80,7 @@ roles = { 'riferimento-citazione': 'citation-reference', 'riferimento-sostituzione': 'substitution-reference', 'destinazione': 'target', - 'riferimento-uri': 'uri-reference',} + 'riferimento-uri': 'uri-reference', + 'raw (translation required)': 'raw',} """Mapping of Italian role names to canonical role names for interpreted text. """ diff --git a/docutils/parsers/rst/languages/pt_br.py b/docutils/parsers/rst/languages/pt_br.py index 66aa143c3..ba60beb8e 100644 --- a/docutils/parsers/rst/languages/pt_br.py +++ b/docutils/parsers/rst/languages/pt_br.py @@ -84,7 +84,7 @@ roles = { 'rfc': 'rfc-reference', u'\u00EAnfase': 'emphasis', 'forte': 'strong', - 'literal': 'literal', + 'literal': 'literal', # translation required? u'refer\u00EAncia-por-nome': 'named-reference', u'refer\u00EAncia-an\u00F4nima': 'anonymous-reference', u'refer\u00EAncia-a-nota-de-rodap\u00E9': 'footnote-reference', @@ -93,6 +93,7 @@ roles = { 'alvo': 'target', u'refer\u00EAncia-a-uri': 'uri-reference', 'uri': 'uri-reference', - 'url': 'uri-reference',} + 'url': 'uri-reference', + 'raw (translation required)': 'raw',} """Mapping of Brazilian Portuguese role names to canonical role names for interpreted text.""" diff --git a/docutils/parsers/rst/languages/ru.py b/docutils/parsers/rst/languages/ru.py index 87deeebad..361565f62 100644 --- a/docutils/parsers/rst/languages/ru.py +++ b/docutils/parsers/rst/languages/ru.py @@ -92,6 +92,7 @@ roles = { 'footnote-reference', u'\u0446\u0438\u0442\u0430\u0442\u043d\u0430\u044f-\u0441\u0441\u044b\u043b\u043a\u0430': 'citation-reference', - u'\u0446\u0435\u043b\u044c': 'target'} + u'\u0446\u0435\u043b\u044c': 'target', + u'raw (translation required)': 'raw',} """Mapping of Russian role names to canonical role names for interpreted text. """ diff --git a/docutils/parsers/rst/languages/sk.py b/docutils/parsers/rst/languages/sk.py index 2d637d984..17d6b42d2 100644 --- a/docutils/parsers/rst/languages/sk.py +++ b/docutils/parsers/rst/languages/sk.py @@ -80,6 +80,7 @@ roles = { u'citation-reference (translation required)': 'citation-reference', u'substitution-reference (translation required)': 'substitution-reference', u'target (translation required)': 'target', - u'uri-reference (translation required)': 'uri-reference',} + u'uri-reference (translation required)': 'uri-reference', + u'raw (translation required)': 'raw',} """Mapping of Slovak role names to canonical role names for interpreted text. """ diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index e014bc612..404cac45a 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -79,6 +79,7 @@ roles = { u'citation-reference (translation required)': 'citation-reference', u'substitution-reference (translation required)': 'substitution-reference', u'target (translation required)': 'target', - u'uri-reference (translation required)': 'uri-reference',} + u'uri-reference (translation required)': 'uri-reference', + u'raw (translation required)': 'raw',} """Mapping of Swedish role names to canonical role names for interpreted text. """ diff --git a/docutils/parsers/rst/languages/zh_tw.py b/docutils/parsers/rst/languages/zh_tw.py index acddae237..b10a0a45a 100644 --- a/docutils/parsers/rst/languages/zh_tw.py +++ b/docutils/parsers/rst/languages/zh_tw.py @@ -93,6 +93,7 @@ roles = { 'target (translation required)': 'target', 'uri-reference (translation required)': 'uri-reference', 'uri (translation required)': 'uri-reference', - 'url (translation required)': 'uri-reference',} + 'url (translation required)': 'uri-reference', + 'raw (translation required)': 'raw',} """Mapping of Traditional Chinese role names to canonical role names for interpreted text. """ -- cgit v1.2.1 From a2458fbff98892912f8b2c1b0fb39ebe5cbcb646 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 6 Nov 2004 19:52:19 +0000 Subject: Changed role function API: the "text" parameter now takes null-escaped interpreted text content. Moved ``escape2null`` and ``unescape`` functions from to docutils/utils.py. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2816 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 874110a30..7de9165a8 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -114,6 +114,7 @@ from docutils import ApplicationError, DataError from docutils.statemachine import StateMachineWS, StateWS from docutils.nodes import fully_normalize_name as normalize_name from docutils.nodes import whitespace_normalize_name +from docutils.utils import escape2null, unescape from docutils.parsers.rst import directives, languages, tableparser, roles from docutils.parsers.rst.languages import en as _fallback_language_module @@ -758,7 +759,6 @@ class Inliner: role = endmatch.group('suffix')[1:-1] position = 'suffix' escaped = endmatch.string[:endmatch.start(1)] - text = unescape(escaped, 0) rawsource = unescape(string[matchstart:textend], 1) if rawsource[-1:] == '_': if role: @@ -769,10 +769,10 @@ class Inliner: prb = self.problematic(text, text, msg) return string[:rolestart], [prb], string[textend:], [msg] return self.phrase_ref(string[:matchstart], string[textend:], - rawsource, escaped, text) + rawsource, escaped, unescape(escaped)) else: rawsource = unescape(string[rolestart:textend], 1) - nodelist, messages = self.interpreted(rawsource, text, role, + nodelist, messages = self.interpreted(rawsource, escaped, role, lineno) return (string[:rolestart], nodelist, string[textend:], messages) @@ -2917,29 +2917,3 @@ state_classes = (Body, BulletList, DefinitionList, EnumeratedList, FieldList, OptionList, LineBlock, ExtensionOptions, Explicit, Text, Definition, Line, SubstitutionDef, RFC2822Body, RFC2822List) """Standard set of State classes used to start `RSTStateMachine`.""" - - -def escape2null(text): - """Return a string with escape-backslashes converted to nulls.""" - parts = [] - start = 0 - while 1: - found = text.find('\\', start) - if found == -1: - parts.append(text[start:]) - return ''.join(parts) - parts.append(text[start:found]) - parts.append('\x00' + text[found+1:found+2]) - start = found + 2 # skip character after escape - -def unescape(text, restore_backslashes=0): - """ - Return a string with nulls removed or restored to backslashes. - Backslash-escaped spaces are also removed. - """ - if restore_backslashes: - return text.replace('\x00', '\\') - else: - for sep in ['\x00 ', '\x00\n', '\x00']: - text = ''.join(text.split(sep)) - return text -- cgit v1.2.1 From 0a76dd265b7bdb27e65747a10a07d1a00259f857 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 6 Nov 2004 19:52:26 +0000 Subject: Added "raw" role. Changed role function API: the "text" parameter now takes null-escaped interpreted text content. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2817 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/roles.py | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/roles.py b/docutils/parsers/rst/roles.py index aff19f30c..2f3ab11a5 100644 --- a/docutils/parsers/rst/roles.py +++ b/docutils/parsers/rst/roles.py @@ -28,7 +28,8 @@ Parameters: Return it as a ``problematic`` node linked to a system message if there is a problem. -- ``text`` is the interpreted text content. +- ``text`` is the interpreted text content, with backslash escapes converted + to nulls (``\x00``). - ``lineno`` is the line number where the interpreted text beings. @@ -73,7 +74,7 @@ Interpreted role functions return a tuple of two values: __docformat__ = 'reStructuredText' -from docutils import nodes +from docutils import nodes, utils from docutils.parsers.rst import directives from docutils.parsers.rst.languages import en as _fallback_language_module @@ -194,7 +195,7 @@ class GenericRole: def __call__(self, role, rawtext, text, lineno, inliner, options={}, content=[]): - return [self.node_class(rawtext, text, **options)], [] + return [self.node_class(rawtext, utils.unescape(text), **options)], [] class CustomRole: @@ -232,7 +233,7 @@ def generic_custom_role(role, rawtext, text, lineno, inliner, """""" # Once nested inline markup is implemented, this and other methods should # recursively call inliner.nested_parse(). - return [nodes.inline(rawtext, text, **options)], [] + return [nodes.inline(rawtext, utils.unescape(text), **options)], [] generic_custom_role.options = {'class': directives.class_option} @@ -264,7 +265,8 @@ def pep_reference_role(role, rawtext, text, lineno, inliner, return [prb], [msg] # Base URL mainly used by inliner.pep_reference; so this is correct: ref = inliner.document.settings.pep_base_url + inliner.pep_url % pepnum - return [nodes.reference(rawtext, 'PEP ' + text, refuri=ref, **options)], [] + return [nodes.reference(rawtext, 'PEP ' + utils.unescape(text), refuri=ref, + **options)], [] register_canonical_role('pep-reference', pep_reference_role) @@ -282,11 +284,28 @@ def rfc_reference_role(role, rawtext, text, lineno, inliner, return [prb], [msg] # Base URL mainly used by inliner.rfc_reference, so this is correct: ref = inliner.document.settings.rfc_base_url + inliner.rfc_url % rfcnum - node = nodes.reference(rawtext, 'RFC ' + text, refuri=ref, **options) + node = nodes.reference(rawtext, 'RFC ' + utils.unescape(text), refuri=ref, + **options) return [node], [] register_canonical_role('rfc-reference', rfc_reference_role) +def raw_role(role, rawtext, text, lineno, inliner, options={}, content=[]): + if not options.has_key('format'): + msg = inliner.reporter.error( + 'No format (Writer name) is associated with this role: "%s".\n' + 'The "raw" role cannot be used directly.\n' + 'Instead, use the "role" directive to create a new role with ' + 'an associated format.' % role, line=lineno) + prb = inliner.problematic(rawtext, rawtext, msg) + return [prb], [msg] + node = nodes.raw(rawtext, utils.unescape(text, 1), **options) + return [node], [] + +raw_role.options = {'format': directives.class_option} + +register_canonical_role('raw', raw_role) + ###################################################################### # Register roles that are currently unimplemented. -- cgit v1.2.1 From a0bf43cf6055c71ebf22bf60e017ed72e0ce49ac Mon Sep 17 00:00:00 2001 From: richieadler Date: Sun, 7 Nov 2004 11:44:40 +0000 Subject: translation for the "raw" role git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2824 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/eo.py | 5 +++-- docutils/parsers/rst/languages/es.py | 9 ++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/eo.py b/docutils/parsers/rst/languages/eo.py index 14a01d5f6..0eada6bb5 100644 --- a/docutils/parsers/rst/languages/eo.py +++ b/docutils/parsers/rst/languages/eo.py @@ -53,7 +53,7 @@ directives = { u'bildo': 'image', u'figuro': 'figure', u'inkludi': 'include', - u'senformata': 'raw', + u'senanaliza': 'raw', u'anstatauxi': 'replace', u'anstata\u016di': 'replace', u'unicode': 'unicode', @@ -102,6 +102,7 @@ roles = { u'uri-referenco': 'uri-reference', u'uri': 'uri-reference', u'url': 'uri-reference', - u'raw (translation required)': 'raw',} + u'senanaliza': 'raw', +} """Mapping of Esperanto role names to canonical role names for interpreted text. """ diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index 35fe17044..e7a1cfd5c 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -55,7 +55,8 @@ directives = { u'imagen': 'image', u'figura': 'figure', u'incluir': 'include', - u'raw': 'raw', + u'sin-analisis': 'raw', + u'sin-an\u00e1lisis': 'raw', u'reemplazar': 'replace', u'unicode': 'unicode', u'clase': 'class', @@ -94,7 +95,7 @@ roles = { u'enfasis': 'emphasis', u'\u00e9nfasis': 'emphasis', u'destacado': 'strong', - u'literal': 'literal', # translation required? + u'literal': 'literal', # "literal" is also a word in Spanish :-) u'referencia-con-nombre': 'named-reference', u'referencia-anonima': 'anonymous-reference', u'referencia-an\u00f3nima': 'anonymous-reference', @@ -106,6 +107,8 @@ roles = { u'referencia-uri': 'uri-reference', u'uri': 'uri-reference', u'url': 'uri-reference', - u'raw (translation required)': 'raw',} + u'sin-analisis': 'raw', + u'sin-an\u00e1lisis': 'raw', +} """Mapping of Spanish role names to canonical role names for interpreted text. """ -- cgit v1.2.1 From 020a9519cd5b72b152ffe7a89d89b3040ee2451e Mon Sep 17 00:00:00 2001 From: wiemann Date: Sun, 7 Nov 2004 19:31:00 +0000 Subject: removed newline at end of raw text, because sometimes (when there are two consecutive newlines) the newline creates a new paragraph in LaTeX; added test git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2825 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index ee718063c..6f50bfd31 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -82,7 +82,7 @@ def raw(name, arguments, options, content, lineno, 'have content.' % name, nodes.literal_block(block_text, block_text), line=lineno) return [error] - text = '\n'.join(content) + '\n' + text = '\n'.join(content) elif options.has_key('file'): if options.has_key('url'): error = state_machine.reporter.error( -- cgit v1.2.1 From 4f7958de234a5d9443ec3c423a85c1087eaba030 Mon Sep 17 00:00:00 2001 From: wiemann Date: Sun, 7 Nov 2004 20:06:11 +0000 Subject: added German translations for "raw" and "literal" git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2826 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/de.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index a8c215b3a..31d012725 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -47,6 +47,7 @@ directives = { 'bild': 'image', 'abbildung': 'figure', u'unver\xe4ndert': 'raw', + u'roh': 'raw', u'einf\xfcgen': 'include', 'ersetzung': 'replace', 'ersetzen': 'replace', @@ -75,7 +76,7 @@ roles = { 'rfc-referenz': 'rfc-reference', 'betonung': 'emphasis', 'fett': 'strong', - 'literal (translation required)': 'literal', + u'w\xf6rtlich': 'literal', 'benannte-referenz': 'named-reference', 'unbenannte-referenz': 'anonymous-reference', u'fu\xdfnoten-referenz': 'footnote-reference', -- cgit v1.2.1 From 3cec404604dca055dd807bdb3ca65ff6b2f8b8d9 Mon Sep 17 00:00:00 2001 From: wiemann Date: Mon, 8 Nov 2004 14:51:49 +0000 Subject: added (translation required) git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2827 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/cs.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/cs.py b/docutils/parsers/rst/languages/cs.py index 61ab1a79a..5d14b353e 100644 --- a/docutils/parsers/rst/languages/cs.py +++ b/docutils/parsers/rst/languages/cs.py @@ -20,45 +20,45 @@ __docformat__ = 'reStructuredText' directives = { # language-dependent: fixed u'pozor': 'attention', - u'caution': 'caution', # jak rozlisit caution a warning? + u'caution (translation required)': 'caution', # jak rozlisit caution a warning? u'nebezpe\u010D\u00ED': 'danger', u'chyba': 'error', u'rada': 'hint', u'd\u016Fle\u017Eit\u00E9': 'important', u'pozn\u00E1mka': 'note', - u'tip': 'tip', + u'tip (translation required)': 'tip', u'varov\u00E1n\u00ED': 'warning', - u'admonition': 'admonition', - u'sidebar': 'sidebar', + u'admonition (translation required)': 'admonition', + u'sidebar (translation required)': 'sidebar', u't\u00E9ma': 'topic', - u'line-block': 'line-block', - u'parsed-literal': 'parsed-literal', + u'line-block (translation required)': 'line-block', + u'parsed-literal (translation required)': 'parsed-literal', u'odd\u00EDl': 'rubric', u'moto': 'epigraph', - u'highlights': 'highlights', - u'pull-quote': 'pull-quote', + u'highlights (translation required)': 'highlights', + u'pull-quote (translation required)': 'pull-quote', u'compound (translation required)': 'compound', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', u'table (translation required)': 'table', u'csv-table (translation required)': 'csv-table', - u'meta': 'meta', + u'meta (translation required)': 'meta', #'imagemap': 'imagemap', - u'image': 'image', # obrazek - u'figure': 'figure', # a tady? - u'include': 'include', - u'raw': 'raw', - u'replace': 'replace', - u'unicode': 'unicode', + u'image (translation required)': 'image', # obrazek + u'figure (translation required)': 'figure', # a tady? + u'include (translation required)': 'include', + u'raw (translation required)': 'raw', + u'replace (translation required)': 'replace', + u'unicode (translation required)': 'unicode', u't\u0159\u00EDda': 'class', u'role (translation required)': 'role', u'obsah': 'contents', - u'sectnum': 'sectnum', - u'section-numbering': 'sectnum', + u'sectnum (translation required)': 'sectnum', + u'section-numbering (translation required)': 'sectnum', #'footnotes': 'footnotes', #'citations': 'citations', - u'target-notes': 'target-notes', + u'target-notes (translation required)': 'target-notes', u'restructuredtext-test-directive': 'restructuredtext-test-directive'} """Czech name to registered (in directives/__init__.py) directive name mapping.""" -- cgit v1.2.1 From f791c2296a457a1df4e0cadb5104cbe9a74817e5 Mon Sep 17 00:00:00 2001 From: wiemann Date: Mon, 8 Nov 2004 14:58:04 +0000 Subject: added (translation required) git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2828 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/sk.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/sk.py b/docutils/parsers/rst/languages/sk.py index 17d6b42d2..13c72a1fd 100644 --- a/docutils/parsers/rst/languages/sk.py +++ b/docutils/parsers/rst/languages/sk.py @@ -25,7 +25,7 @@ directives = { u'rada': 'hint', u'd\xf4le\x9eit\xe9': 'important', u'pozn\xe1mka': 'note', - u'tip': 'tip', + u'tip (translation required)': 'tip', u'varovanie': 'warning', u'admonition (translation required)': 'admonition', u'sidebar (translation required)': 'sidebar', @@ -47,7 +47,7 @@ directives = { u'obr\xe1zok': 'image', u'tvar': 'figure', u'vlo\x9ei\x9d': 'include', - u'raw': 'raw', + u'raw (translation required)': 'raw', u'nahradi\x9d': 'replace', u'unicode': 'unicode', u'class (translation required)': 'class', -- cgit v1.2.1 From 1a3d835d5e2c9a5186f4769745508bc0fa062863 Mon Sep 17 00:00:00 2001 From: wiemann Date: Mon, 8 Nov 2004 14:59:32 +0000 Subject: inserted translation of raw directive as translation for raw role git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2829 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/af.py | 2 +- docutils/parsers/rst/languages/de.py | 3 ++- docutils/parsers/rst/languages/fr.py | 2 +- docutils/parsers/rst/languages/it.py | 2 +- docutils/parsers/rst/languages/pt_br.py | 2 +- docutils/parsers/rst/languages/sv.py | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/af.py b/docutils/parsers/rst/languages/af.py index 9c3b05633..26a9449bc 100644 --- a/docutils/parsers/rst/languages/af.py +++ b/docutils/parsers/rst/languages/af.py @@ -92,6 +92,6 @@ roles = { 'uri-verwysing': 'uri-reference', 'uri': 'uri-reference', 'url': 'uri-reference', - 'raw (translation required)': 'raw',} + 'rou': 'raw',} """Mapping of Afrikaans role names to canonical role names for interpreted text. """ diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index 31d012725..66ca1cb95 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -84,6 +84,7 @@ roles = { 'ersetzungs-referenz': 'substitution-reference', 'ziel': 'target', 'uri-referenz': 'uri-reference', - 'raw (translation required)': 'raw',} + u'unver\xe4ndert': 'raw', + u'roh': 'raw',} """Mapping of German role names to canonical role names for interpreted text. """ diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index c43781179..126abbf1e 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -89,6 +89,6 @@ roles = { u'substitution-r\u00E9f\u00E9rence': 'substitution-reference', u'lien': 'target', u'uri-r\u00E9f\u00E9rence': 'uri-reference', - u'raw (translation required)': 'raw',} + u'brut': 'raw',} """Mapping of French role names to canonical role names for interpreted text. """ diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index 87a615e07..365853fa2 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -81,6 +81,6 @@ roles = { 'riferimento-sostituzione': 'substitution-reference', 'destinazione': 'target', 'riferimento-uri': 'uri-reference', - 'raw (translation required)': 'raw',} + 'grezzo': 'raw',} """Mapping of Italian role names to canonical role names for interpreted text. """ diff --git a/docutils/parsers/rst/languages/pt_br.py b/docutils/parsers/rst/languages/pt_br.py index ba60beb8e..48abd5689 100644 --- a/docutils/parsers/rst/languages/pt_br.py +++ b/docutils/parsers/rst/languages/pt_br.py @@ -94,6 +94,6 @@ roles = { u'refer\u00EAncia-a-uri': 'uri-reference', 'uri': 'uri-reference', 'url': 'uri-reference', - 'raw (translation required)': 'raw',} + 'cru': 'raw',} """Mapping of Brazilian Portuguese role names to canonical role names for interpreted text.""" diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index 404cac45a..ba4407860 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -80,6 +80,6 @@ roles = { u'substitution-reference (translation required)': 'substitution-reference', u'target (translation required)': 'target', u'uri-reference (translation required)': 'uri-reference', - u'raw (translation required)': 'raw',} + u'r\u00e5': 'raw',} """Mapping of Swedish role names to canonical role names for interpreted text. """ -- cgit v1.2.1 From 3c9295317e8dc78cdf2de4e5ca4cd4da7ea39469 Mon Sep 17 00:00:00 2001 From: wiemann Date: Mon, 8 Nov 2004 15:01:40 +0000 Subject: typo; wrapped long lines git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2830 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/zh_tw.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/zh_tw.py b/docutils/parsers/rst/languages/zh_tw.py index b10a0a45a..c0f1632ff 100644 --- a/docutils/parsers/rst/languages/zh_tw.py +++ b/docutils/parsers/rst/languages/zh_tw.py @@ -60,8 +60,8 @@ directives = { #'citations (translation required)': 'citations', 'target-notes (translation required)': 'target-notes', 'restructuredtext-test-directive': 'restructuredtext-test-directive'} -"""English name to registered (in directives/__init__.py) directive name -mapping.""" +"""Traditional Chinese name to registered (in directives/__init__.py) +directive name mapping.""" roles = { # language-dependent: fixed @@ -95,5 +95,5 @@ roles = { 'uri (translation required)': 'uri-reference', 'url (translation required)': 'uri-reference', 'raw (translation required)': 'raw',} -"""Mapping of Traditional Chinese role names to canonical role names for interpreted text. -""" +"""Mapping of Traditional Chinese role names to canonical role names for +interpreted text.""" -- cgit v1.2.1 From a33879a926ba9d3beffcc35e5f8c45cb62e85ce4 Mon Sep 17 00:00:00 2001 From: wiemann Date: Fri, 26 Nov 2004 09:27:55 +0000 Subject: allow empty sections and documents git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2870 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 7de9165a8..b6954fe99 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -170,16 +170,8 @@ class RSTStateMachine(StateMachineWS): results = StateMachineWS.run(self, input_lines, input_offset, input_source=document['source']) assert results == [], 'RSTStateMachine.run() results should be empty!' - self.check_document() self.node = self.memo = None # remove unneeded references - def check_document(self): - """Check for illegal structure: empty document.""" - if len(self.document) == 0: - error = self.reporter.error( - 'Document empty; must have contents.', line=0) - self.document += error - class NestedStateMachine(StateMachineWS): @@ -384,27 +376,11 @@ class RSTState(StateWS): self.state_machine.input_lines[offset:], input_offset=absoffset, node=section_node, match_titles=1) self.goto_line(newabsoffset) - self.check_section(section_node) if memo.section_level <= mylevel: # can't handle next section? raise EOFError # bubble up to supersection # reset section_level; next pass will detect it properly memo.section_level = mylevel - def check_section(self, section): - """ - Check for illegal structure: empty section, misplaced transitions. - """ - lineno = section.line - if len(section) <= 1: - error = self.reporter.error( - 'Section empty; must have contents.', line=lineno) - section += error - return - if not isinstance(section[0], nodes.title): # shouldn't ever happen - error = self.reporter.error( - 'First element of section must be a title.', line=lineno) - section.insert(0, error) - def paragraph(self, lines, lineno): """ Return a list (paragraph & messages) & a boolean: literal_block next? -- cgit v1.2.1 From 36036fa24780fe111ff0ab42bf8e712e79fcda7e Mon Sep 17 00:00:00 2001 From: wiemann Date: Tue, 30 Nov 2004 19:58:52 +0000 Subject: fixed ("added") encoding support for raw and include directive (closes #1076183) thanks Julio Monteiro git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2876 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 6f50bfd31..d615f5540 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -61,7 +61,8 @@ def include(name, arguments, options, content, lineno, return [] include.arguments = (1, 0, 1) -include.options = {'literal': directives.flag} +include.options = {'literal': directives.flag, + 'encoding': directives.encoding} def raw(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): @@ -139,7 +140,8 @@ def raw(name, arguments, options, content, lineno, raw.arguments = (1, 0, 1) raw.options = {'file': directives.path, - 'url': directives.path} + 'url': directives.path, + 'encoding': directives.encoding} raw.content = 1 def replace(name, arguments, options, content, lineno, -- cgit v1.2.1 From ae854fe9e05524b51690889ae99e1565507ddfda Mon Sep 17 00:00:00 2001 From: wiemann Date: Thu, 13 Jan 2005 20:09:18 +0000 Subject: made email addresses escapable git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2935 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index b6954fe99..ddb2e5100 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -533,7 +533,7 @@ class Inliner: emailc = r"""[-_!~*'{|}/#?^`&=+$%a-zA-Z0-9\x00]""" email_pattern = r""" %(emailc)s+(?:\.%(emailc)s+)* # name - @ # at + (? Date: Thu, 20 Jan 2005 12:10:39 +0000 Subject: Translated newest directives git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2943 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/it.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index 365853fa2..127318d0a 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -4,10 +4,10 @@ # Date: $Date$ # Copyright: This module has been placed in the public domain. -# New language mappings are welcome. Before doing a new translation, please -# read . Two files must be -# translated for each language: one in docutils/languages, the other in -# docutils/parsers/rst/languages. +# Beware: the italian translation of the reStructuredText documentation +# at http://docit.bice.dyndns.org/static/ReST, in particular +# http://docit.bice.dyndns.org/static/ReST/ref/rst/directives.html, needs +# to be synced with the content of this file. """ Italian-language mappings for language-dependent features of @@ -34,14 +34,14 @@ directives = { 'blocco-interpretato': 'parsed-literal', 'rubrica': 'rubric', 'epigrafe': 'epigraph', - 'evidenzia': 'highlights', - 'pull-quote (translation required)': 'pull-quote', - 'compound (translation required)': 'compound', + 'punti-salienti': 'highlights', + 'estratto-evidenziato': 'pull-quote', + 'composito': 'compound', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', 'tabella': 'table', - 'csv-table (translation required)': 'csv-table', + 'tabella-csv': 'csv-table', 'meta': 'meta', #'imagemap': 'imagemap', 'immagine': 'image', @@ -53,6 +53,7 @@ directives = { 'classe': 'class', 'ruolo': 'role', 'indice': 'contents', + 'contenuti': 'contents', 'seznum': 'sectnum', 'sezioni-autonumerate': 'sectnum', 'annota-riferimenti-esterni': 'target-notes', -- cgit v1.2.1 From dd317b4e446e8c3666bf6e30e13ebf3a39e168f3 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 11 Feb 2005 15:49:20 +0000 Subject: Added "list-table" directive. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2963 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 1 + docutils/parsers/rst/directives/tables.py | 103 +++++++++++++++++++++++++++- docutils/parsers/rst/languages/af.py | 1 + docutils/parsers/rst/languages/cs.py | 1 + docutils/parsers/rst/languages/de.py | 1 + docutils/parsers/rst/languages/en.py | 1 + docutils/parsers/rst/languages/eo.py | 1 + docutils/parsers/rst/languages/es.py | 1 + docutils/parsers/rst/languages/fi.py | 1 + docutils/parsers/rst/languages/fr.py | 1 + docutils/parsers/rst/languages/it.py | 1 + docutils/parsers/rst/languages/pt_br.py | 1 + docutils/parsers/rst/languages/ru.py | 1 + docutils/parsers/rst/languages/sk.py | 1 + docutils/parsers/rst/languages/sv.py | 1 + docutils/parsers/rst/languages/zh_tw.py | 1 + 16 files changed, 117 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 7ef052053..adc43ffc2 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -113,6 +113,7 @@ _directive_registry = { #'questions': ('body', 'question_list'), 'table': ('tables', 'table'), 'csv-table': ('tables', 'csv_table'), + 'list-table': ('tables', 'list_table'), 'image': ('images', 'image'), 'figure': ('images', 'figure'), 'contents': ('parts', 'contents'), diff --git a/docutils/parsers/rst/directives/tables.py b/docutils/parsers/rst/directives/tables.py index 5b4cf8313..b0d633079 100644 --- a/docutils/parsers/rst/directives/tables.py +++ b/docutils/parsers/rst/directives/tables.py @@ -44,7 +44,6 @@ def table(name, arguments, options, content, lineno, return [warning] title, messages = make_title(arguments, state, lineno) node = nodes.Element() # anonymous container for parsing - text = '\n'.join(content) state.nested_parse(content, content_offset, node) if len(node) != 1 or not isinstance(node[0], nodes.table): error = state_machine.reporter.error( @@ -304,3 +303,105 @@ def extend_short_rows_with_empty_cells(columns, parts): for row in part: if len(row) < columns: row.extend([(0, 0, 0, [])] * (columns - len(row))) + +def list_table(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + """ + Implement tables whose data is encoded as a uniform two-level bullet list. + For further ideas, see + http://docutils.sf.net/docs/dev/rst/alternatives.html#list-driven-tables + """ + if not content: + error = state_machine.reporter.error( + 'The "%s" directive is empty; content required.' % name, + nodes.literal_block(block_text, block_text), line=lineno) + return [error] + title, messages = make_title(arguments, state, lineno) + node = nodes.Element() # anonymous container for parsing + state.nested_parse(content, content_offset, node) + try: + num_cols, col_widths = check_list_content( + node, name, options, content, lineno, block_text, state_machine) + table_data = [[item.children for item in row_list[0]] + for row_list in node[0]] + header_rows = options.get('header-rows', 0) # default 0 + check_table_dimensions( + table_data, header_rows, name, lineno, block_text, state_machine) + except SystemMessagePropagation, detail: + return [detail.args[0]] + table_node = build_table_from_list(table_data, col_widths, header_rows) + if options.has_key('class'): + table_node.set_class(options['class']) + if title: + table_node.insert(0, title) + return [table_node] + messages + +list_table.arguments = (0, 1, 1) +list_table.options = {'header-rows': directives.nonnegative_int, + 'widths': directives.positive_int_list, + 'class': directives.class_option} +list_table.content = 1 + +def check_list_content(node, name, options, content, lineno, block_text, + state_machine): + if len(node) != 1 or not isinstance(node[0], nodes.bullet_list): + error = state_machine.reporter.error( + 'Error parsing content block for the "%s" directive: ' + 'exactly one bullet list expected.' % name, + nodes.literal_block(block_text, block_text), line=lineno) + raise SystemMessagePropagation(error) + list_node = node[0] + # Check for a uniform two-level bullet list: + for item_index in range(len(list_node)): + item = list_node[item_index] + if len(item) != 1 or not isinstance(item[0], nodes.bullet_list): + error = state_machine.reporter.error( + 'Error parsing content block for the "%s" directive: ' + 'two-level bullet list expected, but row %s does not contain ' + 'a second-level bullet list.' % (name, item_index + 1), + nodes.literal_block(block_text, block_text), line=lineno) + raise SystemMessagePropagation(error) + elif item_index: + if len(item[0]) != num_cols: + error = state_machine.reporter.error( + 'Error parsing content block for the "%s" directive: ' + 'uniform two-level bullet list expected, but row %s does ' + 'not contain the same number of items as row 1 (%s vs %s).' + % (name, item_index + 1, len(item[0]), num_cols), + nodes.literal_block(block_text, block_text), line=lineno) + raise SystemMessagePropagation(error) + else: + num_cols = len(item[0]) + col_widths = get_column_widths( + num_cols, name, options, lineno, block_text, state_machine) + if len(col_widths) != num_cols: + error = state_machine.reporter.error( + 'Error parsing "widths" option of the "%s" directive: ' + 'number of columns does not match the table data (%s vs %s).' + % (name, len(col_widths), num_cols), + nodes.literal_block(block_text, block_text), line=lineno) + raise SystemMessagePropagation(error) + return num_cols, col_widths + +def build_table_from_list(table_data, col_widths, header_rows): + table = nodes.table() + tgroup = nodes.tgroup(cols=len(col_widths)) + table += tgroup + for col_width in col_widths: + tgroup += nodes.colspec(colwidth=col_width) + rows = [] + for row in table_data: + row_node = nodes.row() + for cell in row: + entry = nodes.entry() + entry += cell + row_node += entry + rows.append(row_node) + if header_rows: + thead = nodes.thead() + thead.extend(rows[:header_rows]) + tgroup += thead + tbody = nodes.tbody() + tbody.extend(rows[header_rows:]) + tgroup += tbody + return table diff --git a/docutils/parsers/rst/languages/af.py b/docutils/parsers/rst/languages/af.py index 26a9449bc..e3664f717 100644 --- a/docutils/parsers/rst/languages/af.py +++ b/docutils/parsers/rst/languages/af.py @@ -42,6 +42,7 @@ directives = { #'faq': 'questions', 'table (translation required)': 'table', 'csv-table (translation required)': 'csv-table', + 'list-table (translation required)': 'list-table', 'meta': 'meta', #'beeldkaart': 'imagemap', 'beeld': 'image', diff --git a/docutils/parsers/rst/languages/cs.py b/docutils/parsers/rst/languages/cs.py index 5d14b353e..af32e69d6 100644 --- a/docutils/parsers/rst/languages/cs.py +++ b/docutils/parsers/rst/languages/cs.py @@ -43,6 +43,7 @@ directives = { #'faq': 'questions', u'table (translation required)': 'table', u'csv-table (translation required)': 'csv-table', + u'list-table (translation required)': 'list-table', u'meta (translation required)': 'meta', #'imagemap': 'imagemap', u'image (translation required)': 'image', # obrazek diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index 66ca1cb95..8ea77485b 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -42,6 +42,7 @@ directives = { #'fragen': 'questions', 'tabelle': 'table', 'csv-tabelle': 'csv-table', + 'list-table (translation required)': 'list-table', 'meta': 'meta', #'imagemap': 'imagemap', 'bild': 'image', diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index 5f83cd764..dcd5b9584 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -41,6 +41,7 @@ directives = { #'questions': 'questions', 'table': 'table', 'csv-table': 'csv-table', + 'list-table': 'list-table', #'qa': 'questions', #'faq': 'questions', 'meta': 'meta', diff --git a/docutils/parsers/rst/languages/eo.py b/docutils/parsers/rst/languages/eo.py index 0eada6bb5..4065f88d4 100644 --- a/docutils/parsers/rst/languages/eo.py +++ b/docutils/parsers/rst/languages/eo.py @@ -48,6 +48,7 @@ directives = { u'tabelo': 'table', u'tabelo-vdk': 'csv-table', # "valoroj disigitaj per komoj" u'tabelo-csv': 'csv-table', + u'list-table (translation required)': 'list-table', u'meta': 'meta', #'imagemap': 'imagemap', u'bildo': 'image', diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index e7a1cfd5c..efd7ece08 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -50,6 +50,7 @@ directives = { u'tabla': 'table', u'tabla-vsc': 'csv-table', u'tabla-csv': 'csv-table', + u'list-table (translation required)': 'list-table', u'meta': 'meta', #'imagemap': 'imagemap', u'imagen': 'image', diff --git a/docutils/parsers/rst/languages/fi.py b/docutils/parsers/rst/languages/fi.py index c03618fc3..a718e7773 100644 --- a/docutils/parsers/rst/languages/fi.py +++ b/docutils/parsers/rst/languages/fi.py @@ -39,6 +39,7 @@ directives = { u'lainaus': u'pull-quote', u'taulukko': u'table', u'csv-taulukko': u'csv-table', + u'list-table (translation required)': 'list-table', u'compound (translation required)': 'compound', #u'kysymykset': u'questions', u'meta': u'meta', diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index 126abbf1e..26668ef09 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -44,6 +44,7 @@ directives = { #u'faq': 'questions', u'tableau': 'table', u'csv-table (translation required)': 'csv-table', + u'list-table (translation required)': 'list-table', u'm\u00E9ta': 'meta', #u'imagemap (translation required)': 'imagemap', u'image': 'image', diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index 127318d0a..4a7c15ad9 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -42,6 +42,7 @@ directives = { #'faq': 'questions', 'tabella': 'table', 'tabella-csv': 'csv-table', + 'list-table (translation required)': 'list-table', 'meta': 'meta', #'imagemap': 'imagemap', 'immagine': 'image', diff --git a/docutils/parsers/rst/languages/pt_br.py b/docutils/parsers/rst/languages/pt_br.py index 48abd5689..92801268b 100644 --- a/docutils/parsers/rst/languages/pt_br.py +++ b/docutils/parsers/rst/languages/pt_br.py @@ -43,6 +43,7 @@ directives = { #'faq': 'questions', u'table (translation required)': 'table', u'csv-table (translation required)': 'csv-table', + u'list-table (translation required)': 'list-table', 'meta': 'meta', #'imagemap': 'imagemap', 'imagem': 'image', diff --git a/docutils/parsers/rst/languages/ru.py b/docutils/parsers/rst/languages/ru.py index 361565f62..44363f5f1 100644 --- a/docutils/parsers/rst/languages/ru.py +++ b/docutils/parsers/rst/languages/ru.py @@ -26,6 +26,7 @@ directives = { u'compound (translation required)': 'compound', u'table (translation required)': 'table', u'csv-table (translation required)': 'csv-table', + u'list-table (translation required)': 'list-table', u'\u0441\u044b\u0440\u043e\u0439': u'raw', u'\u0437\u0430\u043c\u0435\u043d\u0430': u'replace', u'\u0442\u0435\u0441\u0442\u043e\u0432\u0430\u044f-\u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430-restructuredtext': diff --git a/docutils/parsers/rst/languages/sk.py b/docutils/parsers/rst/languages/sk.py index 13c72a1fd..fc1c54752 100644 --- a/docutils/parsers/rst/languages/sk.py +++ b/docutils/parsers/rst/languages/sk.py @@ -42,6 +42,7 @@ directives = { #u'faq': 'questions', u'table (translation required)': 'table', u'csv-table (translation required)': 'csv-table', + u'list-table (translation required)': 'list-table', u'meta': 'meta', #u'imagemap': 'imagemap', u'obr\xe1zok': 'image', diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index ba4407860..b64b7a57f 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -42,6 +42,7 @@ directives = { # u'vanliga-fr\u00e5gor': 'questions', u'table (translation required)': 'table', u'csv-table (translation required)': 'csv-table', + u'list-table (translation required)': 'list-table', u'meta': 'meta', # u'bildkarta': 'imagemap', # FIXME: Translation might be too literal. u'bild': 'image', diff --git a/docutils/parsers/rst/languages/zh_tw.py b/docutils/parsers/rst/languages/zh_tw.py index c0f1632ff..57c04eaaa 100644 --- a/docutils/parsers/rst/languages/zh_tw.py +++ b/docutils/parsers/rst/languages/zh_tw.py @@ -41,6 +41,7 @@ directives = { #'questions (translation required)': 'questions', 'table (translation required)': 'table', 'csv-table (translation required)': 'csv-table', + 'list-table (translation required)': 'list-table', #'qa (translation required)': 'questions', #'faq (translation required)': 'questions', 'meta (translation required)': 'meta', -- cgit v1.2.1 From 06ecc66a1e731e2d3cf4c0b4bedbd6353e3a8497 Mon Sep 17 00:00:00 2001 From: wiemann Date: Thu, 17 Feb 2005 14:39:07 +0000 Subject: typo git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2967 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index ddb2e5100..43a25b5ab 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1432,7 +1432,7 @@ class Body(RSTState): optlist.append(option) else: raise MarkupError( - 'wrong numer of option tokens (=%s), should be 1 or 2: ' + 'wrong number of option tokens (=%s), should be 1 or 2: ' '"%s"' % (len(tokens), optionstring), self.state_machine.abs_line_number() + 1) return optlist -- cgit v1.2.1 From 92b0917ae757987cc88daeefb777df3068c703f5 Mon Sep 17 00:00:00 2001 From: wiemann Date: Thu, 17 Feb 2005 14:50:10 +0000 Subject: allow option arguments in angle brackets to start with a non-alphanumeric character git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2969 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 43a25b5ab..b42d32a71 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1039,7 +1039,7 @@ class Body(RSTState): '|%(upperroman)s)' % enum.sequencepats) pats['optname'] = '%(alphanum)s%(alphanumplus)s*' % pats # @@@ Loosen up the pattern? Allow Unicode? - pats['optarg'] = '(%(alpha)s%(alphanumplus)s*|<%(alphanum)s[^ <>]+>)' % pats + pats['optarg'] = '(%(alpha)s%(alphanumplus)s*|<[^ <>]+>)' % pats pats['shortopt'] = r'(-|\+)%(alphanum)s( ?%(optarg)s)?' % pats pats['longopt'] = r'(--|/)%(optname)s([ =]%(optarg)s)?' % pats pats['option'] = r'(%(shortopt)s|%(longopt)s)' % pats -- cgit v1.2.1 From dbcbf302d825c92cd21ae2b163ad443c0f22ebc4 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 17 Feb 2005 16:26:15 +0000 Subject: Fixed "include" and "raw" directives to catch text decoding errors. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2973 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index d615f5540..c774eeef0 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -48,7 +48,14 @@ def include(name, arguments, options, content, lineno, % (name, error.__class__.__name__, error), nodes.literal_block(block_text, block_text), line=lineno) return [severe] - include_text = include_file.read() + try: + include_text = include_file.read() + except UnicodeError, error: + severe = state_machine.reporter.severe( + 'Problem with "%s" directive:\n%s: %s' + % (name, error.__class__.__name__, error), + nodes.literal_block(block_text, block_text), line=lineno) + return [severe] if options.has_key('literal'): literal_block = nodes.literal_block(include_text, include_text, source=path) @@ -106,7 +113,14 @@ def raw(name, arguments, options, content, lineno, 'Problems with "%s" directive path:\n%s.' % (name, error), nodes.literal_block(block_text, block_text), line=lineno) return [severe] - text = raw_file.read() + try: + text = raw_file.read() + except UnicodeError, error: + severe = state_machine.reporter.severe( + 'Problem with "%s" directive:\n%s: %s' + % (name, error.__class__.__name__, error), + nodes.literal_block(block_text, block_text), line=lineno) + return [severe] attributes['source'] = path elif options.has_key('url'): if not urllib2: @@ -128,7 +142,14 @@ def raw(name, arguments, options, content, lineno, raw_file = io.StringInput( source=raw_text, source_path=source, encoding=encoding, error_handler=state.document.settings.input_encoding_error_handler) - text = raw_file.read() + try: + text = raw_file.read() + except UnicodeError, error: + severe = state_machine.reporter.severe( + 'Problem with "%s" directive:\n%s: %s' + % (name, error.__class__.__name__, error), + nodes.literal_block(block_text, block_text), line=lineno) + return [severe] attributes['source'] = source else: error = state_machine.reporter.warning( -- cgit v1.2.1 From 6e59df17d0c4a53e5d5ced08f5ef58852bc66ec8 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 19 Feb 2005 01:23:10 +0000 Subject: Fixed option lists to allow spaces inside ````. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2975 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index b42d32a71..3427c4694 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1039,7 +1039,7 @@ class Body(RSTState): '|%(upperroman)s)' % enum.sequencepats) pats['optname'] = '%(alphanum)s%(alphanumplus)s*' % pats # @@@ Loosen up the pattern? Allow Unicode? - pats['optarg'] = '(%(alpha)s%(alphanumplus)s*|<[^ <>]+>)' % pats + pats['optarg'] = '(%(alpha)s%(alphanumplus)s*|<[^<>]+>)' % pats pats['shortopt'] = r'(-|\+)%(alphanum)s( ?%(optarg)s)?' % pats pats['longopt'] = r'(--|/)%(optname)s([ =]%(optarg)s)?' % pats pats['option'] = r'(%(shortopt)s|%(longopt)s)' % pats @@ -1415,14 +1415,20 @@ class Body(RSTState): delimiter = ' ' firstopt = tokens[0].split('=') if len(firstopt) > 1: + # "--opt=value" form tokens[:1] = firstopt delimiter = '=' elif (len(tokens[0]) > 2 and ((tokens[0].startswith('-') and not tokens[0].startswith('--')) or tokens[0].startswith('+'))): + # "-ovalue" form tokens[:1] = [tokens[0][:2], tokens[0][2:]] delimiter = '' + if len(tokens) > 1 and (tokens[1].startswith('<') + and tokens[-1].endswith('>')): + # "-o " form; join all values into one token + tokens[1:] = [' '.join(tokens[1:])] if 0 < len(tokens) <= 2: option = nodes.option(optionstring) option += nodes.option_string(tokens[0], tokens[0]) -- cgit v1.2.1 From 7d3cee3b8d94922de7bfac09fd09a051b26176b9 Mon Sep 17 00:00:00 2001 From: lele Date: Sun, 20 Feb 2005 17:06:35 +0000 Subject: New translation for 'list-table' git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2978 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/it.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index 4a7c15ad9..a04f98fa4 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -42,7 +42,7 @@ directives = { #'faq': 'questions', 'tabella': 'table', 'tabella-csv': 'csv-table', - 'list-table (translation required)': 'list-table', + 'tabella-elenco': 'list-table', 'meta': 'meta', #'imagemap': 'imagemap', 'immagine': 'image', -- cgit v1.2.1 From a3e14f83bb27fe386e91b58604f7cf77810793cf Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 22 Feb 2005 01:29:17 +0000 Subject: Caught empty CSV table bug git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2980 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/tables.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/tables.py b/docutils/parsers/rst/directives/tables.py index b0d633079..6940bc72f 100644 --- a/docutils/parsers/rst/directives/tables.py +++ b/docutils/parsers/rst/directives/tables.py @@ -294,8 +294,13 @@ def get_column_widths(max_cols, name, options, lineno, block_text, % (name, max_cols), nodes.literal_block(block_text, block_text), line=lineno) raise SystemMessagePropagation(error) - else: + elif max_cols: col_widths = [100 / max_cols] * max_cols + else: + error = state_machine.reporter.error( + 'No table data detected in CSV file.', + nodes.literal_block(block_text, block_text), line=lineno) + raise SystemMessagePropagation(error) return col_widths def extend_short_rows_with_empty_cells(columns, parts): -- cgit v1.2.1 From 6e194ab6b0f7b77f7c8edf53730f52bd8ce5f4a1 Mon Sep 17 00:00:00 2001 From: wiemann Date: Sun, 27 Feb 2005 01:00:59 +0000 Subject: when relocating a target, it now acquires the children of its new parent; fixed bug in recording internal targets so that anonymous targets are relocated as well git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@2996 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 3427c4694..f2c2d5144 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1857,6 +1857,8 @@ class Body(RSTState): else: # anonymous target if refuri: target['refuri'] = refuri + else: + self.document.note_internal_target(target) target['anonymous'] = 1 self.document.note_anonymous_target(target) -- cgit v1.2.1 From aa76cea304f331ad416e6f4623c2e5f00f995c58 Mon Sep 17 00:00:00 2001 From: wiemann Date: Fri, 4 Mar 2005 22:52:04 +0000 Subject: removed direct references to Element.children attribute outside nodes.py git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3004 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 2 +- docutils/parsers/rst/directives/misc.py | 4 ++-- docutils/parsers/rst/directives/tables.py | 2 +- docutils/parsers/rst/states.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index bf13b93e1..eac3d174c 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -97,7 +97,7 @@ def figure(name, arguments, options, content, lineno, first_node = node[0] if isinstance(first_node, nodes.paragraph): caption = nodes.caption(first_node.rawsource, '', - *first_node.children) + *first_node.get_children()) figure_node += caption elif not (isinstance(first_node, nodes.comment) and len(first_node) == 0): diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index c774eeef0..127ec2d42 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -190,7 +190,7 @@ def replace(name, arguments, options, content, lineno, messages.append(error) return messages else: - return element[0].children + return element[0].get_children() else: error = state_machine.reporter.error( 'The "%s" directive is empty; content required.' % (name), @@ -234,7 +234,7 @@ def unicode_directive(name, arguments, options, content, lineno, nodes.literal_block(block_text, block_text), line=lineno) return [error] element += nodes.Text(decoded) - return element.children + return element.get_children() unicode_directive.arguments = (1, 0, 1) unicode_directive.options = {'trim': directives.flag, diff --git a/docutils/parsers/rst/directives/tables.py b/docutils/parsers/rst/directives/tables.py index 6940bc72f..653499c20 100644 --- a/docutils/parsers/rst/directives/tables.py +++ b/docutils/parsers/rst/directives/tables.py @@ -327,7 +327,7 @@ def list_table(name, arguments, options, content, lineno, try: num_cols, col_widths = check_list_content( node, name, options, content, lineno, block_text, state_machine) - table_data = [[item.children for item in row_list[0]] + table_data = [[item.get_children() for item in row_list[0]] for row_list in node[0]] header_rows = options.get('header-rows', 0) # default 0 check_table_dimensions( diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index f2c2d5144..c4dff990a 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -2621,7 +2621,7 @@ class Text(RSTState): state_machine_kwargs={'state_classes': (QuotedLiteralBlock,), 'initial_state': 'QuotedLiteralBlock'}) self.goto_line(new_abs_offset) - return parent_node.children + return parent_node.get_children() def definition_list_item(self, termline): indented, indent, line_offset, blank_finish = \ -- cgit v1.2.1 From b17334d09de7211955e834b0243695d6cb637d84 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 5 Mar 2005 18:32:47 +0000 Subject: Allowed whitespace in paths and URLs (targets; "image", "figure", & "include" directive args; ":file:" & ":url:" directive options). git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3018 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 5 +---- docutils/parsers/rst/directives/images.py | 5 ----- docutils/parsers/rst/directives/misc.py | 5 ----- docutils/parsers/rst/states.py | 9 +-------- 4 files changed, 2 insertions(+), 22 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index adc43ffc2..4d45d72be 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -258,10 +258,7 @@ def path(argument): raise ValueError('argument required but none supplied') else: path = ''.join([s.strip() for s in argument.splitlines()]) - if path.find(' ') == -1: - return path - else: - raise ValueError('path contains whitespace') + return path def nonnegative_int(argument): """ diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index eac3d174c..e47315576 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -30,11 +30,6 @@ def image(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): messages = [] reference = ''.join(arguments[0].split('\n')) - if reference.find(' ') != -1: - error = state_machine.reporter.error( - 'Image URI contains whitespace.', - nodes.literal_block(block_text, block_text), line=lineno) - return [error] options['uri'] = reference reference_node = None if options.has_key('target'): diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 127ec2d42..c88ed0922 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -28,11 +28,6 @@ def include(name, arguments, options, content, lineno, lineno - state_machine.input_offset - 1) source_dir = os.path.dirname(os.path.abspath(source)) path = ''.join(arguments[0].splitlines()) - if path.find(' ') != -1: - error = state_machine.reporter.error( - '"%s" directive path contains whitespace.' % name, - nodes.literal_block(block_text, block_text), line=lineno) - return [error] path = os.path.normpath(os.path.join(source_dir, path)) path = utils.relative_path(None, path) encoding = options.get('encoding', state.document.settings.input_encoding) diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index c4dff990a..b9d257924 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1823,14 +1823,7 @@ class Body(RSTState): if refname: return 'refname', refname reference = ''.join([line.strip() for line in block]) - if reference.find(' ') == -1: - return 'refuri', unescape(reference) - else: - warning = self.reporter.warning( - 'Hyperlink target contains whitespace. Perhaps a footnote ' - 'was intended?', - nodes.literal_block(block_text, block_text), line=lineno) - return 'malformed', warning + return 'refuri', unescape(reference) def is_reference(self, reference): match = self.explicit.patterns.reference.match( -- cgit v1.2.1 From 43ca6a79125d28fce6c2ab2142f93733319382d4 Mon Sep 17 00:00:00 2001 From: wiemann Date: Mon, 14 Mar 2005 16:16:57 +0000 Subject: removed redundant get_children(); in case we want to change the behavior later, be can use __getattr__ or a descriptor; (the list is modified in place anyway, so there'd be not much to change about get_children) git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3038 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/html.py | 2 +- docutils/parsers/rst/directives/images.py | 2 +- docutils/parsers/rst/directives/misc.py | 4 ++-- docutils/parsers/rst/directives/tables.py | 2 +- docutils/parsers/rst/states.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/html.py b/docutils/parsers/rst/directives/html.py index a6e656994..86e19dcfc 100644 --- a/docutils/parsers/rst/directives/html.py +++ b/docutils/parsers/rst/directives/html.py @@ -34,7 +34,7 @@ def meta(name, arguments, options, content, lineno, 'Empty meta directive.', nodes.literal_block(block_text, block_text), line=lineno) node += error - return node.get_children() + return node.children meta.content = 1 diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index e47315576..32120cde8 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -92,7 +92,7 @@ def figure(name, arguments, options, content, lineno, first_node = node[0] if isinstance(first_node, nodes.paragraph): caption = nodes.caption(first_node.rawsource, '', - *first_node.get_children()) + *first_node.children) figure_node += caption elif not (isinstance(first_node, nodes.comment) and len(first_node) == 0): diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index c88ed0922..c5d26b3f1 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -185,7 +185,7 @@ def replace(name, arguments, options, content, lineno, messages.append(error) return messages else: - return element[0].get_children() + return element[0].children else: error = state_machine.reporter.error( 'The "%s" directive is empty; content required.' % (name), @@ -229,7 +229,7 @@ def unicode_directive(name, arguments, options, content, lineno, nodes.literal_block(block_text, block_text), line=lineno) return [error] element += nodes.Text(decoded) - return element.get_children() + return element.children unicode_directive.arguments = (1, 0, 1) unicode_directive.options = {'trim': directives.flag, diff --git a/docutils/parsers/rst/directives/tables.py b/docutils/parsers/rst/directives/tables.py index 653499c20..6940bc72f 100644 --- a/docutils/parsers/rst/directives/tables.py +++ b/docutils/parsers/rst/directives/tables.py @@ -327,7 +327,7 @@ def list_table(name, arguments, options, content, lineno, try: num_cols, col_widths = check_list_content( node, name, options, content, lineno, block_text, state_machine) - table_data = [[item.get_children() for item in row_list[0]] + table_data = [[item.children for item in row_list[0]] for row_list in node[0]] header_rows = options.get('header-rows', 0) # default 0 check_table_dimensions( diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index b9d257924..04713fbdc 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -2614,7 +2614,7 @@ class Text(RSTState): state_machine_kwargs={'state_classes': (QuotedLiteralBlock,), 'initial_state': 'QuotedLiteralBlock'}) self.goto_line(new_abs_offset) - return parent_node.get_children() + return parent_node.children def definition_list_item(self, termline): indented, indent, line_offset, blank_finish = \ -- cgit v1.2.1 From 2913454311795655ccd224ad249d5ff6a30301c6 Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 15 Mar 2005 00:33:59 +0000 Subject: Added "uri" directive option conversion function. Added docstrings & documentation. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3045 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 44 +++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 4d45d72be..b8207599f 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -251,8 +251,7 @@ def path(argument): Return the path argument unwrapped (with newlines removed). (Directive option conversion function.) - Raise ``ValueError`` if no argument is found or if the path contains - internal whitespace. + Raise ``ValueError`` if no argument is found. """ if argument is None: raise ValueError('argument required but none supplied') @@ -260,6 +259,19 @@ def path(argument): path = ''.join([s.strip() for s in argument.splitlines()]) return path +def uri(argument): + """ + Return the URI argument with whitespace removed. + (Directive option conversion function.) + + Raise ``ValueError`` if no argument is found. + """ + if argument is None: + raise ValueError('argument required but none supplied') + else: + uri = ''.join(argument.split()) + return uri + def nonnegative_int(argument): """ Check for a nonnegative integer argument; raise ``ValueError`` if not. @@ -294,10 +306,13 @@ unicode_pattern = re.compile( def unicode_code(code): r""" Convert a Unicode character code to a Unicode character. + (Directive option conversion function.) Codes may be decimal numbers, hexadecimal numbers (prefixed by ``0x``, ``x``, ``\x``, ``U+``, ``u``, or ``\u``; e.g. ``U+262E``), or XML-style numeric character entities (e.g. ``☮``). Other text remains as-is. + + Raise ValueError for illegal Unicode code values. """ try: if code.isdigit(): # decimal number @@ -313,6 +328,10 @@ def unicode_code(code): raise ValueError('code too large (%s)' % detail) def single_char_or_unicode(argument): + """ + A single character is returned as-is. Unicode characters codes are + converted as in `unicode_code`. (Directive option conversion function.) + """ char = unicode_code(argument) if len(char) > 1: raise ValueError('%r invalid; must be a single character or ' @@ -320,6 +339,10 @@ def single_char_or_unicode(argument): return char def single_char_or_whitespace_or_unicode(argument): + """ + As with `single_char_or_unicode`, but "tab" and "space" are also supported. + (Directive option conversion function.) + """ if argument == 'tab': char = '\t' elif argument == 'space': @@ -329,12 +352,23 @@ def single_char_or_whitespace_or_unicode(argument): return char def positive_int(argument): + """ + Converts the argument into an integer. Raises ValueError for negative, + zero, or non-integer values. (Directive option conversion function.) + """ value = int(argument) if value < 1: raise ValueError('negative or zero value; must be positive') return value def positive_int_list(argument): + """ + Converts a space- or comma-separated list of values into a Python list + of integers. + (Directive option conversion function.) + + Raises ValueError for non-positive-integer values. + """ if ',' in argument: entries = argument.split(',') else: @@ -342,6 +376,12 @@ def positive_int_list(argument): return [positive_int(entry) for entry in entries] def encoding(argument): + """ + Verfies the encoding argument by lookup. + (Directive option conversion function.) + + Raises ValueError for unknown encodings. + """ try: codecs.lookup(argument) except LookupError: -- cgit v1.2.1 From 0a938a279683da492acd6512d0af6fa636c5a51c Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 15 Mar 2005 00:37:51 +0000 Subject: differentiate between paths and URIs git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3046 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 2 +- docutils/parsers/rst/directives/misc.py | 4 ++-- docutils/parsers/rst/directives/tables.py | 2 +- docutils/parsers/rst/states.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index 32120cde8..765c14d61 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -29,7 +29,7 @@ def align(argument): def image(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): messages = [] - reference = ''.join(arguments[0].split('\n')) + reference = directives.uri(arguments[0]) options['uri'] = reference reference_node = None if options.has_key('target'): diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index c5d26b3f1..1ea4699f3 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -27,7 +27,7 @@ def include(name, arguments, options, content, lineno, source = state_machine.input_lines.source( lineno - state_machine.input_offset - 1) source_dir = os.path.dirname(os.path.abspath(source)) - path = ''.join(arguments[0].splitlines()) + path = directives.path(arguments[0]) path = os.path.normpath(os.path.join(source_dir, path)) path = utils.relative_path(None, path) encoding = options.get('encoding', state.document.settings.input_encoding) @@ -156,7 +156,7 @@ def raw(name, arguments, options, content, lineno, raw.arguments = (1, 0, 1) raw.options = {'file': directives.path, - 'url': directives.path, + 'url': directives.uri, 'encoding': directives.encoding} raw.content = 1 diff --git a/docutils/parsers/rst/directives/tables.py b/docutils/parsers/rst/directives/tables.py index 6940bc72f..116a2759f 100644 --- a/docutils/parsers/rst/directives/tables.py +++ b/docutils/parsers/rst/directives/tables.py @@ -152,7 +152,7 @@ csv_table.options = {'header-rows': directives.nonnegative_int, 'header': directives.unchanged, 'widths': directives.positive_int_list, 'file': directives.path, - 'url': directives.path, + 'url': directives.uri, 'encoding': directives.encoding, 'class': directives.class_option, # field delimiter char diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 04713fbdc..628a1b02c 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1822,7 +1822,7 @@ class Body(RSTState): refname = self.is_reference(reference) if refname: return 'refname', refname - reference = ''.join([line.strip() for line in block]) + reference = ''.join([''.join(line.split()) for line in block]) return 'refuri', unescape(reference) def is_reference(self, reference): -- cgit v1.2.1 From abb20e7fa0f5cc85164b9cd97d00493aacae213b Mon Sep 17 00:00:00 2001 From: wiemann Date: Fri, 18 Mar 2005 14:05:05 +0000 Subject: added Dutch translations; thanks to Martijn Pieters git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3056 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/nl.py | 105 +++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 docutils/parsers/rst/languages/nl.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/nl.py b/docutils/parsers/rst/languages/nl.py new file mode 100644 index 000000000..6840137df --- /dev/null +++ b/docutils/parsers/rst/languages/nl.py @@ -0,0 +1,105 @@ +# Author: Martijn Pieters +# Contact: mjpieters@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +# New language mappings are welcome. Before doing a new translation, please +# read . Two files must be +# translated for each language: one in docutils/languages, the other in +# docutils/parsers/rst/languages. + +""" +Dutch-language mappings for language-dependent features of +reStructuredText. +""" + +__docformat__ = 'reStructuredText' + + +directives = { + # language-dependent: fixed + 'attentie': 'attention', + 'waarschuwing': 'caution', + 'gevaar': 'danger', + 'fout': 'error', + 'hint': 'hint', + 'belangrijk': 'important', + 'opmerking': 'note', + 'tip': 'tip', + 'waarschuwing': 'warning', + 'aanmaning': 'admonition', + 'katern': 'sidebar', + 'onderwerp': 'topic', + 'lijn-blok': 'lijn-blok', + 'letterlijk-ontleed': 'parsed-literal', + 'rubriek': 'rubric', + 'opschrift': 'epigraph', + 'hoogtepunten': 'highlights', + 'pull-quote': 'pull-quote', # Dutch printers use the english term + 'samenstelling': 'compound', + 'verbinding': 'compound', + #'vragen': 'questions', + 'tabel': 'table', + 'csv-tabel': 'csv-table', + #'veelgestelde-vragen': 'questions', + 'meta': 'meta', + #'imagemap': 'imagemap', + 'beeld': 'image', + 'figuur': 'figure', + 'opnemen': 'include', + 'onbewerkt': 'raw', + 'letterlijk': 'raw', + 'vervang': 'replace', + 'vervanging': 'replace', + 'unicode': 'unicode', + 'klasse': 'class', + 'rol': 'role', + 'inhoud': 'contents', + 'sectnum': 'sectnum', + 'sectie-nummering': 'sectnum', + 'hoofdstuk-nummering': 'sectnum', + #'voetnoten': 'footnotes', + #'citaten': 'citations', + 'verwijzing-voetnoten': 'target-notes', + 'restructuredtext-test-instructie': 'restructuredtext-test-directive'} +"""Dutch name to registered (in directives/__init__.py) directive name +mapping.""" + +roles = { + # language-dependent: fixed + 'afkorting': 'abbreviation', + # 'ab': 'abbreviation', + 'acroniem': 'acronym', + 'ac': 'acronym', + 'index': 'index', + 'i': 'index', + 'inferieur': 'subscript', + 'inf': 'subscript', + 'superieur': 'superscript', + 'sup': 'superscript', + 'titel-referentie': 'title-reference', + 'titel': 'title-reference', + 't': 'title-reference', + 'pep-referentie': 'pep-reference', + 'pep': 'pep-reference', + 'rfc-referentie': 'rfc-reference', + 'rfc': 'rfc-reference', + 'nadruk': 'emphasis', + 'extra': 'strong', + 'extra-nadruk': 'strong', + 'vet': 'strong', + 'letterlijk': 'literal', + 'benoemde-referentie': 'named-reference', + 'anonieme-referentie': 'anonymous-reference', + 'voetnoot-referentie': 'footnote-reference', + 'citaat-referentie': 'citation-reference', + 'substitie-reference': 'substitution-reference', + 'verwijzing': 'target', + 'uri-referentie': 'uri-reference', + 'uri': 'uri-reference', + 'url': 'uri-reference', + 'letterlijk': 'raw', + 'onbewerkt': 'raw',} +"""Mapping of Dutch role names to canonical role names for interpreted text. +""" -- cgit v1.2.1 From c664df1b6f35351fb2d171c969b2ea433fe5e013 Mon Sep 17 00:00:00 2001 From: wiemann Date: Fri, 18 Mar 2005 20:09:22 +0000 Subject: applied some corrections for Dutch translations git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3058 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/nl.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/nl.py b/docutils/parsers/rst/languages/nl.py index 6840137df..fa6a1324a 100644 --- a/docutils/parsers/rst/languages/nl.py +++ b/docutils/parsers/rst/languages/nl.py @@ -20,7 +20,7 @@ __docformat__ = 'reStructuredText' directives = { # language-dependent: fixed 'attentie': 'attention', - 'waarschuwing': 'caution', + 'let-op': 'caution', 'gevaar': 'danger', 'fout': 'error', 'hint': 'hint', @@ -31,7 +31,7 @@ directives = { 'aanmaning': 'admonition', 'katern': 'sidebar', 'onderwerp': 'topic', - 'lijn-blok': 'lijn-blok', + 'lijn-blok': 'line-block', 'letterlijk-ontleed': 'parsed-literal', 'rubriek': 'rubric', 'opschrift': 'epigraph', @@ -42,6 +42,7 @@ directives = { #'vragen': 'questions', 'tabel': 'table', 'csv-tabel': 'csv-table', + 'lijst-tabel': 'list-table', #'veelgestelde-vragen': 'questions', 'meta': 'meta', #'imagemap': 'imagemap', @@ -49,7 +50,6 @@ directives = { 'figuur': 'figure', 'opnemen': 'include', 'onbewerkt': 'raw', - 'letterlijk': 'raw', 'vervang': 'replace', 'vervanging': 'replace', 'unicode': 'unicode', @@ -99,7 +99,6 @@ roles = { 'uri-referentie': 'uri-reference', 'uri': 'uri-reference', 'url': 'uri-reference', - 'letterlijk': 'raw', 'onbewerkt': 'raw',} """Mapping of Dutch role names to canonical role names for interpreted text. """ -- cgit v1.2.1 From d06b559d1082b9881e16d0278a65aca3b42ec5e2 Mon Sep 17 00:00:00 2001 From: goodger Date: Mon, 21 Mar 2005 21:26:21 +0000 Subject: Added settings: ``file_insertion_enabled`` & ``raw_enabled``. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3071 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/__init__.py | 18 +++++++++++++++++- docutils/parsers/rst/directives/misc.py | 12 ++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/__init__.py b/docutils/parsers/rst/__init__.py index 88795a830..8d7935be6 100644 --- a/docutils/parsers/rst/__init__.py +++ b/docutils/parsers/rst/__init__.py @@ -112,7 +112,23 @@ class Parser(docutils.parsers.Parser): ('Leave spaces before footnote references.', ['--leave-footnote-reference-space'], {'action': 'store_false', 'dest': 'trim_footnote_reference_space', - 'validator': frontend.validate_boolean}),)) + 'validator': frontend.validate_boolean}), + ('Disable directives that insert the contents of external file ' + '("include" & "raw"); replaced with a "warning" system message.', + ['--no-file-insertion'], + {'action': 'store_false', 'default': 1, + 'dest': 'file_insertion_enabled'}), + ('Enable directives that insert the contents of external file ' + '("include" & "raw"). Enabled by default.', + ['--file-insertion-enabled'], + {'action': 'store_true', 'dest': 'file_insertion_enabled'}), + ('Disable the "raw" directives; replaced with a "warning" ' + 'system message.', + ['--no-raw'], + {'action': 'store_false', 'default': 1, 'dest': 'raw_enabled'}), + ('Enable the "raw" directive. Enabled by default.', + ['--raw-enabled'], + {'action': 'store_true', 'dest': 'raw_enabled'}),)) config_section = 'restructuredtext parser' config_section_dependencies = ('parsers',) diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 1ea4699f3..1a6cbc17c 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -24,6 +24,11 @@ except ImportError: def include(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): """Include a reST file as part of the content of this reST file.""" + if not state.document.settings.file_insertion_enabled: + warning = state_machine.reporter.warning( + '"%s" directive disabled.' % name, + nodes.literal_block(block_text, block_text), line=lineno) + return [warning] source = state_machine.input_lines.source( lineno - state_machine.input_offset - 1) source_dir = os.path.dirname(os.path.abspath(source)) @@ -76,6 +81,13 @@ def raw(name, arguments, options, content, lineno, Content may be included inline (content section of directive) or imported from a file or url. """ + if ( not state.document.settings.raw_enabled + or (not state.document.settings.file_insertion_enabled + and (options.has_key('file') or options.has_key('url'))) ): + warning = state_machine.reporter.warning( + '"%s" directive disabled.' % name, + nodes.literal_block(block_text, block_text), line=lineno) + return [warning] attributes = {'format': ' '.join(arguments[0].lower().split())} encoding = options.get('encoding', state.document.settings.input_encoding) if content: -- cgit v1.2.1 From b559771f98c67ca07b71c41dd947c2be6df75fee Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 22 Mar 2005 19:18:06 +0000 Subject: added csv-table directive support for the file_insertion_enabled setting git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3083 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/tables.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/tables.py b/docutils/parsers/rst/directives/tables.py index 116a2759f..e47c9f9e4 100644 --- a/docutils/parsers/rst/directives/tables.py +++ b/docutils/parsers/rst/directives/tables.py @@ -115,6 +115,12 @@ if csv: def csv_table(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): try: + if ( not state.document.settings.file_insertion_enabled + and (options.has_key('file') or options.has_key('url')) ): + warning = state_machine.reporter.warning( + '"%s" directive disabled.' % name, + nodes.literal_block(block_text, block_text), line=lineno) + return [warning] check_requirements(name, lineno, block_text, state_machine) title, messages = make_title(arguments, state, lineno) csv_data, source = get_csv_data( @@ -205,7 +211,8 @@ def get_csv_data(name, options, content, lineno, block_text, state.document.settings.record_dependencies.add(source) csv_file = io.FileInput( source_path=source, encoding=encoding, - error_handler=state.document.settings.input_encoding_error_handler, + error_handler + =state.document.settings.input_encoding_error_handler, handle_io_errors=None) csv_data = csv_file.read().splitlines() except IOError, error: -- cgit v1.2.1 From 6adf9034472d079b9f0b9397a8c076e40b1f9ed9 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 24 Mar 2005 03:14:33 +0000 Subject: applied file_insertion_enabled setting to "figure" directive (disable "figwidth" option) git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3106 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index 765c14d61..d6ac5a0c9 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -73,7 +73,7 @@ def figure(name, arguments, options, content, lineno, return [image_node] figure_node = nodes.figure('', image_node) if figwidth == 'image': - if Image: + if Image and state.document.settings.file_insertion_enabled: # PIL doesn't like Unicode paths: try: i = Image.open(str(image_node['uri'])) -- cgit v1.2.1 From 7d76b140ee974b59e35f1f044949dc032630e15f Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 25 Mar 2005 03:02:32 +0000 Subject: added auto-enumerated list items git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3113 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 59 ++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 19 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 628a1b02c..34c206ed2 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1036,7 +1036,7 @@ class Body(RSTState): pats['alphanum'] = '[a-zA-Z0-9]' pats['alphanumplus'] = '[a-zA-Z0-9_-]' pats['enum'] = ('(%(arabic)s|%(loweralpha)s|%(upperalpha)s|%(lowerroman)s' - '|%(upperroman)s)' % enum.sequencepats) + '|%(upperroman)s|#)' % enum.sequencepats) pats['optname'] = '%(alphanum)s%(alphanumplus)s*' % pats # @@@ Loosen up the pattern? Allow Unicode? pats['optarg'] = '(%(alpha)s%(alphanumplus)s*|<[^<>]+>)' % pats @@ -1182,7 +1182,10 @@ class Body(RSTState): raise statemachine.TransitionCorrection('text') enumlist = nodes.enumerated_list() self.parent += enumlist - enumlist['enumtype'] = sequence + if sequence == '#': + enumlist['enumtype'] = 'arabic' + else: + enumlist['enumtype'] = sequence enumlist['prefix'] = self.enum.formatinfo[format].prefix enumlist['suffix'] = self.enum.formatinfo[format].suffix if ordinal != 1: @@ -1199,7 +1202,9 @@ class Body(RSTState): input_offset=self.state_machine.abs_line_offset() + 1, node=enumlist, initial_state='EnumeratedList', blank_finish=blank_finish, - extra_settings={'lastordinal': ordinal, 'format': format}) + extra_settings={'lastordinal': ordinal, + 'format': format, + 'auto': sequence == '#'}) self.goto_line(newline_offset) if not blank_finish: self.parent += self.unindent_warning('Enumerated list') @@ -1232,7 +1237,9 @@ class Body(RSTState): raise ParserError('enumerator format not matched') text = groupdict[format][self.enum.formatinfo[format].start :self.enum.formatinfo[format].end] - if expected_sequence: + if text == '#': + sequence = '#' + elif expected_sequence: try: if self.enum.sequenceregexps[expected_sequence].match(text): sequence = expected_sequence @@ -1249,10 +1256,13 @@ class Body(RSTState): break else: # shouldn't happen raise ParserError('enumerator sequence not matched') - try: - ordinal = self.enum.converters[sequence](text) - except roman.InvalidRomanNumeralError: - ordinal = None + if sequence == '#': + ordinal = 1 + else: + try: + ordinal = self.enum.converters[sequence](text) + except roman.InvalidRomanNumeralError: + ordinal = None return format, sequence, text, ordinal def is_enumerated_list_item(self, ordinal, sequence, format): @@ -1260,7 +1270,7 @@ class Body(RSTState): Check validity based on the ordinal value and the second line. Return true iff the ordinal is valid and the second line is blank, - indented, or starts with the next enumerator. + indented, or starts with the next enumerator or an auto-enumerator. """ if ordinal is None: return None @@ -1273,9 +1283,11 @@ class Body(RSTState): self.state_machine.previous_line() if not next_line[:1].strip(): # blank or indented return 1 - next_enumerator = self.make_enumerator(ordinal + 1, sequence, format) + next_enumerator, auto_enumerator = self.make_enumerator( + ordinal + 1, sequence, format) try: - if next_line.startswith(next_enumerator): + if ( next_line.startswith(next_enumerator) or + next_line.startswith(auto_enumerator) ): return 1 except TypeError: pass @@ -1283,11 +1295,14 @@ class Body(RSTState): def make_enumerator(self, ordinal, sequence, format): """ - Construct and return an enumerated list item marker. + Construct and return the next enumerated list item marker, and an + auto-enumerator ("#" instead of the regular enumerator). Return ``None`` for invalid (out of range) ordinals. - """ - if sequence == 'arabic': + """ #" + if sequence == '#': + enumerator = '#' + elif sequence == 'arabic': enumerator = str(ordinal) else: if sequence.endswith('alpha'): @@ -1310,7 +1325,10 @@ class Body(RSTState): raise ParserError('unknown enumerator sequence: "%s"' % sequence) formatinfo = self.enum.formatinfo[format] - return formatinfo.prefix + enumerator + formatinfo.suffix + ' ' + next_enumerator = (formatinfo.prefix + enumerator + formatinfo.suffix + + ' ') + auto_enumerator = formatinfo.prefix + '#' + formatinfo.suffix + ' ' + return next_enumerator, auto_enumerator def field_marker(self, match, context, next_state): """Field list item.""" @@ -2348,12 +2366,15 @@ class EnumeratedList(SpecializedBody): """Enumerated list item.""" format, sequence, text, ordinal = self.parse_enumerator( match, self.parent['enumtype']) - if (sequence != self.parent['enumtype'] or - format != self.format or - ordinal != (self.lastordinal + 1) or - not self.is_enumerated_list_item(ordinal, sequence, format)): + if ( format != self.format + or (sequence != '#' and (sequence != self.parent['enumtype'] + or self.auto + or ordinal != (self.lastordinal + 1))) + or not self.is_enumerated_list_item(ordinal, sequence, format)): # different enumeration: new list self.invalid_input() + if sequence == '#': + self.auto = 1 listitem, blank_finish = self.list_item(match.end()) self.parent += listitem self.blank_finish = blank_finish -- cgit v1.2.1 From 4df9fad485c1e12e850f9d7ff225d51c538af3dc Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 26 Mar 2005 01:04:09 +0000 Subject: fixed a bug that assumed text follows ".. _" git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3119 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 34c206ed2..ddf47df7f 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -2146,13 +2146,13 @@ class Body(RSTState): re.compile(r""" \.\.[ ]+ # explicit markup start _ # target indicator - (?![ ]) # first char. not space + (?![ ]|$) # first char. not space or EOL """, re.VERBOSE)), (substitution_def, re.compile(r""" \.\.[ ]+ # explicit markup start \| # substitution indicator - (?![ ]) # first char. not space + (?![ ]|$) # first char. not space or EOL """, re.VERBOSE)), (directive, re.compile(r""" -- cgit v1.2.1 From 9dbc2adead008935245a396eab10bb7bcb11b226 Mon Sep 17 00:00:00 2001 From: wiemann Date: Sat, 26 Mar 2005 16:21:28 +0000 Subject: merged rev. 3094:3101 and 3102:HEAD from branches/multiple-ids to trunk git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3129 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 4 ++-- docutils/parsers/rst/directives/misc.py | 3 +-- docutils/parsers/rst/directives/parts.py | 4 ++-- docutils/parsers/rst/roles.py | 18 +++++++++++++++++- docutils/parsers/rst/states.py | 19 +++++++++---------- 5 files changed, 31 insertions(+), 17 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index d6ac5a0c9..76d0d75eb 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -39,8 +39,8 @@ def image(name, arguments, options, content, lineno, if target_type == 'refuri': reference_node = nodes.reference(refuri=data) elif target_type == 'refname': - reference_node = nodes.reference( - refname=data, name=whitespace_normalize_name(options['target'])) + reference_node = nodes.reference(refname=data, + name=whitespace_normalize_name(options['target'])) state.document.note_refname(reference_node) else: # malformed target messages.append(data) # data is a system message diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 1a6cbc17c..7bae832d2 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -188,8 +188,7 @@ def replace(name, arguments, options, content, lineno, messages = [] for node in element: if isinstance(node, nodes.system_message): - if node.has_key('backrefs'): - del node['backrefs'] + node['backrefs'] = [] messages.append(node) error = state_machine.reporter.error( 'Error in "%s" directive: may contain a single paragraph ' diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py index c182ad0fd..217def5b6 100644 --- a/docutils/parsers/rst/directives/parts.py +++ b/docutils/parsers/rst/directives/parts.py @@ -41,7 +41,7 @@ def contents(name, arguments, options, content, lineno, else: title = nodes.title('', language.labels['contents']) - topic = nodes.topic(CLASS='contents') + topic = nodes.topic(classes=['contents']) cls = options.get('class') if cls: @@ -55,7 +55,7 @@ def contents(name, arguments, options, content, lineno, name = nodes.fully_normalize_name(name) if not document.has_name(name): - topic['name'] = name + topic['names'].append(name) document.note_implicit_target(topic) pending = nodes.pending(parts.Contents, rawsource=block_text) diff --git a/docutils/parsers/rst/roles.py b/docutils/parsers/rst/roles.py index 2f3ab11a5..cf6d5a971 100644 --- a/docutils/parsers/rst/roles.py +++ b/docutils/parsers/rst/roles.py @@ -174,7 +174,7 @@ def set_implicit_options(role_fn): if not hasattr(role_fn, 'options') or role_fn.options is None: role_fn.options = {'class': directives.class_option} elif not role_fn.options.has_key('class'): - role_fn.options['class'] = directives.class_option + role_fn.options['class'] = directives.class_option def register_generic_role(canonical_name, node_class): """For roles which simply wrap a given `node_class` around the text.""" @@ -195,6 +195,7 @@ class GenericRole: def __call__(self, role, rawtext, text, lineno, inliner, options={}, content=[]): + set_classes(options) return [self.node_class(rawtext, utils.unescape(text), **options)], [] @@ -233,6 +234,7 @@ def generic_custom_role(role, rawtext, text, lineno, inliner, """""" # Once nested inline markup is implemented, this and other methods should # recursively call inliner.nested_parse(). + set_classes(options) return [nodes.inline(rawtext, utils.unescape(text), **options)], [] generic_custom_role.options = {'class': directives.class_option} @@ -265,6 +267,7 @@ def pep_reference_role(role, rawtext, text, lineno, inliner, return [prb], [msg] # Base URL mainly used by inliner.pep_reference; so this is correct: ref = inliner.document.settings.pep_base_url + inliner.pep_url % pepnum + set_classes(options) return [nodes.reference(rawtext, 'PEP ' + utils.unescape(text), refuri=ref, **options)], [] @@ -284,6 +287,7 @@ def rfc_reference_role(role, rawtext, text, lineno, inliner, return [prb], [msg] # Base URL mainly used by inliner.rfc_reference, so this is correct: ref = inliner.document.settings.rfc_base_url + inliner.rfc_url % rfcnum + set_classes(options) node = nodes.reference(rawtext, 'RFC ' + utils.unescape(text), refuri=ref, **options) return [node], [] @@ -299,6 +303,7 @@ def raw_role(role, rawtext, text, lineno, inliner, options={}, content=[]): 'an associated format.' % role, line=lineno) prb = inliner.problematic(rawtext, rawtext, msg) return [prb], [msg] + set_classes(options) node = nodes.raw(rawtext, utils.unescape(text, 1), **options) return [node], [] @@ -329,3 +334,14 @@ register_canonical_role('target', unimplemented_role) # This should remain unimplemented, for testing purposes: register_canonical_role('restructuredtext-unimplemented-role', unimplemented_role) + + +def set_classes(options): + """ + Auxiliary function to set options['classes'] and delete + options['class']. + """ + if options.has_key('class'): + assert not options.has_key('classes') + options['classes'] = options['class'].split() + del options['class'] diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index ddf47df7f..a44f47027 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -365,7 +365,7 @@ class RSTState(StateWS): textnodes, title_messages = self.inline_text(title, lineno) titlenode = nodes.title(title, '', *textnodes) name = normalize_name(titlenode.astext()) - section_node['name'] = name + section_node['names'].append(name) section_node += titlenode section_node += messages section_node += title_messages @@ -787,7 +787,7 @@ class Inliner: else: if target: reference['refuri'] = uri - target['name'] = refname + target['names'].append(refname) self.document.note_external_target(target) self.document.note_explicit_target(target, self.parent) node_list.append(target) @@ -829,7 +829,7 @@ class Inliner: assert len(inlines) == 1 target = inlines[0] name = normalize_name(target.astext()) - target['name'] = name + target['names'].append(name) self.document.note_explicit_target(target, self.parent) return before, inlines, remaining, sysmessages @@ -1751,7 +1751,7 @@ class Body(RSTState): name = name[1:] # autonumber label footnote['auto'] = 1 if name: - footnote['name'] = name + footnote['names'].append(name) self.document.note_autofootnote(footnote) elif name == '*': # auto-symbol name = '' @@ -1759,7 +1759,7 @@ class Body(RSTState): self.document.note_symbol_footnote(footnote) else: # manually numbered footnote += nodes.label('', label) - footnote['name'] = name + footnote['names'].append(name) self.document.note_footnote(footnote) if name: self.document.note_explicit_target(footnote, footnote) @@ -1778,7 +1778,7 @@ class Body(RSTState): citation = nodes.citation('\n'.join(indented)) citation.line = lineno citation += nodes.label('', label) - citation['name'] = name + citation['names'].append(name) self.document.note_citation(citation) self.document.note_explicit_target(citation, citation) if indented: @@ -1814,7 +1814,6 @@ class Body(RSTState): target_type, data = self.parse_target(block, block_text, lineno) if target_type == 'refname': target = nodes.target(block_text, '', refname=normalize_name(data)) - target.indirect_reference_name = data self.add_target(target_name, '', target, lineno) self.document.note_indirect_target(target) return target @@ -1854,7 +1853,7 @@ class Body(RSTState): target.line = lineno if targetname: name = normalize_name(unescape(targetname)) - target['name'] = name + target['names'].append(name) if refuri: uri = self.inliner.adjust_uri(refuri) if uri: @@ -2259,7 +2258,7 @@ class RFC2822Body(Body): def rfc2822(self, match, context, next_state): """RFC2822-style field list item.""" - fieldlist = nodes.field_list(CLASS='rfc2822') + fieldlist = nodes.field_list(classes=['rfc2822']) self.parent += fieldlist field, blank_finish = self.rfc2822_field(match) fieldlist += field @@ -2497,7 +2496,7 @@ class SubstitutionDef(Body): def embedded_directive(self, match, context, next_state): nodelist, blank_finish = self.directive(match, - alt=self.parent['name']) + alt=self.parent['names'][0]) self.parent += nodelist if not self.state_machine.at_eof(): self.blank_finish = blank_finish -- cgit v1.2.1 From 232e7e218a2c4b14569bd11890ad26ab2d5cb76c Mon Sep 17 00:00:00 2001 From: wiemann Date: Sat, 2 Apr 2005 21:57:06 +0000 Subject: removed nodes.Element.set_class() method; directives.class_option now returns a *list* of classes; added test for :figclass: option of figure directive; the raw role's :format: option is now "unchanged", not "class_option"; some fixes: the :class: option should now always be propagated correctly from directives git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3155 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 4 ++-- docutils/parsers/rst/directives/admonitions.py | 6 +++--- docutils/parsers/rst/directives/body.py | 16 ++++++++-------- docutils/parsers/rst/directives/images.py | 8 +++++--- docutils/parsers/rst/directives/parts.py | 4 +--- docutils/parsers/rst/directives/tables.py | 9 +++------ docutils/parsers/rst/roles.py | 4 ++-- 7 files changed, 24 insertions(+), 27 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index b8207599f..05f552edd 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -284,7 +284,7 @@ def nonnegative_int(argument): def class_option(argument): """ - Convert the argument into an ID-compatible string and return it. + Convert the argument into a list of ID-compatible strings and return it. (Directive option conversion function.) Raise ``ValueError`` if no argument is found. @@ -298,7 +298,7 @@ def class_option(argument): if not class_name: raise ValueError('cannot make "%s" into a class name' % name) class_names.append(class_name) - return ' '.join(class_names) + return class_names unicode_pattern = re.compile( r'(?:0x|x|\\x|U\+?|\\u)([0-9a-f]+)$|&#x([0-9a-f]+);$', re.IGNORECASE) diff --git a/docutils/parsers/rst/directives/admonitions.py b/docutils/parsers/rst/directives/admonitions.py index 8e3a92895..73ca18161 100644 --- a/docutils/parsers/rst/directives/admonitions.py +++ b/docutils/parsers/rst/directives/admonitions.py @@ -30,10 +30,10 @@ def make_admonition(node_class, name, arguments, options, content, lineno, admonition_node += nodes.title(title_text, '', *textnodes) admonition_node += messages if options.has_key('class'): - class_value = options['class'] + classes = options['class'] else: - class_value = 'admonition-' + nodes.make_id(title_text) - admonition_node.set_class(class_value) + classes = ['admonition-' + nodes.make_id(title_text)] + admonition_node['classes'] += classes state.nested_parse(content, content_offset, admonition_node) return [admonition_node] diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index cfc3c04f4..117311720 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -16,6 +16,7 @@ __docformat__ = 'reStructuredText' import sys from docutils import nodes from docutils.parsers.rst import directives +from docutils.parsers.rst.roles import set_classes def topic(name, arguments, options, content, lineno, @@ -44,8 +45,7 @@ def topic(name, arguments, options, content, lineno, messages.extend(more_messages) text = '\n'.join(content) node = node_class(text, *(titles + messages)) - if options.has_key('class'): - node.set_class(options['class']) + node['classes'] += options.get('class', []) if text: state.nested_parse(content, content_offset, node) return [node] @@ -72,7 +72,7 @@ def line_block(name, arguments, options, content, lineno, 'Content block expected for the "%s" directive; none found.' % name, nodes.literal_block(block_text, block_text), line=lineno) return [warning] - block = nodes.line_block() + block = nodes.line_block(classes=options.get('class', [])) node_list = [block] for line_text in content: text_nodes, messages = state.inline_text(line_text.strip(), @@ -91,6 +91,7 @@ line_block.content = 1 def parsed_literal(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): + set_classes(options) return block(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine, node_class=nodes.literal_block) @@ -124,7 +125,7 @@ rubric.options = {'class': directives.class_option} def epigraph(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): block_quote, messages = state.block_quote(content, content_offset) - block_quote.set_class('epigraph') + block_quote['classes'].append('epigraph') return [block_quote] + messages epigraph.content = 1 @@ -132,7 +133,7 @@ epigraph.content = 1 def highlights(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): block_quote, messages = state.block_quote(content, content_offset) - block_quote.set_class('highlights') + block_quote['classes'].append('highlights') return [block_quote] + messages highlights.content = 1 @@ -140,7 +141,7 @@ highlights.content = 1 def pull_quote(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): block_quote, messages = state.block_quote(content, content_offset) - block_quote.set_class('pull-quote') + block_quote['classes'].append('pull-quote') return [block_quote] + messages pull_quote.content = 1 @@ -154,8 +155,7 @@ def compound(name, arguments, options, content, lineno, nodes.literal_block(block_text, block_text), line=lineno) return [error] node = nodes.compound(text) - if options.has_key('class'): - node.set_class(options['class']) + node['classes'] += options.get('class', []) state.nested_parse(content, content_offset, node) return [node] diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index 76d0d75eb..d4cd20a7f 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -15,6 +15,7 @@ import sys from docutils import nodes, utils from docutils.parsers.rst import directives, states from docutils.nodes import whitespace_normalize_name +from docutils.parsers.rst.roles import set_classes try: import Image # PIL @@ -45,6 +46,7 @@ def image(name, arguments, options, content, lineno, else: # malformed target messages.append(data) # data is a system message del options['target'] + set_classes(options) image_node = nodes.image(block_text, **options) if reference_node: reference_node += image_node @@ -64,7 +66,7 @@ image.options = {'alt': directives.unchanged, def figure(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): figwidth = options.setdefault('figwidth') - figclass = options.setdefault('figclass') + figclasses = options.setdefault('figclass') del options['figwidth'] del options['figclass'] (image_node,) = image(name, arguments, options, content, lineno, @@ -84,8 +86,8 @@ def figure(name, arguments, options, content, lineno, figure_node['width'] = i.size[0] elif figwidth is not None: figure_node['width'] = figwidth - if figclass: - figure_node.set_class(figclass) + if figclasses: + figure_node['classes'] += figclasses if content: node = nodes.Element() # anonymous container for parsing state.nested_parse(content, content_offset, node) diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py index 217def5b6..c87c239ec 100644 --- a/docutils/parsers/rst/directives/parts.py +++ b/docutils/parsers/rst/directives/parts.py @@ -43,9 +43,7 @@ def contents(name, arguments, options, content, lineno, topic = nodes.topic(classes=['contents']) - cls = options.get('class') - if cls: - topic.set_class(cls) + topic['classes'] += options.get('class', []) if title: name = title.astext() diff --git a/docutils/parsers/rst/directives/tables.py b/docutils/parsers/rst/directives/tables.py index e47c9f9e4..8f16beda0 100644 --- a/docutils/parsers/rst/directives/tables.py +++ b/docutils/parsers/rst/directives/tables.py @@ -53,8 +53,7 @@ def table(name, arguments, options, content, lineno, line=lineno) return [error] table_node = node[0] - if options.has_key('class'): - table_node.set_class(options['class']) + table_node['classes'] += options.get('class', []) if title: table_node.insert(0, title) return [table_node] + messages @@ -147,8 +146,7 @@ def csv_table(name, arguments, options, content, lineno, return [error] table = (col_widths, table_head, table_body) table_node = state.build_table(table, content_offset) - if options.has_key('class'): - table_node.set_class(options['class']) + table_node['classes'] += options.get('class', []) if title: table_node.insert(0, title) return [table_node] + messages @@ -342,8 +340,7 @@ def list_table(name, arguments, options, content, lineno, except SystemMessagePropagation, detail: return [detail.args[0]] table_node = build_table_from_list(table_data, col_widths, header_rows) - if options.has_key('class'): - table_node.set_class(options['class']) + table_node['classes'] += options.get('class', []) if title: table_node.insert(0, title) return [table_node] + messages diff --git a/docutils/parsers/rst/roles.py b/docutils/parsers/rst/roles.py index cf6d5a971..554e1f441 100644 --- a/docutils/parsers/rst/roles.py +++ b/docutils/parsers/rst/roles.py @@ -307,7 +307,7 @@ def raw_role(role, rawtext, text, lineno, inliner, options={}, content=[]): node = nodes.raw(rawtext, utils.unescape(text, 1), **options) return [node], [] -raw_role.options = {'format': directives.class_option} +raw_role.options = {'format': directives.unchanged} register_canonical_role('raw', raw_role) @@ -343,5 +343,5 @@ def set_classes(options): """ if options.has_key('class'): assert not options.has_key('classes') - options['classes'] = options['class'].split() + options['classes'] = options['class'] del options['class'] -- cgit v1.2.1 From dc3284ca85006e72f0e3b2c4ffbe078aa9148f76 Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 5 Apr 2005 02:55:06 +0000 Subject: added "stub-columns" options to "csv-table" and "list-table" directives, plus support, docs, and tests git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3165 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/tables.py | 43 ++++++++++++++++++++++++------- docutils/parsers/rst/states.py | 14 ++++++---- 2 files changed, 43 insertions(+), 14 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/tables.py b/docutils/parsers/rst/directives/tables.py index 8f16beda0..87131277d 100644 --- a/docutils/parsers/rst/directives/tables.py +++ b/docutils/parsers/rst/directives/tables.py @@ -130,8 +130,10 @@ def csv_table(name, arguments, options, content, lineno, csv_data, DocutilsDialect(options), source, options) max_cols = max(max_cols, max_header_cols) header_rows = options.get('header-rows', 0) # default 0 + stub_columns = options.get('stub-columns', 0) # default 0 check_table_dimensions( - rows, header_rows, name, lineno, block_text, state_machine) + rows, header_rows, stub_columns, name, lineno, + block_text, state_machine) table_head.extend(rows[:header_rows]) table_body = rows[header_rows:] col_widths = get_column_widths( @@ -145,7 +147,7 @@ def csv_table(name, arguments, options, content, lineno, nodes.literal_block(block_text, block_text), line=lineno) return [error] table = (col_widths, table_head, table_body) - table_node = state.build_table(table, content_offset) + table_node = state.build_table(table, content_offset, stub_columns) table_node['classes'] += options.get('class', []) if title: table_node.insert(0, title) @@ -153,6 +155,7 @@ def csv_table(name, arguments, options, content, lineno, csv_table.arguments = (0, 1, 1) csv_table.options = {'header-rows': directives.nonnegative_int, + 'stub-columns': directives.nonnegative_int, 'header': directives.unchanged, 'widths': directives.positive_int_list, 'file': directives.path, @@ -274,20 +277,34 @@ def parse_csv_data_into_rows(csv_data, dialect, source, options): max_cols = max(max_cols, len(row)) return rows, max_cols -def check_table_dimensions(rows, header_rows, name, lineno, block_text, - state_machine): +def check_table_dimensions(rows, header_rows, stub_columns, name, lineno, + block_text, state_machine): if len(rows) < header_rows: error = state_machine.reporter.error( '%s header row(s) specified but only %s row(s) of data supplied ' '("%s" directive).' % (header_rows, len(rows), name), nodes.literal_block(block_text, block_text), line=lineno) raise SystemMessagePropagation(error) - elif len(rows) == header_rows > 0: + if len(rows) == header_rows > 0: error = state_machine.reporter.error( 'Insufficient data supplied (%s row(s)); no data remaining for ' 'table body, required by "%s" directive.' % (len(rows), name), nodes.literal_block(block_text, block_text), line=lineno) raise SystemMessagePropagation(error) + for row in rows: + if len(row) < stub_columns: + error = state_machine.reporter.error( + '%s stub column(s) specified but only %s columns(s) of data ' + 'supplied ("%s" directive).' % (stub_columns, len(row), name), + nodes.literal_block(block_text, block_text), line=lineno) + raise SystemMessagePropagation(error) + if len(row) == stub_columns > 0: + error = state_machine.reporter.error( + 'Insufficient data supplied (%s columns(s)); no data remaining ' + 'for table body, required by "%s" directive.' + % (len(row), name), + nodes.literal_block(block_text, block_text), line=lineno) + raise SystemMessagePropagation(error) def get_column_widths(max_cols, name, options, lineno, block_text, state_machine): @@ -335,11 +352,14 @@ def list_table(name, arguments, options, content, lineno, table_data = [[item.children for item in row_list[0]] for row_list in node[0]] header_rows = options.get('header-rows', 0) # default 0 + stub_columns = options.get('stub-columns', 0) # default 0 check_table_dimensions( - table_data, header_rows, name, lineno, block_text, state_machine) + table_data, header_rows, stub_columns, name, lineno, + block_text, state_machine) except SystemMessagePropagation, detail: return [detail.args[0]] - table_node = build_table_from_list(table_data, col_widths, header_rows) + table_node = build_table_from_list(table_data, col_widths, + header_rows, stub_columns) table_node['classes'] += options.get('class', []) if title: table_node.insert(0, title) @@ -347,6 +367,7 @@ def list_table(name, arguments, options, content, lineno, list_table.arguments = (0, 1, 1) list_table.options = {'header-rows': directives.nonnegative_int, + 'stub-columns': directives.nonnegative_int, 'widths': directives.positive_int_list, 'class': directives.class_option} list_table.content = 1 @@ -392,12 +413,16 @@ def check_list_content(node, name, options, content, lineno, block_text, raise SystemMessagePropagation(error) return num_cols, col_widths -def build_table_from_list(table_data, col_widths, header_rows): +def build_table_from_list(table_data, col_widths, header_rows, stub_columns): table = nodes.table() tgroup = nodes.tgroup(cols=len(col_widths)) table += tgroup for col_width in col_widths: - tgroup += nodes.colspec(colwidth=col_width) + colspec = nodes.colspec(colwidth=col_width) + if stub_columns: + colspec.attributes['stub'] = 1 + stub_columns -= 1 + tgroup += colspec rows = [] for row in table_data: row_node = nodes.row() diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index a44f47027..f779df8b2 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1657,13 +1657,17 @@ class Body(RSTState): line=lineno) return [error] - def build_table(self, tabledata, tableline): - colspecs, headrows, bodyrows = tabledata + def build_table(self, tabledata, tableline, stub_columns=0): + colwidths, headrows, bodyrows = tabledata table = nodes.table() - tgroup = nodes.tgroup(cols=len(colspecs)) + tgroup = nodes.tgroup(cols=len(colwidths)) table += tgroup - for colspec in colspecs: - tgroup += nodes.colspec(colwidth=colspec) + for colwidth in colwidths: + colspec = nodes.colspec(colwidth=colwidth) + if stub_columns: + colspec.attributes['stub'] = 1 + stub_columns -= 1 + tgroup += colspec if headrows: thead = nodes.thead() tgroup += thead -- cgit v1.2.1 From a9cb01249ed3351c1e3ba36caa9fc45d0522b842 Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 5 Apr 2005 15:26:16 +0000 Subject: merged reporter-categories branch into trunk: removed docutils.utils.Reporter.categories, docutils.utils.ConditionSet, and all references to them, to simplify error reporting git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3171 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/__init__.py b/docutils/parsers/rst/__init__.py index 8d7935be6..30825d7c4 100644 --- a/docutils/parsers/rst/__init__.py +++ b/docutils/parsers/rst/__init__.py @@ -144,11 +144,10 @@ class Parser(docutils.parsers.Parser): def parse(self, inputstring, document): """Parse `inputstring` and populate `document`, a document tree.""" self.setup_parse(inputstring, document) - debug = document.reporter[''].debug self.statemachine = states.RSTStateMachine( state_classes=self.state_classes, initial_state=self.initial_state, - debug=debug) + debug=document.reporter.debug_flag) inputlines = docutils.statemachine.string2lines( inputstring, tab_width=document.settings.tab_width, convert_whitespace=1) -- cgit v1.2.1 From dcc80f043243f34d0373a3150bacfff20b3212ae Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 7 Apr 2005 19:36:11 +0000 Subject: added "header" & "footer" directives, tests, docs, support, and some tweaks git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3184 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 2 ++ docutils/parsers/rst/directives/parts.py | 33 +++++++++++++++++++++++++++++ docutils/parsers/rst/languages/af.py | 2 ++ docutils/parsers/rst/languages/cs.py | 2 ++ docutils/parsers/rst/languages/de.py | 2 ++ docutils/parsers/rst/languages/en.py | 2 ++ docutils/parsers/rst/languages/eo.py | 2 ++ docutils/parsers/rst/languages/es.py | 2 ++ docutils/parsers/rst/languages/fi.py | 2 ++ docutils/parsers/rst/languages/fr.py | 2 ++ docutils/parsers/rst/languages/it.py | 2 ++ docutils/parsers/rst/languages/nl.py | 2 ++ docutils/parsers/rst/languages/pt_br.py | 2 ++ docutils/parsers/rst/languages/ru.py | 4 +++- docutils/parsers/rst/languages/sk.py | 2 ++ docutils/parsers/rst/languages/sv.py | 2 ++ docutils/parsers/rst/languages/zh_tw.py | 2 ++ 17 files changed, 66 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 05f552edd..8e9f42284 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -118,6 +118,8 @@ _directive_registry = { 'figure': ('images', 'figure'), 'contents': ('parts', 'contents'), 'sectnum': ('parts', 'sectnum'), + 'header': ('parts', 'header'), + 'footer': ('parts', 'footer'), #'footnotes': ('parts', 'footnotes'), #'citations': ('parts', 'citations'), 'target-notes': ('references', 'target_notes'), diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py index c87c239ec..623e2cd5e 100644 --- a/docutils/parsers/rst/directives/parts.py +++ b/docutils/parsers/rst/directives/parts.py @@ -80,3 +80,36 @@ sectnum.options = {'depth': int, 'start': int, 'prefix': directives.unchanged_required, 'suffix': directives.unchanged_required} + +def header_footer(node, name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + """Contents of document header or footer.""" + if not content: + warning = state_machine.reporter.warning( + 'Content block expected for the "%s" directive; none found.' + % name, nodes.literal_block(block_text, block_text), + line=lineno) + node.children.append(nodes.paragraph( + '', 'Problem with the "%s" directive: no content supplied.' % name)) + return [warning] + text = '\n'.join(content) + state.nested_parse(content, content_offset, node) + return [] + +def header(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + decoration = state_machine.document.get_decoration() + node = decoration.get_header() + return header_footer(node, name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine) + +header.content = 1 + +def footer(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + decoration = state_machine.document.get_decoration() + node = decoration.get_footer() + return header_footer(node, name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine) + +footer.content = 1 diff --git a/docutils/parsers/rst/languages/af.py b/docutils/parsers/rst/languages/af.py index e3664f717..9dddae716 100644 --- a/docutils/parsers/rst/languages/af.py +++ b/docutils/parsers/rst/languages/af.py @@ -56,6 +56,8 @@ directives = { 'inhoud': 'contents', 'sectnum': 'sectnum', 'section-numbering': 'sectnum', + u'header (translation required)': 'header', + u'footer (translation required)': 'footer', #'voetnote': 'footnotes', #'aanhalings': 'citations', 'teikennotas': 'target-notes', diff --git a/docutils/parsers/rst/languages/cs.py b/docutils/parsers/rst/languages/cs.py index af32e69d6..7163cbf8f 100644 --- a/docutils/parsers/rst/languages/cs.py +++ b/docutils/parsers/rst/languages/cs.py @@ -57,6 +57,8 @@ directives = { u'obsah': 'contents', u'sectnum (translation required)': 'sectnum', u'section-numbering (translation required)': 'sectnum', + u'header (translation required)': 'header', + u'footer (translation required)': 'footer', #'footnotes': 'footnotes', #'citations': 'citations', u'target-notes (translation required)': 'target-notes', diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index 8ea77485b..9431f0e9d 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -60,6 +60,8 @@ directives = { 'kapitel-nummerierung': 'sectnum', 'abschnitts-nummerierung': 'sectnum', u'linkziel-fu\xdfnoten': 'target-notes', + u'header (translation required)': 'header', + u'footer (translation required)': 'footer', #u'fu\xdfnoten': 'footnotes', #'zitate': 'citations', } diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index dcd5b9584..63ddcb1b9 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -57,6 +57,8 @@ directives = { 'contents': 'contents', 'sectnum': 'sectnum', 'section-numbering': 'sectnum', + 'header': 'header', + 'footer': 'footer', #'footnotes': 'footnotes', #'citations': 'citations', 'target-notes': 'target-notes', diff --git a/docutils/parsers/rst/languages/eo.py b/docutils/parsers/rst/languages/eo.py index 4065f88d4..8f7e33807 100644 --- a/docutils/parsers/rst/languages/eo.py +++ b/docutils/parsers/rst/languages/eo.py @@ -63,6 +63,8 @@ directives = { u'enhavo': 'contents', u'seknum': 'sectnum', u'sekcia-numerado': 'sectnum', + u'header (translation required)': 'header', + u'footer (translation required)': 'footer', #'footnotes': 'footnotes', #'citations': 'citations', u'celaj-notoj': 'target-notes', diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index efd7ece08..59b3a2228 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -68,6 +68,8 @@ directives = { u'numeracion-seccion': 'sectnum', u'numeraci\u00f3n-secci\u00f3n': 'sectnum', u'notas-destino': 'target-notes', + u'header (translation required)': 'header', + u'footer (translation required)': 'footer', #'footnotes': 'footnotes', #'citations': 'citations', u'restructuredtext-test-directive': 'restructuredtext-test-directive'} diff --git a/docutils/parsers/rst/languages/fi.py b/docutils/parsers/rst/languages/fi.py index a718e7773..c60444e3f 100644 --- a/docutils/parsers/rst/languages/fi.py +++ b/docutils/parsers/rst/languages/fi.py @@ -54,6 +54,8 @@ directives = { u'rooli': u'role', u'sis\u00e4llys': u'contents', u'kappale': u'sectnum', + u'header (translation required)': 'header', + u'footer (translation required)': 'footer', #u'alaviitteet': u'footnotes', #u'viitaukset': u'citations', u'target-notes (translation required)': u'target-notes'} diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index 26668ef09..8b9cb04de 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -61,6 +61,8 @@ directives = { u'sectnum': 'sectnum', u'section-num\u00E9rot\u00E9e': 'sectnum', u'liens': 'target-notes', + u'header (translation required)': 'header', + u'footer (translation required)': 'footer', #u'footnotes (translation required)': 'footnotes', #u'citations (translation required)': 'citations', } diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index a04f98fa4..ee31b42ae 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -58,6 +58,8 @@ directives = { 'seznum': 'sectnum', 'sezioni-autonumerate': 'sectnum', 'annota-riferimenti-esterni': 'target-notes', + u'header (translation required)': 'header', + u'footer (translation required)': 'footer', #'footnotes': 'footnotes', #'citations': 'citations', 'restructuredtext-test-directive': 'restructuredtext-test-directive'} diff --git a/docutils/parsers/rst/languages/nl.py b/docutils/parsers/rst/languages/nl.py index fa6a1324a..35942ca05 100644 --- a/docutils/parsers/rst/languages/nl.py +++ b/docutils/parsers/rst/languages/nl.py @@ -59,6 +59,8 @@ directives = { 'sectnum': 'sectnum', 'sectie-nummering': 'sectnum', 'hoofdstuk-nummering': 'sectnum', + u'header (translation required)': 'header', + u'footer (translation required)': 'footer', #'voetnoten': 'footnotes', #'citaten': 'citations', 'verwijzing-voetnoten': 'target-notes', diff --git a/docutils/parsers/rst/languages/pt_br.py b/docutils/parsers/rst/languages/pt_br.py index 92801268b..6f5d4cc6b 100644 --- a/docutils/parsers/rst/languages/pt_br.py +++ b/docutils/parsers/rst/languages/pt_br.py @@ -57,6 +57,8 @@ directives = { u'\u00EDndice': 'contents', 'numsec': 'sectnum', u'numera\u00E7\u00E3o-de-se\u00E7\u00F5es': 'sectnum', + u'header (translation required)': 'header', + u'footer (translation required)': 'footer', #u'notas-de-rorap\u00E9': 'footnotes', #u'cita\u00E7\u00F5es': 'citations', u'links-no-rodap\u00E9': 'target-notes', diff --git a/docutils/parsers/rst/languages/ru.py b/docutils/parsers/rst/languages/ru.py index 44363f5f1..4ccca658c 100644 --- a/docutils/parsers/rst/languages/ru.py +++ b/docutils/parsers/rst/languages/ru.py @@ -61,7 +61,9 @@ directives = { u'\u0441\u043e\u0432\u0435\u0442': u'hint', u'\u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435': u'contents', u'\u0442\u0435\u043c\u0430': u'topic', - u'\u044d\u043f\u0438\u0433\u0440\u0430\u0444': u'epigraph'} + u'\u044d\u043f\u0438\u0433\u0440\u0430\u0444': u'epigraph', + u'header (translation required)': 'header', + u'footer (translation required)': 'footer',} """Russian name to registered (in directives/__init__.py) directive name mapping.""" diff --git a/docutils/parsers/rst/languages/sk.py b/docutils/parsers/rst/languages/sk.py index fc1c54752..2ba849700 100644 --- a/docutils/parsers/rst/languages/sk.py +++ b/docutils/parsers/rst/languages/sk.py @@ -57,6 +57,8 @@ directives = { u'\xe8as\x9d': 'sectnum', u'\xe8as\x9d-\xe8\xedslovanie': 'sectnum', u'cie\xbeov\xe9-pozn\xe1mky': 'target-notes', + u'header (translation required)': 'header', + u'footer (translation required)': 'footer', #u'footnotes': 'footnotes', #u'citations': 'citations', } diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index b64b7a57f..d6f6fba46 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -56,6 +56,8 @@ directives = { u'inneh\u00e5ll': 'contents', u'sektionsnumrering': 'sectnum', u'target-notes (translation required)': 'target-notes', + u'header (translation required)': 'header', + u'footer (translation required)': 'footer', # u'fotnoter': 'footnotes', # u'citeringar': 'citations', } diff --git a/docutils/parsers/rst/languages/zh_tw.py b/docutils/parsers/rst/languages/zh_tw.py index 57c04eaaa..15f253114 100644 --- a/docutils/parsers/rst/languages/zh_tw.py +++ b/docutils/parsers/rst/languages/zh_tw.py @@ -57,6 +57,8 @@ directives = { 'contents (translation required)': 'contents', 'sectnum (translation required)': 'sectnum', 'section-numbering (translation required)': 'sectnum', + u'header (translation required)': 'header', + u'footer (translation required)': 'footer', #'footnotes (translation required)': 'footnotes', #'citations (translation required)': 'citations', 'target-notes (translation required)': 'target-notes', -- cgit v1.2.1 From e743c7a5d3e7908af5702ddacfbcb4b7556914d9 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 7 Apr 2005 19:51:45 +0000 Subject: fixed bugs: don't access a node's children attribute directly\! git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3186 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/parts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py index 623e2cd5e..2c0171696 100644 --- a/docutils/parsers/rst/directives/parts.py +++ b/docutils/parsers/rst/directives/parts.py @@ -89,7 +89,7 @@ def header_footer(node, name, arguments, options, content, lineno, 'Content block expected for the "%s" directive; none found.' % name, nodes.literal_block(block_text, block_text), line=lineno) - node.children.append(nodes.paragraph( + node.append(nodes.paragraph( '', 'Problem with the "%s" directive: no content supplied.' % name)) return [warning] text = '\n'.join(content) -- cgit v1.2.1 From ff539aca41253daa55523d0d4bbbb465f450adfe Mon Sep 17 00:00:00 2001 From: richieadler Date: Fri, 8 Apr 2005 03:05:45 +0000 Subject: translation of "list-table", "header" and "footer" directives git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3189 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/eo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/eo.py b/docutils/parsers/rst/languages/eo.py index 8f7e33807..069fea45e 100644 --- a/docutils/parsers/rst/languages/eo.py +++ b/docutils/parsers/rst/languages/eo.py @@ -48,7 +48,7 @@ directives = { u'tabelo': 'table', u'tabelo-vdk': 'csv-table', # "valoroj disigitaj per komoj" u'tabelo-csv': 'csv-table', - u'list-table (translation required)': 'list-table', + u'tabelo-lista': 'list-table', u'meta': 'meta', #'imagemap': 'imagemap', u'bildo': 'image', @@ -63,8 +63,8 @@ directives = { u'enhavo': 'contents', u'seknum': 'sectnum', u'sekcia-numerado': 'sectnum', - u'header (translation required)': 'header', - u'footer (translation required)': 'footer', + u'kapsekcio': 'header', + u'piedsekcio': 'footer', #'footnotes': 'footnotes', #'citations': 'citations', u'celaj-notoj': 'target-notes', -- cgit v1.2.1 From 962a4420aa386783d5c475e84a84e2efea8b3ab2 Mon Sep 17 00:00:00 2001 From: richieadler Date: Fri, 8 Apr 2005 03:06:12 +0000 Subject: translation of "list-table", "header" and "footer" directives git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3190 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/es.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index 59b3a2228..5f0a094da 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -50,7 +50,7 @@ directives = { u'tabla': 'table', u'tabla-vsc': 'csv-table', u'tabla-csv': 'csv-table', - u'list-table (translation required)': 'list-table', + u'tabla-lista': 'list-table', u'meta': 'meta', #'imagemap': 'imagemap', u'imagen': 'image', @@ -68,8 +68,8 @@ directives = { u'numeracion-seccion': 'sectnum', u'numeraci\u00f3n-secci\u00f3n': 'sectnum', u'notas-destino': 'target-notes', - u'header (translation required)': 'header', - u'footer (translation required)': 'footer', + u'cabecera': 'header', + u'pie': 'footer', #'footnotes': 'footnotes', #'citations': 'citations', u'restructuredtext-test-directive': 'restructuredtext-test-directive'} -- cgit v1.2.1 From 7e297f36f3c1d3ebf5f26a60dcec7613efa63ba5 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 8 Apr 2005 18:42:33 +0000 Subject: moved implementation description out of the docs into the code; whitespace git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3193 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/parts.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py index 2c0171696..a224101f6 100644 --- a/docutils/parsers/rst/directives/parts.py +++ b/docutils/parsers/rst/directives/parts.py @@ -26,10 +26,17 @@ def backlinks(arg): def contents(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): - """Table of contents.""" + """ + Table of contents. + + The table of contents is generated in two passes: initial parse and + transform. During the initial parse, a 'pending' element is generated + which acts as a placeholder, storing the TOC title and any options + internally. At a later stage in the processing, the 'pending' element is + replaced by a 'topic' element, a title and the table of contents proper. + """ document = state_machine.document language = languages.get_language(document.settings.language_code) - if arguments: title_text = arguments[0] text_nodes, messages = state.inline_text(title_text, lineno) @@ -40,22 +47,17 @@ def contents(name, arguments, options, content, lineno, title = None else: title = nodes.title('', language.labels['contents']) - topic = nodes.topic(classes=['contents']) - topic['classes'] += options.get('class', []) - if title: name = title.astext() topic += title else: name = language.labels['contents'] - name = nodes.fully_normalize_name(name) if not document.has_name(name): topic['names'].append(name) document.note_implicit_target(topic) - pending = nodes.pending(parts.Contents, rawsource=block_text) pending.details.update(options) document.note_pending(pending) -- cgit v1.2.1 From a65d49465f32f45cc8152ccfdd0ee4d26c398353 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 9 Apr 2005 01:32:29 +0000 Subject: allow topics within sidebars; no topics within body elements git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3199 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/body.py | 5 +++-- docutils/parsers/rst/directives/parts.py | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index 117311720..61c58daad 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -22,9 +22,10 @@ from docutils.parsers.rst.roles import set_classes def topic(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine, node_class=nodes.topic): - if not state_machine.match_titles: + if not (state_machine.match_titles + or isinstance(state_machine.node, nodes.sidebar)): error = state_machine.reporter.error( - 'The "%s" directive may not be used within topics, sidebars, ' + 'The "%s" directive may not be used within topics ' 'or body elements.' % name, nodes.literal_block(block_text, block_text), line=lineno) return [error] diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py index a224101f6..37a32a963 100644 --- a/docutils/parsers/rst/directives/parts.py +++ b/docutils/parsers/rst/directives/parts.py @@ -35,6 +35,13 @@ def contents(name, arguments, options, content, lineno, internally. At a later stage in the processing, the 'pending' element is replaced by a 'topic' element, a title and the table of contents proper. """ + if not (state_machine.match_titles + or isinstance(state_machine.node, nodes.sidebar)): + error = state_machine.reporter.error( + 'The "%s" directive may not be used within topics ' + 'or body elements.' % name, + nodes.literal_block(block_text, block_text), line=lineno) + return [error] document = state_machine.document language = languages.get_language(document.settings.language_code) if arguments: -- cgit v1.2.1 From f74332157ab86e93794a4e9566f6737aefa7328d Mon Sep 17 00:00:00 2001 From: goodger Date: Mon, 11 Apr 2005 23:16:11 +0000 Subject: added checks for recursive sidebars git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3206 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/body.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index 61c58daad..28682328a 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -57,6 +57,11 @@ topic.content = 1 def sidebar(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): + if isinstance(state_machine.node, nodes.sidebar): + error = state_machine.reporter.error( + 'The "%s" directive may not be used within a sidebar element.' + % name, nodes.literal_block(block_text, block_text), line=lineno) + return [error] return topic(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine, node_class=nodes.sidebar) -- cgit v1.2.1 From bd559044426b3f80dd1e7cc9b2d3a25c61bb952f Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 21 Apr 2005 14:52:41 +0000 Subject: "image" directive: added checks for valid values of "align" option, depending on context. "figure" directive: added specialized "align" option and attribute on "figure" element. Added HTML support for ``align`` attribute on ``figure`` elements. Updated docs & tests. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3231 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index d4cd20a7f..7efb2588d 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -22,13 +22,33 @@ try: except ImportError: Image = None -align_values = ('top', 'middle', 'bottom', 'left', 'center', 'right') +align_h_values = ('left', 'center', 'right') +align_v_values = ('top', 'middle', 'bottom') +align_values = align_v_values + align_h_values def align(argument): return directives.choice(argument, align_values) def image(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): + if options.has_key('align'): + # check for align_v values only + if isinstance(state, states.SubstitutionDef): + if options['align'] not in align_v_values: + error = state_machine.reporter.error( + 'Error in "%s" directive: "%s" is not a valid value for ' + 'the "align" option within a substitution definition. ' + 'Valid values for "align" are: "%s".' + % (name, options['align'], '", "'.join(align_v_values)), + nodes.literal_block(block_text, block_text), line=lineno) + return [error] + elif options['align'] not in align_h_values: + error = state_machine.reporter.error( + 'Error in "%s" directive: "%s" is not a valid value for ' + 'the "align" option. Valid values for "align" are: "%s".' + % (name, options['align'], '", "'.join(align_h_values)), + nodes.literal_block(block_text, block_text), line=lineno) + return [error] messages = [] reference = directives.uri(arguments[0]) options['uri'] = reference @@ -63,12 +83,17 @@ image.options = {'alt': directives.unchanged, 'target': directives.unchanged_required, 'class': directives.class_option} +def figure_align(argument): + return directives.choice(argument, align_h_values) + def figure(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): figwidth = options.setdefault('figwidth') figclasses = options.setdefault('figclass') + align = options.setdefault('align') del options['figwidth'] del options['figclass'] + del options['align'] (image_node,) = image(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine) if isinstance(image_node, nodes.system_message): @@ -88,6 +113,8 @@ def figure(name, arguments, options, content, lineno, figure_node['width'] = figwidth if figclasses: figure_node['classes'] += figclasses + if align: + figure_node['align'] = align if content: node = nodes.Element() # anonymous container for parsing state.nested_parse(content, content_offset, node) @@ -116,4 +143,5 @@ figure.arguments = (1, 0, 1) figure.options = {'figwidth': figwidth_value, 'figclass': directives.class_option} figure.options.update(image.options) +figure.options['align'] = figure_align figure.content = 1 -- cgit v1.2.1 From 3da860aec26788ffd148bdbbedeee98b53a1436a Mon Sep 17 00:00:00 2001 From: wiemann Date: Mon, 25 Apr 2005 15:08:01 +0000 Subject: str(Exception) doesn't work for anything but ASCII Exception texts, so '%s' % exception_instance is unsafe unless exception_instance.args contains only byte strings. The change in alltests.py is a first attempt to catch such cases where a str(Exception) is done with an Exception text which is not necessarily ASCII-only (i.e. with a unicode string in Exception.args), but since most input data (in the totest dicts) is passed in as byte strings, it doesn't catch much. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3253 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index f779df8b2..1ee9dc6f2 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1565,7 +1565,8 @@ class Body(RSTState): table = self.build_table(tabledata, tableline) nodelist = [table] + messages except tableparser.TableMarkupError, detail: - nodelist = self.malformed_table(block, str(detail)) + messages + nodelist = self.malformed_table( + block, ' '.join(detail.args)) + messages else: nodelist = messages return nodelist, blank_finish @@ -1982,7 +1983,8 @@ class Body(RSTState): directive_fn, option_presets)) except MarkupError, detail: error = self.reporter.error( - 'Error in "%s" directive:\n%s.' % (type_name, detail), + 'Error in "%s" directive:\n%s.' % (type_name, + ' '.join(detail.args)), nodes.literal_block(block_text, block_text), line=lineno) return [error], blank_finish result = directive_fn(type_name, arguments, options, content, lineno, @@ -2093,9 +2095,9 @@ class Body(RSTState): except KeyError, detail: return 0, ('unknown option: "%s"' % detail.args[0]) except (ValueError, TypeError), detail: - return 0, ('invalid option value: %s' % detail) + return 0, ('invalid option value: %s' % ' '.join(detail.args)) except utils.ExtensionOptionError, detail: - return 0, ('invalid option data: %s' % detail) + return 0, ('invalid option data: %s' % ' '.join(detail.args)) if blank_finish: return 1, options else: -- cgit v1.2.1 From 4fcf4836929b04bcd10083a7200c0930ac858893 Mon Sep 17 00:00:00 2001 From: wiemann Date: Sat, 30 Apr 2005 11:34:52 +0000 Subject: added Catalan language mappings; thanks to Ivan Vilata i Balaguer git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3276 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/ca.py | 119 +++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 docutils/parsers/rst/languages/ca.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/ca.py b/docutils/parsers/rst/languages/ca.py new file mode 100644 index 000000000..9fdce400d --- /dev/null +++ b/docutils/parsers/rst/languages/ca.py @@ -0,0 +1,119 @@ +# Author: Ivan Vilata i Balaguer +# Contact: ivan@selidor.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +# New language mappings are welcome. Before doing a new translation, please +# read . Two files must be +# translated for each language: one in docutils/languages, the other in +# docutils/parsers/rst/languages. + +""" +Catalan-language mappings for language-dependent features of +reStructuredText. +""" + +__docformat__ = 'reStructuredText' + + +directives = { + # language-dependent: fixed + u'atenci\u00F3': 'attention', + u'compte': 'caution', + u'perill': 'danger', + u'error': 'error', + u'suggeriment': 'hint', + u'important': 'important', + u'nota': 'note', + u'consell': 'tip', + u'av\u00EDs': 'warning', + u'advertiment': 'admonition', + u'nota-al-marge': 'sidebar', + u'nota-marge': 'sidebar', + u'tema': 'topic', + u'bloc-de-l\u00EDnies': 'line-block', + u'bloc-l\u00EDnies': 'line-block', + u'literal-analitzat': 'parsed-literal', + u'r\u00FAbrica': 'rubric', + u'ep\u00EDgraf': 'epigraph', + u'sumari': 'highlights', + u'cita-destacada': 'pull-quote', + u'compost': 'compound', + #'questions': 'questions', + u'taula': 'table', + u'taula-csv': 'csv-table', + u'taula-llista': 'list-table', + #'qa': 'questions', + #'faq': 'questions', + u'meta': 'meta', + #'imagemap': 'imagemap', + u'imatge': 'image', + u'figura': 'figure', + u'inclou': 'include', + u'incloure': 'include', + u'cru': 'raw', + u'reempla\u00E7a': 'replace', + u'reempla\u00E7ar': 'replace', + u'unicode': 'unicode', + u'classe': 'class', + u'rol': 'role', + u'contingut': 'contents', + u'numsec': 'sectnum', + u'numeraci\u00F3-de-seccions': 'sectnum', + u'numeraci\u00F3-seccions': 'sectnum', + u'cap\u00E7alera': 'header', + u'peu-de-p\u00E0gina': 'footer', + u'peu-p\u00E0gina': 'footer', + #'footnotes': 'footnotes', + #'citations': 'citations', + u'notes-amb-destinacions': 'target-notes', + u'notes-destinacions': 'target-notes', + u'directiva-de-prova-de-restructuredtext': 'restructuredtext-test-directive'} +"""Catalan name to registered (in directives/__init__.py) directive name +mapping.""" + +roles = { + # language-dependent: fixed + u'abreviatura': 'abbreviation', + u'abreviaci\u00F3': 'abbreviation', + u'abrev': 'abbreviation', + u'ab': 'abbreviation', + u'acr\u00F2nim': 'acronym', + u'ac': 'acronym', + u'\u00EDndex': 'index', + u'i': 'index', + u'sub\u00EDndex': 'subscript', + u'sub': 'subscript', + u'super\u00EDndex': 'superscript', + u'sup': 'superscript', + u'refer\u00E8ncia-a-t\u00EDtol': 'title-reference', + u'refer\u00E8ncia-t\u00EDtol': 'title-reference', + u't\u00EDtol': 'title-reference', + u't': 'title-reference', + u'refer\u00E8ncia-a-pep': 'pep-reference', + u'refer\u00E8ncia-pep': 'pep-reference', + u'pep': 'pep-reference', + u'refer\u00E8ncia-a-rfc': 'rfc-reference', + u'refer\u00E8ncia-rfc': 'rfc-reference', + u'rfc': 'rfc-reference', + u'\u00E8mfasi': 'emphasis', + u'destacat': 'strong', + u'literal': 'literal', + u'refer\u00E8ncia-amb-nom': 'named-reference', + u'refer\u00E8ncia-nom': 'named-reference', + u'refer\u00E8ncia-an\u00F2nima': 'anonymous-reference', + u'refer\u00E8ncia-a-nota-al-peu': 'footnote-reference', + u'refer\u00E8ncia-nota-al-peu': 'footnote-reference', + u'refer\u00E8ncia-a-cita': 'citation-reference', + u'refer\u00E8ncia-cita': 'citation-reference', + u'refer\u00E8ncia-a-substituci\u00F3': 'substitution-reference', + u'refer\u00E8ncia-substituci\u00F3': 'substitution-reference', + u'destinaci\u00F3': 'target', + u'refer\u00E8ncia-a-uri': 'uri-reference', + u'refer\u00E8ncia-uri': 'uri-reference', + u'uri': 'uri-reference', + u'url': 'uri-reference', + u'cru': 'raw',} +"""Mapping of Catalan role names to canonical role names for interpreted text. +""" -- cgit v1.2.1 From 55cd5272b6cec7dc3cc9eae6bd8076dd0df064ab Mon Sep 17 00:00:00 2001 From: goodger Date: Mon, 9 May 2005 15:49:37 +0000 Subject: Added "border" option to "image" directive (& attribute to doctree element); updated docs & tests. Closes Feature Request 1193389. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3322 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 1 + 1 file changed, 1 insertion(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index 7efb2588d..96d01aeab 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -76,6 +76,7 @@ def image(name, arguments, options, content, lineno, image.arguments = (1, 0, 1) image.options = {'alt': directives.unchanged, + 'border': directives.nonnegative_int, 'height': directives.nonnegative_int, 'width': directives.nonnegative_int, 'scale': directives.nonnegative_int, -- cgit v1.2.1 From 9ed38a53f7de2eed5ed8ba98afb3e2ee28f2f75d Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 14 May 2005 16:14:44 +0000 Subject: reverting revision 3322: addition of ":border:" option to "image" directive git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3340 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 1 - 1 file changed, 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index 96d01aeab..7efb2588d 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -76,7 +76,6 @@ def image(name, arguments, options, content, lineno, image.arguments = (1, 0, 1) image.options = {'alt': directives.unchanged, - 'border': directives.nonnegative_int, 'height': directives.nonnegative_int, 'width': directives.nonnegative_int, 'scale': directives.nonnegative_int, -- cgit v1.2.1 From ad515ddd08093c451941419471afc6e422ab55fb Mon Sep 17 00:00:00 2001 From: wiemann Date: Wed, 18 May 2005 18:08:14 +0000 Subject: Fixed bug with ":width: image" option of figure directive. Closing https://sourceforge.net/tracker/?func=detail&atid=422030&aid=1202510&group_id=38414 git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3346 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index 7efb2588d..c9f793f4b 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -107,7 +107,7 @@ def figure(name, arguments, options, content, lineno, except (IOError, UnicodeError): pass else: - state.document.settings.record_dependencies.add(reference) + state.document.settings.record_dependencies.add(image_node['uri']) figure_node['width'] = i.size[0] elif figwidth is not None: figure_node['width'] = figwidth -- cgit v1.2.1 From e8a50ca456b98d2a10a82a689cf6805c541b1244 Mon Sep 17 00:00:00 2001 From: wiemann Date: Wed, 18 May 2005 18:17:33 +0000 Subject: Fixed bug with uppercase image targets. Closing https://sourceforge.net/tracker/index.php?func=detail&aid=1202510&group_id=38414&atid=422030 git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3347 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index c9f793f4b..670f969a0 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -14,7 +14,7 @@ __docformat__ = 'reStructuredText' import sys from docutils import nodes, utils from docutils.parsers.rst import directives, states -from docutils.nodes import whitespace_normalize_name +from docutils.nodes import fully_normalize_name from docutils.parsers.rst.roles import set_classes try: @@ -61,7 +61,7 @@ def image(name, arguments, options, content, lineno, reference_node = nodes.reference(refuri=data) elif target_type == 'refname': reference_node = nodes.reference(refname=data, - name=whitespace_normalize_name(options['target'])) + name=fully_normalize_name(options['target'])) state.document.note_refname(reference_node) else: # malformed target messages.append(data) # data is a system message -- cgit v1.2.1 From e10b9dee23a956499f61c0bd3d8a3c4233c754c3 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 1 Jun 2005 13:52:43 +0000 Subject: Added validator to tab_width setting, with test. Closes SF bug #1212515, report from Wu Wei. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3416 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/__init__.py b/docutils/parsers/rst/__init__.py index 30825d7c4..ff1d7b4f8 100644 --- a/docutils/parsers/rst/__init__.py +++ b/docutils/parsers/rst/__init__.py @@ -105,7 +105,8 @@ class Parser(docutils.parsers.Parser): 'validator': frontend.validate_url_trailing_slash}), ('Set number of spaces for tab expansion (default 8).', ['--tab-width'], - {'metavar': '', 'type': 'int', 'default': 8}), + {'metavar': '', 'type': 'int', 'default': 8, + 'validator': frontend.validate_nonnegative_int}), ('Remove spaces before footnote references.', ['--trim-footnote-reference-space'], {'action': 'store_true', 'validator': frontend.validate_boolean}), -- cgit v1.2.1 From c1312b37ba8887cf092065cb09f3d09ee034ac31 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 4 Jun 2005 04:01:58 +0000 Subject: added "default-role" directive git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3427 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 1 + docutils/parsers/rst/directives/misc.py | 22 ++++++++++++++++++++++ docutils/parsers/rst/languages/af.py | 1 + docutils/parsers/rst/languages/ca.py | 1 + docutils/parsers/rst/languages/cs.py | 1 + docutils/parsers/rst/languages/de.py | 1 + docutils/parsers/rst/languages/en.py | 1 + docutils/parsers/rst/languages/eo.py | 1 + docutils/parsers/rst/languages/es.py | 1 + docutils/parsers/rst/languages/fi.py | 1 + docutils/parsers/rst/languages/fr.py | 1 + docutils/parsers/rst/languages/it.py | 1 + docutils/parsers/rst/languages/nl.py | 1 + docutils/parsers/rst/languages/pt_br.py | 1 + docutils/parsers/rst/languages/ru.py | 1 + docutils/parsers/rst/languages/sk.py | 1 + docutils/parsers/rst/languages/sv.py | 1 + docutils/parsers/rst/languages/zh_tw.py | 1 + 18 files changed, 39 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 8e9f42284..1db0c76e0 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -131,6 +131,7 @@ _directive_registry = { 'unicode': ('misc', 'unicode_directive'), 'class': ('misc', 'class_directive'), 'role': ('misc', 'role'), + 'default-role': ('misc', 'default_role'), 'restructuredtext-test-directive': ('misc', 'directive_test_function'),} """Mapping of directive name to (module name, function name). The directive name is canonical & must be lowercase. Language-dependent names are defined diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 7bae832d2..7007546df 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -329,6 +329,28 @@ def role(name, arguments, options, content, lineno, role.content = 1 +def default_role(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + """Set the default interpreted text role.""" + if not arguments: + if roles._roles.has_key(''): + # restore the "default" default role + del roles._roles[''] + return [] + role_name = arguments[0] + role, messages = roles.role( + role_name, state_machine.language, lineno, state.reporter) + if role is None: + error = state.reporter.error( + 'Unknown interpreted text role "%s".' % role_name, + nodes.literal_block(block_text, block_text), line=lineno) + return messages + [error] + roles._roles[''] = role + # @@@ should this be local to the document, not the parser? + return messages + +default_role.arguments = (0, 1, 0) + def directive_test_function(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): """This directive is useful only for testing purposes.""" diff --git a/docutils/parsers/rst/languages/af.py b/docutils/parsers/rst/languages/af.py index 9dddae716..7304f153b 100644 --- a/docutils/parsers/rst/languages/af.py +++ b/docutils/parsers/rst/languages/af.py @@ -53,6 +53,7 @@ directives = { 'unicode': 'unicode', # should this be translated? unikode 'klas': 'class', 'role (translation required)': 'role', + 'default-role (translation required)': 'default-role', 'inhoud': 'contents', 'sectnum': 'sectnum', 'section-numbering': 'sectnum', diff --git a/docutils/parsers/rst/languages/ca.py b/docutils/parsers/rst/languages/ca.py index 9fdce400d..691887325 100644 --- a/docutils/parsers/rst/languages/ca.py +++ b/docutils/parsers/rst/languages/ca.py @@ -58,6 +58,7 @@ directives = { u'unicode': 'unicode', u'classe': 'class', u'rol': 'role', + u'default-role (translation required)': 'default-role', u'contingut': 'contents', u'numsec': 'sectnum', u'numeraci\u00F3-de-seccions': 'sectnum', diff --git a/docutils/parsers/rst/languages/cs.py b/docutils/parsers/rst/languages/cs.py index 7163cbf8f..24087badf 100644 --- a/docutils/parsers/rst/languages/cs.py +++ b/docutils/parsers/rst/languages/cs.py @@ -54,6 +54,7 @@ directives = { u'unicode (translation required)': 'unicode', u't\u0159\u00EDda': 'class', u'role (translation required)': 'role', + u'default-role (translation required)': 'default-role', u'obsah': 'contents', u'sectnum (translation required)': 'sectnum', u'section-numbering (translation required)': 'sectnum', diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index 9431f0e9d..56cca5c5b 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -56,6 +56,7 @@ directives = { 'unicode': 'unicode', 'klasse': 'class', 'rolle': 'role', + u'default-role (translation required)': 'default-role', 'inhalt': 'contents', 'kapitel-nummerierung': 'sectnum', 'abschnitts-nummerierung': 'sectnum', diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index 63ddcb1b9..46822b891 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -54,6 +54,7 @@ directives = { 'unicode': 'unicode', 'class': 'class', 'role': 'role', + 'default-role': 'default-role', 'contents': 'contents', 'sectnum': 'sectnum', 'section-numbering': 'sectnum', diff --git a/docutils/parsers/rst/languages/eo.py b/docutils/parsers/rst/languages/eo.py index 069fea45e..99b6d6970 100644 --- a/docutils/parsers/rst/languages/eo.py +++ b/docutils/parsers/rst/languages/eo.py @@ -60,6 +60,7 @@ directives = { u'unicode': 'unicode', u'klaso': 'class', u'rolo': 'role', + u'default-role (translation required)': 'default-role', u'enhavo': 'contents', u'seknum': 'sectnum', u'sekcia-numerado': 'sectnum', diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index 5f0a094da..726d97e88 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -62,6 +62,7 @@ directives = { u'unicode': 'unicode', u'clase': 'class', u'rol': 'role', + u'default-role (translation required)': 'default-role', u'contenido': 'contents', u'numseccion': 'sectnum', u'numsecci\u00f3n': 'sectnum', diff --git a/docutils/parsers/rst/languages/fi.py b/docutils/parsers/rst/languages/fi.py index c60444e3f..ba159cc70 100644 --- a/docutils/parsers/rst/languages/fi.py +++ b/docutils/parsers/rst/languages/fi.py @@ -52,6 +52,7 @@ directives = { u'unicode': u'unicode', u'luokka': u'class', u'rooli': u'role', + u'default-role (translation required)': 'default-role', u'sis\u00e4llys': u'contents', u'kappale': u'sectnum', u'header (translation required)': 'header', diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index 8b9cb04de..acb8d35e6 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -56,6 +56,7 @@ directives = { u'unicode': 'unicode', u'classe': 'class', u'role (translation required)': 'role', + u'default-role (translation required)': 'default-role', u'sommaire': 'contents', u'table-des-mati\u00E8res': 'contents', u'sectnum': 'sectnum', diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index ee31b42ae..f3afd2d35 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -53,6 +53,7 @@ directives = { 'unicode': 'unicode', 'classe': 'class', 'ruolo': 'role', + u'default-role (translation required)': 'default-role', 'indice': 'contents', 'contenuti': 'contents', 'seznum': 'sectnum', diff --git a/docutils/parsers/rst/languages/nl.py b/docutils/parsers/rst/languages/nl.py index 35942ca05..273828062 100644 --- a/docutils/parsers/rst/languages/nl.py +++ b/docutils/parsers/rst/languages/nl.py @@ -55,6 +55,7 @@ directives = { 'unicode': 'unicode', 'klasse': 'class', 'rol': 'role', + u'default-role (translation required)': 'default-role', 'inhoud': 'contents', 'sectnum': 'sectnum', 'sectie-nummering': 'sectnum', diff --git a/docutils/parsers/rst/languages/pt_br.py b/docutils/parsers/rst/languages/pt_br.py index 6f5d4cc6b..8a2534923 100644 --- a/docutils/parsers/rst/languages/pt_br.py +++ b/docutils/parsers/rst/languages/pt_br.py @@ -54,6 +54,7 @@ directives = { 'unicode': 'unicode', 'classe': 'class', 'role (translation required)': 'role', + u'default-role (translation required)': 'default-role', u'\u00EDndice': 'contents', 'numsec': 'sectnum', u'numera\u00E7\u00E3o-de-se\u00E7\u00F5es': 'sectnum', diff --git a/docutils/parsers/rst/languages/ru.py b/docutils/parsers/rst/languages/ru.py index 4ccca658c..23a842399 100644 --- a/docutils/parsers/rst/languages/ru.py +++ b/docutils/parsers/rst/languages/ru.py @@ -45,6 +45,7 @@ directives = { u'image', u'\u043a\u043b\u0430\u0441\u0441': u'class', u'role (translation required)': 'role', + u'default-role (translation required)': 'default-role', u'\u043d\u043e\u043c\u0435\u0440-\u0440\u0430\u0437\u0434\u0435\u043b\u0430': u'sectnum', u'\u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f-\u0440\u0430\u0437' diff --git a/docutils/parsers/rst/languages/sk.py b/docutils/parsers/rst/languages/sk.py index 2ba849700..e58296280 100644 --- a/docutils/parsers/rst/languages/sk.py +++ b/docutils/parsers/rst/languages/sk.py @@ -53,6 +53,7 @@ directives = { u'unicode': 'unicode', u'class (translation required)': 'class', u'role (translation required)': 'role', + u'default-role (translation required)': 'default-role', u'obsah': 'contents', u'\xe8as\x9d': 'sectnum', u'\xe8as\x9d-\xe8\xedslovanie': 'sectnum', diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index d6f6fba46..59d13f699 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -53,6 +53,7 @@ directives = { u'unicode': 'unicode', u'class (translation required)': 'class', u'role (translation required)': 'role', + u'default-role (translation required)': 'default-role', u'inneh\u00e5ll': 'contents', u'sektionsnumrering': 'sectnum', u'target-notes (translation required)': 'target-notes', diff --git a/docutils/parsers/rst/languages/zh_tw.py b/docutils/parsers/rst/languages/zh_tw.py index 15f253114..3eaea044a 100644 --- a/docutils/parsers/rst/languages/zh_tw.py +++ b/docutils/parsers/rst/languages/zh_tw.py @@ -54,6 +54,7 @@ directives = { 'unicode (translation required)': 'unicode', 'class (translation required)': 'class', 'role (translation required)': 'role', + u'default-role (translation required)': 'default-role', 'contents (translation required)': 'contents', 'sectnum (translation required)': 'sectnum', 'section-numbering (translation required)': 'sectnum', -- cgit v1.2.1 From 9061c56e4edac24c8e7adbe7aa6131578af9f040 Mon Sep 17 00:00:00 2001 From: wiemann Date: Mon, 6 Jun 2005 01:20:35 +0000 Subject: added "local" class to local TOCs git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3439 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/parts.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/parts.py b/docutils/parsers/rst/directives/parts.py index 37a32a963..2a1a092a4 100644 --- a/docutils/parsers/rst/directives/parts.py +++ b/docutils/parsers/rst/directives/parts.py @@ -56,6 +56,8 @@ def contents(name, arguments, options, content, lineno, title = nodes.title('', language.labels['contents']) topic = nodes.topic(classes=['contents']) topic['classes'] += options.get('class', []) + if options.has_key('local'): + topic['classes'].append('local') if title: name = title.astext() topic += title -- cgit v1.2.1 From cec037b796bfbd3481a37b0691c68a96f56ba0d9 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 8 Jun 2005 14:08:21 +0000 Subject: removed "from __future__ import" statements and lambda expressions git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3454 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 1ee9dc6f2..b7a359159 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -984,6 +984,16 @@ class Inliner: '__': anonymous_reference} +def _loweralpha_to_int(s, _zero=(ord('a')-1)): + return ord(s) - _zero + +def _upperalpha_to_int(s, _zero=(ord('A')-1)): + return ord(s) - _zero + +def _lowerroman_to_int(s): + return roman.fromRoman(s.upper()) + + class Body(RSTState): """ @@ -1006,12 +1016,9 @@ class Body(RSTState): 'lowerroman': '[ivxlcdm]+', 'upperroman': '[IVXLCDM]+',} enum.converters = {'arabic': int, - 'loweralpha': - lambda s, zero=(ord('a')-1): ord(s) - zero, - 'upperalpha': - lambda s, zero=(ord('A')-1): ord(s) - zero, - 'lowerroman': - lambda s: roman.fromRoman(s.upper()), + 'loweralpha': _loweralpha_to_int, + 'upperalpha': _upperalpha_to_int, + 'lowerroman': _lowerroman_to_int, 'upperroman': roman.fromRoman} enum.sequenceregexps = {} -- cgit v1.2.1 From 61075e34557635f6facec931b31da5ec3b04243c Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 9 Jun 2005 17:32:17 +0000 Subject: added "title" directive git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3455 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 1 + docutils/parsers/rst/directives/misc.py | 7 +++++++ docutils/parsers/rst/languages/af.py | 1 + docutils/parsers/rst/languages/ca.py | 1 + docutils/parsers/rst/languages/cs.py | 1 + docutils/parsers/rst/languages/de.py | 1 + docutils/parsers/rst/languages/en.py | 1 + docutils/parsers/rst/languages/eo.py | 1 + docutils/parsers/rst/languages/es.py | 1 + docutils/parsers/rst/languages/fi.py | 1 + docutils/parsers/rst/languages/fr.py | 1 + docutils/parsers/rst/languages/it.py | 1 + docutils/parsers/rst/languages/nl.py | 1 + docutils/parsers/rst/languages/pt_br.py | 1 + docutils/parsers/rst/languages/ru.py | 1 + docutils/parsers/rst/languages/sk.py | 1 + docutils/parsers/rst/languages/sv.py | 1 + docutils/parsers/rst/languages/zh_tw.py | 1 + 18 files changed, 24 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 1db0c76e0..d78a3b9c1 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -132,6 +132,7 @@ _directive_registry = { 'class': ('misc', 'class_directive'), 'role': ('misc', 'role'), 'default-role': ('misc', 'default_role'), + 'title': ('misc', 'title'), 'restructuredtext-test-directive': ('misc', 'directive_test_function'),} """Mapping of directive name to (module name, function name). The directive name is canonical & must be lowercase. Language-dependent names are defined diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 7007546df..798512eeb 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -351,6 +351,13 @@ def default_role(name, arguments, options, content, lineno, default_role.arguments = (0, 1, 0) +def title(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + state_machine.document.settings.title = arguments[0] + return [] + +title.arguments = (1, 0, 1) + def directive_test_function(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): """This directive is useful only for testing purposes.""" diff --git a/docutils/parsers/rst/languages/af.py b/docutils/parsers/rst/languages/af.py index 7304f153b..e8fa9cbb8 100644 --- a/docutils/parsers/rst/languages/af.py +++ b/docutils/parsers/rst/languages/af.py @@ -54,6 +54,7 @@ directives = { 'klas': 'class', 'role (translation required)': 'role', 'default-role (translation required)': 'default-role', + 'title (translation required)': 'title', 'inhoud': 'contents', 'sectnum': 'sectnum', 'section-numbering': 'sectnum', diff --git a/docutils/parsers/rst/languages/ca.py b/docutils/parsers/rst/languages/ca.py index 691887325..d534ecfbc 100644 --- a/docutils/parsers/rst/languages/ca.py +++ b/docutils/parsers/rst/languages/ca.py @@ -59,6 +59,7 @@ directives = { u'classe': 'class', u'rol': 'role', u'default-role (translation required)': 'default-role', + u'title (translation required)': 'title', u'contingut': 'contents', u'numsec': 'sectnum', u'numeraci\u00F3-de-seccions': 'sectnum', diff --git a/docutils/parsers/rst/languages/cs.py b/docutils/parsers/rst/languages/cs.py index 24087badf..cf3fbf132 100644 --- a/docutils/parsers/rst/languages/cs.py +++ b/docutils/parsers/rst/languages/cs.py @@ -55,6 +55,7 @@ directives = { u't\u0159\u00EDda': 'class', u'role (translation required)': 'role', u'default-role (translation required)': 'default-role', + u'title (translation required)': 'title', u'obsah': 'contents', u'sectnum (translation required)': 'sectnum', u'section-numbering (translation required)': 'sectnum', diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index 56cca5c5b..7bf72c149 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -57,6 +57,7 @@ directives = { 'klasse': 'class', 'rolle': 'role', u'default-role (translation required)': 'default-role', + u'title (translation required)': 'title', 'inhalt': 'contents', 'kapitel-nummerierung': 'sectnum', 'abschnitts-nummerierung': 'sectnum', diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index 46822b891..2c9e78737 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -55,6 +55,7 @@ directives = { 'class': 'class', 'role': 'role', 'default-role': 'default-role', + 'title': 'title', 'contents': 'contents', 'sectnum': 'sectnum', 'section-numbering': 'sectnum', diff --git a/docutils/parsers/rst/languages/eo.py b/docutils/parsers/rst/languages/eo.py index 99b6d6970..d324e2201 100644 --- a/docutils/parsers/rst/languages/eo.py +++ b/docutils/parsers/rst/languages/eo.py @@ -61,6 +61,7 @@ directives = { u'klaso': 'class', u'rolo': 'role', u'default-role (translation required)': 'default-role', + u'title (translation required)': 'title', u'enhavo': 'contents', u'seknum': 'sectnum', u'sekcia-numerado': 'sectnum', diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index 726d97e88..8d864afb6 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -63,6 +63,7 @@ directives = { u'clase': 'class', u'rol': 'role', u'default-role (translation required)': 'default-role', + u'title (translation required)': 'title', u'contenido': 'contents', u'numseccion': 'sectnum', u'numsecci\u00f3n': 'sectnum', diff --git a/docutils/parsers/rst/languages/fi.py b/docutils/parsers/rst/languages/fi.py index ba159cc70..bf175081e 100644 --- a/docutils/parsers/rst/languages/fi.py +++ b/docutils/parsers/rst/languages/fi.py @@ -53,6 +53,7 @@ directives = { u'luokka': u'class', u'rooli': u'role', u'default-role (translation required)': 'default-role', + u'title (translation required)': 'title', u'sis\u00e4llys': u'contents', u'kappale': u'sectnum', u'header (translation required)': 'header', diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index acb8d35e6..b75cad50b 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -57,6 +57,7 @@ directives = { u'classe': 'class', u'role (translation required)': 'role', u'default-role (translation required)': 'default-role', + u'title (translation required)': 'title', u'sommaire': 'contents', u'table-des-mati\u00E8res': 'contents', u'sectnum': 'sectnum', diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index f3afd2d35..e28f3ec00 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -54,6 +54,7 @@ directives = { 'classe': 'class', 'ruolo': 'role', u'default-role (translation required)': 'default-role', + 'title (translation required)': 'title', 'indice': 'contents', 'contenuti': 'contents', 'seznum': 'sectnum', diff --git a/docutils/parsers/rst/languages/nl.py b/docutils/parsers/rst/languages/nl.py index 273828062..7ade5d721 100644 --- a/docutils/parsers/rst/languages/nl.py +++ b/docutils/parsers/rst/languages/nl.py @@ -56,6 +56,7 @@ directives = { 'klasse': 'class', 'rol': 'role', u'default-role (translation required)': 'default-role', + 'title (translation required)': 'title', 'inhoud': 'contents', 'sectnum': 'sectnum', 'sectie-nummering': 'sectnum', diff --git a/docutils/parsers/rst/languages/pt_br.py b/docutils/parsers/rst/languages/pt_br.py index 8a2534923..ba02538fd 100644 --- a/docutils/parsers/rst/languages/pt_br.py +++ b/docutils/parsers/rst/languages/pt_br.py @@ -55,6 +55,7 @@ directives = { 'classe': 'class', 'role (translation required)': 'role', u'default-role (translation required)': 'default-role', + u'title (translation required)': 'title', u'\u00EDndice': 'contents', 'numsec': 'sectnum', u'numera\u00E7\u00E3o-de-se\u00E7\u00F5es': 'sectnum', diff --git a/docutils/parsers/rst/languages/ru.py b/docutils/parsers/rst/languages/ru.py index 23a842399..61a8f2297 100644 --- a/docutils/parsers/rst/languages/ru.py +++ b/docutils/parsers/rst/languages/ru.py @@ -46,6 +46,7 @@ directives = { u'\u043a\u043b\u0430\u0441\u0441': u'class', u'role (translation required)': 'role', u'default-role (translation required)': 'default-role', + u'title (translation required)': 'title', u'\u043d\u043e\u043c\u0435\u0440-\u0440\u0430\u0437\u0434\u0435\u043b\u0430': u'sectnum', u'\u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f-\u0440\u0430\u0437' diff --git a/docutils/parsers/rst/languages/sk.py b/docutils/parsers/rst/languages/sk.py index e58296280..b47e6228d 100644 --- a/docutils/parsers/rst/languages/sk.py +++ b/docutils/parsers/rst/languages/sk.py @@ -54,6 +54,7 @@ directives = { u'class (translation required)': 'class', u'role (translation required)': 'role', u'default-role (translation required)': 'default-role', + u'title (translation required)': 'title', u'obsah': 'contents', u'\xe8as\x9d': 'sectnum', u'\xe8as\x9d-\xe8\xedslovanie': 'sectnum', diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index 59d13f699..11697ec55 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -54,6 +54,7 @@ directives = { u'class (translation required)': 'class', u'role (translation required)': 'role', u'default-role (translation required)': 'default-role', + u'title (translation required)': 'title', u'inneh\u00e5ll': 'contents', u'sektionsnumrering': 'sectnum', u'target-notes (translation required)': 'target-notes', diff --git a/docutils/parsers/rst/languages/zh_tw.py b/docutils/parsers/rst/languages/zh_tw.py index 3eaea044a..664aaf6ea 100644 --- a/docutils/parsers/rst/languages/zh_tw.py +++ b/docutils/parsers/rst/languages/zh_tw.py @@ -55,6 +55,7 @@ directives = { 'class (translation required)': 'class', 'role (translation required)': 'role', u'default-role (translation required)': 'default-role', + u'title (translation required)': 'title', 'contents (translation required)': 'contents', 'sectnum (translation required)': 'sectnum', 'section-numbering (translation required)': 'sectnum', -- cgit v1.2.1 From d161fd862fb3bbec9472ee5f9e26e63ef5cac692 Mon Sep 17 00:00:00 2001 From: richieadler Date: Fri, 10 Jun 2005 02:29:03 +0000 Subject: translation for "default-role" and "title" directives git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3457 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/eo.py | 4 ++-- docutils/parsers/rst/languages/es.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/eo.py b/docutils/parsers/rst/languages/eo.py index d324e2201..316b98e03 100644 --- a/docutils/parsers/rst/languages/eo.py +++ b/docutils/parsers/rst/languages/eo.py @@ -60,8 +60,8 @@ directives = { u'unicode': 'unicode', u'klaso': 'class', u'rolo': 'role', - u'default-role (translation required)': 'default-role', - u'title (translation required)': 'title', + u'preterlasita-rolo': 'default-role', + u'titolo': 'title', u'enhavo': 'contents', u'seknum': 'sectnum', u'sekcia-numerado': 'sectnum', diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index 8d864afb6..d2f650b14 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -62,8 +62,10 @@ directives = { u'unicode': 'unicode', u'clase': 'class', u'rol': 'role', - u'default-role (translation required)': 'default-role', - u'title (translation required)': 'title', + u'rol-por-omision': 'default-role', + u'rol-por-omisi\u00f3n': 'default-role', + u'titulo': 'title', + u't\u00edtulo': 'title', u'contenido': 'contents', u'numseccion': 'sectnum', u'numsecci\u00f3n': 'sectnum', -- cgit v1.2.1 From 3b7a7200860068db23463a6a4246c19814012ee9 Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 12 Jun 2005 16:40:14 +0000 Subject: Added standard data file syntax to the "include" directive. Added docutils/parsers/rst/include/ directory; contains the standard data files, with character entity substitution definition sets as initial contents. Added docs/ref/rst/substitutions.txt: "reStructuredText Standard Substitution Definition Sets". Updated docs, tests, & setup.py. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3472 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 4 + docutils/parsers/rst/include/README.txt | 21 + docutils/parsers/rst/include/docutils.conf | 5 + docutils/parsers/rst/include/isoamsa.txt | 162 +++++++ docutils/parsers/rst/include/isoamsb.txt | 126 ++++++ docutils/parsers/rst/include/isoamsc.txt | 29 ++ docutils/parsers/rst/include/isoamsn.txt | 96 ++++ docutils/parsers/rst/include/isoamso.txt | 62 +++ docutils/parsers/rst/include/isoamsr.txt | 191 ++++++++ docutils/parsers/rst/include/isobox.txt | 46 ++ docutils/parsers/rst/include/isocyr1.txt | 73 ++++ docutils/parsers/rst/include/isocyr2.txt | 32 ++ docutils/parsers/rst/include/isodia.txt | 20 + docutils/parsers/rst/include/isogrk1.txt | 55 +++ docutils/parsers/rst/include/isogrk2.txt | 26 ++ docutils/parsers/rst/include/isogrk3.txt | 52 +++ docutils/parsers/rst/include/isogrk4-wide.txt | 49 +++ docutils/parsers/rst/include/isogrk4.txt | 8 + docutils/parsers/rst/include/isolat1.txt | 68 +++ docutils/parsers/rst/include/isolat2.txt | 128 ++++++ docutils/parsers/rst/include/isomfrk-wide.txt | 58 +++ docutils/parsers/rst/include/isomfrk.txt | 11 + docutils/parsers/rst/include/isomopf-wide.txt | 32 ++ docutils/parsers/rst/include/isomopf.txt | 13 + docutils/parsers/rst/include/isomscr-wide.txt | 58 +++ docutils/parsers/rst/include/isomscr.txt | 17 + docutils/parsers/rst/include/isonum.txt | 82 ++++ docutils/parsers/rst/include/isopub.txt | 90 ++++ docutils/parsers/rst/include/isotech.txt | 168 +++++++ docutils/parsers/rst/include/mmlalias.txt | 554 ++++++++++++++++++++++++ docutils/parsers/rst/include/mmlextra-wide.txt | 113 +++++ docutils/parsers/rst/include/mmlextra.txt | 87 ++++ docutils/parsers/rst/include/xhtml1-lat1.txt | 102 +++++ docutils/parsers/rst/include/xhtml1-special.txt | 37 ++ docutils/parsers/rst/include/xhtml1-symbol.txt | 130 ++++++ 35 files changed, 2805 insertions(+) create mode 100644 docutils/parsers/rst/include/README.txt create mode 100644 docutils/parsers/rst/include/docutils.conf create mode 100644 docutils/parsers/rst/include/isoamsa.txt create mode 100644 docutils/parsers/rst/include/isoamsb.txt create mode 100644 docutils/parsers/rst/include/isoamsc.txt create mode 100644 docutils/parsers/rst/include/isoamsn.txt create mode 100644 docutils/parsers/rst/include/isoamso.txt create mode 100644 docutils/parsers/rst/include/isoamsr.txt create mode 100644 docutils/parsers/rst/include/isobox.txt create mode 100644 docutils/parsers/rst/include/isocyr1.txt create mode 100644 docutils/parsers/rst/include/isocyr2.txt create mode 100644 docutils/parsers/rst/include/isodia.txt create mode 100644 docutils/parsers/rst/include/isogrk1.txt create mode 100644 docutils/parsers/rst/include/isogrk2.txt create mode 100644 docutils/parsers/rst/include/isogrk3.txt create mode 100644 docutils/parsers/rst/include/isogrk4-wide.txt create mode 100644 docutils/parsers/rst/include/isogrk4.txt create mode 100644 docutils/parsers/rst/include/isolat1.txt create mode 100644 docutils/parsers/rst/include/isolat2.txt create mode 100644 docutils/parsers/rst/include/isomfrk-wide.txt create mode 100644 docutils/parsers/rst/include/isomfrk.txt create mode 100644 docutils/parsers/rst/include/isomopf-wide.txt create mode 100644 docutils/parsers/rst/include/isomopf.txt create mode 100644 docutils/parsers/rst/include/isomscr-wide.txt create mode 100644 docutils/parsers/rst/include/isomscr.txt create mode 100644 docutils/parsers/rst/include/isonum.txt create mode 100644 docutils/parsers/rst/include/isopub.txt create mode 100644 docutils/parsers/rst/include/isotech.txt create mode 100644 docutils/parsers/rst/include/mmlalias.txt create mode 100644 docutils/parsers/rst/include/mmlextra-wide.txt create mode 100644 docutils/parsers/rst/include/mmlextra.txt create mode 100644 docutils/parsers/rst/include/xhtml1-lat1.txt create mode 100644 docutils/parsers/rst/include/xhtml1-special.txt create mode 100644 docutils/parsers/rst/include/xhtml1-symbol.txt (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 798512eeb..af206751f 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -21,6 +21,8 @@ except ImportError: urllib2 = None +standard_include_path = os.path.join(os.path.dirname(states.__file__), 'data') + def include(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): """Include a reST file as part of the content of this reST file.""" @@ -33,6 +35,8 @@ def include(name, arguments, options, content, lineno, lineno - state_machine.input_offset - 1) source_dir = os.path.dirname(os.path.abspath(source)) path = directives.path(arguments[0]) + if path.startswith('<') and path.endswith('>'): + path = os.path.join(standard_include_path, path[1:-1]) path = os.path.normpath(os.path.join(source_dir, path)) path = utils.relative_path(None, path) encoding = options.get('encoding', state.document.settings.input_encoding) diff --git a/docutils/parsers/rst/include/README.txt b/docutils/parsers/rst/include/README.txt new file mode 100644 index 000000000..af29691be --- /dev/null +++ b/docutils/parsers/rst/include/README.txt @@ -0,0 +1,21 @@ +============================================ + ``docutils/parsers/rst/include`` Directory +============================================ + +The individual data files are stored with the Docutils source code in +the "docutils" package, in the ``docutils/parsers/rst/include`` +directory. + +This directory contains standard data files intended for inclusion in +reStructuredText documents. To access these files, use the "include" +directive with the special syntax for standard "include" data files, +angle brackets around the file name:: + + .. include:: + +See the documentation for the `"include" directive`__ and +`reStructuredText Standard Substitution Definition Sets`__ for +details. + +__ http://docutils.sf.net/docs/ref/rst/directives.html#include +__ http://docutils.sf.net/docs/ref/rst/substitutions.html diff --git a/docutils/parsers/rst/include/docutils.conf b/docutils/parsers/rst/include/docutils.conf new file mode 100644 index 000000000..cdce8d629 --- /dev/null +++ b/docutils/parsers/rst/include/docutils.conf @@ -0,0 +1,5 @@ +# This configuration file is to prevent tools/buildhtml.py from +# processing text files in and below this directory. + +[buildhtml application] +prune: . diff --git a/docutils/parsers/rst/include/isoamsa.txt b/docutils/parsers/rst/include/isoamsa.txt new file mode 100644 index 000000000..e6f451800 --- /dev/null +++ b/docutils/parsers/rst/include/isoamsa.txt @@ -0,0 +1,162 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |angzarr| unicode:: U+0237C .. RIGHT ANGLE WITH DOWNWARDS ZIGZAG ARROW +.. |cirmid| unicode:: U+02AEF .. VERTICAL LINE WITH CIRCLE ABOVE +.. |cudarrl| unicode:: U+02938 .. RIGHT-SIDE ARC CLOCKWISE ARROW +.. |cudarrr| unicode:: U+02935 .. ARROW POINTING RIGHTWARDS THEN CURVING DOWNWARDS +.. |cularr| unicode:: U+021B6 .. ANTICLOCKWISE TOP SEMICIRCLE ARROW +.. |cularrp| unicode:: U+0293D .. TOP ARC ANTICLOCKWISE ARROW WITH PLUS +.. |curarr| unicode:: U+021B7 .. CLOCKWISE TOP SEMICIRCLE ARROW +.. |curarrm| unicode:: U+0293C .. TOP ARC CLOCKWISE ARROW WITH MINUS +.. |Darr| unicode:: U+021A1 .. DOWNWARDS TWO HEADED ARROW +.. |dArr| unicode:: U+021D3 .. DOWNWARDS DOUBLE ARROW +.. |darr2| unicode:: U+021CA .. DOWNWARDS PAIRED ARROWS +.. |ddarr| unicode:: U+021CA .. DOWNWARDS PAIRED ARROWS +.. |DDotrahd| unicode:: U+02911 .. RIGHTWARDS ARROW WITH DOTTED STEM +.. |dfisht| unicode:: U+0297F .. DOWN FISH TAIL +.. |dHar| unicode:: U+02965 .. DOWNWARDS HARPOON WITH BARB LEFT BESIDE DOWNWARDS HARPOON WITH BARB RIGHT +.. |dharl| unicode:: U+021C3 .. DOWNWARDS HARPOON WITH BARB LEFTWARDS +.. |dharr| unicode:: U+021C2 .. DOWNWARDS HARPOON WITH BARB RIGHTWARDS +.. |dlarr| unicode:: U+02199 .. SOUTH WEST ARROW +.. |drarr| unicode:: U+02198 .. SOUTH EAST ARROW +.. |duarr| unicode:: U+021F5 .. DOWNWARDS ARROW LEFTWARDS OF UPWARDS ARROW +.. |duhar| unicode:: U+0296F .. DOWNWARDS HARPOON WITH BARB LEFT BESIDE UPWARDS HARPOON WITH BARB RIGHT +.. |dzigrarr| unicode:: U+027FF .. LONG RIGHTWARDS SQUIGGLE ARROW +.. |erarr| unicode:: U+02971 .. EQUALS SIGN ABOVE RIGHTWARDS ARROW +.. |hArr| unicode:: U+021D4 .. LEFT RIGHT DOUBLE ARROW +.. |harr| unicode:: U+02194 .. LEFT RIGHT ARROW +.. |harrcir| unicode:: U+02948 .. LEFT RIGHT ARROW THROUGH SMALL CIRCLE +.. |harrw| unicode:: U+021AD .. LEFT RIGHT WAVE ARROW +.. |hoarr| unicode:: U+021FF .. LEFT RIGHT OPEN-HEADED ARROW +.. |imof| unicode:: U+022B7 .. IMAGE OF +.. |lAarr| unicode:: U+021DA .. LEFTWARDS TRIPLE ARROW +.. |Larr| unicode:: U+0219E .. LEFTWARDS TWO HEADED ARROW +.. |larr2| unicode:: U+021C7 .. LEFTWARDS PAIRED ARROWS +.. |larrbfs| unicode:: U+0291F .. LEFTWARDS ARROW FROM BAR TO BLACK DIAMOND +.. |larrfs| unicode:: U+0291D .. LEFTWARDS ARROW TO BLACK DIAMOND +.. |larrhk| unicode:: U+021A9 .. LEFTWARDS ARROW WITH HOOK +.. |larrlp| unicode:: U+021AB .. LEFTWARDS ARROW WITH LOOP +.. |larrpl| unicode:: U+02939 .. LEFT-SIDE ARC ANTICLOCKWISE ARROW +.. |larrsim| unicode:: U+02973 .. LEFTWARDS ARROW ABOVE TILDE OPERATOR +.. |larrtl| unicode:: U+021A2 .. LEFTWARDS ARROW WITH TAIL +.. |lAtail| unicode:: U+0291B .. LEFTWARDS DOUBLE ARROW-TAIL +.. |latail| unicode:: U+02919 .. LEFTWARDS ARROW-TAIL +.. |lBarr| unicode:: U+0290E .. LEFTWARDS TRIPLE DASH ARROW +.. |lbarr| unicode:: U+0290C .. LEFTWARDS DOUBLE DASH ARROW +.. |ldca| unicode:: U+02936 .. ARROW POINTING DOWNWARDS THEN CURVING LEFTWARDS +.. |ldrdhar| unicode:: U+02967 .. LEFTWARDS HARPOON WITH BARB DOWN ABOVE RIGHTWARDS HARPOON WITH BARB DOWN +.. |ldrushar| unicode:: U+0294B .. LEFT BARB DOWN RIGHT BARB UP HARPOON +.. |ldsh| unicode:: U+021B2 .. DOWNWARDS ARROW WITH TIP LEFTWARDS +.. |lfisht| unicode:: U+0297C .. LEFT FISH TAIL +.. |lHar| unicode:: U+02962 .. LEFTWARDS HARPOON WITH BARB UP ABOVE LEFTWARDS HARPOON WITH BARB DOWN +.. |lhard| unicode:: U+021BD .. LEFTWARDS HARPOON WITH BARB DOWNWARDS +.. |lharu| unicode:: U+021BC .. LEFTWARDS HARPOON WITH BARB UPWARDS +.. |lharul| unicode:: U+0296A .. LEFTWARDS HARPOON WITH BARB UP ABOVE LONG DASH +.. |llarr| unicode:: U+021C7 .. LEFTWARDS PAIRED ARROWS +.. |llhard| unicode:: U+0296B .. LEFTWARDS HARPOON WITH BARB DOWN BELOW LONG DASH +.. |loarr| unicode:: U+021FD .. LEFTWARDS OPEN-HEADED ARROW +.. |lrarr| unicode:: U+021C6 .. LEFTWARDS ARROW OVER RIGHTWARDS ARROW +.. |lrarr2| unicode:: U+021C6 .. LEFTWARDS ARROW OVER RIGHTWARDS ARROW +.. |lrhar| unicode:: U+021CB .. LEFTWARDS HARPOON OVER RIGHTWARDS HARPOON +.. |lrhar2| unicode:: U+021CB .. LEFTWARDS HARPOON OVER RIGHTWARDS HARPOON +.. |lrhard| unicode:: U+0296D .. RIGHTWARDS HARPOON WITH BARB DOWN BELOW LONG DASH +.. |lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS +.. |lurdshar| unicode:: U+0294A .. LEFT BARB UP RIGHT BARB DOWN HARPOON +.. |luruhar| unicode:: U+02966 .. LEFTWARDS HARPOON WITH BARB UP ABOVE RIGHTWARDS HARPOON WITH BARB UP +.. |Map| unicode:: U+02905 .. RIGHTWARDS TWO-HEADED ARROW FROM BAR +.. |map| unicode:: U+021A6 .. RIGHTWARDS ARROW FROM BAR +.. |midcir| unicode:: U+02AF0 .. VERTICAL LINE WITH CIRCLE BELOW +.. |mumap| unicode:: U+022B8 .. MULTIMAP +.. |nearhk| unicode:: U+02924 .. NORTH EAST ARROW WITH HOOK +.. |neArr| unicode:: U+021D7 .. NORTH EAST DOUBLE ARROW +.. |nearr| unicode:: U+02197 .. NORTH EAST ARROW +.. |nesear| unicode:: U+02928 .. NORTH EAST ARROW AND SOUTH EAST ARROW +.. |nhArr| unicode:: U+021CE .. LEFT RIGHT DOUBLE ARROW WITH STROKE +.. |nharr| unicode:: U+021AE .. LEFT RIGHT ARROW WITH STROKE +.. |nlArr| unicode:: U+021CD .. LEFTWARDS DOUBLE ARROW WITH STROKE +.. |nlarr| unicode:: U+0219A .. LEFTWARDS ARROW WITH STROKE +.. |nrArr| unicode:: U+021CF .. RIGHTWARDS DOUBLE ARROW WITH STROKE +.. |nrarr| unicode:: U+0219B .. RIGHTWARDS ARROW WITH STROKE +.. |nrarrc| unicode:: U+02933 U+00338 .. WAVE ARROW POINTING DIRECTLY RIGHT with slash +.. |nrarrw| unicode:: U+0219D U+00338 .. RIGHTWARDS WAVE ARROW with slash +.. |nvHarr| unicode:: U+02904 .. LEFT RIGHT DOUBLE ARROW WITH VERTICAL STROKE +.. |nvlArr| unicode:: U+02902 .. LEFTWARDS DOUBLE ARROW WITH VERTICAL STROKE +.. |nvrArr| unicode:: U+02903 .. RIGHTWARDS DOUBLE ARROW WITH VERTICAL STROKE +.. |nwarhk| unicode:: U+02923 .. NORTH WEST ARROW WITH HOOK +.. |nwArr| unicode:: U+021D6 .. NORTH WEST DOUBLE ARROW +.. |nwarr| unicode:: U+02196 .. NORTH WEST ARROW +.. |nwnear| unicode:: U+02927 .. NORTH WEST ARROW AND NORTH EAST ARROW +.. |olarr| unicode:: U+021BA .. ANTICLOCKWISE OPEN CIRCLE ARROW +.. |orarr| unicode:: U+021BB .. CLOCKWISE OPEN CIRCLE ARROW +.. |origof| unicode:: U+022B6 .. ORIGINAL OF +.. |rAarr| unicode:: U+021DB .. RIGHTWARDS TRIPLE ARROW +.. |Rarr| unicode:: U+021A0 .. RIGHTWARDS TWO HEADED ARROW +.. |rarr2| unicode:: U+021C9 .. RIGHTWARDS PAIRED ARROWS +.. |rarrap| unicode:: U+02975 .. RIGHTWARDS ARROW ABOVE ALMOST EQUAL TO +.. |rarrbfs| unicode:: U+02920 .. RIGHTWARDS ARROW FROM BAR TO BLACK DIAMOND +.. |rarrc| unicode:: U+02933 .. WAVE ARROW POINTING DIRECTLY RIGHT +.. |rarrfs| unicode:: U+0291E .. RIGHTWARDS ARROW TO BLACK DIAMOND +.. |rarrhk| unicode:: U+021AA .. RIGHTWARDS ARROW WITH HOOK +.. |rarrlp| unicode:: U+021AC .. RIGHTWARDS ARROW WITH LOOP +.. |rarrpl| unicode:: U+02945 .. RIGHTWARDS ARROW WITH PLUS BELOW +.. |rarrsim| unicode:: U+02974 .. RIGHTWARDS ARROW ABOVE TILDE OPERATOR +.. |Rarrtl| unicode:: U+02916 .. RIGHTWARDS TWO-HEADED ARROW WITH TAIL +.. |rarrtl| unicode:: U+021A3 .. RIGHTWARDS ARROW WITH TAIL +.. |rarrw| unicode:: U+0219D .. RIGHTWARDS WAVE ARROW +.. |rAtail| unicode:: U+0291C .. RIGHTWARDS DOUBLE ARROW-TAIL +.. |ratail| unicode:: U+0291A .. RIGHTWARDS ARROW-TAIL +.. |RBarr| unicode:: U+02910 .. RIGHTWARDS TWO-HEADED TRIPLE DASH ARROW +.. |rBarr| unicode:: U+0290F .. RIGHTWARDS TRIPLE DASH ARROW +.. |rbarr| unicode:: U+0290D .. RIGHTWARDS DOUBLE DASH ARROW +.. |rdca| unicode:: U+02937 .. ARROW POINTING DOWNWARDS THEN CURVING RIGHTWARDS +.. |rdldhar| unicode:: U+02969 .. RIGHTWARDS HARPOON WITH BARB DOWN ABOVE LEFTWARDS HARPOON WITH BARB DOWN +.. |rdsh| unicode:: U+021B3 .. DOWNWARDS ARROW WITH TIP RIGHTWARDS +.. |rfisht| unicode:: U+0297D .. RIGHT FISH TAIL +.. |rHar| unicode:: U+02964 .. RIGHTWARDS HARPOON WITH BARB UP ABOVE RIGHTWARDS HARPOON WITH BARB DOWN +.. |rhard| unicode:: U+021C1 .. RIGHTWARDS HARPOON WITH BARB DOWNWARDS +.. |rharu| unicode:: U+021C0 .. RIGHTWARDS HARPOON WITH BARB UPWARDS +.. |rharul| unicode:: U+0296C .. RIGHTWARDS HARPOON WITH BARB UP ABOVE LONG DASH +.. |rlarr| unicode:: U+021C4 .. RIGHTWARDS ARROW OVER LEFTWARDS ARROW +.. |rlarr2| unicode:: U+021C4 .. RIGHTWARDS ARROW OVER LEFTWARDS ARROW +.. |rlhar| unicode:: U+021CC .. RIGHTWARDS HARPOON OVER LEFTWARDS HARPOON +.. |rlhar2| unicode:: U+021CC .. RIGHTWARDS HARPOON OVER LEFTWARDS HARPOON +.. |roarr| unicode:: U+021FE .. RIGHTWARDS OPEN-HEADED ARROW +.. |rrarr| unicode:: U+021C9 .. RIGHTWARDS PAIRED ARROWS +.. |rsh| unicode:: U+021B1 .. UPWARDS ARROW WITH TIP RIGHTWARDS +.. |ruluhar| unicode:: U+02968 .. RIGHTWARDS HARPOON WITH BARB UP ABOVE LEFTWARDS HARPOON WITH BARB UP +.. |searhk| unicode:: U+02925 .. SOUTH EAST ARROW WITH HOOK +.. |seArr| unicode:: U+021D8 .. SOUTH EAST DOUBLE ARROW +.. |searr| unicode:: U+02198 .. SOUTH EAST ARROW +.. |seswar| unicode:: U+02929 .. SOUTH EAST ARROW AND SOUTH WEST ARROW +.. |simrarr| unicode:: U+02972 .. TILDE OPERATOR ABOVE RIGHTWARDS ARROW +.. |slarr| unicode:: U+02190 .. LEFTWARDS ARROW +.. |srarr| unicode:: U+02192 .. RIGHTWARDS ARROW +.. |swarhk| unicode:: U+02926 .. SOUTH WEST ARROW WITH HOOK +.. |swArr| unicode:: U+021D9 .. SOUTH WEST DOUBLE ARROW +.. |swarr| unicode:: U+02199 .. SOUTH WEST ARROW +.. |swnwar| unicode:: U+0292A .. SOUTH WEST ARROW AND NORTH WEST ARROW +.. |Uarr| unicode:: U+0219F .. UPWARDS TWO HEADED ARROW +.. |uArr| unicode:: U+021D1 .. UPWARDS DOUBLE ARROW +.. |uarr2| unicode:: U+021C8 .. UPWARDS PAIRED ARROWS +.. |Uarrocir| unicode:: U+02949 .. UPWARDS TWO-HEADED ARROW FROM SMALL CIRCLE +.. |udarr| unicode:: U+021C5 .. UPWARDS ARROW LEFTWARDS OF DOWNWARDS ARROW +.. |udhar| unicode:: U+0296E .. UPWARDS HARPOON WITH BARB LEFT BESIDE DOWNWARDS HARPOON WITH BARB RIGHT +.. |ufisht| unicode:: U+0297E .. UP FISH TAIL +.. |uHar| unicode:: U+02963 .. UPWARDS HARPOON WITH BARB LEFT BESIDE UPWARDS HARPOON WITH BARB RIGHT +.. |uharl| unicode:: U+021BF .. UPWARDS HARPOON WITH BARB LEFTWARDS +.. |uharr| unicode:: U+021BE .. UPWARDS HARPOON WITH BARB RIGHTWARDS +.. |uuarr| unicode:: U+021C8 .. UPWARDS PAIRED ARROWS +.. |vArr| unicode:: U+021D5 .. UP DOWN DOUBLE ARROW +.. |varr| unicode:: U+02195 .. UP DOWN ARROW +.. |xhArr| unicode:: U+027FA .. LONG LEFT RIGHT DOUBLE ARROW +.. |xharr| unicode:: U+027F7 .. LONG LEFT RIGHT ARROW +.. |xlArr| unicode:: U+027F8 .. LONG LEFTWARDS DOUBLE ARROW +.. |xlarr| unicode:: U+027F5 .. LONG LEFTWARDS ARROW +.. |xmap| unicode:: U+027FC .. LONG RIGHTWARDS ARROW FROM BAR +.. |xrArr| unicode:: U+027F9 .. LONG RIGHTWARDS DOUBLE ARROW +.. |xrarr| unicode:: U+027F6 .. LONG RIGHTWARDS ARROW +.. |zigrarr| unicode:: U+021DD .. RIGHTWARDS SQUIGGLE ARROW diff --git a/docutils/parsers/rst/include/isoamsb.txt b/docutils/parsers/rst/include/isoamsb.txt new file mode 100644 index 000000000..05e68d99d --- /dev/null +++ b/docutils/parsers/rst/include/isoamsb.txt @@ -0,0 +1,126 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |ac| unicode:: U+0223E .. INVERTED LAZY S +.. |acE| unicode:: U+0223E U+00333 .. INVERTED LAZY S with double underline +.. |amalg| unicode:: U+02A3F .. AMALGAMATION OR COPRODUCT +.. |barvee| unicode:: U+022BD .. NOR +.. |Barwed| unicode:: U+02306 .. PERSPECTIVE +.. |barwed| unicode:: U+02305 .. PROJECTIVE +.. |bsolb| unicode:: U+029C5 .. SQUARED FALLING DIAGONAL SLASH +.. |Cap| unicode:: U+022D2 .. DOUBLE INTERSECTION +.. |capand| unicode:: U+02A44 .. INTERSECTION WITH LOGICAL AND +.. |capbrcup| unicode:: U+02A49 .. INTERSECTION ABOVE BAR ABOVE UNION +.. |capcap| unicode:: U+02A4B .. INTERSECTION BESIDE AND JOINED WITH INTERSECTION +.. |capcup| unicode:: U+02A47 .. INTERSECTION ABOVE UNION +.. |capdot| unicode:: U+02A40 .. INTERSECTION WITH DOT +.. |caps| unicode:: U+02229 U+0FE00 .. INTERSECTION with serifs +.. |ccaps| unicode:: U+02A4D .. CLOSED INTERSECTION WITH SERIFS +.. |ccups| unicode:: U+02A4C .. CLOSED UNION WITH SERIFS +.. |ccupssm| unicode:: U+02A50 .. CLOSED UNION WITH SERIFS AND SMASH PRODUCT +.. |coprod| unicode:: U+02210 .. N-ARY COPRODUCT +.. |Cup| unicode:: U+022D3 .. DOUBLE UNION +.. |cupbrcap| unicode:: U+02A48 .. UNION ABOVE BAR ABOVE INTERSECTION +.. |cupcap| unicode:: U+02A46 .. UNION ABOVE INTERSECTION +.. |cupcup| unicode:: U+02A4A .. UNION BESIDE AND JOINED WITH UNION +.. |cupdot| unicode:: U+0228D .. MULTISET MULTIPLICATION +.. |cupor| unicode:: U+02A45 .. UNION WITH LOGICAL OR +.. |cups| unicode:: U+0222A U+0FE00 .. UNION with serifs +.. |cuvee| unicode:: U+022CE .. CURLY LOGICAL OR +.. |cuwed| unicode:: U+022CF .. CURLY LOGICAL AND +.. |Dagger| unicode:: U+02021 .. DOUBLE DAGGER +.. |dagger| unicode:: U+02020 .. DAGGER +.. |diam| unicode:: U+022C4 .. DIAMOND OPERATOR +.. |divonx| unicode:: U+022C7 .. DIVISION TIMES +.. |eplus| unicode:: U+02A71 .. EQUALS SIGN ABOVE PLUS SIGN +.. |hercon| unicode:: U+022B9 .. HERMITIAN CONJUGATE MATRIX +.. |intcal| unicode:: U+022BA .. INTERCALATE +.. |iprod| unicode:: U+02A3C .. INTERIOR PRODUCT +.. |loplus| unicode:: U+02A2D .. PLUS SIGN IN LEFT HALF CIRCLE +.. |lotimes| unicode:: U+02A34 .. MULTIPLICATION SIGN IN LEFT HALF CIRCLE +.. |lthree| unicode:: U+022CB .. LEFT SEMIDIRECT PRODUCT +.. |ltimes| unicode:: U+022C9 .. LEFT NORMAL FACTOR SEMIDIRECT PRODUCT +.. |midast| unicode:: U+0002A .. ASTERISK +.. |minusb| unicode:: U+0229F .. SQUARED MINUS +.. |minusd| unicode:: U+02238 .. DOT MINUS +.. |minusdu| unicode:: U+02A2A .. MINUS SIGN WITH DOT BELOW +.. |ncap| unicode:: U+02A43 .. INTERSECTION WITH OVERBAR +.. |ncup| unicode:: U+02A42 .. UNION WITH OVERBAR +.. |oast| unicode:: U+0229B .. CIRCLED ASTERISK OPERATOR +.. |ocir| unicode:: U+0229A .. CIRCLED RING OPERATOR +.. |odash| unicode:: U+0229D .. CIRCLED DASH +.. |odiv| unicode:: U+02A38 .. CIRCLED DIVISION SIGN +.. |odot| unicode:: U+02299 .. CIRCLED DOT OPERATOR +.. |odsold| unicode:: U+029BC .. CIRCLED ANTICLOCKWISE-ROTATED DIVISION SIGN +.. |ofcir| unicode:: U+029BF .. CIRCLED BULLET +.. |ogt| unicode:: U+029C1 .. CIRCLED GREATER-THAN +.. |ohbar| unicode:: U+029B5 .. CIRCLE WITH HORIZONTAL BAR +.. |olcir| unicode:: U+029BE .. CIRCLED WHITE BULLET +.. |olt| unicode:: U+029C0 .. CIRCLED LESS-THAN +.. |omid| unicode:: U+029B6 .. CIRCLED VERTICAL BAR +.. |ominus| unicode:: U+02296 .. CIRCLED MINUS +.. |opar| unicode:: U+029B7 .. CIRCLED PARALLEL +.. |operp| unicode:: U+029B9 .. CIRCLED PERPENDICULAR +.. |oplus| unicode:: U+02295 .. CIRCLED PLUS +.. |osol| unicode:: U+02298 .. CIRCLED DIVISION SLASH +.. |Otimes| unicode:: U+02A37 .. MULTIPLICATION SIGN IN DOUBLE CIRCLE +.. |otimes| unicode:: U+02297 .. CIRCLED TIMES +.. |otimesas| unicode:: U+02A36 .. CIRCLED MULTIPLICATION SIGN WITH CIRCUMFLEX ACCENT +.. |ovbar| unicode:: U+0233D .. APL FUNCTIONAL SYMBOL CIRCLE STILE +.. |plusacir| unicode:: U+02A23 .. PLUS SIGN WITH CIRCUMFLEX ACCENT ABOVE +.. |plusb| unicode:: U+0229E .. SQUARED PLUS +.. |pluscir| unicode:: U+02A22 .. PLUS SIGN WITH SMALL CIRCLE ABOVE +.. |plusdo| unicode:: U+02214 .. DOT PLUS +.. |plusdu| unicode:: U+02A25 .. PLUS SIGN WITH DOT BELOW +.. |pluse| unicode:: U+02A72 .. PLUS SIGN ABOVE EQUALS SIGN +.. |plussim| unicode:: U+02A26 .. PLUS SIGN WITH TILDE BELOW +.. |plustwo| unicode:: U+02A27 .. PLUS SIGN WITH SUBSCRIPT TWO +.. |prod| unicode:: U+0220F .. N-ARY PRODUCT +.. |race| unicode:: U+029DA .. LEFT DOUBLE WIGGLY FENCE +.. |roplus| unicode:: U+02A2E .. PLUS SIGN IN RIGHT HALF CIRCLE +.. |rotimes| unicode:: U+02A35 .. MULTIPLICATION SIGN IN RIGHT HALF CIRCLE +.. |rthree| unicode:: U+022CC .. RIGHT SEMIDIRECT PRODUCT +.. |rtimes| unicode:: U+022CA .. RIGHT NORMAL FACTOR SEMIDIRECT PRODUCT +.. |sdot| unicode:: U+022C5 .. DOT OPERATOR +.. |sdotb| unicode:: U+022A1 .. SQUARED DOT OPERATOR +.. |setmn| unicode:: U+02216 .. SET MINUS +.. |simplus| unicode:: U+02A24 .. PLUS SIGN WITH TILDE ABOVE +.. |smashp| unicode:: U+02A33 .. SMASH PRODUCT +.. |solb| unicode:: U+029C4 .. SQUARED RISING DIAGONAL SLASH +.. |sqcap| unicode:: U+02293 .. SQUARE CAP +.. |sqcaps| unicode:: U+02293 U+0FE00 .. SQUARE CAP with serifs +.. |sqcup| unicode:: U+02294 .. SQUARE CUP +.. |sqcups| unicode:: U+02294 U+0FE00 .. SQUARE CUP with serifs +.. |ssetmn| unicode:: U+02216 .. SET MINUS +.. |sstarf| unicode:: U+022C6 .. STAR OPERATOR +.. |subdot| unicode:: U+02ABD .. SUBSET WITH DOT +.. |sum| unicode:: U+02211 .. N-ARY SUMMATION +.. |supdot| unicode:: U+02ABE .. SUPERSET WITH DOT +.. |timesb| unicode:: U+022A0 .. SQUARED TIMES +.. |timesbar| unicode:: U+02A31 .. MULTIPLICATION SIGN WITH UNDERBAR +.. |timesd| unicode:: U+02A30 .. MULTIPLICATION SIGN WITH DOT ABOVE +.. |top| unicode:: U+022A4 .. DOWN TACK +.. |tridot| unicode:: U+025EC .. WHITE UP-POINTING TRIANGLE WITH DOT +.. |triminus| unicode:: U+02A3A .. MINUS SIGN IN TRIANGLE +.. |triplus| unicode:: U+02A39 .. PLUS SIGN IN TRIANGLE +.. |trisb| unicode:: U+029CD .. TRIANGLE WITH SERIFS AT BOTTOM +.. |tritime| unicode:: U+02A3B .. MULTIPLICATION SIGN IN TRIANGLE +.. |uplus| unicode:: U+0228E .. MULTISET UNION +.. |veebar| unicode:: U+022BB .. XOR +.. |wedbar| unicode:: U+02A5F .. LOGICAL AND WITH UNDERBAR +.. |wreath| unicode:: U+02240 .. WREATH PRODUCT +.. |xcap| unicode:: U+022C2 .. N-ARY INTERSECTION +.. |xcirc| unicode:: U+025EF .. LARGE CIRCLE +.. |xcup| unicode:: U+022C3 .. N-ARY UNION +.. |xdtri| unicode:: U+025BD .. WHITE DOWN-POINTING TRIANGLE +.. |xodot| unicode:: U+02A00 .. N-ARY CIRCLED DOT OPERATOR +.. |xoplus| unicode:: U+02A01 .. N-ARY CIRCLED PLUS OPERATOR +.. |xotime| unicode:: U+02A02 .. N-ARY CIRCLED TIMES OPERATOR +.. |xsqcup| unicode:: U+02A06 .. N-ARY SQUARE UNION OPERATOR +.. |xuplus| unicode:: U+02A04 .. N-ARY UNION OPERATOR WITH PLUS +.. |xutri| unicode:: U+025B3 .. WHITE UP-POINTING TRIANGLE +.. |xvee| unicode:: U+022C1 .. N-ARY LOGICAL OR +.. |xwedge| unicode:: U+022C0 .. N-ARY LOGICAL AND diff --git a/docutils/parsers/rst/include/isoamsc.txt b/docutils/parsers/rst/include/isoamsc.txt new file mode 100644 index 000000000..343504d83 --- /dev/null +++ b/docutils/parsers/rst/include/isoamsc.txt @@ -0,0 +1,29 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |dlcorn| unicode:: U+0231E .. BOTTOM LEFT CORNER +.. |drcorn| unicode:: U+0231F .. BOTTOM RIGHT CORNER +.. |gtlPar| unicode:: U+02995 .. DOUBLE LEFT ARC GREATER-THAN BRACKET +.. |langd| unicode:: U+02991 .. LEFT ANGLE BRACKET WITH DOT +.. |lbrke| unicode:: U+0298B .. LEFT SQUARE BRACKET WITH UNDERBAR +.. |lbrksld| unicode:: U+0298F .. LEFT SQUARE BRACKET WITH TICK IN BOTTOM CORNER +.. |lbrkslu| unicode:: U+0298D .. LEFT SQUARE BRACKET WITH TICK IN TOP CORNER +.. |lceil| unicode:: U+02308 .. LEFT CEILING +.. |lfloor| unicode:: U+0230A .. LEFT FLOOR +.. |lmoust| unicode:: U+023B0 .. UPPER LEFT OR LOWER RIGHT CURLY BRACKET SECTION +.. |lpargt| unicode:: U+029A0 .. SPHERICAL ANGLE OPENING LEFT +.. |lparlt| unicode:: U+02993 .. LEFT ARC LESS-THAN BRACKET +.. |ltrPar| unicode:: U+02996 .. DOUBLE RIGHT ARC LESS-THAN BRACKET +.. |rangd| unicode:: U+02992 .. RIGHT ANGLE BRACKET WITH DOT +.. |rbrke| unicode:: U+0298C .. RIGHT SQUARE BRACKET WITH UNDERBAR +.. |rbrksld| unicode:: U+0298E .. RIGHT SQUARE BRACKET WITH TICK IN BOTTOM CORNER +.. |rbrkslu| unicode:: U+02990 .. RIGHT SQUARE BRACKET WITH TICK IN TOP CORNER +.. |rceil| unicode:: U+02309 .. RIGHT CEILING +.. |rfloor| unicode:: U+0230B .. RIGHT FLOOR +.. |rmoust| unicode:: U+023B1 .. UPPER RIGHT OR LOWER LEFT CURLY BRACKET SECTION +.. |rpargt| unicode:: U+02994 .. RIGHT ARC GREATER-THAN BRACKET +.. |ulcorn| unicode:: U+0231C .. TOP LEFT CORNER +.. |urcorn| unicode:: U+0231D .. TOP RIGHT CORNER diff --git a/docutils/parsers/rst/include/isoamsn.txt b/docutils/parsers/rst/include/isoamsn.txt new file mode 100644 index 000000000..5ff17291e --- /dev/null +++ b/docutils/parsers/rst/include/isoamsn.txt @@ -0,0 +1,96 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |gnap| unicode:: U+02A8A .. GREATER-THAN AND NOT APPROXIMATE +.. |gnE| unicode:: U+02269 .. GREATER-THAN BUT NOT EQUAL TO +.. |gne| unicode:: U+02A88 .. GREATER-THAN AND SINGLE-LINE NOT EQUAL TO +.. |gnsim| unicode:: U+022E7 .. GREATER-THAN BUT NOT EQUIVALENT TO +.. |gvnE| unicode:: U+02269 U+0FE00 .. GREATER-THAN BUT NOT EQUAL TO - with vertical stroke +.. |lnap| unicode:: U+02A89 .. LESS-THAN AND NOT APPROXIMATE +.. |lnE| unicode:: U+02268 .. LESS-THAN BUT NOT EQUAL TO +.. |lne| unicode:: U+02A87 .. LESS-THAN AND SINGLE-LINE NOT EQUAL TO +.. |lnsim| unicode:: U+022E6 .. LESS-THAN BUT NOT EQUIVALENT TO +.. |lvnE| unicode:: U+02268 U+0FE00 .. LESS-THAN BUT NOT EQUAL TO - with vertical stroke +.. |nap| unicode:: U+02249 .. NOT ALMOST EQUAL TO +.. |napE| unicode:: U+02A70 U+00338 .. APPROXIMATELY EQUAL OR EQUAL TO with slash +.. |napid| unicode:: U+0224B U+00338 .. TRIPLE TILDE with slash +.. |ncong| unicode:: U+02247 .. NEITHER APPROXIMATELY NOR ACTUALLY EQUAL TO +.. |ncongdot| unicode:: U+02A6D U+00338 .. CONGRUENT WITH DOT ABOVE with slash +.. |nequiv| unicode:: U+02262 .. NOT IDENTICAL TO +.. |ngE| unicode:: U+02267 U+00338 .. GREATER-THAN OVER EQUAL TO with slash +.. |nge| unicode:: U+02271 .. NEITHER GREATER-THAN NOR EQUAL TO +.. |nges| unicode:: U+02A7E U+00338 .. GREATER-THAN OR SLANTED EQUAL TO with slash +.. |nGg| unicode:: U+022D9 U+00338 .. VERY MUCH GREATER-THAN with slash +.. |ngsim| unicode:: U+02275 .. NEITHER GREATER-THAN NOR EQUIVALENT TO +.. |nGt| unicode:: U+0226B U+020D2 .. MUCH GREATER THAN with vertical line +.. |ngt| unicode:: U+0226F .. NOT GREATER-THAN +.. |nGtv| unicode:: U+0226B U+00338 .. MUCH GREATER THAN with slash +.. |nlE| unicode:: U+02266 U+00338 .. LESS-THAN OVER EQUAL TO with slash +.. |nle| unicode:: U+02270 .. NEITHER LESS-THAN NOR EQUAL TO +.. |nles| unicode:: U+02A7D U+00338 .. LESS-THAN OR SLANTED EQUAL TO with slash +.. |nLl| unicode:: U+022D8 U+00338 .. VERY MUCH LESS-THAN with slash +.. |nlsim| unicode:: U+02274 .. NEITHER LESS-THAN NOR EQUIVALENT TO +.. |nLt| unicode:: U+0226A U+020D2 .. MUCH LESS THAN with vertical line +.. |nlt| unicode:: U+0226E .. NOT LESS-THAN +.. |nltri| unicode:: U+022EA .. NOT NORMAL SUBGROUP OF +.. |nltrie| unicode:: U+022EC .. NOT NORMAL SUBGROUP OF OR EQUAL TO +.. |nLtv| unicode:: U+0226A U+00338 .. MUCH LESS THAN with slash +.. |nmid| unicode:: U+02224 .. DOES NOT DIVIDE +.. |npar| unicode:: U+02226 .. NOT PARALLEL TO +.. |npr| unicode:: U+02280 .. DOES NOT PRECEDE +.. |nprcue| unicode:: U+022E0 .. DOES NOT PRECEDE OR EQUAL +.. |npre| unicode:: U+02AAF U+00338 .. PRECEDES ABOVE SINGLE-LINE EQUALS SIGN with slash +.. |nrtri| unicode:: U+022EB .. DOES NOT CONTAIN AS NORMAL SUBGROUP +.. |nrtrie| unicode:: U+022ED .. DOES NOT CONTAIN AS NORMAL SUBGROUP OR EQUAL +.. |nsc| unicode:: U+02281 .. DOES NOT SUCCEED +.. |nsccue| unicode:: U+022E1 .. DOES NOT SUCCEED OR EQUAL +.. |nsce| unicode:: U+02AB0 U+00338 .. SUCCEEDS ABOVE SINGLE-LINE EQUALS SIGN with slash +.. |nsim| unicode:: U+02241 .. NOT TILDE +.. |nsime| unicode:: U+02244 .. NOT ASYMPTOTICALLY EQUAL TO +.. |nsmid| unicode:: U+02224 .. DOES NOT DIVIDE +.. |nspar| unicode:: U+02226 .. NOT PARALLEL TO +.. |nsqsube| unicode:: U+022E2 .. NOT SQUARE IMAGE OF OR EQUAL TO +.. |nsqsupe| unicode:: U+022E3 .. NOT SQUARE ORIGINAL OF OR EQUAL TO +.. |nsub| unicode:: U+02284 .. NOT A SUBSET OF +.. |nsubE| unicode:: U+02AC5 U+00338 .. SUBSET OF ABOVE EQUALS SIGN with slash +.. |nsube| unicode:: U+02288 .. NEITHER A SUBSET OF NOR EQUAL TO +.. |nsup| unicode:: U+02285 .. NOT A SUPERSET OF +.. |nsupE| unicode:: U+02AC6 U+00338 .. SUPERSET OF ABOVE EQUALS SIGN with slash +.. |nsupe| unicode:: U+02289 .. NEITHER A SUPERSET OF NOR EQUAL TO +.. |ntgl| unicode:: U+02279 .. NEITHER GREATER-THAN NOR LESS-THAN +.. |ntlg| unicode:: U+02278 .. NEITHER LESS-THAN NOR GREATER-THAN +.. |nvap| unicode:: U+0224D U+020D2 .. EQUIVALENT TO with vertical line +.. |nVDash| unicode:: U+022AF .. NEGATED DOUBLE VERTICAL BAR DOUBLE RIGHT TURNSTILE +.. |nVdash| unicode:: U+022AE .. DOES NOT FORCE +.. |nvDash| unicode:: U+022AD .. NOT TRUE +.. |nvdash| unicode:: U+022AC .. DOES NOT PROVE +.. |nvge| unicode:: U+02265 U+020D2 .. GREATER-THAN OR EQUAL TO with vertical line +.. |nvgt| unicode:: U+0003E U+020D2 .. GREATER-THAN SIGN with vertical line +.. |nvle| unicode:: U+02264 U+020D2 .. LESS-THAN OR EQUAL TO with vertical line +.. |nvlt| unicode:: U+0003C U+020D2 .. LESS-THAN SIGN with vertical line +.. |nvltrie| unicode:: U+022B4 U+020D2 .. NORMAL SUBGROUP OF OR EQUAL TO with vertical line +.. |nvrtrie| unicode:: U+022B5 U+020D2 .. CONTAINS AS NORMAL SUBGROUP OR EQUAL TO with vertical line +.. |nvsim| unicode:: U+0223C U+020D2 .. TILDE OPERATOR with vertical line +.. |parsim| unicode:: U+02AF3 .. PARALLEL WITH TILDE OPERATOR +.. |prnap| unicode:: U+02AB9 .. PRECEDES ABOVE NOT ALMOST EQUAL TO +.. |prnE| unicode:: U+02AB5 .. PRECEDES ABOVE NOT EQUAL TO +.. |prnsim| unicode:: U+022E8 .. PRECEDES BUT NOT EQUIVALENT TO +.. |rnmid| unicode:: U+02AEE .. DOES NOT DIVIDE WITH REVERSED NEGATION SLASH +.. |scnap| unicode:: U+02ABA .. SUCCEEDS ABOVE NOT ALMOST EQUAL TO +.. |scnE| unicode:: U+02AB6 .. SUCCEEDS ABOVE NOT EQUAL TO +.. |scnsim| unicode:: U+022E9 .. SUCCEEDS BUT NOT EQUIVALENT TO +.. |simne| unicode:: U+02246 .. APPROXIMATELY BUT NOT ACTUALLY EQUAL TO +.. |solbar| unicode:: U+0233F .. APL FUNCTIONAL SYMBOL SLASH BAR +.. |subnE| unicode:: U+02ACB .. SUBSET OF ABOVE NOT EQUAL TO +.. |subne| unicode:: U+0228A .. SUBSET OF WITH NOT EQUAL TO +.. |supnE| unicode:: U+02ACC .. SUPERSET OF ABOVE NOT EQUAL TO +.. |supne| unicode:: U+0228B .. SUPERSET OF WITH NOT EQUAL TO +.. |vnsub| unicode:: U+02282 U+020D2 .. SUBSET OF with vertical line +.. |vnsup| unicode:: U+02283 U+020D2 .. SUPERSET OF with vertical line +.. |vsubnE| unicode:: U+02ACB U+0FE00 .. SUBSET OF ABOVE NOT EQUAL TO - variant with stroke through bottom members +.. |vsubne| unicode:: U+0228A U+0FE00 .. SUBSET OF WITH NOT EQUAL TO - variant with stroke through bottom members +.. |vsupnE| unicode:: U+02ACC U+0FE00 .. SUPERSET OF ABOVE NOT EQUAL TO - variant with stroke through bottom members +.. |vsupne| unicode:: U+0228B U+0FE00 .. SUPERSET OF WITH NOT EQUAL TO - variant with stroke through bottom members diff --git a/docutils/parsers/rst/include/isoamso.txt b/docutils/parsers/rst/include/isoamso.txt new file mode 100644 index 000000000..65cc17e99 --- /dev/null +++ b/docutils/parsers/rst/include/isoamso.txt @@ -0,0 +1,62 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |ang| unicode:: U+02220 .. ANGLE +.. |ange| unicode:: U+029A4 .. ANGLE WITH UNDERBAR +.. |angmsd| unicode:: U+02221 .. MEASURED ANGLE +.. |angmsdaa| unicode:: U+029A8 .. MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING UP AND RIGHT +.. |angmsdab| unicode:: U+029A9 .. MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING UP AND LEFT +.. |angmsdac| unicode:: U+029AA .. MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING DOWN AND RIGHT +.. |angmsdad| unicode:: U+029AB .. MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING DOWN AND LEFT +.. |angmsdae| unicode:: U+029AC .. MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING RIGHT AND UP +.. |angmsdaf| unicode:: U+029AD .. MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING LEFT AND UP +.. |angmsdag| unicode:: U+029AE .. MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING RIGHT AND DOWN +.. |angmsdah| unicode:: U+029AF .. MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING LEFT AND DOWN +.. |angrtvb| unicode:: U+022BE .. RIGHT ANGLE WITH ARC +.. |angrtvbd| unicode:: U+0299D .. MEASURED RIGHT ANGLE WITH DOT +.. |bbrk| unicode:: U+023B5 .. BOTTOM SQUARE BRACKET +.. |bbrktbrk| unicode:: U+023B6 .. BOTTOM SQUARE BRACKET OVER TOP SQUARE BRACKET +.. |bemptyv| unicode:: U+029B0 .. REVERSED EMPTY SET +.. |beth| unicode:: U+02136 .. BET SYMBOL +.. |boxbox| unicode:: U+029C9 .. TWO JOINED SQUARES +.. |bprime| unicode:: U+02035 .. REVERSED PRIME +.. |bsemi| unicode:: U+0204F .. REVERSED SEMICOLON +.. |cemptyv| unicode:: U+029B2 .. EMPTY SET WITH SMALL CIRCLE ABOVE +.. |cirE| unicode:: U+029C3 .. CIRCLE WITH TWO HORIZONTAL STROKES TO THE RIGHT +.. |cirscir| unicode:: U+029C2 .. CIRCLE WITH SMALL CIRCLE TO THE RIGHT +.. |comp| unicode:: U+02201 .. COMPLEMENT +.. |daleth| unicode:: U+02138 .. DALET SYMBOL +.. |demptyv| unicode:: U+029B1 .. EMPTY SET WITH OVERBAR +.. |ell| unicode:: U+02113 .. SCRIPT SMALL L +.. |empty| unicode:: U+02205 .. EMPTY SET +.. |emptyv| unicode:: U+02205 .. EMPTY SET +.. |gimel| unicode:: U+02137 .. GIMEL SYMBOL +.. |iiota| unicode:: U+02129 .. TURNED GREEK SMALL LETTER IOTA +.. |image| unicode:: U+02111 .. BLACK-LETTER CAPITAL I +.. |imath| unicode:: U+00131 .. LATIN SMALL LETTER DOTLESS I +.. |inodot| unicode:: U+00131 .. LATIN SMALL LETTER DOTLESS I +.. |jmath| unicode:: U+0006A .. LATIN SMALL LETTER J +.. |jnodot| unicode:: U+0006A .. LATIN SMALL LETTER J +.. |laemptyv| unicode:: U+029B4 .. EMPTY SET WITH LEFT ARROW ABOVE +.. |lltri| unicode:: U+025FA .. LOWER LEFT TRIANGLE +.. |lrtri| unicode:: U+022BF .. RIGHT TRIANGLE +.. |mho| unicode:: U+02127 .. INVERTED OHM SIGN +.. |nang| unicode:: U+02220 U+020D2 .. ANGLE with vertical line +.. |nexist| unicode:: U+02204 .. THERE DOES NOT EXIST +.. |oS| unicode:: U+024C8 .. CIRCLED LATIN CAPITAL LETTER S +.. |planck| unicode:: U+0210F .. PLANCK CONSTANT OVER TWO PI +.. |plankv| unicode:: U+0210F .. PLANCK CONSTANT OVER TWO PI +.. |raemptyv| unicode:: U+029B3 .. EMPTY SET WITH RIGHT ARROW ABOVE +.. |range| unicode:: U+029A5 .. REVERSED ANGLE WITH UNDERBAR +.. |real| unicode:: U+0211C .. BLACK-LETTER CAPITAL R +.. |sbsol| unicode:: U+0FE68 .. SMALL REVERSE SOLIDUS +.. |tbrk| unicode:: U+023B4 .. TOP SQUARE BRACKET +.. |trpezium| unicode:: U+0FFFD .. REPLACEMENT CHARACTER +.. |ultri| unicode:: U+025F8 .. UPPER LEFT TRIANGLE +.. |urtri| unicode:: U+025F9 .. UPPER RIGHT TRIANGLE +.. |vprime| unicode:: U+02032 .. PRIME +.. |vzigzag| unicode:: U+0299A .. VERTICAL ZIGZAG LINE +.. |weierp| unicode:: U+02118 .. SCRIPT CAPITAL P diff --git a/docutils/parsers/rst/include/isoamsr.txt b/docutils/parsers/rst/include/isoamsr.txt new file mode 100644 index 000000000..a3d03dab7 --- /dev/null +++ b/docutils/parsers/rst/include/isoamsr.txt @@ -0,0 +1,191 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |apE| unicode:: U+02A70 .. APPROXIMATELY EQUAL OR EQUAL TO +.. |ape| unicode:: U+0224A .. ALMOST EQUAL OR EQUAL TO +.. |apid| unicode:: U+0224B .. TRIPLE TILDE +.. |asymp| unicode:: U+02248 .. ALMOST EQUAL TO +.. |Barv| unicode:: U+02AE7 .. SHORT DOWN TACK WITH OVERBAR +.. |bcong| unicode:: U+0224C .. ALL EQUAL TO +.. |bepsi| unicode:: U+003F6 .. GREEK REVERSED LUNATE EPSILON SYMBOL +.. |bowtie| unicode:: U+022C8 .. BOWTIE +.. |bsim| unicode:: U+0223D .. REVERSED TILDE +.. |bsime| unicode:: U+022CD .. REVERSED TILDE EQUALS +.. |bsolhsub| unicode:: U+0005C U+02282 .. REVERSE SOLIDUS, SUBSET OF +.. |bump| unicode:: U+0224E .. GEOMETRICALLY EQUIVALENT TO +.. |bumpE| unicode:: U+02AAE .. EQUALS SIGN WITH BUMPY ABOVE +.. |bumpe| unicode:: U+0224F .. DIFFERENCE BETWEEN +.. |cire| unicode:: U+02257 .. RING EQUAL TO +.. |Colon| unicode:: U+02237 .. PROPORTION +.. |Colone| unicode:: U+02A74 .. DOUBLE COLON EQUAL +.. |colone| unicode:: U+02254 .. COLON EQUALS +.. |congdot| unicode:: U+02A6D .. CONGRUENT WITH DOT ABOVE +.. |csub| unicode:: U+02ACF .. CLOSED SUBSET +.. |csube| unicode:: U+02AD1 .. CLOSED SUBSET OR EQUAL TO +.. |csup| unicode:: U+02AD0 .. CLOSED SUPERSET +.. |csupe| unicode:: U+02AD2 .. CLOSED SUPERSET OR EQUAL TO +.. |cuepr| unicode:: U+022DE .. EQUAL TO OR PRECEDES +.. |cuesc| unicode:: U+022DF .. EQUAL TO OR SUCCEEDS +.. |cupre| unicode:: U+0227C .. PRECEDES OR EQUAL TO +.. |Dashv| unicode:: U+02AE4 .. VERTICAL BAR DOUBLE LEFT TURNSTILE +.. |dashv| unicode:: U+022A3 .. LEFT TACK +.. |easter| unicode:: U+02A6E .. EQUALS WITH ASTERISK +.. |ecir| unicode:: U+02256 .. RING IN EQUAL TO +.. |ecolon| unicode:: U+02255 .. EQUALS COLON +.. |eDDot| unicode:: U+02A77 .. EQUALS SIGN WITH TWO DOTS ABOVE AND TWO DOTS BELOW +.. |eDot| unicode:: U+02251 .. GEOMETRICALLY EQUAL TO +.. |efDot| unicode:: U+02252 .. APPROXIMATELY EQUAL TO OR THE IMAGE OF +.. |eg| unicode:: U+02A9A .. DOUBLE-LINE EQUAL TO OR GREATER-THAN +.. |egs| unicode:: U+02A96 .. SLANTED EQUAL TO OR GREATER-THAN +.. |egsdot| unicode:: U+02A98 .. SLANTED EQUAL TO OR GREATER-THAN WITH DOT INSIDE +.. |el| unicode:: U+02A99 .. DOUBLE-LINE EQUAL TO OR LESS-THAN +.. |els| unicode:: U+02A95 .. SLANTED EQUAL TO OR LESS-THAN +.. |elsdot| unicode:: U+02A97 .. SLANTED EQUAL TO OR LESS-THAN WITH DOT INSIDE +.. |equest| unicode:: U+0225F .. QUESTIONED EQUAL TO +.. |equivDD| unicode:: U+02A78 .. EQUIVALENT WITH FOUR DOTS ABOVE +.. |erDot| unicode:: U+02253 .. IMAGE OF OR APPROXIMATELY EQUAL TO +.. |esdot| unicode:: U+02250 .. APPROACHES THE LIMIT +.. |Esim| unicode:: U+02A73 .. EQUALS SIGN ABOVE TILDE OPERATOR +.. |esim| unicode:: U+02242 .. MINUS TILDE +.. |fork| unicode:: U+022D4 .. PITCHFORK +.. |forkv| unicode:: U+02AD9 .. ELEMENT OF OPENING DOWNWARDS +.. |frown| unicode:: U+02322 .. FROWN +.. |gap| unicode:: U+02A86 .. GREATER-THAN OR APPROXIMATE +.. |gE| unicode:: U+02267 .. GREATER-THAN OVER EQUAL TO +.. |gEl| unicode:: U+02A8C .. GREATER-THAN ABOVE DOUBLE-LINE EQUAL ABOVE LESS-THAN +.. |gel| unicode:: U+022DB .. GREATER-THAN EQUAL TO OR LESS-THAN +.. |ges| unicode:: U+02A7E .. GREATER-THAN OR SLANTED EQUAL TO +.. |gescc| unicode:: U+02AA9 .. GREATER-THAN CLOSED BY CURVE ABOVE SLANTED EQUAL +.. |gesdot| unicode:: U+02A80 .. GREATER-THAN OR SLANTED EQUAL TO WITH DOT INSIDE +.. |gesdoto| unicode:: U+02A82 .. GREATER-THAN OR SLANTED EQUAL TO WITH DOT ABOVE +.. |gesdotol| unicode:: U+02A84 .. GREATER-THAN OR SLANTED EQUAL TO WITH DOT ABOVE LEFT +.. |gesl| unicode:: U+022DB U+0FE00 .. GREATER-THAN slanted EQUAL TO OR LESS-THAN +.. |gesles| unicode:: U+02A94 .. GREATER-THAN ABOVE SLANTED EQUAL ABOVE LESS-THAN ABOVE SLANTED EQUAL +.. |Gg| unicode:: U+022D9 .. VERY MUCH GREATER-THAN +.. |gl| unicode:: U+02277 .. GREATER-THAN OR LESS-THAN +.. |gla| unicode:: U+02AA5 .. GREATER-THAN BESIDE LESS-THAN +.. |glE| unicode:: U+02A92 .. GREATER-THAN ABOVE LESS-THAN ABOVE DOUBLE-LINE EQUAL +.. |glj| unicode:: U+02AA4 .. GREATER-THAN OVERLAPPING LESS-THAN +.. |gsdot| unicode:: U+022D7 .. GREATER-THAN WITH DOT +.. |gsim| unicode:: U+02273 .. GREATER-THAN OR EQUIVALENT TO +.. |gsime| unicode:: U+02A8E .. GREATER-THAN ABOVE SIMILAR OR EQUAL +.. |gsiml| unicode:: U+02A90 .. GREATER-THAN ABOVE SIMILAR ABOVE LESS-THAN +.. |Gt| unicode:: U+0226B .. MUCH GREATER-THAN +.. |gtcc| unicode:: U+02AA7 .. GREATER-THAN CLOSED BY CURVE +.. |gtcir| unicode:: U+02A7A .. GREATER-THAN WITH CIRCLE INSIDE +.. |gtdot| unicode:: U+022D7 .. GREATER-THAN WITH DOT +.. |gtquest| unicode:: U+02A7C .. GREATER-THAN WITH QUESTION MARK ABOVE +.. |gtrarr| unicode:: U+02978 .. GREATER-THAN ABOVE RIGHTWARDS ARROW +.. |homtht| unicode:: U+0223B .. HOMOTHETIC +.. |lap| unicode:: U+02A85 .. LESS-THAN OR APPROXIMATE +.. |lat| unicode:: U+02AAB .. LARGER THAN +.. |late| unicode:: U+02AAD .. LARGER THAN OR EQUAL TO +.. |lates| unicode:: U+02AAD U+0FE00 .. LARGER THAN OR slanted EQUAL +.. |ldot| unicode:: U+022D6 .. LESS-THAN WITH DOT +.. |lE| unicode:: U+02266 .. LESS-THAN OVER EQUAL TO +.. |lEg| unicode:: U+02A8B .. LESS-THAN ABOVE DOUBLE-LINE EQUAL ABOVE GREATER-THAN +.. |leg| unicode:: U+022DA .. LESS-THAN EQUAL TO OR GREATER-THAN +.. |les| unicode:: U+02A7D .. LESS-THAN OR SLANTED EQUAL TO +.. |lescc| unicode:: U+02AA8 .. LESS-THAN CLOSED BY CURVE ABOVE SLANTED EQUAL +.. |lesdot| unicode:: U+02A7F .. LESS-THAN OR SLANTED EQUAL TO WITH DOT INSIDE +.. |lesdoto| unicode:: U+02A81 .. LESS-THAN OR SLANTED EQUAL TO WITH DOT ABOVE +.. |lesdotor| unicode:: U+02A83 .. LESS-THAN OR SLANTED EQUAL TO WITH DOT ABOVE RIGHT +.. |lesg| unicode:: U+022DA U+0FE00 .. LESS-THAN slanted EQUAL TO OR GREATER-THAN +.. |lesges| unicode:: U+02A93 .. LESS-THAN ABOVE SLANTED EQUAL ABOVE GREATER-THAN ABOVE SLANTED EQUAL +.. |lg| unicode:: U+02276 .. LESS-THAN OR GREATER-THAN +.. |lgE| unicode:: U+02A91 .. LESS-THAN ABOVE GREATER-THAN ABOVE DOUBLE-LINE EQUAL +.. |Ll| unicode:: U+022D8 .. VERY MUCH LESS-THAN +.. |lsim| unicode:: U+02272 .. LESS-THAN OR EQUIVALENT TO +.. |lsime| unicode:: U+02A8D .. LESS-THAN ABOVE SIMILAR OR EQUAL +.. |lsimg| unicode:: U+02A8F .. LESS-THAN ABOVE SIMILAR ABOVE GREATER-THAN +.. |Lt| unicode:: U+0226A .. MUCH LESS-THAN +.. |ltcc| unicode:: U+02AA6 .. LESS-THAN CLOSED BY CURVE +.. |ltcir| unicode:: U+02A79 .. LESS-THAN WITH CIRCLE INSIDE +.. |ltdot| unicode:: U+022D6 .. LESS-THAN WITH DOT +.. |ltlarr| unicode:: U+02976 .. LESS-THAN ABOVE LEFTWARDS ARROW +.. |ltquest| unicode:: U+02A7B .. LESS-THAN WITH QUESTION MARK ABOVE +.. |ltrie| unicode:: U+022B4 .. NORMAL SUBGROUP OF OR EQUAL TO +.. |mcomma| unicode:: U+02A29 .. MINUS SIGN WITH COMMA ABOVE +.. |mDDot| unicode:: U+0223A .. GEOMETRIC PROPORTION +.. |mid| unicode:: U+02223 .. DIVIDES +.. |mlcp| unicode:: U+02ADB .. TRANSVERSAL INTERSECTION +.. |models| unicode:: U+022A7 .. MODELS +.. |mstpos| unicode:: U+0223E .. INVERTED LAZY S +.. |Pr| unicode:: U+02ABB .. DOUBLE PRECEDES +.. |pr| unicode:: U+0227A .. PRECEDES +.. |prap| unicode:: U+02AB7 .. PRECEDES ABOVE ALMOST EQUAL TO +.. |prcue| unicode:: U+0227C .. PRECEDES OR EQUAL TO +.. |prE| unicode:: U+02AB3 .. PRECEDES ABOVE EQUALS SIGN +.. |pre| unicode:: U+02AAF .. PRECEDES ABOVE SINGLE-LINE EQUALS SIGN +.. |prsim| unicode:: U+0227E .. PRECEDES OR EQUIVALENT TO +.. |prurel| unicode:: U+022B0 .. PRECEDES UNDER RELATION +.. |ratio| unicode:: U+02236 .. RATIO +.. |rtrie| unicode:: U+022B5 .. CONTAINS AS NORMAL SUBGROUP OR EQUAL TO +.. |rtriltri| unicode:: U+029CE .. RIGHT TRIANGLE ABOVE LEFT TRIANGLE +.. |samalg| unicode:: U+02210 .. N-ARY COPRODUCT +.. |Sc| unicode:: U+02ABC .. DOUBLE SUCCEEDS +.. |sc| unicode:: U+0227B .. SUCCEEDS +.. |scap| unicode:: U+02AB8 .. SUCCEEDS ABOVE ALMOST EQUAL TO +.. |sccue| unicode:: U+0227D .. SUCCEEDS OR EQUAL TO +.. |scE| unicode:: U+02AB4 .. SUCCEEDS ABOVE EQUALS SIGN +.. |sce| unicode:: U+02AB0 .. SUCCEEDS ABOVE SINGLE-LINE EQUALS SIGN +.. |scsim| unicode:: U+0227F .. SUCCEEDS OR EQUIVALENT TO +.. |sdote| unicode:: U+02A66 .. EQUALS SIGN WITH DOT BELOW +.. |sfrown| unicode:: U+02322 .. FROWN +.. |simg| unicode:: U+02A9E .. SIMILAR OR GREATER-THAN +.. |simgE| unicode:: U+02AA0 .. SIMILAR ABOVE GREATER-THAN ABOVE EQUALS SIGN +.. |siml| unicode:: U+02A9D .. SIMILAR OR LESS-THAN +.. |simlE| unicode:: U+02A9F .. SIMILAR ABOVE LESS-THAN ABOVE EQUALS SIGN +.. |smid| unicode:: U+02223 .. DIVIDES +.. |smile| unicode:: U+02323 .. SMILE +.. |smt| unicode:: U+02AAA .. SMALLER THAN +.. |smte| unicode:: U+02AAC .. SMALLER THAN OR EQUAL TO +.. |smtes| unicode:: U+02AAC U+0FE00 .. SMALLER THAN OR slanted EQUAL +.. |spar| unicode:: U+02225 .. PARALLEL TO +.. |sqsub| unicode:: U+0228F .. SQUARE IMAGE OF +.. |sqsube| unicode:: U+02291 .. SQUARE IMAGE OF OR EQUAL TO +.. |sqsup| unicode:: U+02290 .. SQUARE ORIGINAL OF +.. |sqsupe| unicode:: U+02292 .. SQUARE ORIGINAL OF OR EQUAL TO +.. |ssmile| unicode:: U+02323 .. SMILE +.. |Sub| unicode:: U+022D0 .. DOUBLE SUBSET +.. |subE| unicode:: U+02AC5 .. SUBSET OF ABOVE EQUALS SIGN +.. |subedot| unicode:: U+02AC3 .. SUBSET OF OR EQUAL TO WITH DOT ABOVE +.. |submult| unicode:: U+02AC1 .. SUBSET WITH MULTIPLICATION SIGN BELOW +.. |subplus| unicode:: U+02ABF .. SUBSET WITH PLUS SIGN BELOW +.. |subrarr| unicode:: U+02979 .. SUBSET ABOVE RIGHTWARDS ARROW +.. |subsim| unicode:: U+02AC7 .. SUBSET OF ABOVE TILDE OPERATOR +.. |subsub| unicode:: U+02AD5 .. SUBSET ABOVE SUBSET +.. |subsup| unicode:: U+02AD3 .. SUBSET ABOVE SUPERSET +.. |Sup| unicode:: U+022D1 .. DOUBLE SUPERSET +.. |supdsub| unicode:: U+02AD8 .. SUPERSET BESIDE AND JOINED BY DASH WITH SUBSET +.. |supE| unicode:: U+02AC6 .. SUPERSET OF ABOVE EQUALS SIGN +.. |supedot| unicode:: U+02AC4 .. SUPERSET OF OR EQUAL TO WITH DOT ABOVE +.. |suphsol| unicode:: U+02283 U+0002F .. SUPERSET OF, SOLIDUS +.. |suphsub| unicode:: U+02AD7 .. SUPERSET BESIDE SUBSET +.. |suplarr| unicode:: U+0297B .. SUPERSET ABOVE LEFTWARDS ARROW +.. |supmult| unicode:: U+02AC2 .. SUPERSET WITH MULTIPLICATION SIGN BELOW +.. |supplus| unicode:: U+02AC0 .. SUPERSET WITH PLUS SIGN BELOW +.. |supsim| unicode:: U+02AC8 .. SUPERSET OF ABOVE TILDE OPERATOR +.. |supsub| unicode:: U+02AD4 .. SUPERSET ABOVE SUBSET +.. |supsup| unicode:: U+02AD6 .. SUPERSET ABOVE SUPERSET +.. |thkap| unicode:: U+02248 .. ALMOST EQUAL TO +.. |thksim| unicode:: U+0223C .. TILDE OPERATOR +.. |topfork| unicode:: U+02ADA .. PITCHFORK WITH TEE TOP +.. |trie| unicode:: U+0225C .. DELTA EQUAL TO +.. |twixt| unicode:: U+0226C .. BETWEEN +.. |Vbar| unicode:: U+02AEB .. DOUBLE UP TACK +.. |vBar| unicode:: U+02AE8 .. SHORT UP TACK WITH UNDERBAR +.. |vBarv| unicode:: U+02AE9 .. SHORT UP TACK ABOVE SHORT DOWN TACK +.. |VDash| unicode:: U+022AB .. DOUBLE VERTICAL BAR DOUBLE RIGHT TURNSTILE +.. |Vdash| unicode:: U+022A9 .. FORCES +.. |vDash| unicode:: U+022A8 .. TRUE +.. |vdash| unicode:: U+022A2 .. RIGHT TACK +.. |Vdashl| unicode:: U+02AE6 .. LONG DASH FROM LEFT MEMBER OF DOUBLE VERTICAL +.. |veebar| unicode:: U+022BB .. XOR +.. |vltri| unicode:: U+022B2 .. NORMAL SUBGROUP OF +.. |vprop| unicode:: U+0221D .. PROPORTIONAL TO +.. |vrtri| unicode:: U+022B3 .. CONTAINS AS NORMAL SUBGROUP +.. |Vvdash| unicode:: U+022AA .. TRIPLE VERTICAL BAR RIGHT TURNSTILE diff --git a/docutils/parsers/rst/include/isobox.txt b/docutils/parsers/rst/include/isobox.txt new file mode 100644 index 000000000..2304f8770 --- /dev/null +++ b/docutils/parsers/rst/include/isobox.txt @@ -0,0 +1,46 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |boxDL| unicode:: U+02557 .. BOX DRAWINGS DOUBLE DOWN AND LEFT +.. |boxDl| unicode:: U+02556 .. BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE +.. |boxdL| unicode:: U+02555 .. BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE +.. |boxdl| unicode:: U+02510 .. BOX DRAWINGS LIGHT DOWN AND LEFT +.. |boxDR| unicode:: U+02554 .. BOX DRAWINGS DOUBLE DOWN AND RIGHT +.. |boxDr| unicode:: U+02553 .. BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE +.. |boxdR| unicode:: U+02552 .. BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE +.. |boxdr| unicode:: U+0250C .. BOX DRAWINGS LIGHT DOWN AND RIGHT +.. |boxH| unicode:: U+02550 .. BOX DRAWINGS DOUBLE HORIZONTAL +.. |boxh| unicode:: U+02500 .. BOX DRAWINGS LIGHT HORIZONTAL +.. |boxHD| unicode:: U+02566 .. BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL +.. |boxHd| unicode:: U+02564 .. BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE +.. |boxhD| unicode:: U+02565 .. BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE +.. |boxhd| unicode:: U+0252C .. BOX DRAWINGS LIGHT DOWN AND HORIZONTAL +.. |boxHU| unicode:: U+02569 .. BOX DRAWINGS DOUBLE UP AND HORIZONTAL +.. |boxHu| unicode:: U+02567 .. BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE +.. |boxhU| unicode:: U+02568 .. BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE +.. |boxhu| unicode:: U+02534 .. BOX DRAWINGS LIGHT UP AND HORIZONTAL +.. |boxUL| unicode:: U+0255D .. BOX DRAWINGS DOUBLE UP AND LEFT +.. |boxUl| unicode:: U+0255C .. BOX DRAWINGS UP DOUBLE AND LEFT SINGLE +.. |boxuL| unicode:: U+0255B .. BOX DRAWINGS UP SINGLE AND LEFT DOUBLE +.. |boxul| unicode:: U+02518 .. BOX DRAWINGS LIGHT UP AND LEFT +.. |boxUR| unicode:: U+0255A .. BOX DRAWINGS DOUBLE UP AND RIGHT +.. |boxUr| unicode:: U+02559 .. BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE +.. |boxuR| unicode:: U+02558 .. BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE +.. |boxur| unicode:: U+02514 .. BOX DRAWINGS LIGHT UP AND RIGHT +.. |boxV| unicode:: U+02551 .. BOX DRAWINGS DOUBLE VERTICAL +.. |boxv| unicode:: U+02502 .. BOX DRAWINGS LIGHT VERTICAL +.. |boxVH| unicode:: U+0256C .. BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL +.. |boxVh| unicode:: U+0256B .. BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE +.. |boxvH| unicode:: U+0256A .. BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE +.. |boxvh| unicode:: U+0253C .. BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL +.. |boxVL| unicode:: U+02563 .. BOX DRAWINGS DOUBLE VERTICAL AND LEFT +.. |boxVl| unicode:: U+02562 .. BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE +.. |boxvL| unicode:: U+02561 .. BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE +.. |boxvl| unicode:: U+02524 .. BOX DRAWINGS LIGHT VERTICAL AND LEFT +.. |boxVR| unicode:: U+02560 .. BOX DRAWINGS DOUBLE VERTICAL AND RIGHT +.. |boxVr| unicode:: U+0255F .. BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE +.. |boxvR| unicode:: U+0255E .. BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE +.. |boxvr| unicode:: U+0251C .. BOX DRAWINGS LIGHT VERTICAL AND RIGHT diff --git a/docutils/parsers/rst/include/isocyr1.txt b/docutils/parsers/rst/include/isocyr1.txt new file mode 100644 index 000000000..afee744cf --- /dev/null +++ b/docutils/parsers/rst/include/isocyr1.txt @@ -0,0 +1,73 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |Acy| unicode:: U+00410 .. CYRILLIC CAPITAL LETTER A +.. |acy| unicode:: U+00430 .. CYRILLIC SMALL LETTER A +.. |Bcy| unicode:: U+00411 .. CYRILLIC CAPITAL LETTER BE +.. |bcy| unicode:: U+00431 .. CYRILLIC SMALL LETTER BE +.. |CHcy| unicode:: U+00427 .. CYRILLIC CAPITAL LETTER CHE +.. |chcy| unicode:: U+00447 .. CYRILLIC SMALL LETTER CHE +.. |Dcy| unicode:: U+00414 .. CYRILLIC CAPITAL LETTER DE +.. |dcy| unicode:: U+00434 .. CYRILLIC SMALL LETTER DE +.. |Ecy| unicode:: U+0042D .. CYRILLIC CAPITAL LETTER E +.. |ecy| unicode:: U+0044D .. CYRILLIC SMALL LETTER E +.. |Fcy| unicode:: U+00424 .. CYRILLIC CAPITAL LETTER EF +.. |fcy| unicode:: U+00444 .. CYRILLIC SMALL LETTER EF +.. |Gcy| unicode:: U+00413 .. CYRILLIC CAPITAL LETTER GHE +.. |gcy| unicode:: U+00433 .. CYRILLIC SMALL LETTER GHE +.. |HARDcy| unicode:: U+0042A .. CYRILLIC CAPITAL LETTER HARD SIGN +.. |hardcy| unicode:: U+0044A .. CYRILLIC SMALL LETTER HARD SIGN +.. |Icy| unicode:: U+00418 .. CYRILLIC CAPITAL LETTER I +.. |icy| unicode:: U+00438 .. CYRILLIC SMALL LETTER I +.. |IEcy| unicode:: U+00415 .. CYRILLIC CAPITAL LETTER IE +.. |iecy| unicode:: U+00435 .. CYRILLIC SMALL LETTER IE +.. |IOcy| unicode:: U+00401 .. CYRILLIC CAPITAL LETTER IO +.. |iocy| unicode:: U+00451 .. CYRILLIC SMALL LETTER IO +.. |Jcy| unicode:: U+00419 .. CYRILLIC CAPITAL LETTER SHORT I +.. |jcy| unicode:: U+00439 .. CYRILLIC SMALL LETTER SHORT I +.. |Kcy| unicode:: U+0041A .. CYRILLIC CAPITAL LETTER KA +.. |kcy| unicode:: U+0043A .. CYRILLIC SMALL LETTER KA +.. |KHcy| unicode:: U+00425 .. CYRILLIC CAPITAL LETTER HA +.. |khcy| unicode:: U+00445 .. CYRILLIC SMALL LETTER HA +.. |Lcy| unicode:: U+0041B .. CYRILLIC CAPITAL LETTER EL +.. |lcy| unicode:: U+0043B .. CYRILLIC SMALL LETTER EL +.. |Mcy| unicode:: U+0041C .. CYRILLIC CAPITAL LETTER EM +.. |mcy| unicode:: U+0043C .. CYRILLIC SMALL LETTER EM +.. |Ncy| unicode:: U+0041D .. CYRILLIC CAPITAL LETTER EN +.. |ncy| unicode:: U+0043D .. CYRILLIC SMALL LETTER EN +.. |numero| unicode:: U+02116 .. NUMERO SIGN +.. |Ocy| unicode:: U+0041E .. CYRILLIC CAPITAL LETTER O +.. |ocy| unicode:: U+0043E .. CYRILLIC SMALL LETTER O +.. |Pcy| unicode:: U+0041F .. CYRILLIC CAPITAL LETTER PE +.. |pcy| unicode:: U+0043F .. CYRILLIC SMALL LETTER PE +.. |Rcy| unicode:: U+00420 .. CYRILLIC CAPITAL LETTER ER +.. |rcy| unicode:: U+00440 .. CYRILLIC SMALL LETTER ER +.. |Scy| unicode:: U+00421 .. CYRILLIC CAPITAL LETTER ES +.. |scy| unicode:: U+00441 .. CYRILLIC SMALL LETTER ES +.. |SHCHcy| unicode:: U+00429 .. CYRILLIC CAPITAL LETTER SHCHA +.. |shchcy| unicode:: U+00449 .. CYRILLIC SMALL LETTER SHCHA +.. |SHcy| unicode:: U+00428 .. CYRILLIC CAPITAL LETTER SHA +.. |shcy| unicode:: U+00448 .. CYRILLIC SMALL LETTER SHA +.. |SOFTcy| unicode:: U+0042C .. CYRILLIC CAPITAL LETTER SOFT SIGN +.. |softcy| unicode:: U+0044C .. CYRILLIC SMALL LETTER SOFT SIGN +.. |Tcy| unicode:: U+00422 .. CYRILLIC CAPITAL LETTER TE +.. |tcy| unicode:: U+00442 .. CYRILLIC SMALL LETTER TE +.. |TScy| unicode:: U+00426 .. CYRILLIC CAPITAL LETTER TSE +.. |tscy| unicode:: U+00446 .. CYRILLIC SMALL LETTER TSE +.. |Ucy| unicode:: U+00423 .. CYRILLIC CAPITAL LETTER U +.. |ucy| unicode:: U+00443 .. CYRILLIC SMALL LETTER U +.. |Vcy| unicode:: U+00412 .. CYRILLIC CAPITAL LETTER VE +.. |vcy| unicode:: U+00432 .. CYRILLIC SMALL LETTER VE +.. |YAcy| unicode:: U+0042F .. CYRILLIC CAPITAL LETTER YA +.. |yacy| unicode:: U+0044F .. CYRILLIC SMALL LETTER YA +.. |Ycy| unicode:: U+0042B .. CYRILLIC CAPITAL LETTER YERU +.. |ycy| unicode:: U+0044B .. CYRILLIC SMALL LETTER YERU +.. |YUcy| unicode:: U+0042E .. CYRILLIC CAPITAL LETTER YU +.. |yucy| unicode:: U+0044E .. CYRILLIC SMALL LETTER YU +.. |Zcy| unicode:: U+00417 .. CYRILLIC CAPITAL LETTER ZE +.. |zcy| unicode:: U+00437 .. CYRILLIC SMALL LETTER ZE +.. |ZHcy| unicode:: U+00416 .. CYRILLIC CAPITAL LETTER ZHE +.. |zhcy| unicode:: U+00436 .. CYRILLIC SMALL LETTER ZHE diff --git a/docutils/parsers/rst/include/isocyr2.txt b/docutils/parsers/rst/include/isocyr2.txt new file mode 100644 index 000000000..fe09c015b --- /dev/null +++ b/docutils/parsers/rst/include/isocyr2.txt @@ -0,0 +1,32 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |DJcy| unicode:: U+00402 .. CYRILLIC CAPITAL LETTER DJE +.. |djcy| unicode:: U+00452 .. CYRILLIC SMALL LETTER DJE +.. |DScy| unicode:: U+00405 .. CYRILLIC CAPITAL LETTER DZE +.. |dscy| unicode:: U+00455 .. CYRILLIC SMALL LETTER DZE +.. |DZcy| unicode:: U+0040F .. CYRILLIC CAPITAL LETTER DZHE +.. |dzcy| unicode:: U+0045F .. CYRILLIC SMALL LETTER DZHE +.. |GJcy| unicode:: U+00403 .. CYRILLIC CAPITAL LETTER GJE +.. |gjcy| unicode:: U+00453 .. CYRILLIC SMALL LETTER GJE +.. |Iukcy| unicode:: U+00406 .. CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I +.. |iukcy| unicode:: U+00456 .. CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I +.. |Jsercy| unicode:: U+00408 .. CYRILLIC CAPITAL LETTER JE +.. |jsercy| unicode:: U+00458 .. CYRILLIC SMALL LETTER JE +.. |Jukcy| unicode:: U+00404 .. CYRILLIC CAPITAL LETTER UKRAINIAN IE +.. |jukcy| unicode:: U+00454 .. CYRILLIC SMALL LETTER UKRAINIAN IE +.. |KJcy| unicode:: U+0040C .. CYRILLIC CAPITAL LETTER KJE +.. |kjcy| unicode:: U+0045C .. CYRILLIC SMALL LETTER KJE +.. |LJcy| unicode:: U+00409 .. CYRILLIC CAPITAL LETTER LJE +.. |ljcy| unicode:: U+00459 .. CYRILLIC SMALL LETTER LJE +.. |NJcy| unicode:: U+0040A .. CYRILLIC CAPITAL LETTER NJE +.. |njcy| unicode:: U+0045A .. CYRILLIC SMALL LETTER NJE +.. |TSHcy| unicode:: U+0040B .. CYRILLIC CAPITAL LETTER TSHE +.. |tshcy| unicode:: U+0045B .. CYRILLIC SMALL LETTER TSHE +.. |Ubrcy| unicode:: U+0040E .. CYRILLIC CAPITAL LETTER SHORT U +.. |ubrcy| unicode:: U+0045E .. CYRILLIC SMALL LETTER SHORT U +.. |YIcy| unicode:: U+00407 .. CYRILLIC CAPITAL LETTER YI +.. |yicy| unicode:: U+00457 .. CYRILLIC SMALL LETTER YI diff --git a/docutils/parsers/rst/include/isodia.txt b/docutils/parsers/rst/include/isodia.txt new file mode 100644 index 000000000..ede6d9946 --- /dev/null +++ b/docutils/parsers/rst/include/isodia.txt @@ -0,0 +1,20 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |acute| unicode:: U+000B4 .. ACUTE ACCENT +.. |breve| unicode:: U+002D8 .. BREVE +.. |caron| unicode:: U+002C7 .. CARON +.. |cedil| unicode:: U+000B8 .. CEDILLA +.. |circ| unicode:: U+002C6 .. MODIFIER LETTER CIRCUMFLEX ACCENT +.. |dblac| unicode:: U+002DD .. DOUBLE ACUTE ACCENT +.. |die| unicode:: U+000A8 .. DIAERESIS +.. |dot| unicode:: U+002D9 .. DOT ABOVE +.. |grave| unicode:: U+00060 .. GRAVE ACCENT +.. |macr| unicode:: U+000AF .. MACRON +.. |ogon| unicode:: U+002DB .. OGONEK +.. |ring| unicode:: U+002DA .. RING ABOVE +.. |tilde| unicode:: U+002DC .. SMALL TILDE +.. |uml| unicode:: U+000A8 .. DIAERESIS diff --git a/docutils/parsers/rst/include/isogrk1.txt b/docutils/parsers/rst/include/isogrk1.txt new file mode 100644 index 000000000..434368a03 --- /dev/null +++ b/docutils/parsers/rst/include/isogrk1.txt @@ -0,0 +1,55 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |Agr| unicode:: U+00391 .. GREEK CAPITAL LETTER ALPHA +.. |agr| unicode:: U+003B1 .. GREEK SMALL LETTER ALPHA +.. |Bgr| unicode:: U+00392 .. GREEK CAPITAL LETTER BETA +.. |bgr| unicode:: U+003B2 .. GREEK SMALL LETTER BETA +.. |Dgr| unicode:: U+00394 .. GREEK CAPITAL LETTER DELTA +.. |dgr| unicode:: U+003B4 .. GREEK SMALL LETTER DELTA +.. |EEgr| unicode:: U+00397 .. GREEK CAPITAL LETTER ETA +.. |eegr| unicode:: U+003B7 .. GREEK SMALL LETTER ETA +.. |Egr| unicode:: U+00395 .. GREEK CAPITAL LETTER EPSILON +.. |egr| unicode:: U+003B5 .. GREEK SMALL LETTER EPSILON +.. |Ggr| unicode:: U+00393 .. GREEK CAPITAL LETTER GAMMA +.. |ggr| unicode:: U+003B3 .. GREEK SMALL LETTER GAMMA +.. |Igr| unicode:: U+00399 .. GREEK CAPITAL LETTER IOTA +.. |igr| unicode:: U+003B9 .. GREEK SMALL LETTER IOTA +.. |Kgr| unicode:: U+0039A .. GREEK CAPITAL LETTER KAPPA +.. |kgr| unicode:: U+003BA .. GREEK SMALL LETTER KAPPA +.. |KHgr| unicode:: U+003A7 .. GREEK CAPITAL LETTER CHI +.. |khgr| unicode:: U+003C7 .. GREEK SMALL LETTER CHI +.. |Lgr| unicode:: U+0039B .. GREEK CAPITAL LETTER LAMDA +.. |lgr| unicode:: U+003BB .. GREEK SMALL LETTER LAMDA +.. |Mgr| unicode:: U+0039C .. GREEK CAPITAL LETTER MU +.. |mgr| unicode:: U+003BC .. GREEK SMALL LETTER MU +.. |Ngr| unicode:: U+0039D .. GREEK CAPITAL LETTER NU +.. |ngr| unicode:: U+003BD .. GREEK SMALL LETTER NU +.. |Ogr| unicode:: U+0039F .. GREEK CAPITAL LETTER OMICRON +.. |ogr| unicode:: U+003BF .. GREEK SMALL LETTER OMICRON +.. |OHgr| unicode:: U+003A9 .. GREEK CAPITAL LETTER OMEGA +.. |ohgr| unicode:: U+003C9 .. GREEK SMALL LETTER OMEGA +.. |Pgr| unicode:: U+003A0 .. GREEK CAPITAL LETTER PI +.. |pgr| unicode:: U+003C0 .. GREEK SMALL LETTER PI +.. |PHgr| unicode:: U+003A6 .. GREEK CAPITAL LETTER PHI +.. |phgr| unicode:: U+003C6 .. GREEK SMALL LETTER PHI +.. |PSgr| unicode:: U+003A8 .. GREEK CAPITAL LETTER PSI +.. |psgr| unicode:: U+003C8 .. GREEK SMALL LETTER PSI +.. |Rgr| unicode:: U+003A1 .. GREEK CAPITAL LETTER RHO +.. |rgr| unicode:: U+003C1 .. GREEK SMALL LETTER RHO +.. |sfgr| unicode:: U+003C2 .. GREEK SMALL LETTER FINAL SIGMA +.. |Sgr| unicode:: U+003A3 .. GREEK CAPITAL LETTER SIGMA +.. |sgr| unicode:: U+003C3 .. GREEK SMALL LETTER SIGMA +.. |Tgr| unicode:: U+003A4 .. GREEK CAPITAL LETTER TAU +.. |tgr| unicode:: U+003C4 .. GREEK SMALL LETTER TAU +.. |THgr| unicode:: U+00398 .. GREEK CAPITAL LETTER THETA +.. |thgr| unicode:: U+003B8 .. GREEK SMALL LETTER THETA +.. |Ugr| unicode:: U+003A5 .. GREEK CAPITAL LETTER UPSILON +.. |ugr| unicode:: U+003C5 .. GREEK SMALL LETTER UPSILON +.. |Xgr| unicode:: U+0039E .. GREEK CAPITAL LETTER XI +.. |xgr| unicode:: U+003BE .. GREEK SMALL LETTER XI +.. |Zgr| unicode:: U+00396 .. GREEK CAPITAL LETTER ZETA +.. |zgr| unicode:: U+003B6 .. GREEK SMALL LETTER ZETA diff --git a/docutils/parsers/rst/include/isogrk2.txt b/docutils/parsers/rst/include/isogrk2.txt new file mode 100644 index 000000000..fa59f968d --- /dev/null +++ b/docutils/parsers/rst/include/isogrk2.txt @@ -0,0 +1,26 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |Aacgr| unicode:: U+00386 .. GREEK CAPITAL LETTER ALPHA WITH TONOS +.. |aacgr| unicode:: U+003AC .. GREEK SMALL LETTER ALPHA WITH TONOS +.. |Eacgr| unicode:: U+00388 .. GREEK CAPITAL LETTER EPSILON WITH TONOS +.. |eacgr| unicode:: U+003AD .. GREEK SMALL LETTER EPSILON WITH TONOS +.. |EEacgr| unicode:: U+00389 .. GREEK CAPITAL LETTER ETA WITH TONOS +.. |eeacgr| unicode:: U+003AE .. GREEK SMALL LETTER ETA WITH TONOS +.. |Iacgr| unicode:: U+0038A .. GREEK CAPITAL LETTER IOTA WITH TONOS +.. |iacgr| unicode:: U+003AF .. GREEK SMALL LETTER IOTA WITH TONOS +.. |idiagr| unicode:: U+00390 .. GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS +.. |Idigr| unicode:: U+003AA .. GREEK CAPITAL LETTER IOTA WITH DIALYTIKA +.. |idigr| unicode:: U+003CA .. GREEK SMALL LETTER IOTA WITH DIALYTIKA +.. |Oacgr| unicode:: U+0038C .. GREEK CAPITAL LETTER OMICRON WITH TONOS +.. |oacgr| unicode:: U+003CC .. GREEK SMALL LETTER OMICRON WITH TONOS +.. |OHacgr| unicode:: U+0038F .. GREEK CAPITAL LETTER OMEGA WITH TONOS +.. |ohacgr| unicode:: U+003CE .. GREEK SMALL LETTER OMEGA WITH TONOS +.. |Uacgr| unicode:: U+0038E .. GREEK CAPITAL LETTER UPSILON WITH TONOS +.. |uacgr| unicode:: U+003CD .. GREEK SMALL LETTER UPSILON WITH TONOS +.. |udiagr| unicode:: U+003B0 .. GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS +.. |Udigr| unicode:: U+003AB .. GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA +.. |udigr| unicode:: U+003CB .. GREEK SMALL LETTER UPSILON WITH DIALYTIKA diff --git a/docutils/parsers/rst/include/isogrk3.txt b/docutils/parsers/rst/include/isogrk3.txt new file mode 100644 index 000000000..efacd980b --- /dev/null +++ b/docutils/parsers/rst/include/isogrk3.txt @@ -0,0 +1,52 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |alpha| unicode:: U+003B1 .. GREEK SMALL LETTER ALPHA +.. |beta| unicode:: U+003B2 .. GREEK SMALL LETTER BETA +.. |chi| unicode:: U+003C7 .. GREEK SMALL LETTER CHI +.. |Delta| unicode:: U+00394 .. GREEK CAPITAL LETTER DELTA +.. |delta| unicode:: U+003B4 .. GREEK SMALL LETTER DELTA +.. |epsi| unicode:: U+003F5 .. GREEK LUNATE EPSILON SYMBOL +.. |epsis| unicode:: U+003F5 .. GREEK LUNATE EPSILON SYMBOL +.. |epsiv| unicode:: U+003B5 .. GREEK SMALL LETTER EPSILON +.. |eta| unicode:: U+003B7 .. GREEK SMALL LETTER ETA +.. |Gamma| unicode:: U+00393 .. GREEK CAPITAL LETTER GAMMA +.. |gamma| unicode:: U+003B3 .. GREEK SMALL LETTER GAMMA +.. |Gammad| unicode:: U+003DC .. GREEK LETTER DIGAMMA +.. |gammad| unicode:: U+003DD .. GREEK SMALL LETTER DIGAMMA +.. |iota| unicode:: U+003B9 .. GREEK SMALL LETTER IOTA +.. |kappa| unicode:: U+003BA .. GREEK SMALL LETTER KAPPA +.. |kappav| unicode:: U+003F0 .. GREEK KAPPA SYMBOL +.. |Lambda| unicode:: U+0039B .. GREEK CAPITAL LETTER LAMDA +.. |lambda| unicode:: U+003BB .. GREEK SMALL LETTER LAMDA +.. |mu| unicode:: U+003BC .. GREEK SMALL LETTER MU +.. |nu| unicode:: U+003BD .. GREEK SMALL LETTER NU +.. |Omega| unicode:: U+003A9 .. GREEK CAPITAL LETTER OMEGA +.. |omega| unicode:: U+003C9 .. GREEK SMALL LETTER OMEGA +.. |Phi| unicode:: U+003A6 .. GREEK CAPITAL LETTER PHI +.. |phi| unicode:: U+003D5 .. GREEK PHI SYMBOL +.. |phis| unicode:: U+003D5 .. GREEK PHI SYMBOL +.. |phiv| unicode:: U+003C6 .. GREEK SMALL LETTER PHI +.. |Pi| unicode:: U+003A0 .. GREEK CAPITAL LETTER PI +.. |pi| unicode:: U+003C0 .. GREEK SMALL LETTER PI +.. |piv| unicode:: U+003D6 .. GREEK PI SYMBOL +.. |Psi| unicode:: U+003A8 .. GREEK CAPITAL LETTER PSI +.. |psi| unicode:: U+003C8 .. GREEK SMALL LETTER PSI +.. |rho| unicode:: U+003C1 .. GREEK SMALL LETTER RHO +.. |rhov| unicode:: U+003F1 .. GREEK RHO SYMBOL +.. |Sigma| unicode:: U+003A3 .. GREEK CAPITAL LETTER SIGMA +.. |sigma| unicode:: U+003C3 .. GREEK SMALL LETTER SIGMA +.. |sigmav| unicode:: U+003C2 .. GREEK SMALL LETTER FINAL SIGMA +.. |tau| unicode:: U+003C4 .. GREEK SMALL LETTER TAU +.. |Theta| unicode:: U+00398 .. GREEK CAPITAL LETTER THETA +.. |theta| unicode:: U+003B8 .. GREEK SMALL LETTER THETA +.. |thetas| unicode:: U+003B8 .. GREEK SMALL LETTER THETA +.. |thetav| unicode:: U+003D1 .. GREEK THETA SYMBOL +.. |Upsi| unicode:: U+003D2 .. GREEK UPSILON WITH HOOK SYMBOL +.. |upsi| unicode:: U+003C5 .. GREEK SMALL LETTER UPSILON +.. |Xi| unicode:: U+0039E .. GREEK CAPITAL LETTER XI +.. |xi| unicode:: U+003BE .. GREEK SMALL LETTER XI +.. |zeta| unicode:: U+003B6 .. GREEK SMALL LETTER ZETA diff --git a/docutils/parsers/rst/include/isogrk4-wide.txt b/docutils/parsers/rst/include/isogrk4-wide.txt new file mode 100644 index 000000000..39a63075d --- /dev/null +++ b/docutils/parsers/rst/include/isogrk4-wide.txt @@ -0,0 +1,49 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |b.alpha| unicode:: U+1D6C2 .. MATHEMATICAL BOLD SMALL ALPHA +.. |b.beta| unicode:: U+1D6C3 .. MATHEMATICAL BOLD SMALL BETA +.. |b.chi| unicode:: U+1D6D8 .. MATHEMATICAL BOLD SMALL CHI +.. |b.Delta| unicode:: U+1D6AB .. MATHEMATICAL BOLD CAPITAL DELTA +.. |b.delta| unicode:: U+1D6C5 .. MATHEMATICAL BOLD SMALL DELTA +.. |b.epsi| unicode:: U+1D6C6 .. MATHEMATICAL BOLD SMALL EPSILON +.. |b.epsiv| unicode:: U+1D6DC .. MATHEMATICAL BOLD EPSILON SYMBOL +.. |b.eta| unicode:: U+1D6C8 .. MATHEMATICAL BOLD SMALL ETA +.. |b.Gamma| unicode:: U+1D6AA .. MATHEMATICAL BOLD CAPITAL GAMMA +.. |b.gamma| unicode:: U+1D6C4 .. MATHEMATICAL BOLD SMALL GAMMA +.. |b.Gammad| unicode:: U+003DC .. GREEK LETTER DIGAMMA +.. |b.gammad| unicode:: U+003DD .. GREEK SMALL LETTER DIGAMMA +.. |b.iota| unicode:: U+1D6CA .. MATHEMATICAL BOLD SMALL IOTA +.. |b.kappa| unicode:: U+1D6CB .. MATHEMATICAL BOLD SMALL KAPPA +.. |b.kappav| unicode:: U+1D6DE .. MATHEMATICAL BOLD KAPPA SYMBOL +.. |b.Lambda| unicode:: U+1D6B2 .. MATHEMATICAL BOLD CAPITAL LAMDA +.. |b.lambda| unicode:: U+1D6CC .. MATHEMATICAL BOLD SMALL LAMDA +.. |b.mu| unicode:: U+1D6CD .. MATHEMATICAL BOLD SMALL MU +.. |b.nu| unicode:: U+1D6CE .. MATHEMATICAL BOLD SMALL NU +.. |b.Omega| unicode:: U+1D6C0 .. MATHEMATICAL BOLD CAPITAL OMEGA +.. |b.omega| unicode:: U+1D6DA .. MATHEMATICAL BOLD SMALL OMEGA +.. |b.Phi| unicode:: U+1D6BD .. MATHEMATICAL BOLD CAPITAL PHI +.. |b.phi| unicode:: U+1D6D7 .. MATHEMATICAL BOLD SMALL PHI +.. |b.phiv| unicode:: U+1D6DF .. MATHEMATICAL BOLD PHI SYMBOL +.. |b.Pi| unicode:: U+1D6B7 .. MATHEMATICAL BOLD CAPITAL PI +.. |b.pi| unicode:: U+1D6D1 .. MATHEMATICAL BOLD SMALL PI +.. |b.piv| unicode:: U+1D6E1 .. MATHEMATICAL BOLD PI SYMBOL +.. |b.Psi| unicode:: U+1D6BF .. MATHEMATICAL BOLD CAPITAL PSI +.. |b.psi| unicode:: U+1D6D9 .. MATHEMATICAL BOLD SMALL PSI +.. |b.rho| unicode:: U+1D6D2 .. MATHEMATICAL BOLD SMALL RHO +.. |b.rhov| unicode:: U+1D6E0 .. MATHEMATICAL BOLD RHO SYMBOL +.. |b.Sigma| unicode:: U+1D6BA .. MATHEMATICAL BOLD CAPITAL SIGMA +.. |b.sigma| unicode:: U+1D6D4 .. MATHEMATICAL BOLD SMALL SIGMA +.. |b.sigmav| unicode:: U+1D6D3 .. MATHEMATICAL BOLD SMALL FINAL SIGMA +.. |b.tau| unicode:: U+1D6D5 .. MATHEMATICAL BOLD SMALL TAU +.. |b.Theta| unicode:: U+1D6AF .. MATHEMATICAL BOLD CAPITAL THETA +.. |b.thetas| unicode:: U+1D6C9 .. MATHEMATICAL BOLD SMALL THETA +.. |b.thetav| unicode:: U+1D6DD .. MATHEMATICAL BOLD THETA SYMBOL +.. |b.Upsi| unicode:: U+1D6BC .. MATHEMATICAL BOLD CAPITAL UPSILON +.. |b.upsi| unicode:: U+1D6D6 .. MATHEMATICAL BOLD SMALL UPSILON +.. |b.Xi| unicode:: U+1D6B5 .. MATHEMATICAL BOLD CAPITAL XI +.. |b.xi| unicode:: U+1D6CF .. MATHEMATICAL BOLD SMALL XI +.. |b.zeta| unicode:: U+1D6C7 .. MATHEMATICAL BOLD SMALL ZETA diff --git a/docutils/parsers/rst/include/isogrk4.txt b/docutils/parsers/rst/include/isogrk4.txt new file mode 100644 index 000000000..5b9f4104f --- /dev/null +++ b/docutils/parsers/rst/include/isogrk4.txt @@ -0,0 +1,8 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |b.Gammad| unicode:: U+003DC .. GREEK LETTER DIGAMMA +.. |b.gammad| unicode:: U+003DD .. GREEK SMALL LETTER DIGAMMA diff --git a/docutils/parsers/rst/include/isolat1.txt b/docutils/parsers/rst/include/isolat1.txt new file mode 100644 index 000000000..3e9ad9df3 --- /dev/null +++ b/docutils/parsers/rst/include/isolat1.txt @@ -0,0 +1,68 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |Aacute| unicode:: U+000C1 .. LATIN CAPITAL LETTER A WITH ACUTE +.. |aacute| unicode:: U+000E1 .. LATIN SMALL LETTER A WITH ACUTE +.. |Acirc| unicode:: U+000C2 .. LATIN CAPITAL LETTER A WITH CIRCUMFLEX +.. |acirc| unicode:: U+000E2 .. LATIN SMALL LETTER A WITH CIRCUMFLEX +.. |AElig| unicode:: U+000C6 .. LATIN CAPITAL LETTER AE +.. |aelig| unicode:: U+000E6 .. LATIN SMALL LETTER AE +.. |Agrave| unicode:: U+000C0 .. LATIN CAPITAL LETTER A WITH GRAVE +.. |agrave| unicode:: U+000E0 .. LATIN SMALL LETTER A WITH GRAVE +.. |Aring| unicode:: U+000C5 .. LATIN CAPITAL LETTER A WITH RING ABOVE +.. |aring| unicode:: U+000E5 .. LATIN SMALL LETTER A WITH RING ABOVE +.. |Atilde| unicode:: U+000C3 .. LATIN CAPITAL LETTER A WITH TILDE +.. |atilde| unicode:: U+000E3 .. LATIN SMALL LETTER A WITH TILDE +.. |Auml| unicode:: U+000C4 .. LATIN CAPITAL LETTER A WITH DIAERESIS +.. |auml| unicode:: U+000E4 .. LATIN SMALL LETTER A WITH DIAERESIS +.. |Ccedil| unicode:: U+000C7 .. LATIN CAPITAL LETTER C WITH CEDILLA +.. |ccedil| unicode:: U+000E7 .. LATIN SMALL LETTER C WITH CEDILLA +.. |Eacute| unicode:: U+000C9 .. LATIN CAPITAL LETTER E WITH ACUTE +.. |eacute| unicode:: U+000E9 .. LATIN SMALL LETTER E WITH ACUTE +.. |Ecirc| unicode:: U+000CA .. LATIN CAPITAL LETTER E WITH CIRCUMFLEX +.. |ecirc| unicode:: U+000EA .. LATIN SMALL LETTER E WITH CIRCUMFLEX +.. |Egrave| unicode:: U+000C8 .. LATIN CAPITAL LETTER E WITH GRAVE +.. |egrave| unicode:: U+000E8 .. LATIN SMALL LETTER E WITH GRAVE +.. |ETH| unicode:: U+000D0 .. LATIN CAPITAL LETTER ETH +.. |eth| unicode:: U+000F0 .. LATIN SMALL LETTER ETH +.. |Euml| unicode:: U+000CB .. LATIN CAPITAL LETTER E WITH DIAERESIS +.. |euml| unicode:: U+000EB .. LATIN SMALL LETTER E WITH DIAERESIS +.. |Iacute| unicode:: U+000CD .. LATIN CAPITAL LETTER I WITH ACUTE +.. |iacute| unicode:: U+000ED .. LATIN SMALL LETTER I WITH ACUTE +.. |Icirc| unicode:: U+000CE .. LATIN CAPITAL LETTER I WITH CIRCUMFLEX +.. |icirc| unicode:: U+000EE .. LATIN SMALL LETTER I WITH CIRCUMFLEX +.. |Igrave| unicode:: U+000CC .. LATIN CAPITAL LETTER I WITH GRAVE +.. |igrave| unicode:: U+000EC .. LATIN SMALL LETTER I WITH GRAVE +.. |Iuml| unicode:: U+000CF .. LATIN CAPITAL LETTER I WITH DIAERESIS +.. |iuml| unicode:: U+000EF .. LATIN SMALL LETTER I WITH DIAERESIS +.. |Ntilde| unicode:: U+000D1 .. LATIN CAPITAL LETTER N WITH TILDE +.. |ntilde| unicode:: U+000F1 .. LATIN SMALL LETTER N WITH TILDE +.. |Oacute| unicode:: U+000D3 .. LATIN CAPITAL LETTER O WITH ACUTE +.. |oacute| unicode:: U+000F3 .. LATIN SMALL LETTER O WITH ACUTE +.. |Ocirc| unicode:: U+000D4 .. LATIN CAPITAL LETTER O WITH CIRCUMFLEX +.. |ocirc| unicode:: U+000F4 .. LATIN SMALL LETTER O WITH CIRCUMFLEX +.. |Ograve| unicode:: U+000D2 .. LATIN CAPITAL LETTER O WITH GRAVE +.. |ograve| unicode:: U+000F2 .. LATIN SMALL LETTER O WITH GRAVE +.. |Oslash| unicode:: U+000D8 .. LATIN CAPITAL LETTER O WITH STROKE +.. |oslash| unicode:: U+000F8 .. LATIN SMALL LETTER O WITH STROKE +.. |Otilde| unicode:: U+000D5 .. LATIN CAPITAL LETTER O WITH TILDE +.. |otilde| unicode:: U+000F5 .. LATIN SMALL LETTER O WITH TILDE +.. |Ouml| unicode:: U+000D6 .. LATIN CAPITAL LETTER O WITH DIAERESIS +.. |ouml| unicode:: U+000F6 .. LATIN SMALL LETTER O WITH DIAERESIS +.. |szlig| unicode:: U+000DF .. LATIN SMALL LETTER SHARP S +.. |THORN| unicode:: U+000DE .. LATIN CAPITAL LETTER THORN +.. |thorn| unicode:: U+000FE .. LATIN SMALL LETTER THORN +.. |Uacute| unicode:: U+000DA .. LATIN CAPITAL LETTER U WITH ACUTE +.. |uacute| unicode:: U+000FA .. LATIN SMALL LETTER U WITH ACUTE +.. |Ucirc| unicode:: U+000DB .. LATIN CAPITAL LETTER U WITH CIRCUMFLEX +.. |ucirc| unicode:: U+000FB .. LATIN SMALL LETTER U WITH CIRCUMFLEX +.. |Ugrave| unicode:: U+000D9 .. LATIN CAPITAL LETTER U WITH GRAVE +.. |ugrave| unicode:: U+000F9 .. LATIN SMALL LETTER U WITH GRAVE +.. |Uuml| unicode:: U+000DC .. LATIN CAPITAL LETTER U WITH DIAERESIS +.. |uuml| unicode:: U+000FC .. LATIN SMALL LETTER U WITH DIAERESIS +.. |Yacute| unicode:: U+000DD .. LATIN CAPITAL LETTER Y WITH ACUTE +.. |yacute| unicode:: U+000FD .. LATIN SMALL LETTER Y WITH ACUTE +.. |yuml| unicode:: U+000FF .. LATIN SMALL LETTER Y WITH DIAERESIS diff --git a/docutils/parsers/rst/include/isolat2.txt b/docutils/parsers/rst/include/isolat2.txt new file mode 100644 index 000000000..20de84576 --- /dev/null +++ b/docutils/parsers/rst/include/isolat2.txt @@ -0,0 +1,128 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |Abreve| unicode:: U+00102 .. LATIN CAPITAL LETTER A WITH BREVE +.. |abreve| unicode:: U+00103 .. LATIN SMALL LETTER A WITH BREVE +.. |Amacr| unicode:: U+00100 .. LATIN CAPITAL LETTER A WITH MACRON +.. |amacr| unicode:: U+00101 .. LATIN SMALL LETTER A WITH MACRON +.. |Aogon| unicode:: U+00104 .. LATIN CAPITAL LETTER A WITH OGONEK +.. |aogon| unicode:: U+00105 .. LATIN SMALL LETTER A WITH OGONEK +.. |Cacute| unicode:: U+00106 .. LATIN CAPITAL LETTER C WITH ACUTE +.. |cacute| unicode:: U+00107 .. LATIN SMALL LETTER C WITH ACUTE +.. |Ccaron| unicode:: U+0010C .. LATIN CAPITAL LETTER C WITH CARON +.. |ccaron| unicode:: U+0010D .. LATIN SMALL LETTER C WITH CARON +.. |Ccirc| unicode:: U+00108 .. LATIN CAPITAL LETTER C WITH CIRCUMFLEX +.. |ccirc| unicode:: U+00109 .. LATIN SMALL LETTER C WITH CIRCUMFLEX +.. |Cdot| unicode:: U+0010A .. LATIN CAPITAL LETTER C WITH DOT ABOVE +.. |cdot| unicode:: U+0010B .. LATIN SMALL LETTER C WITH DOT ABOVE +.. |Dcaron| unicode:: U+0010E .. LATIN CAPITAL LETTER D WITH CARON +.. |dcaron| unicode:: U+0010F .. LATIN SMALL LETTER D WITH CARON +.. |Dstrok| unicode:: U+00110 .. LATIN CAPITAL LETTER D WITH STROKE +.. |dstrok| unicode:: U+00111 .. LATIN SMALL LETTER D WITH STROKE +.. |Ecaron| unicode:: U+0011A .. LATIN CAPITAL LETTER E WITH CARON +.. |ecaron| unicode:: U+0011B .. LATIN SMALL LETTER E WITH CARON +.. |Edot| unicode:: U+00116 .. LATIN CAPITAL LETTER E WITH DOT ABOVE +.. |edot| unicode:: U+00117 .. LATIN SMALL LETTER E WITH DOT ABOVE +.. |Emacr| unicode:: U+00112 .. LATIN CAPITAL LETTER E WITH MACRON +.. |emacr| unicode:: U+00113 .. LATIN SMALL LETTER E WITH MACRON +.. |ENG| unicode:: U+0014A .. LATIN CAPITAL LETTER ENG +.. |eng| unicode:: U+0014B .. LATIN SMALL LETTER ENG +.. |Eogon| unicode:: U+00118 .. LATIN CAPITAL LETTER E WITH OGONEK +.. |eogon| unicode:: U+00119 .. LATIN SMALL LETTER E WITH OGONEK +.. |gacute| unicode:: U+001F5 .. LATIN SMALL LETTER G WITH ACUTE +.. |Gbreve| unicode:: U+0011E .. LATIN CAPITAL LETTER G WITH BREVE +.. |gbreve| unicode:: U+0011F .. LATIN SMALL LETTER G WITH BREVE +.. |Gcedil| unicode:: U+00122 .. LATIN CAPITAL LETTER G WITH CEDILLA +.. |gcedil| unicode:: U+00123 .. LATIN SMALL LETTER G WITH CEDILLA +.. |Gcirc| unicode:: U+0011C .. LATIN CAPITAL LETTER G WITH CIRCUMFLEX +.. |gcirc| unicode:: U+0011D .. LATIN SMALL LETTER G WITH CIRCUMFLEX +.. |Gdot| unicode:: U+00120 .. LATIN CAPITAL LETTER G WITH DOT ABOVE +.. |gdot| unicode:: U+00121 .. LATIN SMALL LETTER G WITH DOT ABOVE +.. |Hcirc| unicode:: U+00124 .. LATIN CAPITAL LETTER H WITH CIRCUMFLEX +.. |hcirc| unicode:: U+00125 .. LATIN SMALL LETTER H WITH CIRCUMFLEX +.. |Hstrok| unicode:: U+00126 .. LATIN CAPITAL LETTER H WITH STROKE +.. |hstrok| unicode:: U+00127 .. LATIN SMALL LETTER H WITH STROKE +.. |Idot| unicode:: U+00130 .. LATIN CAPITAL LETTER I WITH DOT ABOVE +.. |IJlig| unicode:: U+00132 .. LATIN CAPITAL LIGATURE IJ +.. |ijlig| unicode:: U+00133 .. LATIN SMALL LIGATURE IJ +.. |Imacr| unicode:: U+0012A .. LATIN CAPITAL LETTER I WITH MACRON +.. |imacr| unicode:: U+0012B .. LATIN SMALL LETTER I WITH MACRON +.. |inodot| unicode:: U+00131 .. LATIN SMALL LETTER DOTLESS I +.. |Iogon| unicode:: U+0012E .. LATIN CAPITAL LETTER I WITH OGONEK +.. |iogon| unicode:: U+0012F .. LATIN SMALL LETTER I WITH OGONEK +.. |Itilde| unicode:: U+00128 .. LATIN CAPITAL LETTER I WITH TILDE +.. |itilde| unicode:: U+00129 .. LATIN SMALL LETTER I WITH TILDE +.. |Jcirc| unicode:: U+00134 .. LATIN CAPITAL LETTER J WITH CIRCUMFLEX +.. |jcirc| unicode:: U+00135 .. LATIN SMALL LETTER J WITH CIRCUMFLEX +.. |Kcedil| unicode:: U+00136 .. LATIN CAPITAL LETTER K WITH CEDILLA +.. |kcedil| unicode:: U+00137 .. LATIN SMALL LETTER K WITH CEDILLA +.. |kgreen| unicode:: U+00138 .. LATIN SMALL LETTER KRA +.. |Lacute| unicode:: U+00139 .. LATIN CAPITAL LETTER L WITH ACUTE +.. |lacute| unicode:: U+0013A .. LATIN SMALL LETTER L WITH ACUTE +.. |Lcaron| unicode:: U+0013D .. LATIN CAPITAL LETTER L WITH CARON +.. |lcaron| unicode:: U+0013E .. LATIN SMALL LETTER L WITH CARON +.. |Lcedil| unicode:: U+0013B .. LATIN CAPITAL LETTER L WITH CEDILLA +.. |lcedil| unicode:: U+0013C .. LATIN SMALL LETTER L WITH CEDILLA +.. |Lmidot| unicode:: U+0013F .. LATIN CAPITAL LETTER L WITH MIDDLE DOT +.. |lmidot| unicode:: U+00140 .. LATIN SMALL LETTER L WITH MIDDLE DOT +.. |Lstrok| unicode:: U+00141 .. LATIN CAPITAL LETTER L WITH STROKE +.. |lstrok| unicode:: U+00142 .. LATIN SMALL LETTER L WITH STROKE +.. |Nacute| unicode:: U+00143 .. LATIN CAPITAL LETTER N WITH ACUTE +.. |nacute| unicode:: U+00144 .. LATIN SMALL LETTER N WITH ACUTE +.. |napos| unicode:: U+00149 .. LATIN SMALL LETTER N PRECEDED BY APOSTROPHE +.. |Ncaron| unicode:: U+00147 .. LATIN CAPITAL LETTER N WITH CARON +.. |ncaron| unicode:: U+00148 .. LATIN SMALL LETTER N WITH CARON +.. |Ncedil| unicode:: U+00145 .. LATIN CAPITAL LETTER N WITH CEDILLA +.. |ncedil| unicode:: U+00146 .. LATIN SMALL LETTER N WITH CEDILLA +.. |Odblac| unicode:: U+00150 .. LATIN CAPITAL LETTER O WITH DOUBLE ACUTE +.. |odblac| unicode:: U+00151 .. LATIN SMALL LETTER O WITH DOUBLE ACUTE +.. |OElig| unicode:: U+00152 .. LATIN CAPITAL LIGATURE OE +.. |oelig| unicode:: U+00153 .. LATIN SMALL LIGATURE OE +.. |Omacr| unicode:: U+0014C .. LATIN CAPITAL LETTER O WITH MACRON +.. |omacr| unicode:: U+0014D .. LATIN SMALL LETTER O WITH MACRON +.. |Racute| unicode:: U+00154 .. LATIN CAPITAL LETTER R WITH ACUTE +.. |racute| unicode:: U+00155 .. LATIN SMALL LETTER R WITH ACUTE +.. |Rcaron| unicode:: U+00158 .. LATIN CAPITAL LETTER R WITH CARON +.. |rcaron| unicode:: U+00159 .. LATIN SMALL LETTER R WITH CARON +.. |Rcedil| unicode:: U+00156 .. LATIN CAPITAL LETTER R WITH CEDILLA +.. |rcedil| unicode:: U+00157 .. LATIN SMALL LETTER R WITH CEDILLA +.. |Sacute| unicode:: U+0015A .. LATIN CAPITAL LETTER S WITH ACUTE +.. |sacute| unicode:: U+0015B .. LATIN SMALL LETTER S WITH ACUTE +.. |Scaron| unicode:: U+00160 .. LATIN CAPITAL LETTER S WITH CARON +.. |scaron| unicode:: U+00161 .. LATIN SMALL LETTER S WITH CARON +.. |Scedil| unicode:: U+0015E .. LATIN CAPITAL LETTER S WITH CEDILLA +.. |scedil| unicode:: U+0015F .. LATIN SMALL LETTER S WITH CEDILLA +.. |Scirc| unicode:: U+0015C .. LATIN CAPITAL LETTER S WITH CIRCUMFLEX +.. |scirc| unicode:: U+0015D .. LATIN SMALL LETTER S WITH CIRCUMFLEX +.. |Tcaron| unicode:: U+00164 .. LATIN CAPITAL LETTER T WITH CARON +.. |tcaron| unicode:: U+00165 .. LATIN SMALL LETTER T WITH CARON +.. |Tcedil| unicode:: U+00162 .. LATIN CAPITAL LETTER T WITH CEDILLA +.. |tcedil| unicode:: U+00163 .. LATIN SMALL LETTER T WITH CEDILLA +.. |Tstrok| unicode:: U+00166 .. LATIN CAPITAL LETTER T WITH STROKE +.. |tstrok| unicode:: U+00167 .. LATIN SMALL LETTER T WITH STROKE +.. |Ubreve| unicode:: U+0016C .. LATIN CAPITAL LETTER U WITH BREVE +.. |ubreve| unicode:: U+0016D .. LATIN SMALL LETTER U WITH BREVE +.. |Udblac| unicode:: U+00170 .. LATIN CAPITAL LETTER U WITH DOUBLE ACUTE +.. |udblac| unicode:: U+00171 .. LATIN SMALL LETTER U WITH DOUBLE ACUTE +.. |Umacr| unicode:: U+0016A .. LATIN CAPITAL LETTER U WITH MACRON +.. |umacr| unicode:: U+0016B .. LATIN SMALL LETTER U WITH MACRON +.. |Uogon| unicode:: U+00172 .. LATIN CAPITAL LETTER U WITH OGONEK +.. |uogon| unicode:: U+00173 .. LATIN SMALL LETTER U WITH OGONEK +.. |Uring| unicode:: U+0016E .. LATIN CAPITAL LETTER U WITH RING ABOVE +.. |uring| unicode:: U+0016F .. LATIN SMALL LETTER U WITH RING ABOVE +.. |Utilde| unicode:: U+00168 .. LATIN CAPITAL LETTER U WITH TILDE +.. |utilde| unicode:: U+00169 .. LATIN SMALL LETTER U WITH TILDE +.. |Wcirc| unicode:: U+00174 .. LATIN CAPITAL LETTER W WITH CIRCUMFLEX +.. |wcirc| unicode:: U+00175 .. LATIN SMALL LETTER W WITH CIRCUMFLEX +.. |Ycirc| unicode:: U+00176 .. LATIN CAPITAL LETTER Y WITH CIRCUMFLEX +.. |ycirc| unicode:: U+00177 .. LATIN SMALL LETTER Y WITH CIRCUMFLEX +.. |Yuml| unicode:: U+00178 .. LATIN CAPITAL LETTER Y WITH DIAERESIS +.. |Zacute| unicode:: U+00179 .. LATIN CAPITAL LETTER Z WITH ACUTE +.. |zacute| unicode:: U+0017A .. LATIN SMALL LETTER Z WITH ACUTE +.. |Zcaron| unicode:: U+0017D .. LATIN CAPITAL LETTER Z WITH CARON +.. |zcaron| unicode:: U+0017E .. LATIN SMALL LETTER Z WITH CARON +.. |Zdot| unicode:: U+0017B .. LATIN CAPITAL LETTER Z WITH DOT ABOVE +.. |zdot| unicode:: U+0017C .. LATIN SMALL LETTER Z WITH DOT ABOVE diff --git a/docutils/parsers/rst/include/isomfrk-wide.txt b/docutils/parsers/rst/include/isomfrk-wide.txt new file mode 100644 index 000000000..75bba2575 --- /dev/null +++ b/docutils/parsers/rst/include/isomfrk-wide.txt @@ -0,0 +1,58 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |Afr| unicode:: U+1D504 .. MATHEMATICAL FRAKTUR CAPITAL A +.. |afr| unicode:: U+1D51E .. MATHEMATICAL FRAKTUR SMALL A +.. |Bfr| unicode:: U+1D505 .. MATHEMATICAL FRAKTUR CAPITAL B +.. |bfr| unicode:: U+1D51F .. MATHEMATICAL FRAKTUR SMALL B +.. |Cfr| unicode:: U+0212D .. BLACK-LETTER CAPITAL C +.. |cfr| unicode:: U+1D520 .. MATHEMATICAL FRAKTUR SMALL C +.. |Dfr| unicode:: U+1D507 .. MATHEMATICAL FRAKTUR CAPITAL D +.. |dfr| unicode:: U+1D521 .. MATHEMATICAL FRAKTUR SMALL D +.. |Efr| unicode:: U+1D508 .. MATHEMATICAL FRAKTUR CAPITAL E +.. |efr| unicode:: U+1D522 .. MATHEMATICAL FRAKTUR SMALL E +.. |Ffr| unicode:: U+1D509 .. MATHEMATICAL FRAKTUR CAPITAL F +.. |ffr| unicode:: U+1D523 .. MATHEMATICAL FRAKTUR SMALL F +.. |Gfr| unicode:: U+1D50A .. MATHEMATICAL FRAKTUR CAPITAL G +.. |gfr| unicode:: U+1D524 .. MATHEMATICAL FRAKTUR SMALL G +.. |Hfr| unicode:: U+0210C .. BLACK-LETTER CAPITAL H +.. |hfr| unicode:: U+1D525 .. MATHEMATICAL FRAKTUR SMALL H +.. |Ifr| unicode:: U+02111 .. BLACK-LETTER CAPITAL I +.. |ifr| unicode:: U+1D526 .. MATHEMATICAL FRAKTUR SMALL I +.. |Jfr| unicode:: U+1D50D .. MATHEMATICAL FRAKTUR CAPITAL J +.. |jfr| unicode:: U+1D527 .. MATHEMATICAL FRAKTUR SMALL J +.. |Kfr| unicode:: U+1D50E .. MATHEMATICAL FRAKTUR CAPITAL K +.. |kfr| unicode:: U+1D528 .. MATHEMATICAL FRAKTUR SMALL K +.. |Lfr| unicode:: U+1D50F .. MATHEMATICAL FRAKTUR CAPITAL L +.. |lfr| unicode:: U+1D529 .. MATHEMATICAL FRAKTUR SMALL L +.. |Mfr| unicode:: U+1D510 .. MATHEMATICAL FRAKTUR CAPITAL M +.. |mfr| unicode:: U+1D52A .. MATHEMATICAL FRAKTUR SMALL M +.. |Nfr| unicode:: U+1D511 .. MATHEMATICAL FRAKTUR CAPITAL N +.. |nfr| unicode:: U+1D52B .. MATHEMATICAL FRAKTUR SMALL N +.. |Ofr| unicode:: U+1D512 .. MATHEMATICAL FRAKTUR CAPITAL O +.. |ofr| unicode:: U+1D52C .. MATHEMATICAL FRAKTUR SMALL O +.. |Pfr| unicode:: U+1D513 .. MATHEMATICAL FRAKTUR CAPITAL P +.. |pfr| unicode:: U+1D52D .. MATHEMATICAL FRAKTUR SMALL P +.. |Qfr| unicode:: U+1D514 .. MATHEMATICAL FRAKTUR CAPITAL Q +.. |qfr| unicode:: U+1D52E .. MATHEMATICAL FRAKTUR SMALL Q +.. |Rfr| unicode:: U+0211C .. BLACK-LETTER CAPITAL R +.. |rfr| unicode:: U+1D52F .. MATHEMATICAL FRAKTUR SMALL R +.. |Sfr| unicode:: U+1D516 .. MATHEMATICAL FRAKTUR CAPITAL S +.. |sfr| unicode:: U+1D530 .. MATHEMATICAL FRAKTUR SMALL S +.. |Tfr| unicode:: U+1D517 .. MATHEMATICAL FRAKTUR CAPITAL T +.. |tfr| unicode:: U+1D531 .. MATHEMATICAL FRAKTUR SMALL T +.. |Ufr| unicode:: U+1D518 .. MATHEMATICAL FRAKTUR CAPITAL U +.. |ufr| unicode:: U+1D532 .. MATHEMATICAL FRAKTUR SMALL U +.. |Vfr| unicode:: U+1D519 .. MATHEMATICAL FRAKTUR CAPITAL V +.. |vfr| unicode:: U+1D533 .. MATHEMATICAL FRAKTUR SMALL V +.. |Wfr| unicode:: U+1D51A .. MATHEMATICAL FRAKTUR CAPITAL W +.. |wfr| unicode:: U+1D534 .. MATHEMATICAL FRAKTUR SMALL W +.. |Xfr| unicode:: U+1D51B .. MATHEMATICAL FRAKTUR CAPITAL X +.. |xfr| unicode:: U+1D535 .. MATHEMATICAL FRAKTUR SMALL X +.. |Yfr| unicode:: U+1D51C .. MATHEMATICAL FRAKTUR CAPITAL Y +.. |yfr| unicode:: U+1D536 .. MATHEMATICAL FRAKTUR SMALL Y +.. |Zfr| unicode:: U+02128 .. BLACK-LETTER CAPITAL Z +.. |zfr| unicode:: U+1D537 .. MATHEMATICAL FRAKTUR SMALL Z diff --git a/docutils/parsers/rst/include/isomfrk.txt b/docutils/parsers/rst/include/isomfrk.txt new file mode 100644 index 000000000..868b687a5 --- /dev/null +++ b/docutils/parsers/rst/include/isomfrk.txt @@ -0,0 +1,11 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |Cfr| unicode:: U+0212D .. BLACK-LETTER CAPITAL C +.. |Hfr| unicode:: U+0210C .. BLACK-LETTER CAPITAL H +.. |Ifr| unicode:: U+02111 .. BLACK-LETTER CAPITAL I +.. |Rfr| unicode:: U+0211C .. BLACK-LETTER CAPITAL R +.. |Zfr| unicode:: U+02128 .. BLACK-LETTER CAPITAL Z diff --git a/docutils/parsers/rst/include/isomopf-wide.txt b/docutils/parsers/rst/include/isomopf-wide.txt new file mode 100644 index 000000000..a91ea43eb --- /dev/null +++ b/docutils/parsers/rst/include/isomopf-wide.txt @@ -0,0 +1,32 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |Aopf| unicode:: U+1D538 .. MATHEMATICAL DOUBLE-STRUCK CAPITAL A +.. |Bopf| unicode:: U+1D539 .. MATHEMATICAL DOUBLE-STRUCK CAPITAL B +.. |Copf| unicode:: U+02102 .. DOUBLE-STRUCK CAPITAL C +.. |Dopf| unicode:: U+1D53B .. MATHEMATICAL DOUBLE-STRUCK CAPITAL D +.. |Eopf| unicode:: U+1D53C .. MATHEMATICAL DOUBLE-STRUCK CAPITAL E +.. |Fopf| unicode:: U+1D53D .. MATHEMATICAL DOUBLE-STRUCK CAPITAL F +.. |Gopf| unicode:: U+1D53E .. MATHEMATICAL DOUBLE-STRUCK CAPITAL G +.. |Hopf| unicode:: U+0210D .. DOUBLE-STRUCK CAPITAL H +.. |Iopf| unicode:: U+1D540 .. MATHEMATICAL DOUBLE-STRUCK CAPITAL I +.. |Jopf| unicode:: U+1D541 .. MATHEMATICAL DOUBLE-STRUCK CAPITAL J +.. |Kopf| unicode:: U+1D542 .. MATHEMATICAL DOUBLE-STRUCK CAPITAL K +.. |Lopf| unicode:: U+1D543 .. MATHEMATICAL DOUBLE-STRUCK CAPITAL L +.. |Mopf| unicode:: U+1D544 .. MATHEMATICAL DOUBLE-STRUCK CAPITAL M +.. |Nopf| unicode:: U+02115 .. DOUBLE-STRUCK CAPITAL N +.. |Oopf| unicode:: U+1D546 .. MATHEMATICAL DOUBLE-STRUCK CAPITAL O +.. |Popf| unicode:: U+02119 .. DOUBLE-STRUCK CAPITAL P +.. |Qopf| unicode:: U+0211A .. DOUBLE-STRUCK CAPITAL Q +.. |Ropf| unicode:: U+0211D .. DOUBLE-STRUCK CAPITAL R +.. |Sopf| unicode:: U+1D54A .. MATHEMATICAL DOUBLE-STRUCK CAPITAL S +.. |Topf| unicode:: U+1D54B .. MATHEMATICAL DOUBLE-STRUCK CAPITAL T +.. |Uopf| unicode:: U+1D54C .. MATHEMATICAL DOUBLE-STRUCK CAPITAL U +.. |Vopf| unicode:: U+1D54D .. MATHEMATICAL DOUBLE-STRUCK CAPITAL V +.. |Wopf| unicode:: U+1D54E .. MATHEMATICAL DOUBLE-STRUCK CAPITAL W +.. |Xopf| unicode:: U+1D54F .. MATHEMATICAL DOUBLE-STRUCK CAPITAL X +.. |Yopf| unicode:: U+1D550 .. MATHEMATICAL DOUBLE-STRUCK CAPITAL Y +.. |Zopf| unicode:: U+02124 .. DOUBLE-STRUCK CAPITAL Z diff --git a/docutils/parsers/rst/include/isomopf.txt b/docutils/parsers/rst/include/isomopf.txt new file mode 100644 index 000000000..4350db61b --- /dev/null +++ b/docutils/parsers/rst/include/isomopf.txt @@ -0,0 +1,13 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |Copf| unicode:: U+02102 .. DOUBLE-STRUCK CAPITAL C +.. |Hopf| unicode:: U+0210D .. DOUBLE-STRUCK CAPITAL H +.. |Nopf| unicode:: U+02115 .. DOUBLE-STRUCK CAPITAL N +.. |Popf| unicode:: U+02119 .. DOUBLE-STRUCK CAPITAL P +.. |Qopf| unicode:: U+0211A .. DOUBLE-STRUCK CAPITAL Q +.. |Ropf| unicode:: U+0211D .. DOUBLE-STRUCK CAPITAL R +.. |Zopf| unicode:: U+02124 .. DOUBLE-STRUCK CAPITAL Z diff --git a/docutils/parsers/rst/include/isomscr-wide.txt b/docutils/parsers/rst/include/isomscr-wide.txt new file mode 100644 index 000000000..34b278b98 --- /dev/null +++ b/docutils/parsers/rst/include/isomscr-wide.txt @@ -0,0 +1,58 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |Ascr| unicode:: U+1D49C .. MATHEMATICAL SCRIPT CAPITAL A +.. |ascr| unicode:: U+1D4B6 .. MATHEMATICAL SCRIPT SMALL A +.. |Bscr| unicode:: U+0212C .. SCRIPT CAPITAL B +.. |bscr| unicode:: U+1D4B7 .. MATHEMATICAL SCRIPT SMALL B +.. |Cscr| unicode:: U+1D49E .. MATHEMATICAL SCRIPT CAPITAL C +.. |cscr| unicode:: U+1D4B8 .. MATHEMATICAL SCRIPT SMALL C +.. |Dscr| unicode:: U+1D49F .. MATHEMATICAL SCRIPT CAPITAL D +.. |dscr| unicode:: U+1D4B9 .. MATHEMATICAL SCRIPT SMALL D +.. |Escr| unicode:: U+02130 .. SCRIPT CAPITAL E +.. |escr| unicode:: U+0212F .. SCRIPT SMALL E +.. |Fscr| unicode:: U+02131 .. SCRIPT CAPITAL F +.. |fscr| unicode:: U+1D4BB .. MATHEMATICAL SCRIPT SMALL F +.. |Gscr| unicode:: U+1D4A2 .. MATHEMATICAL SCRIPT CAPITAL G +.. |gscr| unicode:: U+0210A .. SCRIPT SMALL G +.. |Hscr| unicode:: U+0210B .. SCRIPT CAPITAL H +.. |hscr| unicode:: U+1D4BD .. MATHEMATICAL SCRIPT SMALL H +.. |Iscr| unicode:: U+02110 .. SCRIPT CAPITAL I +.. |iscr| unicode:: U+1D4BE .. MATHEMATICAL SCRIPT SMALL I +.. |Jscr| unicode:: U+1D4A5 .. MATHEMATICAL SCRIPT CAPITAL J +.. |jscr| unicode:: U+1D4BF .. MATHEMATICAL SCRIPT SMALL J +.. |Kscr| unicode:: U+1D4A6 .. MATHEMATICAL SCRIPT CAPITAL K +.. |kscr| unicode:: U+1D4C0 .. MATHEMATICAL SCRIPT SMALL K +.. |Lscr| unicode:: U+02112 .. SCRIPT CAPITAL L +.. |lscr| unicode:: U+1D4C1 .. MATHEMATICAL SCRIPT SMALL L +.. |Mscr| unicode:: U+02133 .. SCRIPT CAPITAL M +.. |mscr| unicode:: U+1D4C2 .. MATHEMATICAL SCRIPT SMALL M +.. |Nscr| unicode:: U+1D4A9 .. MATHEMATICAL SCRIPT CAPITAL N +.. |nscr| unicode:: U+1D4C3 .. MATHEMATICAL SCRIPT SMALL N +.. |Oscr| unicode:: U+1D4AA .. MATHEMATICAL SCRIPT CAPITAL O +.. |oscr| unicode:: U+02134 .. SCRIPT SMALL O +.. |Pscr| unicode:: U+1D4AB .. MATHEMATICAL SCRIPT CAPITAL P +.. |pscr| unicode:: U+1D4C5 .. MATHEMATICAL SCRIPT SMALL P +.. |Qscr| unicode:: U+1D4AC .. MATHEMATICAL SCRIPT CAPITAL Q +.. |qscr| unicode:: U+1D4C6 .. MATHEMATICAL SCRIPT SMALL Q +.. |Rscr| unicode:: U+0211B .. SCRIPT CAPITAL R +.. |rscr| unicode:: U+1D4C7 .. MATHEMATICAL SCRIPT SMALL R +.. |Sscr| unicode:: U+1D4AE .. MATHEMATICAL SCRIPT CAPITAL S +.. |sscr| unicode:: U+1D4C8 .. MATHEMATICAL SCRIPT SMALL S +.. |Tscr| unicode:: U+1D4AF .. MATHEMATICAL SCRIPT CAPITAL T +.. |tscr| unicode:: U+1D4C9 .. MATHEMATICAL SCRIPT SMALL T +.. |Uscr| unicode:: U+1D4B0 .. MATHEMATICAL SCRIPT CAPITAL U +.. |uscr| unicode:: U+1D4CA .. MATHEMATICAL SCRIPT SMALL U +.. |Vscr| unicode:: U+1D4B1 .. MATHEMATICAL SCRIPT CAPITAL V +.. |vscr| unicode:: U+1D4CB .. MATHEMATICAL SCRIPT SMALL V +.. |Wscr| unicode:: U+1D4B2 .. MATHEMATICAL SCRIPT CAPITAL W +.. |wscr| unicode:: U+1D4CC .. MATHEMATICAL SCRIPT SMALL W +.. |Xscr| unicode:: U+1D4B3 .. MATHEMATICAL SCRIPT CAPITAL X +.. |xscr| unicode:: U+1D4CD .. MATHEMATICAL SCRIPT SMALL X +.. |Yscr| unicode:: U+1D4B4 .. MATHEMATICAL SCRIPT CAPITAL Y +.. |yscr| unicode:: U+1D4CE .. MATHEMATICAL SCRIPT SMALL Y +.. |Zscr| unicode:: U+1D4B5 .. MATHEMATICAL SCRIPT CAPITAL Z +.. |zscr| unicode:: U+1D4CF .. MATHEMATICAL SCRIPT SMALL Z diff --git a/docutils/parsers/rst/include/isomscr.txt b/docutils/parsers/rst/include/isomscr.txt new file mode 100644 index 000000000..a77890e97 --- /dev/null +++ b/docutils/parsers/rst/include/isomscr.txt @@ -0,0 +1,17 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |Bscr| unicode:: U+0212C .. SCRIPT CAPITAL B +.. |Escr| unicode:: U+02130 .. SCRIPT CAPITAL E +.. |escr| unicode:: U+0212F .. SCRIPT SMALL E +.. |Fscr| unicode:: U+02131 .. SCRIPT CAPITAL F +.. |gscr| unicode:: U+0210A .. SCRIPT SMALL G +.. |Hscr| unicode:: U+0210B .. SCRIPT CAPITAL H +.. |Iscr| unicode:: U+02110 .. SCRIPT CAPITAL I +.. |Lscr| unicode:: U+02112 .. SCRIPT CAPITAL L +.. |Mscr| unicode:: U+02133 .. SCRIPT CAPITAL M +.. |oscr| unicode:: U+02134 .. SCRIPT SMALL O +.. |Rscr| unicode:: U+0211B .. SCRIPT CAPITAL R diff --git a/docutils/parsers/rst/include/isonum.txt b/docutils/parsers/rst/include/isonum.txt new file mode 100644 index 000000000..35793b365 --- /dev/null +++ b/docutils/parsers/rst/include/isonum.txt @@ -0,0 +1,82 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |amp| unicode:: U+00026 .. AMPERSAND +.. |apos| unicode:: U+00027 .. APOSTROPHE +.. |ast| unicode:: U+0002A .. ASTERISK +.. |brvbar| unicode:: U+000A6 .. BROKEN BAR +.. |bsol| unicode:: U+0005C .. REVERSE SOLIDUS +.. |cent| unicode:: U+000A2 .. CENT SIGN +.. |colon| unicode:: U+0003A .. COLON +.. |comma| unicode:: U+0002C .. COMMA +.. |commat| unicode:: U+00040 .. COMMERCIAL AT +.. |copy| unicode:: U+000A9 .. COPYRIGHT SIGN +.. |curren| unicode:: U+000A4 .. CURRENCY SIGN +.. |darr| unicode:: U+02193 .. DOWNWARDS ARROW +.. |deg| unicode:: U+000B0 .. DEGREE SIGN +.. |divide| unicode:: U+000F7 .. DIVISION SIGN +.. |dollar| unicode:: U+00024 .. DOLLAR SIGN +.. |equals| unicode:: U+0003D .. EQUALS SIGN +.. |excl| unicode:: U+00021 .. EXCLAMATION MARK +.. |frac12| unicode:: U+000BD .. VULGAR FRACTION ONE HALF +.. |frac14| unicode:: U+000BC .. VULGAR FRACTION ONE QUARTER +.. |frac18| unicode:: U+0215B .. VULGAR FRACTION ONE EIGHTH +.. |frac34| unicode:: U+000BE .. VULGAR FRACTION THREE QUARTERS +.. |frac38| unicode:: U+0215C .. VULGAR FRACTION THREE EIGHTHS +.. |frac58| unicode:: U+0215D .. VULGAR FRACTION FIVE EIGHTHS +.. |frac78| unicode:: U+0215E .. VULGAR FRACTION SEVEN EIGHTHS +.. |gt| unicode:: U+0003E .. GREATER-THAN SIGN +.. |half| unicode:: U+000BD .. VULGAR FRACTION ONE HALF +.. |horbar| unicode:: U+02015 .. HORIZONTAL BAR +.. |hyphen| unicode:: U+02010 .. HYPHEN +.. |iexcl| unicode:: U+000A1 .. INVERTED EXCLAMATION MARK +.. |iquest| unicode:: U+000BF .. INVERTED QUESTION MARK +.. |laquo| unicode:: U+000AB .. LEFT-POINTING DOUBLE ANGLE QUOTATION MARK +.. |larr| unicode:: U+02190 .. LEFTWARDS ARROW +.. |lcub| unicode:: U+0007B .. LEFT CURLY BRACKET +.. |ldquo| unicode:: U+0201C .. LEFT DOUBLE QUOTATION MARK +.. |lowbar| unicode:: U+0005F .. LOW LINE +.. |lpar| unicode:: U+00028 .. LEFT PARENTHESIS +.. |lsqb| unicode:: U+0005B .. LEFT SQUARE BRACKET +.. |lsquo| unicode:: U+02018 .. LEFT SINGLE QUOTATION MARK +.. |lt| unicode:: U+0003C .. LESS-THAN SIGN +.. |micro| unicode:: U+000B5 .. MICRO SIGN +.. |middot| unicode:: U+000B7 .. MIDDLE DOT +.. |nbsp| unicode:: U+000A0 .. NO-BREAK SPACE +.. |not| unicode:: U+000AC .. NOT SIGN +.. |num| unicode:: U+00023 .. NUMBER SIGN +.. |ohm| unicode:: U+02126 .. OHM SIGN +.. |ordf| unicode:: U+000AA .. FEMININE ORDINAL INDICATOR +.. |ordm| unicode:: U+000BA .. MASCULINE ORDINAL INDICATOR +.. |para| unicode:: U+000B6 .. PILCROW SIGN +.. |percnt| unicode:: U+00025 .. PERCENT SIGN +.. |period| unicode:: U+0002E .. FULL STOP +.. |plus| unicode:: U+0002B .. PLUS SIGN +.. |plusmn| unicode:: U+000B1 .. PLUS-MINUS SIGN +.. |pound| unicode:: U+000A3 .. POUND SIGN +.. |quest| unicode:: U+0003F .. QUESTION MARK +.. |quot| unicode:: U+00022 .. QUOTATION MARK +.. |raquo| unicode:: U+000BB .. RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK +.. |rarr| unicode:: U+02192 .. RIGHTWARDS ARROW +.. |rcub| unicode:: U+0007D .. RIGHT CURLY BRACKET +.. |rdquo| unicode:: U+0201D .. RIGHT DOUBLE QUOTATION MARK +.. |reg| unicode:: U+000AE .. REGISTERED SIGN +.. |rpar| unicode:: U+00029 .. RIGHT PARENTHESIS +.. |rsqb| unicode:: U+0005D .. RIGHT SQUARE BRACKET +.. |rsquo| unicode:: U+02019 .. RIGHT SINGLE QUOTATION MARK +.. |sect| unicode:: U+000A7 .. SECTION SIGN +.. |semi| unicode:: U+0003B .. SEMICOLON +.. |shy| unicode:: U+000AD .. SOFT HYPHEN +.. |sol| unicode:: U+0002F .. SOLIDUS +.. |sung| unicode:: U+0266A .. EIGHTH NOTE +.. |sup1| unicode:: U+000B9 .. SUPERSCRIPT ONE +.. |sup2| unicode:: U+000B2 .. SUPERSCRIPT TWO +.. |sup3| unicode:: U+000B3 .. SUPERSCRIPT THREE +.. |times| unicode:: U+000D7 .. MULTIPLICATION SIGN +.. |trade| unicode:: U+02122 .. TRADE MARK SIGN +.. |uarr| unicode:: U+02191 .. UPWARDS ARROW +.. |verbar| unicode:: U+0007C .. VERTICAL LINE +.. |yen| unicode:: U+000A5 .. YEN SIGN diff --git a/docutils/parsers/rst/include/isopub.txt b/docutils/parsers/rst/include/isopub.txt new file mode 100644 index 000000000..bc5b6d491 --- /dev/null +++ b/docutils/parsers/rst/include/isopub.txt @@ -0,0 +1,90 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |blank| unicode:: U+02423 .. OPEN BOX +.. |blk12| unicode:: U+02592 .. MEDIUM SHADE +.. |blk14| unicode:: U+02591 .. LIGHT SHADE +.. |blk34| unicode:: U+02593 .. DARK SHADE +.. |block| unicode:: U+02588 .. FULL BLOCK +.. |bull| unicode:: U+02022 .. BULLET +.. |caret| unicode:: U+02041 .. CARET INSERTION POINT +.. |check| unicode:: U+02713 .. CHECK MARK +.. |cir| unicode:: U+025CB .. WHITE CIRCLE +.. |clubs| unicode:: U+02663 .. BLACK CLUB SUIT +.. |copysr| unicode:: U+02117 .. SOUND RECORDING COPYRIGHT +.. |cross| unicode:: U+02717 .. BALLOT X +.. |Dagger| unicode:: U+02021 .. DOUBLE DAGGER +.. |dagger| unicode:: U+02020 .. DAGGER +.. |dash| unicode:: U+02010 .. HYPHEN +.. |diams| unicode:: U+02666 .. BLACK DIAMOND SUIT +.. |dlcrop| unicode:: U+0230D .. BOTTOM LEFT CROP +.. |drcrop| unicode:: U+0230C .. BOTTOM RIGHT CROP +.. |dtri| unicode:: U+025BF .. WHITE DOWN-POINTING SMALL TRIANGLE +.. |dtrif| unicode:: U+025BE .. BLACK DOWN-POINTING SMALL TRIANGLE +.. |emsp| unicode:: U+02003 .. EM SPACE +.. |emsp13| unicode:: U+02004 .. THREE-PER-EM SPACE +.. |emsp14| unicode:: U+02005 .. FOUR-PER-EM SPACE +.. |ensp| unicode:: U+02002 .. EN SPACE +.. |female| unicode:: U+02640 .. FEMALE SIGN +.. |ffilig| unicode:: U+0FB03 .. LATIN SMALL LIGATURE FFI +.. |fflig| unicode:: U+0FB00 .. LATIN SMALL LIGATURE FF +.. |ffllig| unicode:: U+0FB04 .. LATIN SMALL LIGATURE FFL +.. |filig| unicode:: U+0FB01 .. LATIN SMALL LIGATURE FI +.. |flat| unicode:: U+0266D .. MUSIC FLAT SIGN +.. |fllig| unicode:: U+0FB02 .. LATIN SMALL LIGATURE FL +.. |frac13| unicode:: U+02153 .. VULGAR FRACTION ONE THIRD +.. |frac15| unicode:: U+02155 .. VULGAR FRACTION ONE FIFTH +.. |frac16| unicode:: U+02159 .. VULGAR FRACTION ONE SIXTH +.. |frac23| unicode:: U+02154 .. VULGAR FRACTION TWO THIRDS +.. |frac25| unicode:: U+02156 .. VULGAR FRACTION TWO FIFTHS +.. |frac35| unicode:: U+02157 .. VULGAR FRACTION THREE FIFTHS +.. |frac45| unicode:: U+02158 .. VULGAR FRACTION FOUR FIFTHS +.. |frac56| unicode:: U+0215A .. VULGAR FRACTION FIVE SIXTHS +.. |hairsp| unicode:: U+0200A .. HAIR SPACE +.. |hearts| unicode:: U+02665 .. BLACK HEART SUIT +.. |hellip| unicode:: U+02026 .. HORIZONTAL ELLIPSIS +.. |hybull| unicode:: U+02043 .. HYPHEN BULLET +.. |incare| unicode:: U+02105 .. CARE OF +.. |ldquor| unicode:: U+0201E .. DOUBLE LOW-9 QUOTATION MARK +.. |lhblk| unicode:: U+02584 .. LOWER HALF BLOCK +.. |loz| unicode:: U+025CA .. LOZENGE +.. |lozf| unicode:: U+029EB .. BLACK LOZENGE +.. |lsquor| unicode:: U+0201A .. SINGLE LOW-9 QUOTATION MARK +.. |ltri| unicode:: U+025C3 .. WHITE LEFT-POINTING SMALL TRIANGLE +.. |ltrif| unicode:: U+025C2 .. BLACK LEFT-POINTING SMALL TRIANGLE +.. |male| unicode:: U+02642 .. MALE SIGN +.. |malt| unicode:: U+02720 .. MALTESE CROSS +.. |marker| unicode:: U+025AE .. BLACK VERTICAL RECTANGLE +.. |mdash| unicode:: U+02014 .. EM DASH +.. |mldr| unicode:: U+02026 .. HORIZONTAL ELLIPSIS +.. |natur| unicode:: U+0266E .. MUSIC NATURAL SIGN +.. |ndash| unicode:: U+02013 .. EN DASH +.. |nldr| unicode:: U+02025 .. TWO DOT LEADER +.. |numsp| unicode:: U+02007 .. FIGURE SPACE +.. |phone| unicode:: U+0260E .. BLACK TELEPHONE +.. |puncsp| unicode:: U+02008 .. PUNCTUATION SPACE +.. |rdquor| unicode:: U+0201D .. RIGHT DOUBLE QUOTATION MARK +.. |rect| unicode:: U+025AD .. WHITE RECTANGLE +.. |rsquor| unicode:: U+02019 .. RIGHT SINGLE QUOTATION MARK +.. |rtri| unicode:: U+025B9 .. WHITE RIGHT-POINTING SMALL TRIANGLE +.. |rtrif| unicode:: U+025B8 .. BLACK RIGHT-POINTING SMALL TRIANGLE +.. |rx| unicode:: U+0211E .. PRESCRIPTION TAKE +.. |sext| unicode:: U+02736 .. SIX POINTED BLACK STAR +.. |sharp| unicode:: U+0266F .. MUSIC SHARP SIGN +.. |spades| unicode:: U+02660 .. BLACK SPADE SUIT +.. |squ| unicode:: U+025A1 .. WHITE SQUARE +.. |squf| unicode:: U+025AA .. BLACK SMALL SQUARE +.. |star| unicode:: U+02606 .. WHITE STAR +.. |starf| unicode:: U+02605 .. BLACK STAR +.. |target| unicode:: U+02316 .. POSITION INDICATOR +.. |telrec| unicode:: U+02315 .. TELEPHONE RECORDER +.. |thinsp| unicode:: U+02009 .. THIN SPACE +.. |uhblk| unicode:: U+02580 .. UPPER HALF BLOCK +.. |ulcrop| unicode:: U+0230F .. TOP LEFT CROP +.. |urcrop| unicode:: U+0230E .. TOP RIGHT CROP +.. |utri| unicode:: U+025B5 .. WHITE UP-POINTING SMALL TRIANGLE +.. |utrif| unicode:: U+025B4 .. BLACK UP-POINTING SMALL TRIANGLE +.. |vellip| unicode:: U+022EE .. VERTICAL ELLIPSIS diff --git a/docutils/parsers/rst/include/isotech.txt b/docutils/parsers/rst/include/isotech.txt new file mode 100644 index 000000000..01f7e346f --- /dev/null +++ b/docutils/parsers/rst/include/isotech.txt @@ -0,0 +1,168 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |acd| unicode:: U+0223F .. SINE WAVE +.. |aleph| unicode:: U+02135 .. ALEF SYMBOL +.. |And| unicode:: U+02A53 .. DOUBLE LOGICAL AND +.. |and| unicode:: U+02227 .. LOGICAL AND +.. |andand| unicode:: U+02A55 .. TWO INTERSECTING LOGICAL AND +.. |andd| unicode:: U+02A5C .. LOGICAL AND WITH HORIZONTAL DASH +.. |andslope| unicode:: U+02A58 .. SLOPING LARGE AND +.. |andv| unicode:: U+02A5A .. LOGICAL AND WITH MIDDLE STEM +.. |ang90| unicode:: U+0221F .. RIGHT ANGLE +.. |angrt| unicode:: U+0221F .. RIGHT ANGLE +.. |angsph| unicode:: U+02222 .. SPHERICAL ANGLE +.. |angst| unicode:: U+0212B .. ANGSTROM SIGN +.. |ap| unicode:: U+02248 .. ALMOST EQUAL TO +.. |apacir| unicode:: U+02A6F .. ALMOST EQUAL TO WITH CIRCUMFLEX ACCENT +.. |awconint| unicode:: U+02233 .. ANTICLOCKWISE CONTOUR INTEGRAL +.. |awint| unicode:: U+02A11 .. ANTICLOCKWISE INTEGRATION +.. |becaus| unicode:: U+02235 .. BECAUSE +.. |bernou| unicode:: U+0212C .. SCRIPT CAPITAL B +.. |bne| unicode:: U+0003D U+020E5 .. EQUALS SIGN with reverse slash +.. |bnequiv| unicode:: U+02261 U+020E5 .. IDENTICAL TO with reverse slash +.. |bNot| unicode:: U+02AED .. REVERSED DOUBLE STROKE NOT SIGN +.. |bnot| unicode:: U+02310 .. REVERSED NOT SIGN +.. |bottom| unicode:: U+022A5 .. UP TACK +.. |cap| unicode:: U+02229 .. INTERSECTION +.. |Cconint| unicode:: U+02230 .. VOLUME INTEGRAL +.. |cirfnint| unicode:: U+02A10 .. CIRCULATION FUNCTION +.. |compfn| unicode:: U+02218 .. RING OPERATOR +.. |cong| unicode:: U+02245 .. APPROXIMATELY EQUAL TO +.. |Conint| unicode:: U+0222F .. SURFACE INTEGRAL +.. |conint| unicode:: U+0222E .. CONTOUR INTEGRAL +.. |ctdot| unicode:: U+022EF .. MIDLINE HORIZONTAL ELLIPSIS +.. |cup| unicode:: U+0222A .. UNION +.. |cwconint| unicode:: U+02232 .. CLOCKWISE CONTOUR INTEGRAL +.. |cwint| unicode:: U+02231 .. CLOCKWISE INTEGRAL +.. |cylcty| unicode:: U+0232D .. CYLINDRICITY +.. |disin| unicode:: U+022F2 .. ELEMENT OF WITH LONG HORIZONTAL STROKE +.. |Dot| unicode:: U+000A8 .. DIAERESIS +.. |DotDot| unicode:: U+020DC .. COMBINING FOUR DOTS ABOVE +.. |dsol| unicode:: U+029F6 .. SOLIDUS WITH OVERBAR +.. |dtdot| unicode:: U+022F1 .. DOWN RIGHT DIAGONAL ELLIPSIS +.. |dwangle| unicode:: U+029A6 .. OBLIQUE ANGLE OPENING UP +.. |elinters| unicode:: U+0FFFD .. REPLACEMENT CHARACTER +.. |epar| unicode:: U+022D5 .. EQUAL AND PARALLEL TO +.. |eparsl| unicode:: U+029E3 .. EQUALS SIGN AND SLANTED PARALLEL +.. |equiv| unicode:: U+02261 .. IDENTICAL TO +.. |eqvparsl| unicode:: U+029E5 .. IDENTICAL TO AND SLANTED PARALLEL +.. |exist| unicode:: U+02203 .. THERE EXISTS +.. |fltns| unicode:: U+025B1 .. WHITE PARALLELOGRAM +.. |fnof| unicode:: U+00192 .. LATIN SMALL LETTER F WITH HOOK +.. |forall| unicode:: U+02200 .. FOR ALL +.. |fpartint| unicode:: U+02A0D .. FINITE PART INTEGRAL +.. |ge| unicode:: U+02265 .. GREATER-THAN OR EQUAL TO +.. |hamilt| unicode:: U+0210B .. SCRIPT CAPITAL H +.. |iff| unicode:: U+021D4 .. LEFT RIGHT DOUBLE ARROW +.. |iinfin| unicode:: U+029DC .. INCOMPLETE INFINITY +.. |imped| unicode:: U+001B5 .. LATIN CAPITAL LETTER Z WITH STROKE +.. |infin| unicode:: U+0221E .. INFINITY +.. |infintie| unicode:: U+029DD .. TIE OVER INFINITY +.. |Int| unicode:: U+0222C .. DOUBLE INTEGRAL +.. |int| unicode:: U+0222B .. INTEGRAL +.. |intlarhk| unicode:: U+02A17 .. INTEGRAL WITH LEFTWARDS ARROW WITH HOOK +.. |isin| unicode:: U+02208 .. ELEMENT OF +.. |isindot| unicode:: U+022F5 .. ELEMENT OF WITH DOT ABOVE +.. |isinE| unicode:: U+022F9 .. ELEMENT OF WITH TWO HORIZONTAL STROKES +.. |isins| unicode:: U+022F4 .. SMALL ELEMENT OF WITH VERTICAL BAR AT END OF HORIZONTAL STROKE +.. |isinsv| unicode:: U+022F3 .. ELEMENT OF WITH VERTICAL BAR AT END OF HORIZONTAL STROKE +.. |isinv| unicode:: U+02208 .. ELEMENT OF +.. |lagran| unicode:: U+02112 .. SCRIPT CAPITAL L +.. |Lang| unicode:: U+0300A .. LEFT DOUBLE ANGLE BRACKET +.. |lang| unicode:: U+02329 .. LEFT-POINTING ANGLE BRACKET +.. |lArr| unicode:: U+021D0 .. LEFTWARDS DOUBLE ARROW +.. |lbbrk| unicode:: U+03014 .. LEFT TORTOISE SHELL BRACKET +.. |le| unicode:: U+02264 .. LESS-THAN OR EQUAL TO +.. |loang| unicode:: U+03018 .. LEFT WHITE TORTOISE SHELL BRACKET +.. |lobrk| unicode:: U+0301A .. LEFT WHITE SQUARE BRACKET +.. |lopar| unicode:: U+02985 .. LEFT WHITE PARENTHESIS +.. |lowast| unicode:: U+02217 .. ASTERISK OPERATOR +.. |minus| unicode:: U+02212 .. MINUS SIGN +.. |mnplus| unicode:: U+02213 .. MINUS-OR-PLUS SIGN +.. |nabla| unicode:: U+02207 .. NABLA +.. |ne| unicode:: U+02260 .. NOT EQUAL TO +.. |nedot| unicode:: U+02250 U+00338 .. APPROACHES THE LIMIT with slash +.. |nhpar| unicode:: U+02AF2 .. PARALLEL WITH HORIZONTAL STROKE +.. |ni| unicode:: U+0220B .. CONTAINS AS MEMBER +.. |nis| unicode:: U+022FC .. SMALL CONTAINS WITH VERTICAL BAR AT END OF HORIZONTAL STROKE +.. |nisd| unicode:: U+022FA .. CONTAINS WITH LONG HORIZONTAL STROKE +.. |niv| unicode:: U+0220B .. CONTAINS AS MEMBER +.. |Not| unicode:: U+02AEC .. DOUBLE STROKE NOT SIGN +.. |notin| unicode:: U+02209 .. NOT AN ELEMENT OF +.. |notindot| unicode:: U+022F5 U+00338 .. ELEMENT OF WITH DOT ABOVE with slash +.. |notinE| unicode:: U+022F9 U+00338 .. ELEMENT OF WITH TWO HORIZONTAL STROKES with slash +.. |notinva| unicode:: U+02209 .. NOT AN ELEMENT OF +.. |notinvb| unicode:: U+022F7 .. SMALL ELEMENT OF WITH OVERBAR +.. |notinvc| unicode:: U+022F6 .. ELEMENT OF WITH OVERBAR +.. |notni| unicode:: U+0220C .. DOES NOT CONTAIN AS MEMBER +.. |notniva| unicode:: U+0220C .. DOES NOT CONTAIN AS MEMBER +.. |notnivb| unicode:: U+022FE .. SMALL CONTAINS WITH OVERBAR +.. |notnivc| unicode:: U+022FD .. CONTAINS WITH OVERBAR +.. |nparsl| unicode:: U+02AFD U+020E5 .. DOUBLE SOLIDUS OPERATOR with reverse slash +.. |npart| unicode:: U+02202 U+00338 .. PARTIAL DIFFERENTIAL with slash +.. |npolint| unicode:: U+02A14 .. LINE INTEGRATION NOT INCLUDING THE POLE +.. |nvinfin| unicode:: U+029DE .. INFINITY NEGATED WITH VERTICAL BAR +.. |olcross| unicode:: U+029BB .. CIRCLE WITH SUPERIMPOSED X +.. |Or| unicode:: U+02A54 .. DOUBLE LOGICAL OR +.. |or| unicode:: U+02228 .. LOGICAL OR +.. |ord| unicode:: U+02A5D .. LOGICAL OR WITH HORIZONTAL DASH +.. |order| unicode:: U+02134 .. SCRIPT SMALL O +.. |oror| unicode:: U+02A56 .. TWO INTERSECTING LOGICAL OR +.. |orslope| unicode:: U+02A57 .. SLOPING LARGE OR +.. |orv| unicode:: U+02A5B .. LOGICAL OR WITH MIDDLE STEM +.. |par| unicode:: U+02225 .. PARALLEL TO +.. |parsl| unicode:: U+02AFD .. DOUBLE SOLIDUS OPERATOR +.. |part| unicode:: U+02202 .. PARTIAL DIFFERENTIAL +.. |permil| unicode:: U+02030 .. PER MILLE SIGN +.. |perp| unicode:: U+022A5 .. UP TACK +.. |pertenk| unicode:: U+02031 .. PER TEN THOUSAND SIGN +.. |phmmat| unicode:: U+02133 .. SCRIPT CAPITAL M +.. |pointint| unicode:: U+02A15 .. INTEGRAL AROUND A POINT OPERATOR +.. |Prime| unicode:: U+02033 .. DOUBLE PRIME +.. |prime| unicode:: U+02032 .. PRIME +.. |profalar| unicode:: U+0232E .. ALL AROUND-PROFILE +.. |profline| unicode:: U+02312 .. ARC +.. |profsurf| unicode:: U+02313 .. SEGMENT +.. |prop| unicode:: U+0221D .. PROPORTIONAL TO +.. |qint| unicode:: U+02A0C .. QUADRUPLE INTEGRAL OPERATOR +.. |qprime| unicode:: U+02057 .. QUADRUPLE PRIME +.. |quatint| unicode:: U+02A16 .. QUATERNION INTEGRAL OPERATOR +.. |radic| unicode:: U+0221A .. SQUARE ROOT +.. |Rang| unicode:: U+0300B .. RIGHT DOUBLE ANGLE BRACKET +.. |rang| unicode:: U+0232A .. RIGHT-POINTING ANGLE BRACKET +.. |rArr| unicode:: U+021D2 .. RIGHTWARDS DOUBLE ARROW +.. |rbbrk| unicode:: U+03015 .. RIGHT TORTOISE SHELL BRACKET +.. |roang| unicode:: U+03019 .. RIGHT WHITE TORTOISE SHELL BRACKET +.. |robrk| unicode:: U+0301B .. RIGHT WHITE SQUARE BRACKET +.. |ropar| unicode:: U+02986 .. RIGHT WHITE PARENTHESIS +.. |rppolint| unicode:: U+02A12 .. LINE INTEGRATION WITH RECTANGULAR PATH AROUND POLE +.. |scpolint| unicode:: U+02A13 .. LINE INTEGRATION WITH SEMICIRCULAR PATH AROUND POLE +.. |sim| unicode:: U+0223C .. TILDE OPERATOR +.. |simdot| unicode:: U+02A6A .. TILDE OPERATOR WITH DOT ABOVE +.. |sime| unicode:: U+02243 .. ASYMPTOTICALLY EQUAL TO +.. |smeparsl| unicode:: U+029E4 .. EQUALS SIGN AND SLANTED PARALLEL WITH TILDE ABOVE +.. |square| unicode:: U+025A1 .. WHITE SQUARE +.. |squarf| unicode:: U+025AA .. BLACK SMALL SQUARE +.. |strns| unicode:: U+000AF .. MACRON +.. |sub| unicode:: U+02282 .. SUBSET OF +.. |sube| unicode:: U+02286 .. SUBSET OF OR EQUAL TO +.. |sup| unicode:: U+02283 .. SUPERSET OF +.. |supe| unicode:: U+02287 .. SUPERSET OF OR EQUAL TO +.. |tdot| unicode:: U+020DB .. COMBINING THREE DOTS ABOVE +.. |there4| unicode:: U+02234 .. THEREFORE +.. |tint| unicode:: U+0222D .. TRIPLE INTEGRAL +.. |top| unicode:: U+022A4 .. DOWN TACK +.. |topbot| unicode:: U+02336 .. APL FUNCTIONAL SYMBOL I-BEAM +.. |topcir| unicode:: U+02AF1 .. DOWN TACK WITH CIRCLE BELOW +.. |tprime| unicode:: U+02034 .. TRIPLE PRIME +.. |utdot| unicode:: U+022F0 .. UP RIGHT DIAGONAL ELLIPSIS +.. |uwangle| unicode:: U+029A7 .. OBLIQUE ANGLE OPENING DOWN +.. |vangrt| unicode:: U+0299C .. RIGHT ANGLE VARIANT WITH SQUARE +.. |veeeq| unicode:: U+0225A .. EQUIANGULAR TO +.. |Verbar| unicode:: U+02016 .. DOUBLE VERTICAL LINE +.. |wedgeq| unicode:: U+02259 .. ESTIMATES +.. |xnis| unicode:: U+022FB .. CONTAINS WITH VERTICAL BAR AT END OF HORIZONTAL STROKE diff --git a/docutils/parsers/rst/include/mmlalias.txt b/docutils/parsers/rst/include/mmlalias.txt new file mode 100644 index 000000000..cabc54ac4 --- /dev/null +++ b/docutils/parsers/rst/include/mmlalias.txt @@ -0,0 +1,554 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |angle| unicode:: U+02220 .. ANGLE +.. |ApplyFunction| unicode:: U+02061 .. FUNCTION APPLICATION +.. |approx| unicode:: U+02248 .. ALMOST EQUAL TO +.. |approxeq| unicode:: U+0224A .. ALMOST EQUAL OR EQUAL TO +.. |Assign| unicode:: U+02254 .. COLON EQUALS +.. |backcong| unicode:: U+0224C .. ALL EQUAL TO +.. |backepsilon| unicode:: U+003F6 .. GREEK REVERSED LUNATE EPSILON SYMBOL +.. |backprime| unicode:: U+02035 .. REVERSED PRIME +.. |backsim| unicode:: U+0223D .. REVERSED TILDE +.. |backsimeq| unicode:: U+022CD .. REVERSED TILDE EQUALS +.. |Backslash| unicode:: U+02216 .. SET MINUS +.. |barwedge| unicode:: U+02305 .. PROJECTIVE +.. |Because| unicode:: U+02235 .. BECAUSE +.. |because| unicode:: U+02235 .. BECAUSE +.. |Bernoullis| unicode:: U+0212C .. SCRIPT CAPITAL B +.. |between| unicode:: U+0226C .. BETWEEN +.. |bigcap| unicode:: U+022C2 .. N-ARY INTERSECTION +.. |bigcirc| unicode:: U+025EF .. LARGE CIRCLE +.. |bigcup| unicode:: U+022C3 .. N-ARY UNION +.. |bigodot| unicode:: U+02A00 .. N-ARY CIRCLED DOT OPERATOR +.. |bigoplus| unicode:: U+02A01 .. N-ARY CIRCLED PLUS OPERATOR +.. |bigotimes| unicode:: U+02A02 .. N-ARY CIRCLED TIMES OPERATOR +.. |bigsqcup| unicode:: U+02A06 .. N-ARY SQUARE UNION OPERATOR +.. |bigstar| unicode:: U+02605 .. BLACK STAR +.. |bigtriangledown| unicode:: U+025BD .. WHITE DOWN-POINTING TRIANGLE +.. |bigtriangleup| unicode:: U+025B3 .. WHITE UP-POINTING TRIANGLE +.. |biguplus| unicode:: U+02A04 .. N-ARY UNION OPERATOR WITH PLUS +.. |bigvee| unicode:: U+022C1 .. N-ARY LOGICAL OR +.. |bigwedge| unicode:: U+022C0 .. N-ARY LOGICAL AND +.. |bkarow| unicode:: U+0290D .. RIGHTWARDS DOUBLE DASH ARROW +.. |blacklozenge| unicode:: U+029EB .. BLACK LOZENGE +.. |blacksquare| unicode:: U+025AA .. BLACK SMALL SQUARE +.. |blacktriangle| unicode:: U+025B4 .. BLACK UP-POINTING SMALL TRIANGLE +.. |blacktriangledown| unicode:: U+025BE .. BLACK DOWN-POINTING SMALL TRIANGLE +.. |blacktriangleleft| unicode:: U+025C2 .. BLACK LEFT-POINTING SMALL TRIANGLE +.. |blacktriangleright| unicode:: U+025B8 .. BLACK RIGHT-POINTING SMALL TRIANGLE +.. |bot| unicode:: U+022A5 .. UP TACK +.. |boxminus| unicode:: U+0229F .. SQUARED MINUS +.. |boxplus| unicode:: U+0229E .. SQUARED PLUS +.. |boxtimes| unicode:: U+022A0 .. SQUARED TIMES +.. |Breve| unicode:: U+002D8 .. BREVE +.. |bullet| unicode:: U+02022 .. BULLET +.. |Bumpeq| unicode:: U+0224E .. GEOMETRICALLY EQUIVALENT TO +.. |bumpeq| unicode:: U+0224F .. DIFFERENCE BETWEEN +.. |CapitalDifferentialD| unicode:: U+02145 .. DOUBLE-STRUCK ITALIC CAPITAL D +.. |Cayleys| unicode:: U+0212D .. BLACK-LETTER CAPITAL C +.. |Cedilla| unicode:: U+000B8 .. CEDILLA +.. |CenterDot| unicode:: U+000B7 .. MIDDLE DOT +.. |centerdot| unicode:: U+000B7 .. MIDDLE DOT +.. |checkmark| unicode:: U+02713 .. CHECK MARK +.. |circeq| unicode:: U+02257 .. RING EQUAL TO +.. |circlearrowleft| unicode:: U+021BA .. ANTICLOCKWISE OPEN CIRCLE ARROW +.. |circlearrowright| unicode:: U+021BB .. CLOCKWISE OPEN CIRCLE ARROW +.. |circledast| unicode:: U+0229B .. CIRCLED ASTERISK OPERATOR +.. |circledcirc| unicode:: U+0229A .. CIRCLED RING OPERATOR +.. |circleddash| unicode:: U+0229D .. CIRCLED DASH +.. |CircleDot| unicode:: U+02299 .. CIRCLED DOT OPERATOR +.. |circledR| unicode:: U+000AE .. REGISTERED SIGN +.. |circledS| unicode:: U+024C8 .. CIRCLED LATIN CAPITAL LETTER S +.. |CircleMinus| unicode:: U+02296 .. CIRCLED MINUS +.. |CirclePlus| unicode:: U+02295 .. CIRCLED PLUS +.. |CircleTimes| unicode:: U+02297 .. CIRCLED TIMES +.. |ClockwiseContourIntegral| unicode:: U+02232 .. CLOCKWISE CONTOUR INTEGRAL +.. |CloseCurlyDoubleQuote| unicode:: U+0201D .. RIGHT DOUBLE QUOTATION MARK +.. |CloseCurlyQuote| unicode:: U+02019 .. RIGHT SINGLE QUOTATION MARK +.. |clubsuit| unicode:: U+02663 .. BLACK CLUB SUIT +.. |coloneq| unicode:: U+02254 .. COLON EQUALS +.. |complement| unicode:: U+02201 .. COMPLEMENT +.. |complexes| unicode:: U+02102 .. DOUBLE-STRUCK CAPITAL C +.. |Congruent| unicode:: U+02261 .. IDENTICAL TO +.. |ContourIntegral| unicode:: U+0222E .. CONTOUR INTEGRAL +.. |Coproduct| unicode:: U+02210 .. N-ARY COPRODUCT +.. |CounterClockwiseContourIntegral| unicode:: U+02233 .. ANTICLOCKWISE CONTOUR INTEGRAL +.. |CupCap| unicode:: U+0224D .. EQUIVALENT TO +.. |curlyeqprec| unicode:: U+022DE .. EQUAL TO OR PRECEDES +.. |curlyeqsucc| unicode:: U+022DF .. EQUAL TO OR SUCCEEDS +.. |curlyvee| unicode:: U+022CE .. CURLY LOGICAL OR +.. |curlywedge| unicode:: U+022CF .. CURLY LOGICAL AND +.. |curvearrowleft| unicode:: U+021B6 .. ANTICLOCKWISE TOP SEMICIRCLE ARROW +.. |curvearrowright| unicode:: U+021B7 .. CLOCKWISE TOP SEMICIRCLE ARROW +.. |dbkarow| unicode:: U+0290F .. RIGHTWARDS TRIPLE DASH ARROW +.. |ddagger| unicode:: U+02021 .. DOUBLE DAGGER +.. |ddotseq| unicode:: U+02A77 .. EQUALS SIGN WITH TWO DOTS ABOVE AND TWO DOTS BELOW +.. |Del| unicode:: U+02207 .. NABLA +.. |DiacriticalAcute| unicode:: U+000B4 .. ACUTE ACCENT +.. |DiacriticalDot| unicode:: U+002D9 .. DOT ABOVE +.. |DiacriticalDoubleAcute| unicode:: U+002DD .. DOUBLE ACUTE ACCENT +.. |DiacriticalGrave| unicode:: U+00060 .. GRAVE ACCENT +.. |DiacriticalTilde| unicode:: U+002DC .. SMALL TILDE +.. |Diamond| unicode:: U+022C4 .. DIAMOND OPERATOR +.. |diamond| unicode:: U+022C4 .. DIAMOND OPERATOR +.. |diamondsuit| unicode:: U+02666 .. BLACK DIAMOND SUIT +.. |DifferentialD| unicode:: U+02146 .. DOUBLE-STRUCK ITALIC SMALL D +.. |digamma| unicode:: U+003DD .. GREEK SMALL LETTER DIGAMMA +.. |div| unicode:: U+000F7 .. DIVISION SIGN +.. |divideontimes| unicode:: U+022C7 .. DIVISION TIMES +.. |doteq| unicode:: U+02250 .. APPROACHES THE LIMIT +.. |doteqdot| unicode:: U+02251 .. GEOMETRICALLY EQUAL TO +.. |DotEqual| unicode:: U+02250 .. APPROACHES THE LIMIT +.. |dotminus| unicode:: U+02238 .. DOT MINUS +.. |dotplus| unicode:: U+02214 .. DOT PLUS +.. |dotsquare| unicode:: U+022A1 .. SQUARED DOT OPERATOR +.. |doublebarwedge| unicode:: U+02306 .. PERSPECTIVE +.. |DoubleContourIntegral| unicode:: U+0222F .. SURFACE INTEGRAL +.. |DoubleDot| unicode:: U+000A8 .. DIAERESIS +.. |DoubleDownArrow| unicode:: U+021D3 .. DOWNWARDS DOUBLE ARROW +.. |DoubleLeftArrow| unicode:: U+021D0 .. LEFTWARDS DOUBLE ARROW +.. |DoubleLeftRightArrow| unicode:: U+021D4 .. LEFT RIGHT DOUBLE ARROW +.. |DoubleLeftTee| unicode:: U+02AE4 .. VERTICAL BAR DOUBLE LEFT TURNSTILE +.. |DoubleLongLeftArrow| unicode:: U+027F8 .. LONG LEFTWARDS DOUBLE ARROW +.. |DoubleLongLeftRightArrow| unicode:: U+027FA .. LONG LEFT RIGHT DOUBLE ARROW +.. |DoubleLongRightArrow| unicode:: U+027F9 .. LONG RIGHTWARDS DOUBLE ARROW +.. |DoubleRightArrow| unicode:: U+021D2 .. RIGHTWARDS DOUBLE ARROW +.. |DoubleRightTee| unicode:: U+022A8 .. TRUE +.. |DoubleUpArrow| unicode:: U+021D1 .. UPWARDS DOUBLE ARROW +.. |DoubleUpDownArrow| unicode:: U+021D5 .. UP DOWN DOUBLE ARROW +.. |DoubleVerticalBar| unicode:: U+02225 .. PARALLEL TO +.. |DownArrow| unicode:: U+02193 .. DOWNWARDS ARROW +.. |Downarrow| unicode:: U+021D3 .. DOWNWARDS DOUBLE ARROW +.. |downarrow| unicode:: U+02193 .. DOWNWARDS ARROW +.. |DownArrowUpArrow| unicode:: U+021F5 .. DOWNWARDS ARROW LEFTWARDS OF UPWARDS ARROW +.. |downdownarrows| unicode:: U+021CA .. DOWNWARDS PAIRED ARROWS +.. |downharpoonleft| unicode:: U+021C3 .. DOWNWARDS HARPOON WITH BARB LEFTWARDS +.. |downharpoonright| unicode:: U+021C2 .. DOWNWARDS HARPOON WITH BARB RIGHTWARDS +.. |DownLeftVector| unicode:: U+021BD .. LEFTWARDS HARPOON WITH BARB DOWNWARDS +.. |DownRightVector| unicode:: U+021C1 .. RIGHTWARDS HARPOON WITH BARB DOWNWARDS +.. |DownTee| unicode:: U+022A4 .. DOWN TACK +.. |DownTeeArrow| unicode:: U+021A7 .. DOWNWARDS ARROW FROM BAR +.. |drbkarow| unicode:: U+02910 .. RIGHTWARDS TWO-HEADED TRIPLE DASH ARROW +.. |Element| unicode:: U+02208 .. ELEMENT OF +.. |emptyset| unicode:: U+02205 .. EMPTY SET +.. |eqcirc| unicode:: U+02256 .. RING IN EQUAL TO +.. |eqcolon| unicode:: U+02255 .. EQUALS COLON +.. |eqsim| unicode:: U+02242 .. MINUS TILDE +.. |eqslantgtr| unicode:: U+02A96 .. SLANTED EQUAL TO OR GREATER-THAN +.. |eqslantless| unicode:: U+02A95 .. SLANTED EQUAL TO OR LESS-THAN +.. |EqualTilde| unicode:: U+02242 .. MINUS TILDE +.. |Equilibrium| unicode:: U+021CC .. RIGHTWARDS HARPOON OVER LEFTWARDS HARPOON +.. |Exists| unicode:: U+02203 .. THERE EXISTS +.. |expectation| unicode:: U+02130 .. SCRIPT CAPITAL E +.. |ExponentialE| unicode:: U+02147 .. DOUBLE-STRUCK ITALIC SMALL E +.. |exponentiale| unicode:: U+02147 .. DOUBLE-STRUCK ITALIC SMALL E +.. |fallingdotseq| unicode:: U+02252 .. APPROXIMATELY EQUAL TO OR THE IMAGE OF +.. |ForAll| unicode:: U+02200 .. FOR ALL +.. |Fouriertrf| unicode:: U+02131 .. SCRIPT CAPITAL F +.. |geq| unicode:: U+02265 .. GREATER-THAN OR EQUAL TO +.. |geqq| unicode:: U+02267 .. GREATER-THAN OVER EQUAL TO +.. |geqslant| unicode:: U+02A7E .. GREATER-THAN OR SLANTED EQUAL TO +.. |gg| unicode:: U+0226B .. MUCH GREATER-THAN +.. |ggg| unicode:: U+022D9 .. VERY MUCH GREATER-THAN +.. |gnapprox| unicode:: U+02A8A .. GREATER-THAN AND NOT APPROXIMATE +.. |gneq| unicode:: U+02A88 .. GREATER-THAN AND SINGLE-LINE NOT EQUAL TO +.. |gneqq| unicode:: U+02269 .. GREATER-THAN BUT NOT EQUAL TO +.. |GreaterEqual| unicode:: U+02265 .. GREATER-THAN OR EQUAL TO +.. |GreaterEqualLess| unicode:: U+022DB .. GREATER-THAN EQUAL TO OR LESS-THAN +.. |GreaterFullEqual| unicode:: U+02267 .. GREATER-THAN OVER EQUAL TO +.. |GreaterLess| unicode:: U+02277 .. GREATER-THAN OR LESS-THAN +.. |GreaterSlantEqual| unicode:: U+02A7E .. GREATER-THAN OR SLANTED EQUAL TO +.. |GreaterTilde| unicode:: U+02273 .. GREATER-THAN OR EQUIVALENT TO +.. |gtrapprox| unicode:: U+02A86 .. GREATER-THAN OR APPROXIMATE +.. |gtrdot| unicode:: U+022D7 .. GREATER-THAN WITH DOT +.. |gtreqless| unicode:: U+022DB .. GREATER-THAN EQUAL TO OR LESS-THAN +.. |gtreqqless| unicode:: U+02A8C .. GREATER-THAN ABOVE DOUBLE-LINE EQUAL ABOVE LESS-THAN +.. |gtrless| unicode:: U+02277 .. GREATER-THAN OR LESS-THAN +.. |gtrsim| unicode:: U+02273 .. GREATER-THAN OR EQUIVALENT TO +.. |gvertneqq| unicode:: U+02269 U+0FE00 .. GREATER-THAN BUT NOT EQUAL TO - with vertical stroke +.. |Hacek| unicode:: U+002C7 .. CARON +.. |hbar| unicode:: U+0210F .. PLANCK CONSTANT OVER TWO PI +.. |heartsuit| unicode:: U+02665 .. BLACK HEART SUIT +.. |HilbertSpace| unicode:: U+0210B .. SCRIPT CAPITAL H +.. |hksearow| unicode:: U+02925 .. SOUTH EAST ARROW WITH HOOK +.. |hkswarow| unicode:: U+02926 .. SOUTH WEST ARROW WITH HOOK +.. |hookleftarrow| unicode:: U+021A9 .. LEFTWARDS ARROW WITH HOOK +.. |hookrightarrow| unicode:: U+021AA .. RIGHTWARDS ARROW WITH HOOK +.. |hslash| unicode:: U+0210F .. PLANCK CONSTANT OVER TWO PI +.. |HumpDownHump| unicode:: U+0224E .. GEOMETRICALLY EQUIVALENT TO +.. |HumpEqual| unicode:: U+0224F .. DIFFERENCE BETWEEN +.. |iiiint| unicode:: U+02A0C .. QUADRUPLE INTEGRAL OPERATOR +.. |iiint| unicode:: U+0222D .. TRIPLE INTEGRAL +.. |Im| unicode:: U+02111 .. BLACK-LETTER CAPITAL I +.. |ImaginaryI| unicode:: U+02148 .. DOUBLE-STRUCK ITALIC SMALL I +.. |imagline| unicode:: U+02110 .. SCRIPT CAPITAL I +.. |imagpart| unicode:: U+02111 .. BLACK-LETTER CAPITAL I +.. |Implies| unicode:: U+021D2 .. RIGHTWARDS DOUBLE ARROW +.. |in| unicode:: U+02208 .. ELEMENT OF +.. |integers| unicode:: U+02124 .. DOUBLE-STRUCK CAPITAL Z +.. |Integral| unicode:: U+0222B .. INTEGRAL +.. |intercal| unicode:: U+022BA .. INTERCALATE +.. |Intersection| unicode:: U+022C2 .. N-ARY INTERSECTION +.. |intprod| unicode:: U+02A3C .. INTERIOR PRODUCT +.. |InvisibleComma| unicode:: U+02063 .. INVISIBLE SEPARATOR +.. |InvisibleTimes| unicode:: U+02062 .. INVISIBLE TIMES +.. |langle| unicode:: U+02329 .. LEFT-POINTING ANGLE BRACKET +.. |Laplacetrf| unicode:: U+02112 .. SCRIPT CAPITAL L +.. |lbrace| unicode:: U+0007B .. LEFT CURLY BRACKET +.. |lbrack| unicode:: U+0005B .. LEFT SQUARE BRACKET +.. |LeftAngleBracket| unicode:: U+02329 .. LEFT-POINTING ANGLE BRACKET +.. |LeftArrow| unicode:: U+02190 .. LEFTWARDS ARROW +.. |Leftarrow| unicode:: U+021D0 .. LEFTWARDS DOUBLE ARROW +.. |leftarrow| unicode:: U+02190 .. LEFTWARDS ARROW +.. |LeftArrowBar| unicode:: U+021E4 .. LEFTWARDS ARROW TO BAR +.. |LeftArrowRightArrow| unicode:: U+021C6 .. LEFTWARDS ARROW OVER RIGHTWARDS ARROW +.. |leftarrowtail| unicode:: U+021A2 .. LEFTWARDS ARROW WITH TAIL +.. |LeftCeiling| unicode:: U+02308 .. LEFT CEILING +.. |LeftDoubleBracket| unicode:: U+0301A .. LEFT WHITE SQUARE BRACKET +.. |LeftDownVector| unicode:: U+021C3 .. DOWNWARDS HARPOON WITH BARB LEFTWARDS +.. |LeftFloor| unicode:: U+0230A .. LEFT FLOOR +.. |leftharpoondown| unicode:: U+021BD .. LEFTWARDS HARPOON WITH BARB DOWNWARDS +.. |leftharpoonup| unicode:: U+021BC .. LEFTWARDS HARPOON WITH BARB UPWARDS +.. |leftleftarrows| unicode:: U+021C7 .. LEFTWARDS PAIRED ARROWS +.. |LeftRightArrow| unicode:: U+02194 .. LEFT RIGHT ARROW +.. |Leftrightarrow| unicode:: U+021D4 .. LEFT RIGHT DOUBLE ARROW +.. |leftrightarrow| unicode:: U+02194 .. LEFT RIGHT ARROW +.. |leftrightarrows| unicode:: U+021C6 .. LEFTWARDS ARROW OVER RIGHTWARDS ARROW +.. |leftrightharpoons| unicode:: U+021CB .. LEFTWARDS HARPOON OVER RIGHTWARDS HARPOON +.. |leftrightsquigarrow| unicode:: U+021AD .. LEFT RIGHT WAVE ARROW +.. |LeftTee| unicode:: U+022A3 .. LEFT TACK +.. |LeftTeeArrow| unicode:: U+021A4 .. LEFTWARDS ARROW FROM BAR +.. |leftthreetimes| unicode:: U+022CB .. LEFT SEMIDIRECT PRODUCT +.. |LeftTriangle| unicode:: U+022B2 .. NORMAL SUBGROUP OF +.. |LeftTriangleEqual| unicode:: U+022B4 .. NORMAL SUBGROUP OF OR EQUAL TO +.. |LeftUpVector| unicode:: U+021BF .. UPWARDS HARPOON WITH BARB LEFTWARDS +.. |LeftVector| unicode:: U+021BC .. LEFTWARDS HARPOON WITH BARB UPWARDS +.. |leq| unicode:: U+02264 .. LESS-THAN OR EQUAL TO +.. |leqq| unicode:: U+02266 .. LESS-THAN OVER EQUAL TO +.. |leqslant| unicode:: U+02A7D .. LESS-THAN OR SLANTED EQUAL TO +.. |lessapprox| unicode:: U+02A85 .. LESS-THAN OR APPROXIMATE +.. |lessdot| unicode:: U+022D6 .. LESS-THAN WITH DOT +.. |lesseqgtr| unicode:: U+022DA .. LESS-THAN EQUAL TO OR GREATER-THAN +.. |lesseqqgtr| unicode:: U+02A8B .. LESS-THAN ABOVE DOUBLE-LINE EQUAL ABOVE GREATER-THAN +.. |LessEqualGreater| unicode:: U+022DA .. LESS-THAN EQUAL TO OR GREATER-THAN +.. |LessFullEqual| unicode:: U+02266 .. LESS-THAN OVER EQUAL TO +.. |LessGreater| unicode:: U+02276 .. LESS-THAN OR GREATER-THAN +.. |lessgtr| unicode:: U+02276 .. LESS-THAN OR GREATER-THAN +.. |lesssim| unicode:: U+02272 .. LESS-THAN OR EQUIVALENT TO +.. |LessSlantEqual| unicode:: U+02A7D .. LESS-THAN OR SLANTED EQUAL TO +.. |LessTilde| unicode:: U+02272 .. LESS-THAN OR EQUIVALENT TO +.. |ll| unicode:: U+0226A .. MUCH LESS-THAN +.. |llcorner| unicode:: U+0231E .. BOTTOM LEFT CORNER +.. |Lleftarrow| unicode:: U+021DA .. LEFTWARDS TRIPLE ARROW +.. |lmoustache| unicode:: U+023B0 .. UPPER LEFT OR LOWER RIGHT CURLY BRACKET SECTION +.. |lnapprox| unicode:: U+02A89 .. LESS-THAN AND NOT APPROXIMATE +.. |lneq| unicode:: U+02A87 .. LESS-THAN AND SINGLE-LINE NOT EQUAL TO +.. |lneqq| unicode:: U+02268 .. LESS-THAN BUT NOT EQUAL TO +.. |LongLeftArrow| unicode:: U+027F5 .. LONG LEFTWARDS ARROW +.. |Longleftarrow| unicode:: U+027F8 .. LONG LEFTWARDS DOUBLE ARROW +.. |longleftarrow| unicode:: U+027F5 .. LONG LEFTWARDS ARROW +.. |LongLeftRightArrow| unicode:: U+027F7 .. LONG LEFT RIGHT ARROW +.. |Longleftrightarrow| unicode:: U+027FA .. LONG LEFT RIGHT DOUBLE ARROW +.. |longleftrightarrow| unicode:: U+027F7 .. LONG LEFT RIGHT ARROW +.. |longmapsto| unicode:: U+027FC .. LONG RIGHTWARDS ARROW FROM BAR +.. |LongRightArrow| unicode:: U+027F6 .. LONG RIGHTWARDS ARROW +.. |Longrightarrow| unicode:: U+027F9 .. LONG RIGHTWARDS DOUBLE ARROW +.. |longrightarrow| unicode:: U+027F6 .. LONG RIGHTWARDS ARROW +.. |looparrowleft| unicode:: U+021AB .. LEFTWARDS ARROW WITH LOOP +.. |looparrowright| unicode:: U+021AC .. RIGHTWARDS ARROW WITH LOOP +.. |LowerLeftArrow| unicode:: U+02199 .. SOUTH WEST ARROW +.. |LowerRightArrow| unicode:: U+02198 .. SOUTH EAST ARROW +.. |lozenge| unicode:: U+025CA .. LOZENGE +.. |lrcorner| unicode:: U+0231F .. BOTTOM RIGHT CORNER +.. |Lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS +.. |lvertneqq| unicode:: U+02268 U+0FE00 .. LESS-THAN BUT NOT EQUAL TO - with vertical stroke +.. |maltese| unicode:: U+02720 .. MALTESE CROSS +.. |mapsto| unicode:: U+021A6 .. RIGHTWARDS ARROW FROM BAR +.. |measuredangle| unicode:: U+02221 .. MEASURED ANGLE +.. |Mellintrf| unicode:: U+02133 .. SCRIPT CAPITAL M +.. |MinusPlus| unicode:: U+02213 .. MINUS-OR-PLUS SIGN +.. |mp| unicode:: U+02213 .. MINUS-OR-PLUS SIGN +.. |multimap| unicode:: U+022B8 .. MULTIMAP +.. |napprox| unicode:: U+02249 .. NOT ALMOST EQUAL TO +.. |natural| unicode:: U+0266E .. MUSIC NATURAL SIGN +.. |naturals| unicode:: U+02115 .. DOUBLE-STRUCK CAPITAL N +.. |nearrow| unicode:: U+02197 .. NORTH EAST ARROW +.. |NegativeMediumSpace| unicode:: U+0200B .. ZERO WIDTH SPACE +.. |NegativeThickSpace| unicode:: U+0200B .. ZERO WIDTH SPACE +.. |NegativeThinSpace| unicode:: U+0200B .. ZERO WIDTH SPACE +.. |NegativeVeryThinSpace| unicode:: U+0200B .. ZERO WIDTH SPACE +.. |NestedGreaterGreater| unicode:: U+0226B .. MUCH GREATER-THAN +.. |NestedLessLess| unicode:: U+0226A .. MUCH LESS-THAN +.. |nexists| unicode:: U+02204 .. THERE DOES NOT EXIST +.. |ngeq| unicode:: U+02271 .. NEITHER GREATER-THAN NOR EQUAL TO +.. |ngeqq| unicode:: U+02267 U+00338 .. GREATER-THAN OVER EQUAL TO with slash +.. |ngeqslant| unicode:: U+02A7E U+00338 .. GREATER-THAN OR SLANTED EQUAL TO with slash +.. |ngtr| unicode:: U+0226F .. NOT GREATER-THAN +.. |nLeftarrow| unicode:: U+021CD .. LEFTWARDS DOUBLE ARROW WITH STROKE +.. |nleftarrow| unicode:: U+0219A .. LEFTWARDS ARROW WITH STROKE +.. |nLeftrightarrow| unicode:: U+021CE .. LEFT RIGHT DOUBLE ARROW WITH STROKE +.. |nleftrightarrow| unicode:: U+021AE .. LEFT RIGHT ARROW WITH STROKE +.. |nleq| unicode:: U+02270 .. NEITHER LESS-THAN NOR EQUAL TO +.. |nleqq| unicode:: U+02266 U+00338 .. LESS-THAN OVER EQUAL TO with slash +.. |nleqslant| unicode:: U+02A7D U+00338 .. LESS-THAN OR SLANTED EQUAL TO with slash +.. |nless| unicode:: U+0226E .. NOT LESS-THAN +.. |NonBreakingSpace| unicode:: U+000A0 .. NO-BREAK SPACE +.. |NotCongruent| unicode:: U+02262 .. NOT IDENTICAL TO +.. |NotDoubleVerticalBar| unicode:: U+02226 .. NOT PARALLEL TO +.. |NotElement| unicode:: U+02209 .. NOT AN ELEMENT OF +.. |NotEqual| unicode:: U+02260 .. NOT EQUAL TO +.. |NotEqualTilde| unicode:: U+02242 U+00338 .. MINUS TILDE with slash +.. |NotExists| unicode:: U+02204 .. THERE DOES NOT EXIST +.. |NotGreater| unicode:: U+0226F .. NOT GREATER-THAN +.. |NotGreaterEqual| unicode:: U+02271 .. NEITHER GREATER-THAN NOR EQUAL TO +.. |NotGreaterFullEqual| unicode:: U+02266 U+00338 .. LESS-THAN OVER EQUAL TO with slash +.. |NotGreaterGreater| unicode:: U+0226B U+00338 .. MUCH GREATER THAN with slash +.. |NotGreaterLess| unicode:: U+02279 .. NEITHER GREATER-THAN NOR LESS-THAN +.. |NotGreaterSlantEqual| unicode:: U+02A7E U+00338 .. GREATER-THAN OR SLANTED EQUAL TO with slash +.. |NotGreaterTilde| unicode:: U+02275 .. NEITHER GREATER-THAN NOR EQUIVALENT TO +.. |NotHumpDownHump| unicode:: U+0224E U+00338 .. GEOMETRICALLY EQUIVALENT TO with slash +.. |NotLeftTriangle| unicode:: U+022EA .. NOT NORMAL SUBGROUP OF +.. |NotLeftTriangleEqual| unicode:: U+022EC .. NOT NORMAL SUBGROUP OF OR EQUAL TO +.. |NotLess| unicode:: U+0226E .. NOT LESS-THAN +.. |NotLessEqual| unicode:: U+02270 .. NEITHER LESS-THAN NOR EQUAL TO +.. |NotLessGreater| unicode:: U+02278 .. NEITHER LESS-THAN NOR GREATER-THAN +.. |NotLessLess| unicode:: U+0226A U+00338 .. MUCH LESS THAN with slash +.. |NotLessSlantEqual| unicode:: U+02A7D U+00338 .. LESS-THAN OR SLANTED EQUAL TO with slash +.. |NotLessTilde| unicode:: U+02274 .. NEITHER LESS-THAN NOR EQUIVALENT TO +.. |NotPrecedes| unicode:: U+02280 .. DOES NOT PRECEDE +.. |NotPrecedesEqual| unicode:: U+02AAF U+00338 .. PRECEDES ABOVE SINGLE-LINE EQUALS SIGN with slash +.. |NotPrecedesSlantEqual| unicode:: U+022E0 .. DOES NOT PRECEDE OR EQUAL +.. |NotReverseElement| unicode:: U+0220C .. DOES NOT CONTAIN AS MEMBER +.. |NotRightTriangle| unicode:: U+022EB .. DOES NOT CONTAIN AS NORMAL SUBGROUP +.. |NotRightTriangleEqual| unicode:: U+022ED .. DOES NOT CONTAIN AS NORMAL SUBGROUP OR EQUAL +.. |NotSquareSubsetEqual| unicode:: U+022E2 .. NOT SQUARE IMAGE OF OR EQUAL TO +.. |NotSquareSupersetEqual| unicode:: U+022E3 .. NOT SQUARE ORIGINAL OF OR EQUAL TO +.. |NotSubset| unicode:: U+02282 U+020D2 .. SUBSET OF with vertical line +.. |NotSubsetEqual| unicode:: U+02288 .. NEITHER A SUBSET OF NOR EQUAL TO +.. |NotSucceeds| unicode:: U+02281 .. DOES NOT SUCCEED +.. |NotSucceedsEqual| unicode:: U+02AB0 U+00338 .. SUCCEEDS ABOVE SINGLE-LINE EQUALS SIGN with slash +.. |NotSucceedsSlantEqual| unicode:: U+022E1 .. DOES NOT SUCCEED OR EQUAL +.. |NotSuperset| unicode:: U+02283 U+020D2 .. SUPERSET OF with vertical line +.. |NotSupersetEqual| unicode:: U+02289 .. NEITHER A SUPERSET OF NOR EQUAL TO +.. |NotTilde| unicode:: U+02241 .. NOT TILDE +.. |NotTildeEqual| unicode:: U+02244 .. NOT ASYMPTOTICALLY EQUAL TO +.. |NotTildeFullEqual| unicode:: U+02247 .. NEITHER APPROXIMATELY NOR ACTUALLY EQUAL TO +.. |NotTildeTilde| unicode:: U+02249 .. NOT ALMOST EQUAL TO +.. |NotVerticalBar| unicode:: U+02224 .. DOES NOT DIVIDE +.. |nparallel| unicode:: U+02226 .. NOT PARALLEL TO +.. |nprec| unicode:: U+02280 .. DOES NOT PRECEDE +.. |npreceq| unicode:: U+02AAF U+00338 .. PRECEDES ABOVE SINGLE-LINE EQUALS SIGN with slash +.. |nRightarrow| unicode:: U+021CF .. RIGHTWARDS DOUBLE ARROW WITH STROKE +.. |nrightarrow| unicode:: U+0219B .. RIGHTWARDS ARROW WITH STROKE +.. |nshortmid| unicode:: U+02224 .. DOES NOT DIVIDE +.. |nshortparallel| unicode:: U+02226 .. NOT PARALLEL TO +.. |nsimeq| unicode:: U+02244 .. NOT ASYMPTOTICALLY EQUAL TO +.. |nsubset| unicode:: U+02282 U+020D2 .. SUBSET OF with vertical line +.. |nsubseteq| unicode:: U+02288 .. NEITHER A SUBSET OF NOR EQUAL TO +.. |nsubseteqq| unicode:: U+02AC5 U+00338 .. SUBSET OF ABOVE EQUALS SIGN with slash +.. |nsucc| unicode:: U+02281 .. DOES NOT SUCCEED +.. |nsucceq| unicode:: U+02AB0 U+00338 .. SUCCEEDS ABOVE SINGLE-LINE EQUALS SIGN with slash +.. |nsupset| unicode:: U+02283 U+020D2 .. SUPERSET OF with vertical line +.. |nsupseteq| unicode:: U+02289 .. NEITHER A SUPERSET OF NOR EQUAL TO +.. |nsupseteqq| unicode:: U+02AC6 U+00338 .. SUPERSET OF ABOVE EQUALS SIGN with slash +.. |ntriangleleft| unicode:: U+022EA .. NOT NORMAL SUBGROUP OF +.. |ntrianglelefteq| unicode:: U+022EC .. NOT NORMAL SUBGROUP OF OR EQUAL TO +.. |ntriangleright| unicode:: U+022EB .. DOES NOT CONTAIN AS NORMAL SUBGROUP +.. |ntrianglerighteq| unicode:: U+022ED .. DOES NOT CONTAIN AS NORMAL SUBGROUP OR EQUAL +.. |nwarrow| unicode:: U+02196 .. NORTH WEST ARROW +.. |oint| unicode:: U+0222E .. CONTOUR INTEGRAL +.. |OpenCurlyDoubleQuote| unicode:: U+0201C .. LEFT DOUBLE QUOTATION MARK +.. |OpenCurlyQuote| unicode:: U+02018 .. LEFT SINGLE QUOTATION MARK +.. |orderof| unicode:: U+02134 .. SCRIPT SMALL O +.. |parallel| unicode:: U+02225 .. PARALLEL TO +.. |PartialD| unicode:: U+02202 .. PARTIAL DIFFERENTIAL +.. |pitchfork| unicode:: U+022D4 .. PITCHFORK +.. |PlusMinus| unicode:: U+000B1 .. PLUS-MINUS SIGN +.. |pm| unicode:: U+000B1 .. PLUS-MINUS SIGN +.. |Poincareplane| unicode:: U+0210C .. BLACK-LETTER CAPITAL H +.. |prec| unicode:: U+0227A .. PRECEDES +.. |precapprox| unicode:: U+02AB7 .. PRECEDES ABOVE ALMOST EQUAL TO +.. |preccurlyeq| unicode:: U+0227C .. PRECEDES OR EQUAL TO +.. |Precedes| unicode:: U+0227A .. PRECEDES +.. |PrecedesEqual| unicode:: U+02AAF .. PRECEDES ABOVE SINGLE-LINE EQUALS SIGN +.. |PrecedesSlantEqual| unicode:: U+0227C .. PRECEDES OR EQUAL TO +.. |PrecedesTilde| unicode:: U+0227E .. PRECEDES OR EQUIVALENT TO +.. |preceq| unicode:: U+02AAF .. PRECEDES ABOVE SINGLE-LINE EQUALS SIGN +.. |precnapprox| unicode:: U+02AB9 .. PRECEDES ABOVE NOT ALMOST EQUAL TO +.. |precneqq| unicode:: U+02AB5 .. PRECEDES ABOVE NOT EQUAL TO +.. |precnsim| unicode:: U+022E8 .. PRECEDES BUT NOT EQUIVALENT TO +.. |precsim| unicode:: U+0227E .. PRECEDES OR EQUIVALENT TO +.. |primes| unicode:: U+02119 .. DOUBLE-STRUCK CAPITAL P +.. |Proportion| unicode:: U+02237 .. PROPORTION +.. |Proportional| unicode:: U+0221D .. PROPORTIONAL TO +.. |propto| unicode:: U+0221D .. PROPORTIONAL TO +.. |quaternions| unicode:: U+0210D .. DOUBLE-STRUCK CAPITAL H +.. |questeq| unicode:: U+0225F .. QUESTIONED EQUAL TO +.. |rangle| unicode:: U+0232A .. RIGHT-POINTING ANGLE BRACKET +.. |rationals| unicode:: U+0211A .. DOUBLE-STRUCK CAPITAL Q +.. |rbrace| unicode:: U+0007D .. RIGHT CURLY BRACKET +.. |rbrack| unicode:: U+0005D .. RIGHT SQUARE BRACKET +.. |Re| unicode:: U+0211C .. BLACK-LETTER CAPITAL R +.. |realine| unicode:: U+0211B .. SCRIPT CAPITAL R +.. |realpart| unicode:: U+0211C .. BLACK-LETTER CAPITAL R +.. |reals| unicode:: U+0211D .. DOUBLE-STRUCK CAPITAL R +.. |ReverseElement| unicode:: U+0220B .. CONTAINS AS MEMBER +.. |ReverseEquilibrium| unicode:: U+021CB .. LEFTWARDS HARPOON OVER RIGHTWARDS HARPOON +.. |ReverseUpEquilibrium| unicode:: U+0296F .. DOWNWARDS HARPOON WITH BARB LEFT BESIDE UPWARDS HARPOON WITH BARB RIGHT +.. |RightAngleBracket| unicode:: U+0232A .. RIGHT-POINTING ANGLE BRACKET +.. |RightArrow| unicode:: U+02192 .. RIGHTWARDS ARROW +.. |Rightarrow| unicode:: U+021D2 .. RIGHTWARDS DOUBLE ARROW +.. |rightarrow| unicode:: U+02192 .. RIGHTWARDS ARROW +.. |RightArrowBar| unicode:: U+021E5 .. RIGHTWARDS ARROW TO BAR +.. |RightArrowLeftArrow| unicode:: U+021C4 .. RIGHTWARDS ARROW OVER LEFTWARDS ARROW +.. |rightarrowtail| unicode:: U+021A3 .. RIGHTWARDS ARROW WITH TAIL +.. |RightCeiling| unicode:: U+02309 .. RIGHT CEILING +.. |RightDoubleBracket| unicode:: U+0301B .. RIGHT WHITE SQUARE BRACKET +.. |RightDownVector| unicode:: U+021C2 .. DOWNWARDS HARPOON WITH BARB RIGHTWARDS +.. |RightFloor| unicode:: U+0230B .. RIGHT FLOOR +.. |rightharpoondown| unicode:: U+021C1 .. RIGHTWARDS HARPOON WITH BARB DOWNWARDS +.. |rightharpoonup| unicode:: U+021C0 .. RIGHTWARDS HARPOON WITH BARB UPWARDS +.. |rightleftarrows| unicode:: U+021C4 .. RIGHTWARDS ARROW OVER LEFTWARDS ARROW +.. |rightleftharpoons| unicode:: U+021CC .. RIGHTWARDS HARPOON OVER LEFTWARDS HARPOON +.. |rightrightarrows| unicode:: U+021C9 .. RIGHTWARDS PAIRED ARROWS +.. |rightsquigarrow| unicode:: U+0219D .. RIGHTWARDS WAVE ARROW +.. |RightTee| unicode:: U+022A2 .. RIGHT TACK +.. |RightTeeArrow| unicode:: U+021A6 .. RIGHTWARDS ARROW FROM BAR +.. |rightthreetimes| unicode:: U+022CC .. RIGHT SEMIDIRECT PRODUCT +.. |RightTriangle| unicode:: U+022B3 .. CONTAINS AS NORMAL SUBGROUP +.. |RightTriangleEqual| unicode:: U+022B5 .. CONTAINS AS NORMAL SUBGROUP OR EQUAL TO +.. |RightUpVector| unicode:: U+021BE .. UPWARDS HARPOON WITH BARB RIGHTWARDS +.. |RightVector| unicode:: U+021C0 .. RIGHTWARDS HARPOON WITH BARB UPWARDS +.. |risingdotseq| unicode:: U+02253 .. IMAGE OF OR APPROXIMATELY EQUAL TO +.. |rmoustache| unicode:: U+023B1 .. UPPER RIGHT OR LOWER LEFT CURLY BRACKET SECTION +.. |Rrightarrow| unicode:: U+021DB .. RIGHTWARDS TRIPLE ARROW +.. |Rsh| unicode:: U+021B1 .. UPWARDS ARROW WITH TIP RIGHTWARDS +.. |searrow| unicode:: U+02198 .. SOUTH EAST ARROW +.. |setminus| unicode:: U+02216 .. SET MINUS +.. |ShortDownArrow| unicode:: U+02193 .. DOWNWARDS ARROW +.. |ShortLeftArrow| unicode:: U+02190 .. LEFTWARDS ARROW +.. |shortmid| unicode:: U+02223 .. DIVIDES +.. |shortparallel| unicode:: U+02225 .. PARALLEL TO +.. |ShortRightArrow| unicode:: U+02192 .. RIGHTWARDS ARROW +.. |ShortUpArrow| unicode:: U+02191 .. UPWARDS ARROW +.. |simeq| unicode:: U+02243 .. ASYMPTOTICALLY EQUAL TO +.. |SmallCircle| unicode:: U+02218 .. RING OPERATOR +.. |smallsetminus| unicode:: U+02216 .. SET MINUS +.. |spadesuit| unicode:: U+02660 .. BLACK SPADE SUIT +.. |Sqrt| unicode:: U+0221A .. SQUARE ROOT +.. |sqsubset| unicode:: U+0228F .. SQUARE IMAGE OF +.. |sqsubseteq| unicode:: U+02291 .. SQUARE IMAGE OF OR EQUAL TO +.. |sqsupset| unicode:: U+02290 .. SQUARE ORIGINAL OF +.. |sqsupseteq| unicode:: U+02292 .. SQUARE ORIGINAL OF OR EQUAL TO +.. |Square| unicode:: U+025A1 .. WHITE SQUARE +.. |SquareIntersection| unicode:: U+02293 .. SQUARE CAP +.. |SquareSubset| unicode:: U+0228F .. SQUARE IMAGE OF +.. |SquareSubsetEqual| unicode:: U+02291 .. SQUARE IMAGE OF OR EQUAL TO +.. |SquareSuperset| unicode:: U+02290 .. SQUARE ORIGINAL OF +.. |SquareSupersetEqual| unicode:: U+02292 .. SQUARE ORIGINAL OF OR EQUAL TO +.. |SquareUnion| unicode:: U+02294 .. SQUARE CUP +.. |Star| unicode:: U+022C6 .. STAR OPERATOR +.. |straightepsilon| unicode:: U+003F5 .. GREEK LUNATE EPSILON SYMBOL +.. |straightphi| unicode:: U+003D5 .. GREEK PHI SYMBOL +.. |Subset| unicode:: U+022D0 .. DOUBLE SUBSET +.. |subset| unicode:: U+02282 .. SUBSET OF +.. |subseteq| unicode:: U+02286 .. SUBSET OF OR EQUAL TO +.. |subseteqq| unicode:: U+02AC5 .. SUBSET OF ABOVE EQUALS SIGN +.. |SubsetEqual| unicode:: U+02286 .. SUBSET OF OR EQUAL TO +.. |subsetneq| unicode:: U+0228A .. SUBSET OF WITH NOT EQUAL TO +.. |subsetneqq| unicode:: U+02ACB .. SUBSET OF ABOVE NOT EQUAL TO +.. |succ| unicode:: U+0227B .. SUCCEEDS +.. |succapprox| unicode:: U+02AB8 .. SUCCEEDS ABOVE ALMOST EQUAL TO +.. |succcurlyeq| unicode:: U+0227D .. SUCCEEDS OR EQUAL TO +.. |Succeeds| unicode:: U+0227B .. SUCCEEDS +.. |SucceedsEqual| unicode:: U+02AB0 .. SUCCEEDS ABOVE SINGLE-LINE EQUALS SIGN +.. |SucceedsSlantEqual| unicode:: U+0227D .. SUCCEEDS OR EQUAL TO +.. |SucceedsTilde| unicode:: U+0227F .. SUCCEEDS OR EQUIVALENT TO +.. |succeq| unicode:: U+02AB0 .. SUCCEEDS ABOVE SINGLE-LINE EQUALS SIGN +.. |succnapprox| unicode:: U+02ABA .. SUCCEEDS ABOVE NOT ALMOST EQUAL TO +.. |succneqq| unicode:: U+02AB6 .. SUCCEEDS ABOVE NOT EQUAL TO +.. |succnsim| unicode:: U+022E9 .. SUCCEEDS BUT NOT EQUIVALENT TO +.. |succsim| unicode:: U+0227F .. SUCCEEDS OR EQUIVALENT TO +.. |SuchThat| unicode:: U+0220B .. CONTAINS AS MEMBER +.. |Sum| unicode:: U+02211 .. N-ARY SUMMATION +.. |Superset| unicode:: U+02283 .. SUPERSET OF +.. |SupersetEqual| unicode:: U+02287 .. SUPERSET OF OR EQUAL TO +.. |Supset| unicode:: U+022D1 .. DOUBLE SUPERSET +.. |supset| unicode:: U+02283 .. SUPERSET OF +.. |supseteq| unicode:: U+02287 .. SUPERSET OF OR EQUAL TO +.. |supseteqq| unicode:: U+02AC6 .. SUPERSET OF ABOVE EQUALS SIGN +.. |supsetneq| unicode:: U+0228B .. SUPERSET OF WITH NOT EQUAL TO +.. |supsetneqq| unicode:: U+02ACC .. SUPERSET OF ABOVE NOT EQUAL TO +.. |swarrow| unicode:: U+02199 .. SOUTH WEST ARROW +.. |Therefore| unicode:: U+02234 .. THEREFORE +.. |therefore| unicode:: U+02234 .. THEREFORE +.. |thickapprox| unicode:: U+02248 .. ALMOST EQUAL TO +.. |thicksim| unicode:: U+0223C .. TILDE OPERATOR +.. |ThinSpace| unicode:: U+02009 .. THIN SPACE +.. |Tilde| unicode:: U+0223C .. TILDE OPERATOR +.. |TildeEqual| unicode:: U+02243 .. ASYMPTOTICALLY EQUAL TO +.. |TildeFullEqual| unicode:: U+02245 .. APPROXIMATELY EQUAL TO +.. |TildeTilde| unicode:: U+02248 .. ALMOST EQUAL TO +.. |toea| unicode:: U+02928 .. NORTH EAST ARROW AND SOUTH EAST ARROW +.. |tosa| unicode:: U+02929 .. SOUTH EAST ARROW AND SOUTH WEST ARROW +.. |triangle| unicode:: U+025B5 .. WHITE UP-POINTING SMALL TRIANGLE +.. |triangledown| unicode:: U+025BF .. WHITE DOWN-POINTING SMALL TRIANGLE +.. |triangleleft| unicode:: U+025C3 .. WHITE LEFT-POINTING SMALL TRIANGLE +.. |trianglelefteq| unicode:: U+022B4 .. NORMAL SUBGROUP OF OR EQUAL TO +.. |triangleq| unicode:: U+0225C .. DELTA EQUAL TO +.. |triangleright| unicode:: U+025B9 .. WHITE RIGHT-POINTING SMALL TRIANGLE +.. |trianglerighteq| unicode:: U+022B5 .. CONTAINS AS NORMAL SUBGROUP OR EQUAL TO +.. |TripleDot| unicode:: U+020DB .. COMBINING THREE DOTS ABOVE +.. |twoheadleftarrow| unicode:: U+0219E .. LEFTWARDS TWO HEADED ARROW +.. |twoheadrightarrow| unicode:: U+021A0 .. RIGHTWARDS TWO HEADED ARROW +.. |ulcorner| unicode:: U+0231C .. TOP LEFT CORNER +.. |Union| unicode:: U+022C3 .. N-ARY UNION +.. |UnionPlus| unicode:: U+0228E .. MULTISET UNION +.. |UpArrow| unicode:: U+02191 .. UPWARDS ARROW +.. |Uparrow| unicode:: U+021D1 .. UPWARDS DOUBLE ARROW +.. |uparrow| unicode:: U+02191 .. UPWARDS ARROW +.. |UpArrowDownArrow| unicode:: U+021C5 .. UPWARDS ARROW LEFTWARDS OF DOWNWARDS ARROW +.. |UpDownArrow| unicode:: U+02195 .. UP DOWN ARROW +.. |Updownarrow| unicode:: U+021D5 .. UP DOWN DOUBLE ARROW +.. |updownarrow| unicode:: U+02195 .. UP DOWN ARROW +.. |UpEquilibrium| unicode:: U+0296E .. UPWARDS HARPOON WITH BARB LEFT BESIDE DOWNWARDS HARPOON WITH BARB RIGHT +.. |upharpoonleft| unicode:: U+021BF .. UPWARDS HARPOON WITH BARB LEFTWARDS +.. |upharpoonright| unicode:: U+021BE .. UPWARDS HARPOON WITH BARB RIGHTWARDS +.. |UpperLeftArrow| unicode:: U+02196 .. NORTH WEST ARROW +.. |UpperRightArrow| unicode:: U+02197 .. NORTH EAST ARROW +.. |upsilon| unicode:: U+003C5 .. GREEK SMALL LETTER UPSILON +.. |UpTee| unicode:: U+022A5 .. UP TACK +.. |UpTeeArrow| unicode:: U+021A5 .. UPWARDS ARROW FROM BAR +.. |upuparrows| unicode:: U+021C8 .. UPWARDS PAIRED ARROWS +.. |urcorner| unicode:: U+0231D .. TOP RIGHT CORNER +.. |varepsilon| unicode:: U+003B5 .. GREEK SMALL LETTER EPSILON +.. |varkappa| unicode:: U+003F0 .. GREEK KAPPA SYMBOL +.. |varnothing| unicode:: U+02205 .. EMPTY SET +.. |varphi| unicode:: U+003C6 .. GREEK SMALL LETTER PHI +.. |varpi| unicode:: U+003D6 .. GREEK PI SYMBOL +.. |varpropto| unicode:: U+0221D .. PROPORTIONAL TO +.. |varrho| unicode:: U+003F1 .. GREEK RHO SYMBOL +.. |varsigma| unicode:: U+003C2 .. GREEK SMALL LETTER FINAL SIGMA +.. |varsubsetneq| unicode:: U+0228A U+0FE00 .. SUBSET OF WITH NOT EQUAL TO - variant with stroke through bottom members +.. |varsubsetneqq| unicode:: U+02ACB U+0FE00 .. SUBSET OF ABOVE NOT EQUAL TO - variant with stroke through bottom members +.. |varsupsetneq| unicode:: U+0228B U+0FE00 .. SUPERSET OF WITH NOT EQUAL TO - variant with stroke through bottom members +.. |varsupsetneqq| unicode:: U+02ACC U+0FE00 .. SUPERSET OF ABOVE NOT EQUAL TO - variant with stroke through bottom members +.. |vartheta| unicode:: U+003D1 .. GREEK THETA SYMBOL +.. |vartriangleleft| unicode:: U+022B2 .. NORMAL SUBGROUP OF +.. |vartriangleright| unicode:: U+022B3 .. CONTAINS AS NORMAL SUBGROUP +.. |Vee| unicode:: U+022C1 .. N-ARY LOGICAL OR +.. |vee| unicode:: U+02228 .. LOGICAL OR +.. |Vert| unicode:: U+02016 .. DOUBLE VERTICAL LINE +.. |vert| unicode:: U+0007C .. VERTICAL LINE +.. |VerticalBar| unicode:: U+02223 .. DIVIDES +.. |VerticalTilde| unicode:: U+02240 .. WREATH PRODUCT +.. |VeryThinSpace| unicode:: U+0200A .. HAIR SPACE +.. |Wedge| unicode:: U+022C0 .. N-ARY LOGICAL AND +.. |wedge| unicode:: U+02227 .. LOGICAL AND +.. |wp| unicode:: U+02118 .. SCRIPT CAPITAL P +.. |wr| unicode:: U+02240 .. WREATH PRODUCT +.. |zeetrf| unicode:: U+02128 .. BLACK-LETTER CAPITAL Z diff --git a/docutils/parsers/rst/include/mmlextra-wide.txt b/docutils/parsers/rst/include/mmlextra-wide.txt new file mode 100644 index 000000000..0177ccc09 --- /dev/null +++ b/docutils/parsers/rst/include/mmlextra-wide.txt @@ -0,0 +1,113 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |af| unicode:: U+02061 .. FUNCTION APPLICATION +.. |aopf| unicode:: U+1D552 .. MATHEMATICAL DOUBLE-STRUCK SMALL A +.. |asympeq| unicode:: U+0224D .. EQUIVALENT TO +.. |bopf| unicode:: U+1D553 .. MATHEMATICAL DOUBLE-STRUCK SMALL B +.. |copf| unicode:: U+1D554 .. MATHEMATICAL DOUBLE-STRUCK SMALL C +.. |Cross| unicode:: U+02A2F .. VECTOR OR CROSS PRODUCT +.. |DD| unicode:: U+02145 .. DOUBLE-STRUCK ITALIC CAPITAL D +.. |dd| unicode:: U+02146 .. DOUBLE-STRUCK ITALIC SMALL D +.. |dopf| unicode:: U+1D555 .. MATHEMATICAL DOUBLE-STRUCK SMALL D +.. |DownArrowBar| unicode:: U+02913 .. DOWNWARDS ARROW TO BAR +.. |DownBreve| unicode:: U+00311 .. COMBINING INVERTED BREVE +.. |DownLeftRightVector| unicode:: U+02950 .. LEFT BARB DOWN RIGHT BARB DOWN HARPOON +.. |DownLeftTeeVector| unicode:: U+0295E .. LEFTWARDS HARPOON WITH BARB DOWN FROM BAR +.. |DownLeftVectorBar| unicode:: U+02956 .. LEFTWARDS HARPOON WITH BARB DOWN TO BAR +.. |DownRightTeeVector| unicode:: U+0295F .. RIGHTWARDS HARPOON WITH BARB DOWN FROM BAR +.. |DownRightVectorBar| unicode:: U+02957 .. RIGHTWARDS HARPOON WITH BARB DOWN TO BAR +.. |ee| unicode:: U+02147 .. DOUBLE-STRUCK ITALIC SMALL E +.. |EmptySmallSquare| unicode:: U+025FB .. WHITE MEDIUM SQUARE +.. |EmptyVerySmallSquare| unicode:: U+025AB .. WHITE SMALL SQUARE +.. |eopf| unicode:: U+1D556 .. MATHEMATICAL DOUBLE-STRUCK SMALL E +.. |Equal| unicode:: U+02A75 .. TWO CONSECUTIVE EQUALS SIGNS +.. |FilledSmallSquare| unicode:: U+025FC .. BLACK MEDIUM SQUARE +.. |FilledVerySmallSquare| unicode:: U+025AA .. BLACK SMALL SQUARE +.. |fopf| unicode:: U+1D557 .. MATHEMATICAL DOUBLE-STRUCK SMALL F +.. |gopf| unicode:: U+1D558 .. MATHEMATICAL DOUBLE-STRUCK SMALL G +.. |GreaterGreater| unicode:: U+02AA2 .. DOUBLE NESTED GREATER-THAN +.. |Hat| unicode:: U+0005E .. CIRCUMFLEX ACCENT +.. |hopf| unicode:: U+1D559 .. MATHEMATICAL DOUBLE-STRUCK SMALL H +.. |HorizontalLine| unicode:: U+02500 .. BOX DRAWINGS LIGHT HORIZONTAL +.. |ic| unicode:: U+02063 .. INVISIBLE SEPARATOR +.. |ii| unicode:: U+02148 .. DOUBLE-STRUCK ITALIC SMALL I +.. |iopf| unicode:: U+1D55A .. MATHEMATICAL DOUBLE-STRUCK SMALL I +.. |it| unicode:: U+02062 .. INVISIBLE TIMES +.. |jopf| unicode:: U+1D55B .. MATHEMATICAL DOUBLE-STRUCK SMALL J +.. |kopf| unicode:: U+1D55C .. MATHEMATICAL DOUBLE-STRUCK SMALL K +.. |larrb| unicode:: U+021E4 .. LEFTWARDS ARROW TO BAR +.. |LeftDownTeeVector| unicode:: U+02961 .. DOWNWARDS HARPOON WITH BARB LEFT FROM BAR +.. |LeftDownVectorBar| unicode:: U+02959 .. DOWNWARDS HARPOON WITH BARB LEFT TO BAR +.. |LeftRightVector| unicode:: U+0294E .. LEFT BARB UP RIGHT BARB UP HARPOON +.. |LeftTeeVector| unicode:: U+0295A .. LEFTWARDS HARPOON WITH BARB UP FROM BAR +.. |LeftTriangleBar| unicode:: U+029CF .. LEFT TRIANGLE BESIDE VERTICAL BAR +.. |LeftUpDownVector| unicode:: U+02951 .. UP BARB LEFT DOWN BARB LEFT HARPOON +.. |LeftUpTeeVector| unicode:: U+02960 .. UPWARDS HARPOON WITH BARB LEFT FROM BAR +.. |LeftUpVectorBar| unicode:: U+02958 .. UPWARDS HARPOON WITH BARB LEFT TO BAR +.. |LeftVectorBar| unicode:: U+02952 .. LEFTWARDS HARPOON WITH BARB UP TO BAR +.. |LessLess| unicode:: U+02AA1 .. DOUBLE NESTED LESS-THAN +.. |lopf| unicode:: U+1D55D .. MATHEMATICAL DOUBLE-STRUCK SMALL L +.. |mapstodown| unicode:: U+021A7 .. DOWNWARDS ARROW FROM BAR +.. |mapstoleft| unicode:: U+021A4 .. LEFTWARDS ARROW FROM BAR +.. |mapstoup| unicode:: U+021A5 .. UPWARDS ARROW FROM BAR +.. |MediumSpace| unicode:: U+0205F .. MEDIUM MATHEMATICAL SPACE +.. |mopf| unicode:: U+1D55E .. MATHEMATICAL DOUBLE-STRUCK SMALL M +.. |nbump| unicode:: U+0224E U+00338 .. GEOMETRICALLY EQUIVALENT TO with slash +.. |nbumpe| unicode:: U+0224F U+00338 .. DIFFERENCE BETWEEN with slash +.. |nesim| unicode:: U+02242 U+00338 .. MINUS TILDE with slash +.. |NewLine| unicode:: U+0000A .. LINE FEED (LF) +.. |NoBreak| unicode:: U+02060 .. WORD JOINER +.. |nopf| unicode:: U+1D55F .. MATHEMATICAL DOUBLE-STRUCK SMALL N +.. |NotCupCap| unicode:: U+0226D .. NOT EQUIVALENT TO +.. |NotHumpEqual| unicode:: U+0224F U+00338 .. DIFFERENCE BETWEEN with slash +.. |NotLeftTriangleBar| unicode:: U+029CF U+00338 .. LEFT TRIANGLE BESIDE VERTICAL BAR with slash +.. |NotNestedGreaterGreater| unicode:: U+02AA2 U+00338 .. DOUBLE NESTED GREATER-THAN with slash +.. |NotNestedLessLess| unicode:: U+02AA1 U+00338 .. DOUBLE NESTED LESS-THAN with slash +.. |NotRightTriangleBar| unicode:: U+029D0 U+00338 .. VERTICAL BAR BESIDE RIGHT TRIANGLE with slash +.. |NotSquareSubset| unicode:: U+0228F U+00338 .. SQUARE IMAGE OF with slash +.. |NotSquareSuperset| unicode:: U+02290 U+00338 .. SQUARE ORIGINAL OF with slash +.. |NotSucceedsTilde| unicode:: U+0227F U+00338 .. SUCCEEDS OR EQUIVALENT TO with slash +.. |oopf| unicode:: U+1D560 .. MATHEMATICAL DOUBLE-STRUCK SMALL O +.. |OverBar| unicode:: U+000AF .. MACRON +.. |OverBrace| unicode:: U+0FE37 .. PRESENTATION FORM FOR VERTICAL LEFT CURLY BRACKET +.. |OverBracket| unicode:: U+023B4 .. TOP SQUARE BRACKET +.. |OverParenthesis| unicode:: U+0FE35 .. PRESENTATION FORM FOR VERTICAL LEFT PARENTHESIS +.. |planckh| unicode:: U+0210E .. PLANCK CONSTANT +.. |popf| unicode:: U+1D561 .. MATHEMATICAL DOUBLE-STRUCK SMALL P +.. |Product| unicode:: U+0220F .. N-ARY PRODUCT +.. |qopf| unicode:: U+1D562 .. MATHEMATICAL DOUBLE-STRUCK SMALL Q +.. |rarrb| unicode:: U+021E5 .. RIGHTWARDS ARROW TO BAR +.. |RightDownTeeVector| unicode:: U+0295D .. DOWNWARDS HARPOON WITH BARB RIGHT FROM BAR +.. |RightDownVectorBar| unicode:: U+02955 .. DOWNWARDS HARPOON WITH BARB RIGHT TO BAR +.. |RightTeeVector| unicode:: U+0295B .. RIGHTWARDS HARPOON WITH BARB UP FROM BAR +.. |RightTriangleBar| unicode:: U+029D0 .. VERTICAL BAR BESIDE RIGHT TRIANGLE +.. |RightUpDownVector| unicode:: U+0294F .. UP BARB RIGHT DOWN BARB RIGHT HARPOON +.. |RightUpTeeVector| unicode:: U+0295C .. UPWARDS HARPOON WITH BARB RIGHT FROM BAR +.. |RightUpVectorBar| unicode:: U+02954 .. UPWARDS HARPOON WITH BARB RIGHT TO BAR +.. |RightVectorBar| unicode:: U+02953 .. RIGHTWARDS HARPOON WITH BARB UP TO BAR +.. |ropf| unicode:: U+1D563 .. MATHEMATICAL DOUBLE-STRUCK SMALL R +.. |RoundImplies| unicode:: U+02970 .. RIGHT DOUBLE ARROW WITH ROUNDED HEAD +.. |RuleDelayed| unicode:: U+029F4 .. RULE-DELAYED +.. |sopf| unicode:: U+1D564 .. MATHEMATICAL DOUBLE-STRUCK SMALL S +.. |Tab| unicode:: U+00009 .. CHARACTER TABULATION +.. |ThickSpace| unicode:: U+02009 U+0200A U+0200A .. space of width 5/18 em +.. |topf| unicode:: U+1D565 .. MATHEMATICAL DOUBLE-STRUCK SMALL T +.. |UnderBar| unicode:: U+00332 .. COMBINING LOW LINE +.. |UnderBrace| unicode:: U+0FE38 .. PRESENTATION FORM FOR VERTICAL RIGHT CURLY BRACKET +.. |UnderBracket| unicode:: U+023B5 .. BOTTOM SQUARE BRACKET +.. |UnderParenthesis| unicode:: U+0FE36 .. PRESENTATION FORM FOR VERTICAL RIGHT PARENTHESIS +.. |uopf| unicode:: U+1D566 .. MATHEMATICAL DOUBLE-STRUCK SMALL U +.. |UpArrowBar| unicode:: U+02912 .. UPWARDS ARROW TO BAR +.. |Upsilon| unicode:: U+003A5 .. GREEK CAPITAL LETTER UPSILON +.. |VerticalLine| unicode:: U+0007C .. VERTICAL LINE +.. |VerticalSeparator| unicode:: U+02758 .. LIGHT VERTICAL BAR +.. |vopf| unicode:: U+1D567 .. MATHEMATICAL DOUBLE-STRUCK SMALL V +.. |wopf| unicode:: U+1D568 .. MATHEMATICAL DOUBLE-STRUCK SMALL W +.. |xopf| unicode:: U+1D569 .. MATHEMATICAL DOUBLE-STRUCK SMALL X +.. |yopf| unicode:: U+1D56A .. MATHEMATICAL DOUBLE-STRUCK SMALL Y +.. |ZeroWidthSpace| unicode:: U+0200B .. ZERO WIDTH SPACE +.. |zopf| unicode:: U+1D56B .. MATHEMATICAL DOUBLE-STRUCK SMALL Z diff --git a/docutils/parsers/rst/include/mmlextra.txt b/docutils/parsers/rst/include/mmlextra.txt new file mode 100644 index 000000000..790a9775a --- /dev/null +++ b/docutils/parsers/rst/include/mmlextra.txt @@ -0,0 +1,87 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |af| unicode:: U+02061 .. FUNCTION APPLICATION +.. |asympeq| unicode:: U+0224D .. EQUIVALENT TO +.. |Cross| unicode:: U+02A2F .. VECTOR OR CROSS PRODUCT +.. |DD| unicode:: U+02145 .. DOUBLE-STRUCK ITALIC CAPITAL D +.. |dd| unicode:: U+02146 .. DOUBLE-STRUCK ITALIC SMALL D +.. |DownArrowBar| unicode:: U+02913 .. DOWNWARDS ARROW TO BAR +.. |DownBreve| unicode:: U+00311 .. COMBINING INVERTED BREVE +.. |DownLeftRightVector| unicode:: U+02950 .. LEFT BARB DOWN RIGHT BARB DOWN HARPOON +.. |DownLeftTeeVector| unicode:: U+0295E .. LEFTWARDS HARPOON WITH BARB DOWN FROM BAR +.. |DownLeftVectorBar| unicode:: U+02956 .. LEFTWARDS HARPOON WITH BARB DOWN TO BAR +.. |DownRightTeeVector| unicode:: U+0295F .. RIGHTWARDS HARPOON WITH BARB DOWN FROM BAR +.. |DownRightVectorBar| unicode:: U+02957 .. RIGHTWARDS HARPOON WITH BARB DOWN TO BAR +.. |ee| unicode:: U+02147 .. DOUBLE-STRUCK ITALIC SMALL E +.. |EmptySmallSquare| unicode:: U+025FB .. WHITE MEDIUM SQUARE +.. |EmptyVerySmallSquare| unicode:: U+025AB .. WHITE SMALL SQUARE +.. |Equal| unicode:: U+02A75 .. TWO CONSECUTIVE EQUALS SIGNS +.. |FilledSmallSquare| unicode:: U+025FC .. BLACK MEDIUM SQUARE +.. |FilledVerySmallSquare| unicode:: U+025AA .. BLACK SMALL SQUARE +.. |GreaterGreater| unicode:: U+02AA2 .. DOUBLE NESTED GREATER-THAN +.. |Hat| unicode:: U+0005E .. CIRCUMFLEX ACCENT +.. |HorizontalLine| unicode:: U+02500 .. BOX DRAWINGS LIGHT HORIZONTAL +.. |ic| unicode:: U+02063 .. INVISIBLE SEPARATOR +.. |ii| unicode:: U+02148 .. DOUBLE-STRUCK ITALIC SMALL I +.. |it| unicode:: U+02062 .. INVISIBLE TIMES +.. |larrb| unicode:: U+021E4 .. LEFTWARDS ARROW TO BAR +.. |LeftDownTeeVector| unicode:: U+02961 .. DOWNWARDS HARPOON WITH BARB LEFT FROM BAR +.. |LeftDownVectorBar| unicode:: U+02959 .. DOWNWARDS HARPOON WITH BARB LEFT TO BAR +.. |LeftRightVector| unicode:: U+0294E .. LEFT BARB UP RIGHT BARB UP HARPOON +.. |LeftTeeVector| unicode:: U+0295A .. LEFTWARDS HARPOON WITH BARB UP FROM BAR +.. |LeftTriangleBar| unicode:: U+029CF .. LEFT TRIANGLE BESIDE VERTICAL BAR +.. |LeftUpDownVector| unicode:: U+02951 .. UP BARB LEFT DOWN BARB LEFT HARPOON +.. |LeftUpTeeVector| unicode:: U+02960 .. UPWARDS HARPOON WITH BARB LEFT FROM BAR +.. |LeftUpVectorBar| unicode:: U+02958 .. UPWARDS HARPOON WITH BARB LEFT TO BAR +.. |LeftVectorBar| unicode:: U+02952 .. LEFTWARDS HARPOON WITH BARB UP TO BAR +.. |LessLess| unicode:: U+02AA1 .. DOUBLE NESTED LESS-THAN +.. |mapstodown| unicode:: U+021A7 .. DOWNWARDS ARROW FROM BAR +.. |mapstoleft| unicode:: U+021A4 .. LEFTWARDS ARROW FROM BAR +.. |mapstoup| unicode:: U+021A5 .. UPWARDS ARROW FROM BAR +.. |MediumSpace| unicode:: U+0205F .. MEDIUM MATHEMATICAL SPACE +.. |nbump| unicode:: U+0224E U+00338 .. GEOMETRICALLY EQUIVALENT TO with slash +.. |nbumpe| unicode:: U+0224F U+00338 .. DIFFERENCE BETWEEN with slash +.. |nesim| unicode:: U+02242 U+00338 .. MINUS TILDE with slash +.. |NewLine| unicode:: U+0000A .. LINE FEED (LF) +.. |NoBreak| unicode:: U+02060 .. WORD JOINER +.. |NotCupCap| unicode:: U+0226D .. NOT EQUIVALENT TO +.. |NotHumpEqual| unicode:: U+0224F U+00338 .. DIFFERENCE BETWEEN with slash +.. |NotLeftTriangleBar| unicode:: U+029CF U+00338 .. LEFT TRIANGLE BESIDE VERTICAL BAR with slash +.. |NotNestedGreaterGreater| unicode:: U+02AA2 U+00338 .. DOUBLE NESTED GREATER-THAN with slash +.. |NotNestedLessLess| unicode:: U+02AA1 U+00338 .. DOUBLE NESTED LESS-THAN with slash +.. |NotRightTriangleBar| unicode:: U+029D0 U+00338 .. VERTICAL BAR BESIDE RIGHT TRIANGLE with slash +.. |NotSquareSubset| unicode:: U+0228F U+00338 .. SQUARE IMAGE OF with slash +.. |NotSquareSuperset| unicode:: U+02290 U+00338 .. SQUARE ORIGINAL OF with slash +.. |NotSucceedsTilde| unicode:: U+0227F U+00338 .. SUCCEEDS OR EQUIVALENT TO with slash +.. |OverBar| unicode:: U+000AF .. MACRON +.. |OverBrace| unicode:: U+0FE37 .. PRESENTATION FORM FOR VERTICAL LEFT CURLY BRACKET +.. |OverBracket| unicode:: U+023B4 .. TOP SQUARE BRACKET +.. |OverParenthesis| unicode:: U+0FE35 .. PRESENTATION FORM FOR VERTICAL LEFT PARENTHESIS +.. |planckh| unicode:: U+0210E .. PLANCK CONSTANT +.. |Product| unicode:: U+0220F .. N-ARY PRODUCT +.. |rarrb| unicode:: U+021E5 .. RIGHTWARDS ARROW TO BAR +.. |RightDownTeeVector| unicode:: U+0295D .. DOWNWARDS HARPOON WITH BARB RIGHT FROM BAR +.. |RightDownVectorBar| unicode:: U+02955 .. DOWNWARDS HARPOON WITH BARB RIGHT TO BAR +.. |RightTeeVector| unicode:: U+0295B .. RIGHTWARDS HARPOON WITH BARB UP FROM BAR +.. |RightTriangleBar| unicode:: U+029D0 .. VERTICAL BAR BESIDE RIGHT TRIANGLE +.. |RightUpDownVector| unicode:: U+0294F .. UP BARB RIGHT DOWN BARB RIGHT HARPOON +.. |RightUpTeeVector| unicode:: U+0295C .. UPWARDS HARPOON WITH BARB RIGHT FROM BAR +.. |RightUpVectorBar| unicode:: U+02954 .. UPWARDS HARPOON WITH BARB RIGHT TO BAR +.. |RightVectorBar| unicode:: U+02953 .. RIGHTWARDS HARPOON WITH BARB UP TO BAR +.. |RoundImplies| unicode:: U+02970 .. RIGHT DOUBLE ARROW WITH ROUNDED HEAD +.. |RuleDelayed| unicode:: U+029F4 .. RULE-DELAYED +.. |Tab| unicode:: U+00009 .. CHARACTER TABULATION +.. |ThickSpace| unicode:: U+02009 U+0200A U+0200A .. space of width 5/18 em +.. |UnderBar| unicode:: U+00332 .. COMBINING LOW LINE +.. |UnderBrace| unicode:: U+0FE38 .. PRESENTATION FORM FOR VERTICAL RIGHT CURLY BRACKET +.. |UnderBracket| unicode:: U+023B5 .. BOTTOM SQUARE BRACKET +.. |UnderParenthesis| unicode:: U+0FE36 .. PRESENTATION FORM FOR VERTICAL RIGHT PARENTHESIS +.. |UpArrowBar| unicode:: U+02912 .. UPWARDS ARROW TO BAR +.. |Upsilon| unicode:: U+003A5 .. GREEK CAPITAL LETTER UPSILON +.. |VerticalLine| unicode:: U+0007C .. VERTICAL LINE +.. |VerticalSeparator| unicode:: U+02758 .. LIGHT VERTICAL BAR +.. |ZeroWidthSpace| unicode:: U+0200B .. ZERO WIDTH SPACE diff --git a/docutils/parsers/rst/include/xhtml1-lat1.txt b/docutils/parsers/rst/include/xhtml1-lat1.txt new file mode 100644 index 000000000..824dc61c0 --- /dev/null +++ b/docutils/parsers/rst/include/xhtml1-lat1.txt @@ -0,0 +1,102 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |Aacute| unicode:: U+000C1 .. LATIN CAPITAL LETTER A WITH ACUTE +.. |aacute| unicode:: U+000E1 .. LATIN SMALL LETTER A WITH ACUTE +.. |Acirc| unicode:: U+000C2 .. LATIN CAPITAL LETTER A WITH CIRCUMFLEX +.. |acirc| unicode:: U+000E2 .. LATIN SMALL LETTER A WITH CIRCUMFLEX +.. |acute| unicode:: U+000B4 .. ACUTE ACCENT +.. |AElig| unicode:: U+000C6 .. LATIN CAPITAL LETTER AE +.. |aelig| unicode:: U+000E6 .. LATIN SMALL LETTER AE +.. |Agrave| unicode:: U+000C0 .. LATIN CAPITAL LETTER A WITH GRAVE +.. |agrave| unicode:: U+000E0 .. LATIN SMALL LETTER A WITH GRAVE +.. |Aring| unicode:: U+000C5 .. LATIN CAPITAL LETTER A WITH RING ABOVE +.. |aring| unicode:: U+000E5 .. LATIN SMALL LETTER A WITH RING ABOVE +.. |Atilde| unicode:: U+000C3 .. LATIN CAPITAL LETTER A WITH TILDE +.. |atilde| unicode:: U+000E3 .. LATIN SMALL LETTER A WITH TILDE +.. |Auml| unicode:: U+000C4 .. LATIN CAPITAL LETTER A WITH DIAERESIS +.. |auml| unicode:: U+000E4 .. LATIN SMALL LETTER A WITH DIAERESIS +.. |brvbar| unicode:: U+000A6 .. BROKEN BAR +.. |Ccedil| unicode:: U+000C7 .. LATIN CAPITAL LETTER C WITH CEDILLA +.. |ccedil| unicode:: U+000E7 .. LATIN SMALL LETTER C WITH CEDILLA +.. |cedil| unicode:: U+000B8 .. CEDILLA +.. |cent| unicode:: U+000A2 .. CENT SIGN +.. |copy| unicode:: U+000A9 .. COPYRIGHT SIGN +.. |curren| unicode:: U+000A4 .. CURRENCY SIGN +.. |deg| unicode:: U+000B0 .. DEGREE SIGN +.. |divide| unicode:: U+000F7 .. DIVISION SIGN +.. |Eacute| unicode:: U+000C9 .. LATIN CAPITAL LETTER E WITH ACUTE +.. |eacute| unicode:: U+000E9 .. LATIN SMALL LETTER E WITH ACUTE +.. |Ecirc| unicode:: U+000CA .. LATIN CAPITAL LETTER E WITH CIRCUMFLEX +.. |ecirc| unicode:: U+000EA .. LATIN SMALL LETTER E WITH CIRCUMFLEX +.. |Egrave| unicode:: U+000C8 .. LATIN CAPITAL LETTER E WITH GRAVE +.. |egrave| unicode:: U+000E8 .. LATIN SMALL LETTER E WITH GRAVE +.. |ETH| unicode:: U+000D0 .. LATIN CAPITAL LETTER ETH +.. |eth| unicode:: U+000F0 .. LATIN SMALL LETTER ETH +.. |Euml| unicode:: U+000CB .. LATIN CAPITAL LETTER E WITH DIAERESIS +.. |euml| unicode:: U+000EB .. LATIN SMALL LETTER E WITH DIAERESIS +.. |frac12| unicode:: U+000BD .. VULGAR FRACTION ONE HALF +.. |frac14| unicode:: U+000BC .. VULGAR FRACTION ONE QUARTER +.. |frac34| unicode:: U+000BE .. VULGAR FRACTION THREE QUARTERS +.. |Iacute| unicode:: U+000CD .. LATIN CAPITAL LETTER I WITH ACUTE +.. |iacute| unicode:: U+000ED .. LATIN SMALL LETTER I WITH ACUTE +.. |Icirc| unicode:: U+000CE .. LATIN CAPITAL LETTER I WITH CIRCUMFLEX +.. |icirc| unicode:: U+000EE .. LATIN SMALL LETTER I WITH CIRCUMFLEX +.. |iexcl| unicode:: U+000A1 .. INVERTED EXCLAMATION MARK +.. |Igrave| unicode:: U+000CC .. LATIN CAPITAL LETTER I WITH GRAVE +.. |igrave| unicode:: U+000EC .. LATIN SMALL LETTER I WITH GRAVE +.. |iquest| unicode:: U+000BF .. INVERTED QUESTION MARK +.. |Iuml| unicode:: U+000CF .. LATIN CAPITAL LETTER I WITH DIAERESIS +.. |iuml| unicode:: U+000EF .. LATIN SMALL LETTER I WITH DIAERESIS +.. |laquo| unicode:: U+000AB .. LEFT-POINTING DOUBLE ANGLE QUOTATION MARK +.. |macr| unicode:: U+000AF .. MACRON +.. |micro| unicode:: U+000B5 .. MICRO SIGN +.. |middot| unicode:: U+000B7 .. MIDDLE DOT +.. |nbsp| unicode:: U+000A0 .. NO-BREAK SPACE +.. |not| unicode:: U+000AC .. NOT SIGN +.. |Ntilde| unicode:: U+000D1 .. LATIN CAPITAL LETTER N WITH TILDE +.. |ntilde| unicode:: U+000F1 .. LATIN SMALL LETTER N WITH TILDE +.. |Oacute| unicode:: U+000D3 .. LATIN CAPITAL LETTER O WITH ACUTE +.. |oacute| unicode:: U+000F3 .. LATIN SMALL LETTER O WITH ACUTE +.. |Ocirc| unicode:: U+000D4 .. LATIN CAPITAL LETTER O WITH CIRCUMFLEX +.. |ocirc| unicode:: U+000F4 .. LATIN SMALL LETTER O WITH CIRCUMFLEX +.. |Ograve| unicode:: U+000D2 .. LATIN CAPITAL LETTER O WITH GRAVE +.. |ograve| unicode:: U+000F2 .. LATIN SMALL LETTER O WITH GRAVE +.. |ordf| unicode:: U+000AA .. FEMININE ORDINAL INDICATOR +.. |ordm| unicode:: U+000BA .. MASCULINE ORDINAL INDICATOR +.. |Oslash| unicode:: U+000D8 .. LATIN CAPITAL LETTER O WITH STROKE +.. |oslash| unicode:: U+000F8 .. LATIN SMALL LETTER O WITH STROKE +.. |Otilde| unicode:: U+000D5 .. LATIN CAPITAL LETTER O WITH TILDE +.. |otilde| unicode:: U+000F5 .. LATIN SMALL LETTER O WITH TILDE +.. |Ouml| unicode:: U+000D6 .. LATIN CAPITAL LETTER O WITH DIAERESIS +.. |ouml| unicode:: U+000F6 .. LATIN SMALL LETTER O WITH DIAERESIS +.. |para| unicode:: U+000B6 .. PILCROW SIGN +.. |plusmn| unicode:: U+000B1 .. PLUS-MINUS SIGN +.. |pound| unicode:: U+000A3 .. POUND SIGN +.. |raquo| unicode:: U+000BB .. RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK +.. |reg| unicode:: U+000AE .. REGISTERED SIGN +.. |sect| unicode:: U+000A7 .. SECTION SIGN +.. |shy| unicode:: U+000AD .. SOFT HYPHEN +.. |sup1| unicode:: U+000B9 .. SUPERSCRIPT ONE +.. |sup2| unicode:: U+000B2 .. SUPERSCRIPT TWO +.. |sup3| unicode:: U+000B3 .. SUPERSCRIPT THREE +.. |szlig| unicode:: U+000DF .. LATIN SMALL LETTER SHARP S +.. |THORN| unicode:: U+000DE .. LATIN CAPITAL LETTER THORN +.. |thorn| unicode:: U+000FE .. LATIN SMALL LETTER THORN +.. |times| unicode:: U+000D7 .. MULTIPLICATION SIGN +.. |Uacute| unicode:: U+000DA .. LATIN CAPITAL LETTER U WITH ACUTE +.. |uacute| unicode:: U+000FA .. LATIN SMALL LETTER U WITH ACUTE +.. |Ucirc| unicode:: U+000DB .. LATIN CAPITAL LETTER U WITH CIRCUMFLEX +.. |ucirc| unicode:: U+000FB .. LATIN SMALL LETTER U WITH CIRCUMFLEX +.. |Ugrave| unicode:: U+000D9 .. LATIN CAPITAL LETTER U WITH GRAVE +.. |ugrave| unicode:: U+000F9 .. LATIN SMALL LETTER U WITH GRAVE +.. |uml| unicode:: U+000A8 .. DIAERESIS +.. |Uuml| unicode:: U+000DC .. LATIN CAPITAL LETTER U WITH DIAERESIS +.. |uuml| unicode:: U+000FC .. LATIN SMALL LETTER U WITH DIAERESIS +.. |Yacute| unicode:: U+000DD .. LATIN CAPITAL LETTER Y WITH ACUTE +.. |yacute| unicode:: U+000FD .. LATIN SMALL LETTER Y WITH ACUTE +.. |yen| unicode:: U+000A5 .. YEN SIGN +.. |yuml| unicode:: U+000FF .. LATIN SMALL LETTER Y WITH DIAERESIS diff --git a/docutils/parsers/rst/include/xhtml1-special.txt b/docutils/parsers/rst/include/xhtml1-special.txt new file mode 100644 index 000000000..dc6f5753c --- /dev/null +++ b/docutils/parsers/rst/include/xhtml1-special.txt @@ -0,0 +1,37 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |bdquo| unicode:: U+0201E .. DOUBLE LOW-9 QUOTATION MARK +.. |circ| unicode:: U+002C6 .. MODIFIER LETTER CIRCUMFLEX ACCENT +.. |Dagger| unicode:: U+02021 .. DOUBLE DAGGER +.. |dagger| unicode:: U+02020 .. DAGGER +.. |emsp| unicode:: U+02003 .. EM SPACE +.. |ensp| unicode:: U+02002 .. EN SPACE +.. |euro| unicode:: U+020AC .. EURO SIGN +.. |gt| unicode:: U+0003E .. GREATER-THAN SIGN +.. |ldquo| unicode:: U+0201C .. LEFT DOUBLE QUOTATION MARK +.. |lrm| unicode:: U+0200E .. LEFT-TO-RIGHT MARK +.. |lsaquo| unicode:: U+02039 .. SINGLE LEFT-POINTING ANGLE QUOTATION MARK +.. |lsquo| unicode:: U+02018 .. LEFT SINGLE QUOTATION MARK +.. |lt| unicode:: U+0003C .. LESS-THAN SIGN +.. |mdash| unicode:: U+02014 .. EM DASH +.. |ndash| unicode:: U+02013 .. EN DASH +.. |OElig| unicode:: U+00152 .. LATIN CAPITAL LIGATURE OE +.. |oelig| unicode:: U+00153 .. LATIN SMALL LIGATURE OE +.. |permil| unicode:: U+02030 .. PER MILLE SIGN +.. |quot| unicode:: U+00022 .. QUOTATION MARK +.. |rdquo| unicode:: U+0201D .. RIGHT DOUBLE QUOTATION MARK +.. |rlm| unicode:: U+0200F .. RIGHT-TO-LEFT MARK +.. |rsaquo| unicode:: U+0203A .. SINGLE RIGHT-POINTING ANGLE QUOTATION MARK +.. |rsquo| unicode:: U+02019 .. RIGHT SINGLE QUOTATION MARK +.. |sbquo| unicode:: U+0201A .. SINGLE LOW-9 QUOTATION MARK +.. |Scaron| unicode:: U+00160 .. LATIN CAPITAL LETTER S WITH CARON +.. |scaron| unicode:: U+00161 .. LATIN SMALL LETTER S WITH CARON +.. |thinsp| unicode:: U+02009 .. THIN SPACE +.. |tilde| unicode:: U+002DC .. SMALL TILDE +.. |Yuml| unicode:: U+00178 .. LATIN CAPITAL LETTER Y WITH DIAERESIS +.. |zwj| unicode:: U+0200D .. ZERO WIDTH JOINER +.. |zwnj| unicode:: U+0200C .. ZERO WIDTH NON-JOINER diff --git a/docutils/parsers/rst/include/xhtml1-symbol.txt b/docutils/parsers/rst/include/xhtml1-symbol.txt new file mode 100644 index 000000000..8fe97f808 --- /dev/null +++ b/docutils/parsers/rst/include/xhtml1-symbol.txt @@ -0,0 +1,130 @@ +.. This data file has been placed in the public domain. +.. Derived from the Unicode character mappings available from + . + Processed by unicode2rstsubs.py, part of Docutils: + . + +.. |alefsym| unicode:: U+02135 .. ALEF SYMBOL +.. |Alpha| unicode:: U+00391 .. GREEK CAPITAL LETTER ALPHA +.. |alpha| unicode:: U+003B1 .. GREEK SMALL LETTER ALPHA +.. |and| unicode:: U+02227 .. LOGICAL AND +.. |ang| unicode:: U+02220 .. ANGLE +.. |asymp| unicode:: U+02248 .. ALMOST EQUAL TO +.. |Beta| unicode:: U+00392 .. GREEK CAPITAL LETTER BETA +.. |beta| unicode:: U+003B2 .. GREEK SMALL LETTER BETA +.. |bull| unicode:: U+02022 .. BULLET +.. |cap| unicode:: U+02229 .. INTERSECTION +.. |Chi| unicode:: U+003A7 .. GREEK CAPITAL LETTER CHI +.. |chi| unicode:: U+003C7 .. GREEK SMALL LETTER CHI +.. |clubs| unicode:: U+02663 .. BLACK CLUB SUIT +.. |cong| unicode:: U+02245 .. APPROXIMATELY EQUAL TO +.. |crarr| unicode:: U+021B5 .. DOWNWARDS ARROW WITH CORNER LEFTWARDS +.. |cup| unicode:: U+0222A .. UNION +.. |dArr| unicode:: U+021D3 .. DOWNWARDS DOUBLE ARROW +.. |darr| unicode:: U+02193 .. DOWNWARDS ARROW +.. |Delta| unicode:: U+00394 .. GREEK CAPITAL LETTER DELTA +.. |delta| unicode:: U+003B4 .. GREEK SMALL LETTER DELTA +.. |diams| unicode:: U+02666 .. BLACK DIAMOND SUIT +.. |empty| unicode:: U+02205 .. EMPTY SET +.. |Epsilon| unicode:: U+00395 .. GREEK CAPITAL LETTER EPSILON +.. |epsilon| unicode:: U+003B5 .. GREEK SMALL LETTER EPSILON +.. |equiv| unicode:: U+02261 .. IDENTICAL TO +.. |Eta| unicode:: U+00397 .. GREEK CAPITAL LETTER ETA +.. |eta| unicode:: U+003B7 .. GREEK SMALL LETTER ETA +.. |exist| unicode:: U+02203 .. THERE EXISTS +.. |fnof| unicode:: U+00192 .. LATIN SMALL LETTER F WITH HOOK +.. |forall| unicode:: U+02200 .. FOR ALL +.. |frasl| unicode:: U+02044 .. FRACTION SLASH +.. |Gamma| unicode:: U+00393 .. GREEK CAPITAL LETTER GAMMA +.. |gamma| unicode:: U+003B3 .. GREEK SMALL LETTER GAMMA +.. |ge| unicode:: U+02265 .. GREATER-THAN OR EQUAL TO +.. |hArr| unicode:: U+021D4 .. LEFT RIGHT DOUBLE ARROW +.. |harr| unicode:: U+02194 .. LEFT RIGHT ARROW +.. |hearts| unicode:: U+02665 .. BLACK HEART SUIT +.. |hellip| unicode:: U+02026 .. HORIZONTAL ELLIPSIS +.. |image| unicode:: U+02111 .. BLACK-LETTER CAPITAL I +.. |infin| unicode:: U+0221E .. INFINITY +.. |int| unicode:: U+0222B .. INTEGRAL +.. |Iota| unicode:: U+00399 .. GREEK CAPITAL LETTER IOTA +.. |iota| unicode:: U+003B9 .. GREEK SMALL LETTER IOTA +.. |isin| unicode:: U+02208 .. ELEMENT OF +.. |Kappa| unicode:: U+0039A .. GREEK CAPITAL LETTER KAPPA +.. |kappa| unicode:: U+003BA .. GREEK SMALL LETTER KAPPA +.. |Lambda| unicode:: U+0039B .. GREEK CAPITAL LETTER LAMDA +.. |lambda| unicode:: U+003BB .. GREEK SMALL LETTER LAMDA +.. |lang| unicode:: U+02329 .. LEFT-POINTING ANGLE BRACKET +.. |lArr| unicode:: U+021D0 .. LEFTWARDS DOUBLE ARROW +.. |larr| unicode:: U+02190 .. LEFTWARDS ARROW +.. |lceil| unicode:: U+02308 .. LEFT CEILING +.. |le| unicode:: U+02264 .. LESS-THAN OR EQUAL TO +.. |lfloor| unicode:: U+0230A .. LEFT FLOOR +.. |lowast| unicode:: U+02217 .. ASTERISK OPERATOR +.. |loz| unicode:: U+025CA .. LOZENGE +.. |minus| unicode:: U+02212 .. MINUS SIGN +.. |Mu| unicode:: U+0039C .. GREEK CAPITAL LETTER MU +.. |mu| unicode:: U+003BC .. GREEK SMALL LETTER MU +.. |nabla| unicode:: U+02207 .. NABLA +.. |ne| unicode:: U+02260 .. NOT EQUAL TO +.. |ni| unicode:: U+0220B .. CONTAINS AS MEMBER +.. |notin| unicode:: U+02209 .. NOT AN ELEMENT OF +.. |nsub| unicode:: U+02284 .. NOT A SUBSET OF +.. |Nu| unicode:: U+0039D .. GREEK CAPITAL LETTER NU +.. |nu| unicode:: U+003BD .. GREEK SMALL LETTER NU +.. |oline| unicode:: U+0203E .. OVERLINE +.. |Omega| unicode:: U+003A9 .. GREEK CAPITAL LETTER OMEGA +.. |omega| unicode:: U+003C9 .. GREEK SMALL LETTER OMEGA +.. |Omicron| unicode:: U+0039F .. GREEK CAPITAL LETTER OMICRON +.. |omicron| unicode:: U+003BF .. GREEK SMALL LETTER OMICRON +.. |oplus| unicode:: U+02295 .. CIRCLED PLUS +.. |or| unicode:: U+02228 .. LOGICAL OR +.. |otimes| unicode:: U+02297 .. CIRCLED TIMES +.. |part| unicode:: U+02202 .. PARTIAL DIFFERENTIAL +.. |perp| unicode:: U+022A5 .. UP TACK +.. |Phi| unicode:: U+003A6 .. GREEK CAPITAL LETTER PHI +.. |phi| unicode:: U+003D5 .. GREEK PHI SYMBOL +.. |Pi| unicode:: U+003A0 .. GREEK CAPITAL LETTER PI +.. |pi| unicode:: U+003C0 .. GREEK SMALL LETTER PI +.. |piv| unicode:: U+003D6 .. GREEK PI SYMBOL +.. |Prime| unicode:: U+02033 .. DOUBLE PRIME +.. |prime| unicode:: U+02032 .. PRIME +.. |prod| unicode:: U+0220F .. N-ARY PRODUCT +.. |prop| unicode:: U+0221D .. PROPORTIONAL TO +.. |Psi| unicode:: U+003A8 .. GREEK CAPITAL LETTER PSI +.. |psi| unicode:: U+003C8 .. GREEK SMALL LETTER PSI +.. |radic| unicode:: U+0221A .. SQUARE ROOT +.. |rang| unicode:: U+0232A .. RIGHT-POINTING ANGLE BRACKET +.. |rArr| unicode:: U+021D2 .. RIGHTWARDS DOUBLE ARROW +.. |rarr| unicode:: U+02192 .. RIGHTWARDS ARROW +.. |rceil| unicode:: U+02309 .. RIGHT CEILING +.. |real| unicode:: U+0211C .. BLACK-LETTER CAPITAL R +.. |rfloor| unicode:: U+0230B .. RIGHT FLOOR +.. |Rho| unicode:: U+003A1 .. GREEK CAPITAL LETTER RHO +.. |rho| unicode:: U+003C1 .. GREEK SMALL LETTER RHO +.. |sdot| unicode:: U+022C5 .. DOT OPERATOR +.. |Sigma| unicode:: U+003A3 .. GREEK CAPITAL LETTER SIGMA +.. |sigma| unicode:: U+003C3 .. GREEK SMALL LETTER SIGMA +.. |sigmaf| unicode:: U+003C2 .. GREEK SMALL LETTER FINAL SIGMA +.. |sim| unicode:: U+0223C .. TILDE OPERATOR +.. |spades| unicode:: U+02660 .. BLACK SPADE SUIT +.. |sub| unicode:: U+02282 .. SUBSET OF +.. |sube| unicode:: U+02286 .. SUBSET OF OR EQUAL TO +.. |sum| unicode:: U+02211 .. N-ARY SUMMATION +.. |sup| unicode:: U+02283 .. SUPERSET OF +.. |supe| unicode:: U+02287 .. SUPERSET OF OR EQUAL TO +.. |Tau| unicode:: U+003A4 .. GREEK CAPITAL LETTER TAU +.. |tau| unicode:: U+003C4 .. GREEK SMALL LETTER TAU +.. |there4| unicode:: U+02234 .. THEREFORE +.. |Theta| unicode:: U+00398 .. GREEK CAPITAL LETTER THETA +.. |theta| unicode:: U+003B8 .. GREEK SMALL LETTER THETA +.. |thetasym| unicode:: U+003D1 .. GREEK THETA SYMBOL +.. |trade| unicode:: U+02122 .. TRADE MARK SIGN +.. |uArr| unicode:: U+021D1 .. UPWARDS DOUBLE ARROW +.. |uarr| unicode:: U+02191 .. UPWARDS ARROW +.. |upsih| unicode:: U+003D2 .. GREEK UPSILON WITH HOOK SYMBOL +.. |Upsilon| unicode:: U+003A5 .. GREEK CAPITAL LETTER UPSILON +.. |upsilon| unicode:: U+003C5 .. GREEK SMALL LETTER UPSILON +.. |weierp| unicode:: U+02118 .. SCRIPT CAPITAL P +.. |Xi| unicode:: U+0039E .. GREEK CAPITAL LETTER XI +.. |xi| unicode:: U+003BE .. GREEK SMALL LETTER XI +.. |Zeta| unicode:: U+00396 .. GREEK CAPITAL LETTER ZETA +.. |zeta| unicode:: U+003B6 .. GREEK SMALL LETTER ZETA -- cgit v1.2.1 From cbc0c71cce99abae907d275148e80e1e8a201881 Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 12 Jun 2005 16:59:38 +0000 Subject: corrected path to data files git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3474 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index af206751f..de50d3c6b 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -21,7 +21,8 @@ except ImportError: urllib2 = None -standard_include_path = os.path.join(os.path.dirname(states.__file__), 'data') +standard_include_path = os.path.join(os.path.dirname(states.__file__), + 'include') def include(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): -- cgit v1.2.1 From ed1b6c92164e41d468f87eae3cb4b0965431db77 Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 12 Jun 2005 20:34:06 +0000 Subject: removed unnecessary text git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3475 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/include/README.txt | 4 ---- 1 file changed, 4 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/include/README.txt b/docutils/parsers/rst/include/README.txt index af29691be..cd03135f9 100644 --- a/docutils/parsers/rst/include/README.txt +++ b/docutils/parsers/rst/include/README.txt @@ -2,10 +2,6 @@ ``docutils/parsers/rst/include`` Directory ============================================ -The individual data files are stored with the Docutils source code in -the "docutils" package, in the ``docutils/parsers/rst/include`` -directory. - This directory contains standard data files intended for inclusion in reStructuredText documents. To access these files, use the "include" directive with the special syntax for standard "include" data files, -- cgit v1.2.1 From c9bdf0b05fc639f4112d0dfd7538ff63a02c79b5 Mon Sep 17 00:00:00 2001 From: wiemann Date: Thu, 16 Jun 2005 00:27:26 +0000 Subject: fixed bug with escaped colons introducing literal block git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3491 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index b7a359159..9f12bd560 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -386,7 +386,7 @@ class RSTState(StateWS): Return a list (paragraph & messages) & a boolean: literal_block next? """ data = '\n'.join(lines).rstrip() - if data[-2:] == '::': + if re.search(r'(? Date: Thu, 16 Jun 2005 22:03:08 +0000 Subject: added support for units in image widths and heights; I called a number combined with a unit (e.g. 5em) a "measure"; I am not entirely sure if that's the right term, though git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3497 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 26 ++++++++++++++++++++++++++ docutils/parsers/rst/directives/images.py | 4 ++-- 2 files changed, 28 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index d78a3b9c1..dadd08e65 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -286,6 +286,32 @@ def nonnegative_int(argument): raise ValueError('negative value; must be positive or zero') return value +length_units = ['em', 'ex', 'px', 'in', 'cm', 'mm', 'pt', 'pc'] + +def get_measure(argument, units): + """ + Check for a positive argument of one of the units and return a + normalized string of the form "" (without space in + between). + + To be called from directive option conversion functions. + """ + match = re.match(r'^([0-9.]+) *(%s)$' % '|'.join(units), argument) + try: + assert match is not None + float(match.group(1)) + except (AssertionError, ValueError): + raise ValueError( + 'not a positive measure of one of the following units:\n%s' + % ' '.join(['"%s"' % i for i in units])) + return match.group(1) + match.group(2) + +def length_or_unitless(argument): + return get_measure(argument, length_units + ['']) + +def length_or_percentage_or_unitless(argument): + return get_measure(argument, length_units + ['%', '']) + def class_option(argument): """ Convert the argument into a list of ID-compatible strings and return it. diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index 670f969a0..ef77c2bef 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -76,8 +76,8 @@ def image(name, arguments, options, content, lineno, image.arguments = (1, 0, 1) image.options = {'alt': directives.unchanged, - 'height': directives.nonnegative_int, - 'width': directives.nonnegative_int, + 'height': directives.length_or_unitless, + 'width': directives.length_or_percentage_or_unitless, 'scale': directives.nonnegative_int, 'align': align, 'target': directives.unchanged_required, -- cgit v1.2.1 From ddba601498ad2c7e472daa384357b384e6ac2f45 Mon Sep 17 00:00:00 2001 From: wiemann Date: Mon, 27 Jun 2005 02:04:39 +0000 Subject: moved Dummy reader and parser to readers/dummy.py and parsers/dummy.py, resp.; removed "restructuredtext" default for parser_name when initializing a reader git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3594 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/dummy.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 docutils/parsers/dummy.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/dummy.py b/docutils/parsers/dummy.py new file mode 100644 index 000000000..5fd646c7a --- /dev/null +++ b/docutils/parsers/dummy.py @@ -0,0 +1,21 @@ +# Author: Martin Blais +# Contact: blais@furius.ca +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +"""Dummy parser that does nothing.""" + +from docutils import parsers + +class Parser(parsers.Parser): + + """Dummy parser that does nothing.""" + + supported = ('dummy',) + + config_section = 'dummy parser' + config_section_dependencies = ('parsers',) + + def parse(self, inputstring, document): + pass -- cgit v1.2.1 From 87d7a29637a909f7bb7c0a321d09d131fc45d7f8 Mon Sep 17 00:00:00 2001 From: wiemann Date: Wed, 29 Jun 2005 11:26:25 +0000 Subject: move metadata title into document['title'] git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3621 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index de50d3c6b..71c097b33 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -358,7 +358,7 @@ default_role.arguments = (0, 1, 0) def title(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): - state_machine.document.settings.title = arguments[0] + state_machine.document['title'] = arguments[0] return [] title.arguments = (1, 0, 1) -- cgit v1.2.1 From ab590797d28eadbe3580501e2d74e3f665aa0030 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 29 Jun 2005 19:45:15 +0000 Subject: renaming "dummy" parser to "null" git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3628 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/dummy.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/dummy.py b/docutils/parsers/dummy.py index 5fd646c7a..61702dfaf 100644 --- a/docutils/parsers/dummy.py +++ b/docutils/parsers/dummy.py @@ -4,17 +4,18 @@ # Date: $Date$ # Copyright: This module has been placed in the public domain. -"""Dummy parser that does nothing.""" +"""A do-nothing parser.""" from docutils import parsers + class Parser(parsers.Parser): - """Dummy parser that does nothing.""" + """A do-nothing parser.""" - supported = ('dummy',) + supported = ('null',) - config_section = 'dummy parser' + config_section = 'null parser' config_section_dependencies = ('parsers',) def parse(self, inputstring, document): -- cgit v1.2.1 From 7e0a64e309a60fabda5f1d52afa6fc3c1c66ae46 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 29 Jun 2005 19:45:35 +0000 Subject: renamed "dummy" parser to "null" git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3629 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/dummy.py | 22 ---------------------- docutils/parsers/null.py | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 22 deletions(-) delete mode 100644 docutils/parsers/dummy.py create mode 100644 docutils/parsers/null.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/dummy.py b/docutils/parsers/dummy.py deleted file mode 100644 index 61702dfaf..000000000 --- a/docutils/parsers/dummy.py +++ /dev/null @@ -1,22 +0,0 @@ -# Author: Martin Blais -# Contact: blais@furius.ca -# Revision: $Revision$ -# Date: $Date$ -# Copyright: This module has been placed in the public domain. - -"""A do-nothing parser.""" - -from docutils import parsers - - -class Parser(parsers.Parser): - - """A do-nothing parser.""" - - supported = ('null',) - - config_section = 'null parser' - config_section_dependencies = ('parsers',) - - def parse(self, inputstring, document): - pass diff --git a/docutils/parsers/null.py b/docutils/parsers/null.py new file mode 100644 index 000000000..61702dfaf --- /dev/null +++ b/docutils/parsers/null.py @@ -0,0 +1,22 @@ +# Author: Martin Blais +# Contact: blais@furius.ca +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +"""A do-nothing parser.""" + +from docutils import parsers + + +class Parser(parsers.Parser): + + """A do-nothing parser.""" + + supported = ('null',) + + config_section = 'null parser' + config_section_dependencies = ('parsers',) + + def parse(self, inputstring, document): + pass -- cgit v1.2.1 From 6a66e3e696c26896f3d5ffac5376beddd13a6f20 Mon Sep 17 00:00:00 2001 From: wiemann Date: Wed, 29 Jun 2005 22:34:44 +0000 Subject: removed document.internal_targets and document.external_targets; fixed bug (not sure yet if the code is clean -- needs refactoring) git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3637 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 6 ------ 1 file changed, 6 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 9f12bd560..4156fd682 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -788,7 +788,6 @@ class Inliner: if target: reference['refuri'] = uri target['names'].append(refname) - self.document.note_external_target(target) self.document.note_explicit_target(target, self.parent) node_list.append(target) else: @@ -1870,17 +1869,12 @@ class Body(RSTState): uri = self.inliner.adjust_uri(refuri) if uri: target['refuri'] = uri - self.document.note_external_target(target) else: raise ApplicationError('problem with URI: %r' % refuri) - else: - self.document.note_internal_target(target) self.document.note_explicit_target(target, self.parent) else: # anonymous target if refuri: target['refuri'] = refuri - else: - self.document.note_internal_target(target) target['anonymous'] = 1 self.document.note_anonymous_target(target) -- cgit v1.2.1 From dc98554c2fc0308774c70dcebc6fe45617f22e00 Mon Sep 17 00:00:00 2001 From: wiemann Date: Fri, 15 Jul 2005 21:28:22 +0000 Subject: more precise error message git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3759 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/tables.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/tables.py b/docutils/parsers/rst/directives/tables.py index 87131277d..dadcdae68 100644 --- a/docutils/parsers/rst/directives/tables.py +++ b/docutils/parsers/rst/directives/tables.py @@ -117,8 +117,8 @@ def csv_table(name, arguments, options, content, lineno, if ( not state.document.settings.file_insertion_enabled and (options.has_key('file') or options.has_key('url')) ): warning = state_machine.reporter.warning( - '"%s" directive disabled.' % name, - nodes.literal_block(block_text, block_text), line=lineno) + 'File and URL access deactivated; ignoring "%s" directive.' % + name, nodes.literal_block(block_text,block_text), line=lineno) return [warning] check_requirements(name, lineno, block_text, state_machine) title, messages = make_title(arguments, state, lineno) -- cgit v1.2.1 From d854c9bf42f3c21b876ad51e3c691def7e072840 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 10 Aug 2005 02:49:06 +0000 Subject: fixed enumerated list bug (SF#1254145) git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3789 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 4156fd682..175334fd2 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1289,14 +1289,15 @@ class Body(RSTState): self.state_machine.previous_line() if not next_line[:1].strip(): # blank or indented return 1 - next_enumerator, auto_enumerator = self.make_enumerator( - ordinal + 1, sequence, format) - try: - if ( next_line.startswith(next_enumerator) or - next_line.startswith(auto_enumerator) ): - return 1 - except TypeError: - pass + result = self.make_enumerator(ordinal + 1, sequence, format) + if result: + next_enumerator, auto_enumerator = result + try: + if ( next_line.startswith(next_enumerator) or + next_line.startswith(auto_enumerator) ): + return 1 + except TypeError: + pass return None def make_enumerator(self, ordinal, sequence, format): -- cgit v1.2.1 From cf82ee9210cd535244ba63ecfad632fb32cad9c0 Mon Sep 17 00:00:00 2001 From: wiemann Date: Sun, 14 Aug 2005 16:37:53 +0000 Subject: updated Chinese translations, closing SF patch #1243780; thanks Joe YS Jaw git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3798 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/zh_tw.py | 150 ++++++++++++++++---------------- 1 file changed, 75 insertions(+), 75 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/zh_tw.py b/docutils/parsers/rst/languages/zh_tw.py index 664aaf6ea..7e66a56a5 100644 --- a/docutils/parsers/rst/languages/zh_tw.py +++ b/docutils/parsers/rst/languages/zh_tw.py @@ -19,86 +19,86 @@ __docformat__ = 'reStructuredText' directives = { # language-dependent: fixed - 'attention (translation required)': 'attention', - 'caution (translation required)': 'caution', - 'danger (translation required)': 'danger', - 'error (translation required)': 'error', - 'hint (translation required)': 'hint', - 'important (translation required)': 'important', - 'note (translation required)': 'note', - 'tip (translation required)': 'tip', - 'warning (translation required)': 'warning', - 'admonition (translation required)': 'admonition', - 'sidebar (translation required)': 'sidebar', - 'topic (translation required)': 'topic', - 'line-block (translation required)': 'line-block', - 'parsed-literal (translation required)': 'parsed-literal', - 'rubric (translation required)': 'rubric', - 'epigraph (translation required)': 'epigraph', - 'highlights (translation required)': 'highlights', - 'pull-quote (translation required)': 'pull-quote', - 'compound (translation required)': 'compound', - #'questions (translation required)': 'questions', - 'table (translation required)': 'table', - 'csv-table (translation required)': 'csv-table', - 'list-table (translation required)': 'list-table', - #'qa (translation required)': 'questions', - #'faq (translation required)': 'questions', - 'meta (translation required)': 'meta', - #'imagemap (translation required)': 'imagemap', - 'image (translation required)': 'image', - 'figure (translation required)': 'figure', - 'include (translation required)': 'include', - 'raw (translation required)': 'raw', - 'replace (translation required)': 'replace', - 'unicode (translation required)': 'unicode', - 'class (translation required)': 'class', - 'role (translation required)': 'role', - u'default-role (translation required)': 'default-role', - u'title (translation required)': 'title', - 'contents (translation required)': 'contents', - 'sectnum (translation required)': 'sectnum', - 'section-numbering (translation required)': 'sectnum', - u'header (translation required)': 'header', - u'footer (translation required)': 'footer', - #'footnotes (translation required)': 'footnotes', - #'citations (translation required)': 'citations', - 'target-notes (translation required)': 'target-notes', + 'attention': 'attention', + 'caution': 'caution', + 'danger': 'danger', + 'error': 'error', + 'hint': 'hint', + 'important': 'important', + 'note': 'note', + 'tip': 'tip', + 'warning': 'warning', + 'admonition': 'admonition', + 'sidebar': 'sidebar', + 'topic': 'topic', + 'line-block': 'line-block', + 'parsed-literal': 'parsed-literal', + 'rubric': 'rubric', + 'epigraph': 'epigraph', + 'highlights': 'highlights', + 'pull-quote': 'pull-quote', + 'compound': 'compound', + #'questions': 'questions', + 'table': 'table', + 'csv-table': 'csv-table', + 'list-table': 'list-table', + #'qa': 'questions', + #'faq': 'questions', + 'meta': 'meta', + #'imagemap': 'imagemap', + 'image': 'image', + 'figure': 'figure', + 'include': 'include', + 'raw': 'raw', + 'replace': 'replace', + 'unicode': 'unicode', + 'class': 'class', + 'role': 'role', + u'default-role': 'default-role', + u'title': 'title', + 'contents': 'contents', + 'sectnum': 'sectnum', + 'section-numbering': 'sectnum', + u'header': 'header', + u'footer': 'footer', + #'footnotes': 'footnotes', + #'citations': 'citations', + 'target-notes': 'target-notes', 'restructuredtext-test-directive': 'restructuredtext-test-directive'} """Traditional Chinese name to registered (in directives/__init__.py) directive name mapping.""" roles = { # language-dependent: fixed - 'abbreviation (translation required)': 'abbreviation', - 'ab (translation required)': 'abbreviation', - 'acronym (translation required)': 'acronym', - 'ac (translation required)': 'acronym', - 'index (translation required)': 'index', - 'i (translation required)': 'index', - 'subscript (translation required)': 'subscript', - 'sub (translation required)': 'subscript', - 'superscript (translation required)': 'superscript', - 'sup (translation required)': 'superscript', - 'title-reference (translation required)': 'title-reference', - 'title (translation required)': 'title-reference', - 't (translation required)': 'title-reference', - 'pep-reference (translation required)': 'pep-reference', - 'pep (translation required)': 'pep-reference', - 'rfc-reference (translation required)': 'rfc-reference', - 'rfc (translation required)': 'rfc-reference', - 'emphasis (translation required)': 'emphasis', - 'strong (translation required)': 'strong', - 'literal (translation required)': 'literal', - 'named-reference (translation required)': 'named-reference', - 'anonymous-reference (translation required)': 'anonymous-reference', - 'footnote-reference (translation required)': 'footnote-reference', - 'citation-reference (translation required)': 'citation-reference', - 'substitution-reference (translation required)': 'substitution-reference', - 'target (translation required)': 'target', - 'uri-reference (translation required)': 'uri-reference', - 'uri (translation required)': 'uri-reference', - 'url (translation required)': 'uri-reference', - 'raw (translation required)': 'raw',} + 'abbreviation': 'abbreviation', + 'ab': 'abbreviation', + 'acronym': 'acronym', + 'ac': 'acronym', + 'index': 'index', + 'i': 'index', + 'subscript': 'subscript', + 'sub': 'subscript', + 'superscript': 'superscript', + 'sup': 'superscript', + 'title-reference': 'title-reference', + 'title': 'title-reference', + 't': 'title-reference', + 'pep-reference': 'pep-reference', + 'pep': 'pep-reference', + 'rfc-reference': 'rfc-reference', + 'rfc': 'rfc-reference', + 'emphasis': 'emphasis', + 'strong': 'strong', + 'literal': 'literal', + 'named-reference': 'named-reference', + 'anonymous-reference': 'anonymous-reference', + 'footnote-reference': 'footnote-reference', + 'citation-reference': 'citation-reference', + 'substitution-reference': 'substitution-reference', + 'target': 'target', + 'uri-reference': 'uri-reference', + 'uri': 'uri-reference', + 'url': 'uri-reference', + 'raw': 'raw',} """Mapping of Traditional Chinese role names to canonical role names for interpreted text.""" -- cgit v1.2.1 From c5b2358f005d4ed25cda7f3f23a87f56a480f129 Mon Sep 17 00:00:00 2001 From: wiemann Date: Sun, 14 Aug 2005 17:34:37 +0000 Subject: re-added "(translation required)" git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3801 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/zh_tw.py | 150 ++++++++++++++++---------------- 1 file changed, 75 insertions(+), 75 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/zh_tw.py b/docutils/parsers/rst/languages/zh_tw.py index 7e66a56a5..664aaf6ea 100644 --- a/docutils/parsers/rst/languages/zh_tw.py +++ b/docutils/parsers/rst/languages/zh_tw.py @@ -19,86 +19,86 @@ __docformat__ = 'reStructuredText' directives = { # language-dependent: fixed - 'attention': 'attention', - 'caution': 'caution', - 'danger': 'danger', - 'error': 'error', - 'hint': 'hint', - 'important': 'important', - 'note': 'note', - 'tip': 'tip', - 'warning': 'warning', - 'admonition': 'admonition', - 'sidebar': 'sidebar', - 'topic': 'topic', - 'line-block': 'line-block', - 'parsed-literal': 'parsed-literal', - 'rubric': 'rubric', - 'epigraph': 'epigraph', - 'highlights': 'highlights', - 'pull-quote': 'pull-quote', - 'compound': 'compound', - #'questions': 'questions', - 'table': 'table', - 'csv-table': 'csv-table', - 'list-table': 'list-table', - #'qa': 'questions', - #'faq': 'questions', - 'meta': 'meta', - #'imagemap': 'imagemap', - 'image': 'image', - 'figure': 'figure', - 'include': 'include', - 'raw': 'raw', - 'replace': 'replace', - 'unicode': 'unicode', - 'class': 'class', - 'role': 'role', - u'default-role': 'default-role', - u'title': 'title', - 'contents': 'contents', - 'sectnum': 'sectnum', - 'section-numbering': 'sectnum', - u'header': 'header', - u'footer': 'footer', - #'footnotes': 'footnotes', - #'citations': 'citations', - 'target-notes': 'target-notes', + 'attention (translation required)': 'attention', + 'caution (translation required)': 'caution', + 'danger (translation required)': 'danger', + 'error (translation required)': 'error', + 'hint (translation required)': 'hint', + 'important (translation required)': 'important', + 'note (translation required)': 'note', + 'tip (translation required)': 'tip', + 'warning (translation required)': 'warning', + 'admonition (translation required)': 'admonition', + 'sidebar (translation required)': 'sidebar', + 'topic (translation required)': 'topic', + 'line-block (translation required)': 'line-block', + 'parsed-literal (translation required)': 'parsed-literal', + 'rubric (translation required)': 'rubric', + 'epigraph (translation required)': 'epigraph', + 'highlights (translation required)': 'highlights', + 'pull-quote (translation required)': 'pull-quote', + 'compound (translation required)': 'compound', + #'questions (translation required)': 'questions', + 'table (translation required)': 'table', + 'csv-table (translation required)': 'csv-table', + 'list-table (translation required)': 'list-table', + #'qa (translation required)': 'questions', + #'faq (translation required)': 'questions', + 'meta (translation required)': 'meta', + #'imagemap (translation required)': 'imagemap', + 'image (translation required)': 'image', + 'figure (translation required)': 'figure', + 'include (translation required)': 'include', + 'raw (translation required)': 'raw', + 'replace (translation required)': 'replace', + 'unicode (translation required)': 'unicode', + 'class (translation required)': 'class', + 'role (translation required)': 'role', + u'default-role (translation required)': 'default-role', + u'title (translation required)': 'title', + 'contents (translation required)': 'contents', + 'sectnum (translation required)': 'sectnum', + 'section-numbering (translation required)': 'sectnum', + u'header (translation required)': 'header', + u'footer (translation required)': 'footer', + #'footnotes (translation required)': 'footnotes', + #'citations (translation required)': 'citations', + 'target-notes (translation required)': 'target-notes', 'restructuredtext-test-directive': 'restructuredtext-test-directive'} """Traditional Chinese name to registered (in directives/__init__.py) directive name mapping.""" roles = { # language-dependent: fixed - 'abbreviation': 'abbreviation', - 'ab': 'abbreviation', - 'acronym': 'acronym', - 'ac': 'acronym', - 'index': 'index', - 'i': 'index', - 'subscript': 'subscript', - 'sub': 'subscript', - 'superscript': 'superscript', - 'sup': 'superscript', - 'title-reference': 'title-reference', - 'title': 'title-reference', - 't': 'title-reference', - 'pep-reference': 'pep-reference', - 'pep': 'pep-reference', - 'rfc-reference': 'rfc-reference', - 'rfc': 'rfc-reference', - 'emphasis': 'emphasis', - 'strong': 'strong', - 'literal': 'literal', - 'named-reference': 'named-reference', - 'anonymous-reference': 'anonymous-reference', - 'footnote-reference': 'footnote-reference', - 'citation-reference': 'citation-reference', - 'substitution-reference': 'substitution-reference', - 'target': 'target', - 'uri-reference': 'uri-reference', - 'uri': 'uri-reference', - 'url': 'uri-reference', - 'raw': 'raw',} + 'abbreviation (translation required)': 'abbreviation', + 'ab (translation required)': 'abbreviation', + 'acronym (translation required)': 'acronym', + 'ac (translation required)': 'acronym', + 'index (translation required)': 'index', + 'i (translation required)': 'index', + 'subscript (translation required)': 'subscript', + 'sub (translation required)': 'subscript', + 'superscript (translation required)': 'superscript', + 'sup (translation required)': 'superscript', + 'title-reference (translation required)': 'title-reference', + 'title (translation required)': 'title-reference', + 't (translation required)': 'title-reference', + 'pep-reference (translation required)': 'pep-reference', + 'pep (translation required)': 'pep-reference', + 'rfc-reference (translation required)': 'rfc-reference', + 'rfc (translation required)': 'rfc-reference', + 'emphasis (translation required)': 'emphasis', + 'strong (translation required)': 'strong', + 'literal (translation required)': 'literal', + 'named-reference (translation required)': 'named-reference', + 'anonymous-reference (translation required)': 'anonymous-reference', + 'footnote-reference (translation required)': 'footnote-reference', + 'citation-reference (translation required)': 'citation-reference', + 'substitution-reference (translation required)': 'substitution-reference', + 'target (translation required)': 'target', + 'uri-reference (translation required)': 'uri-reference', + 'uri (translation required)': 'uri-reference', + 'url (translation required)': 'uri-reference', + 'raw (translation required)': 'raw',} """Mapping of Traditional Chinese role names to canonical role names for interpreted text.""" -- cgit v1.2.1 From faf70308e43beacc515f5ab14afab0dd1c4af888 Mon Sep 17 00:00:00 2001 From: lele Date: Sun, 14 Aug 2005 19:24:03 +0000 Subject: Italian translation of newest directives git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3803 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/it.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index e28f3ec00..de5e32d8b 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -53,15 +53,15 @@ directives = { 'unicode': 'unicode', 'classe': 'class', 'ruolo': 'role', - u'default-role (translation required)': 'default-role', - 'title (translation required)': 'title', + 'ruolo-predefinito': 'default-role', + 'titolo': 'title', 'indice': 'contents', 'contenuti': 'contents', 'seznum': 'sectnum', 'sezioni-autonumerate': 'sectnum', 'annota-riferimenti-esterni': 'target-notes', - u'header (translation required)': 'header', - u'footer (translation required)': 'footer', + 'intestazione': 'header', + 'piede-pagina': 'footer', #'footnotes': 'footnotes', #'citations': 'citations', 'restructuredtext-test-directive': 'restructuredtext-test-directive'} -- cgit v1.2.1 From 03f113d5425662822ddb565d627b9c6b39e25aab Mon Sep 17 00:00:00 2001 From: wiemann Date: Wed, 17 Aug 2005 13:32:03 +0000 Subject: removed superfluous error message git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3813 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index dadd08e65..0bfb6abd6 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -181,9 +181,7 @@ def directive(directive_name, language_module, document): try: modulename, functionname = _directive_registry[canonicalname] except KeyError: - messages.append(document.reporter.error( - 'Directive "%s" not registered (canonical name "%s").' - % (directive_name, canonicalname), line=document.current_line)) + # Error handling done by caller. return None, messages if _modules.has_key(modulename): module = _modules[modulename] -- cgit v1.2.1 From 090741b70591dc6209c48d4147167b6d88c578c7 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 24 Aug 2005 00:05:38 +0000 Subject: fixed bug with "image" directive "target" option git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3828 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index ef77c2bef..1c9c50e26 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -14,7 +14,7 @@ __docformat__ = 'reStructuredText' import sys from docutils import nodes, utils from docutils.parsers.rst import directives, states -from docutils.nodes import fully_normalize_name +from docutils.nodes import fully_normalize_name, whitespace_normalize_name from docutils.parsers.rst.roles import set_classes try: @@ -60,8 +60,9 @@ def image(name, arguments, options, content, lineno, if target_type == 'refuri': reference_node = nodes.reference(refuri=data) elif target_type == 'refname': - reference_node = nodes.reference(refname=data, - name=fully_normalize_name(options['target'])) + reference_node = nodes.reference( + refname=fully_normalize_name(data), + name=whitespace_normalize_name(data)) state.document.note_refname(reference_node) else: # malformed target messages.append(data) # data is a system message -- cgit v1.2.1 From b67ead9a20e534e7bb5fac07d62a8738ea8e5f46 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 26 Aug 2005 03:14:19 +0000 Subject: catch unescaped colon at end of hyperlink targets git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3833 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 1 + 1 file changed, 1 insertion(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 175334fd2..06077cfca 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1723,6 +1723,7 @@ class Body(RSTState): %(non_whitespace_escape_before)s (?P=quote) # close quote if open quote used ) + (? Date: Fri, 26 Aug 2005 13:10:47 +0000 Subject: catch another case of malformed hyperlink target git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3834 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 06077cfca..d72a96e0c 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1723,7 +1723,7 @@ class Body(RSTState): %(non_whitespace_escape_before)s (?P=quote) # close quote if open quote used ) - (? Date: Sat, 3 Sep 2005 02:59:53 +0000 Subject: removed 1-argument use of ``setdefault``, slated to be removed from Python git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3845 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index 1c9c50e26..8dc94af96 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -89,12 +89,15 @@ def figure_align(argument): def figure(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): - figwidth = options.setdefault('figwidth') - figclasses = options.setdefault('figclass') - align = options.setdefault('align') - del options['figwidth'] - del options['figclass'] - del options['align'] + figwidth = options.get('figwidth') + if figwidth: + del options['figwidth'] + figclasses = options.get('figclass') + if figclasses: + del options['figclass'] + align = options.get('align') + if align: + del options['align'] (image_node,) = image(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine) if isinstance(image_node, nodes.system_message): -- cgit v1.2.1 From f80815602799ff058440771456e212325fd6d2f6 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 24 Sep 2005 15:11:20 +0000 Subject: added clarifying comment; thanks to Anthony Baxter for pointing this out git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3900 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/tables.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/tables.py b/docutils/parsers/rst/directives/tables.py index dadcdae68..70a0de5ab 100644 --- a/docutils/parsers/rst/directives/tables.py +++ b/docutils/parsers/rst/directives/tables.py @@ -392,6 +392,9 @@ def check_list_content(node, name, options, content, lineno, block_text, nodes.literal_block(block_text, block_text), line=lineno) raise SystemMessagePropagation(error) elif item_index: + # ATTN pychecker users: num_cols is guaranteed to be set in the + # "else" clause below for item_index==0, before this branch is + # triggered. if len(item[0]) != num_cols: error = state_machine.reporter.error( 'Error parsing content block for the "%s" directive: ' -- cgit v1.2.1 From 1515f34b2893338ee40861fbcb102d695db2cba4 Mon Sep 17 00:00:00 2001 From: wiemann Date: Mon, 26 Sep 2005 17:54:39 +0000 Subject: moved pruning docutils.conf up the tree so that template.txt isn't processed by buildhtml.py git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3904 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/include/docutils.conf | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 docutils/parsers/rst/include/docutils.conf (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/include/docutils.conf b/docutils/parsers/rst/include/docutils.conf deleted file mode 100644 index cdce8d629..000000000 --- a/docutils/parsers/rst/include/docutils.conf +++ /dev/null @@ -1,5 +0,0 @@ -# This configuration file is to prevent tools/buildhtml.py from -# processing text files in and below this directory. - -[buildhtml application] -prune: . -- cgit v1.2.1 From 4c16652c99cfc1ba8ec7dd2697d606972a98e952 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 29 Sep 2005 13:10:07 +0000 Subject: Added support for "class" directive content. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3912 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/misc.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 71c097b33..0eec557b5 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -256,8 +256,9 @@ unicode_comment_pattern = re.compile(r'( |\n|^)\.\. ') def class_directive(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): """ - Set a "class" attribute on the next element. - A "pending" element is inserted, and a transform does the work later. + Set a "class" attribute on the directive content or the next element. + When applied to the next element, a "pending" element is inserted, and a + transform does the work later. """ try: class_value = directives.class_option(arguments[0]) @@ -267,11 +268,20 @@ def class_directive(name, arguments, options, content, lineno, % (name, arguments[0]), nodes.literal_block(block_text, block_text), line=lineno) return [error] - pending = nodes.pending(misc.ClassAttribute, - {'class': class_value, 'directive': name}, - block_text) - state_machine.document.note_pending(pending) - return [pending] + node_list = [] + if content: + container = nodes.Element() + state.nested_parse(content, content_offset, container) + for node in container: + node['classes'].extend(class_value) + node_list.extend(container.children) + else: + pending = nodes.pending(misc.ClassAttribute, + {'class': class_value, 'directive': name}, + block_text) + state_machine.document.note_pending(pending) + node_list.append(pending) + return node_list class_directive.arguments = (1, 0, 1) class_directive.content = 1 -- cgit v1.2.1 From 8caecfa4637c4690054d994722b629f5dba32721 Mon Sep 17 00:00:00 2001 From: wiemann Date: Tue, 11 Oct 2005 17:51:38 +0000 Subject: disallow targets inside substitution definitions git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3933 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 53 ++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 23 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index d72a96e0c..e9fa14d40 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1910,34 +1910,41 @@ class Body(RSTState): subname = subdefmatch.group('name') substitution_node = nodes.substitution_definition(blocktext) substitution_node.line = lineno - self.document.note_substitution_def( - substitution_node,subname, self.parent) - if block: - block[0] = block[0].strip() - new_abs_offset, blank_finish = self.nested_list_parse( - block, input_offset=offset, node=substitution_node, - initial_state='SubstitutionDef', blank_finish=blank_finish) - i = 0 - for node in substitution_node[:]: - if not (isinstance(node, nodes.Inline) or - isinstance(node, nodes.Text)): - self.parent += substitution_node[i] - del substitution_node[i] - else: - i += 1 - if len(substitution_node) == 0: + if not block: + msg = self.reporter.warning( + 'Substitution definition "%s" missing contents.' % subname, + nodes.literal_block(blocktext, blocktext), line=lineno) + return [msg], blank_finish + block[0] = block[0].strip() + substitution_node['names'].append( + nodes.whitespace_normalize_name(subname)) + new_abs_offset, blank_finish = self.nested_list_parse( + block, input_offset=offset, node=substitution_node, + initial_state='SubstitutionDef', blank_finish=blank_finish) + i = 0 + for node in substitution_node[:]: + if not (isinstance(node, nodes.Inline) or + isinstance(node, nodes.Text)): + self.parent += substitution_node[i] + del substitution_node[i] + else: + i += 1 + for node in substitution_node.traverse(nodes.Element): + if node['ids']: msg = self.reporter.warning( - 'Substitution definition "%s" empty or invalid.' - % subname, - nodes.literal_block(blocktext, blocktext), line=lineno) + 'Substitution definitions may not contain targets.', + nodes.literal_block(blocktext, blocktext), + line=lineno) return [msg], blank_finish - else: - return [substitution_node], blank_finish - else: + if len(substitution_node) == 0: msg = self.reporter.warning( - 'Substitution definition "%s" missing contents.' % subname, + 'Substitution definition "%s" empty or invalid.' + % subname, nodes.literal_block(blocktext, blocktext), line=lineno) return [msg], blank_finish + self.document.note_substitution_def( + substitution_node, subname, self.parent) + return [substitution_node], blank_finish def directive(self, match, **option_presets): """Returns a 2-tuple: list of nodes, and a "blank finish" boolean.""" -- cgit v1.2.1 From 7068fae26ee297f883adf5f884fd64b0892b2a70 Mon Sep 17 00:00:00 2001 From: wiemann Date: Tue, 11 Oct 2005 20:40:41 +0000 Subject: disallow anonymous hyperlink references and auto-numbered footnotes inside of substitution definitions git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3937 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index e9fa14d40..db19c34b6 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1930,10 +1930,11 @@ class Body(RSTState): else: i += 1 for node in substitution_node.traverse(nodes.Element): - if node['ids']: - msg = self.reporter.warning( - 'Substitution definitions may not contain targets.', - nodes.literal_block(blocktext, blocktext), + if self.disallowed_inside_substitution_definitions(node): + pformat = nodes.literal_block('', node.pformat().rstrip()) + msg = self.reporter.error( + 'Substitution definition contains illegal element:', + pformat, nodes.literal_block(blocktext, blocktext), line=lineno) return [msg], blank_finish if len(substitution_node) == 0: @@ -1946,6 +1947,14 @@ class Body(RSTState): substitution_node, subname, self.parent) return [substitution_node], blank_finish + def disallowed_inside_substitution_definitions(self, node): + if (node['ids'] or + isinstance(node, nodes.reference) and node.get('anonymous') or + isinstance(node, nodes.footnote_reference) and node.get('auto')): + return 1 + else: + return 0 + def directive(self, match, **option_presets): """Returns a 2-tuple: list of nodes, and a "blank finish" boolean.""" type_name = match.group(1) -- cgit v1.2.1 From c6e1fdb5efb32575f69e1c0c68cb6715ac896a85 Mon Sep 17 00:00:00 2001 From: wiemann Date: Tue, 11 Oct 2005 21:36:06 +0000 Subject: removed more internal state (`document.anonymous_refs` and `document.anonymous_targets`) git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3939 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 4 ---- 1 file changed, 4 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index db19c34b6..be064db8a 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -783,7 +783,6 @@ class Inliner: reference['refuri'] = uri else: reference['anonymous'] = 1 - self.document.note_anonymous_ref(reference) else: if target: reference['refuri'] = uri @@ -846,8 +845,6 @@ class Inliner: '|%s%s' % (subref_text, endstring), '') if endstring[-2:] == '__': reference_node['anonymous'] = 1 - self.document.note_anonymous_ref( - reference_node) else: reference_node['refname'] = normalize_name(subref_text) self.document.note_refname(reference_node) @@ -898,7 +895,6 @@ class Inliner: name=whitespace_normalize_name(referencename)) if anonymous: referencenode['anonymous'] = 1 - self.document.note_anonymous_ref(referencenode) else: referencenode['refname'] = refname self.document.note_refname(referencenode) -- cgit v1.2.1 From 5eaa35732246484d010b80d2848eba8cd77158d8 Mon Sep 17 00:00:00 2001 From: goodger Date: Fri, 28 Oct 2005 16:12:56 +0000 Subject: added the "container" element & directive, a generic container git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3963 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 1 + docutils/parsers/rst/directives/body.py | 27 +++++++++++++++++++++++++++ docutils/parsers/rst/languages/af.py | 1 + docutils/parsers/rst/languages/ca.py | 1 + docutils/parsers/rst/languages/cs.py | 1 + docutils/parsers/rst/languages/de.py | 1 + docutils/parsers/rst/languages/en.py | 1 + docutils/parsers/rst/languages/eo.py | 1 + docutils/parsers/rst/languages/es.py | 1 + docutils/parsers/rst/languages/fi.py | 1 + docutils/parsers/rst/languages/fr.py | 3 ++- docutils/parsers/rst/languages/it.py | 1 + docutils/parsers/rst/languages/nl.py | 1 + docutils/parsers/rst/languages/pt_br.py | 1 + docutils/parsers/rst/languages/ru.py | 1 + docutils/parsers/rst/languages/sk.py | 1 + docutils/parsers/rst/languages/sv.py | 1 + docutils/parsers/rst/languages/zh_tw.py | 1 + 18 files changed, 45 insertions(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 0bfb6abd6..1a7e680e0 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -110,6 +110,7 @@ _directive_registry = { 'highlights': ('body', 'highlights'), 'pull-quote': ('body', 'pull_quote'), 'compound': ('body', 'compound'), + 'container': ('body', 'container'), #'questions': ('body', 'question_list'), 'table': ('tables', 'table'), 'csv-table': ('tables', 'csv_table'), diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py index 28682328a..2ff89e617 100644 --- a/docutils/parsers/rst/directives/body.py +++ b/docutils/parsers/rst/directives/body.py @@ -167,3 +167,30 @@ def compound(name, arguments, options, content, lineno, compound.options = {'class': directives.class_option} compound.content = 1 + +def container(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + text = '\n'.join(content) + if not text: + error = state_machine.reporter.error( + 'The "%s" directive is empty; content required.' % name, + nodes.literal_block(block_text, block_text), line=lineno) + return [error] + try: + if arguments: + classes = directives.class_option(arguments[0]) + else: + classes = [] + except ValueError: + error = state_machine.reporter.error( + 'Invalid class attribute value for "%s" directive: "%s".' + % (name, arguments[0]), + nodes.literal_block(block_text, block_text), line=lineno) + return [error] + node = nodes.container(text) + node['classes'].extend(classes) + state.nested_parse(content, content_offset, node) + return [node] + +container.arguments = (0, 1, 1) +container.content = 1 diff --git a/docutils/parsers/rst/languages/af.py b/docutils/parsers/rst/languages/af.py index e8fa9cbb8..c9c636044 100644 --- a/docutils/parsers/rst/languages/af.py +++ b/docutils/parsers/rst/languages/af.py @@ -37,6 +37,7 @@ directives = { 'hoogtepunte': 'highlights', 'pull-quote (translation required)': 'pull-quote', u'compound (translation required)': 'compound', + u'container (translation required)': 'container', #'vrae': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/ca.py b/docutils/parsers/rst/languages/ca.py index d534ecfbc..dbee8c267 100644 --- a/docutils/parsers/rst/languages/ca.py +++ b/docutils/parsers/rst/languages/ca.py @@ -40,6 +40,7 @@ directives = { u'sumari': 'highlights', u'cita-destacada': 'pull-quote', u'compost': 'compound', + u'container (translation required)': 'container', #'questions': 'questions', u'taula': 'table', u'taula-csv': 'csv-table', diff --git a/docutils/parsers/rst/languages/cs.py b/docutils/parsers/rst/languages/cs.py index cf3fbf132..80614fe99 100644 --- a/docutils/parsers/rst/languages/cs.py +++ b/docutils/parsers/rst/languages/cs.py @@ -38,6 +38,7 @@ directives = { u'highlights (translation required)': 'highlights', u'pull-quote (translation required)': 'pull-quote', u'compound (translation required)': 'compound', + u'container (translation required)': 'container', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index 7bf72c149..ab32eedac 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -39,6 +39,7 @@ directives = { 'pull-quote (translation required)': 'pull-quote', # kasten too ? 'zusammengesetzt': 'compound', 'verbund': 'compound', + u'container (translation required)': 'container', #'fragen': 'questions', 'tabelle': 'table', 'csv-tabelle': 'csv-table', diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index 2c9e78737..a38f08342 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -38,6 +38,7 @@ directives = { 'highlights': 'highlights', 'pull-quote': 'pull-quote', 'compound': 'compound', + 'container': 'container', #'questions': 'questions', 'table': 'table', 'csv-table': 'csv-table', diff --git a/docutils/parsers/rst/languages/eo.py b/docutils/parsers/rst/languages/eo.py index 316b98e03..c25b8da25 100644 --- a/docutils/parsers/rst/languages/eo.py +++ b/docutils/parsers/rst/languages/eo.py @@ -42,6 +42,7 @@ directives = { u'ekstera-cita\u0135o': 'pull-quote', u'kombinajxo': 'compound', u'kombina\u0135o': 'compound', + u'container (translation required)': 'container', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index d2f650b14..ad7b6c8af 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -44,6 +44,7 @@ directives = { u'cita-destacada': 'pull-quote', u'combinacion': 'compound', u'combinaci\u00f3n': 'compound', + u'container (translation required)': 'container', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/fi.py b/docutils/parsers/rst/languages/fi.py index bf175081e..c36b37615 100644 --- a/docutils/parsers/rst/languages/fi.py +++ b/docutils/parsers/rst/languages/fi.py @@ -41,6 +41,7 @@ directives = { u'csv-taulukko': u'csv-table', u'list-table (translation required)': 'list-table', u'compound (translation required)': 'compound', + u'container (translation required)': 'container', #u'kysymykset': u'questions', u'meta': u'meta', #u'kuvakartta': u'imagemap', diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index b75cad50b..8324da3fe 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -39,6 +39,7 @@ directives = { u'chapeau': 'highlights', u'accroche': 'pull-quote', u'compound (translation required)': 'compound', + u'container (translation required)': 'container', #u'questions': 'questions', #u'qr': 'questions', #u'faq': 'questions', @@ -57,7 +58,7 @@ directives = { u'classe': 'class', u'role (translation required)': 'role', u'default-role (translation required)': 'default-role', - u'title (translation required)': 'title', + u'titre (translation required)': 'title', u'sommaire': 'contents', u'table-des-mati\u00E8res': 'contents', u'sectnum': 'sectnum', diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index de5e32d8b..e5cc9a3ac 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -37,6 +37,7 @@ directives = { 'punti-salienti': 'highlights', 'estratto-evidenziato': 'pull-quote', 'composito': 'compound', + u'container (translation required)': 'container', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/nl.py b/docutils/parsers/rst/languages/nl.py index 7ade5d721..a5d256464 100644 --- a/docutils/parsers/rst/languages/nl.py +++ b/docutils/parsers/rst/languages/nl.py @@ -39,6 +39,7 @@ directives = { 'pull-quote': 'pull-quote', # Dutch printers use the english term 'samenstelling': 'compound', 'verbinding': 'compound', + u'container (translation required)': 'container', #'vragen': 'questions', 'tabel': 'table', 'csv-tabel': 'csv-table', diff --git a/docutils/parsers/rst/languages/pt_br.py b/docutils/parsers/rst/languages/pt_br.py index ba02538fd..9eeb23820 100644 --- a/docutils/parsers/rst/languages/pt_br.py +++ b/docutils/parsers/rst/languages/pt_br.py @@ -38,6 +38,7 @@ directives = { 'destaques': 'highlights', u'cita\u00E7\u00E3o-destacada': 'pull-quote', u'compound (translation required)': 'compound', + u'container (translation required)': 'container', #'perguntas': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/ru.py b/docutils/parsers/rst/languages/ru.py index 61a8f2297..db1eb8617 100644 --- a/docutils/parsers/rst/languages/ru.py +++ b/docutils/parsers/rst/languages/ru.py @@ -24,6 +24,7 @@ directives = { u'\u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u0430\u044f-\u0446\u0438\u0442\u0430\u0442\u0430': u'pull-quote', u'compound (translation required)': 'compound', + u'container (translation required)': 'container', u'table (translation required)': 'table', u'csv-table (translation required)': 'csv-table', u'list-table (translation required)': 'list-table', diff --git a/docutils/parsers/rst/languages/sk.py b/docutils/parsers/rst/languages/sk.py index b47e6228d..f92ffedf1 100644 --- a/docutils/parsers/rst/languages/sk.py +++ b/docutils/parsers/rst/languages/sk.py @@ -37,6 +37,7 @@ directives = { u'highlights (translation required)': 'highlights', u'pull-quote (translation required)': 'pull-quote', u'compound (translation required)': 'compound', + u'container (translation required)': 'container', #u'questions': 'questions', #u'qa': 'questions', #u'faq': 'questions', diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index 11697ec55..bbf749e30 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -36,6 +36,7 @@ directives = { u'highlights (translation required)': 'highlights', u'pull-quote (translation required)': 'pull-quote', u'compound (translation required)': 'compound', + u'container (translation required)': 'container', # u'fr\u00e5gor': 'questions', # NOTE: A bit long, but recommended by http://www.nada.kth.se/dataterm/: # u'fr\u00e5gor-och-svar': 'questions', diff --git a/docutils/parsers/rst/languages/zh_tw.py b/docutils/parsers/rst/languages/zh_tw.py index 664aaf6ea..b1b83f5a1 100644 --- a/docutils/parsers/rst/languages/zh_tw.py +++ b/docutils/parsers/rst/languages/zh_tw.py @@ -38,6 +38,7 @@ directives = { 'highlights (translation required)': 'highlights', 'pull-quote (translation required)': 'pull-quote', 'compound (translation required)': 'compound', + u'container (translation required)': 'container', #'questions (translation required)': 'questions', 'table (translation required)': 'table', 'csv-table (translation required)': 'csv-table', -- cgit v1.2.1 From d92350b57c08a3f642a8a2e6147eb999769180f7 Mon Sep 17 00:00:00 2001 From: wiemann Date: Sat, 29 Oct 2005 12:28:44 +0000 Subject: converted latin1 files to utf8; removed unnecessary -*- coding -*- tags; made some source files ASCII only git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3968 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/es.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index ad7b6c8af..bdbc8c188 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -1,5 +1,5 @@ -# -*- coding: iso-8859-1 -*- -# Author: Marcelo Huerta San Martín +# -*- coding: utf-8 -*- +# Author: Marcelo Huerta San Martín # Contact: richieadler@users.sourceforge.net # Revision: $Revision$ # Date: $Date$ -- cgit v1.2.1 From 906d3ce3a4f095cc123758ae8c31dbb4d4fa59c6 Mon Sep 17 00:00:00 2001 From: wiemann Date: Thu, 17 Nov 2005 19:31:47 +0000 Subject: add zh_cn (simplified Chinese) language mappings; thanks to Panjunyong! git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@4062 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/zh_cn.py | 108 ++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 docutils/parsers/rst/languages/zh_cn.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/zh_cn.py b/docutils/parsers/rst/languages/zh_cn.py new file mode 100644 index 000000000..a8cf20f29 --- /dev/null +++ b/docutils/parsers/rst/languages/zh_cn.py @@ -0,0 +1,108 @@ +# -*- coding: utf-8 -*- +# Author: Panjunyong +# Contact: panjy@zopechina.com +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +# New language mappings are welcome. Before doing a new translation, please +# read . Two files must be +# translated for each language: one in docutils/languages, the other in +# docutils/parsers/rst/languages. + +""" +Simplified Chinese language mappings for language-dependent features of +reStructuredText. +""" + +__docformat__ = 'reStructuredText' + + +directives = { + # language-dependent: fixed + '注æ„': 'attention', + 'å°å¿ƒ': 'caution', + 'å±é™©': 'danger', + '错误': 'error', + 'æç¤º': 'hint', + 'é‡è¦': 'important', + '注解': 'note', + '技巧': 'tip', + '警告': 'warning', + '忠告': 'admonition', + '侧框': 'sidebar', + '主题': 'topic', + 'line-block (translation required)': 'line-block', + 'parsed-literal (translation required)': 'parsed-literal', + '醒目': 'rubric', + 'é“­æ–‡': 'epigraph', + 'è¦ç‚¹': 'highlights', + 'pull-quote (translation required)': 'pull-quote', + 'å¤åˆ': 'compound', + '容器': 'container', + #'questions (translation required)': 'questions', + '表格': 'table', + 'csv表格': 'csv-table', + '列表表格': 'list-table', + #'qa (translation required)': 'questions', + #'faq (translation required)': 'questions', + '元数æ®': 'meta', + #'imagemap (translation required)': 'imagemap', + '图象': 'image', + '图例': 'figure', + '包å«': 'include', + '原文': 'raw', + '代替': 'replace', + '统一ç ': 'unicode', + '类型': 'class', + '角色': 'role', + '默认角色': 'default-role', + '标题': 'title', + '目录': 'contents', + '章节åºå·': 'sectnum', + '题头': 'header', + '页脚': 'footer', + #'footnotes (translation required)': 'footnotes', + #'citations (translation required)': 'citations', + 'target-notes (translation required)': 'target-notes', + 'restructuredtext-test-directive': 'restructuredtext-test-directive'} +"""Traditional Chinese name to registered (in directives/__init__.py) +directive name mapping.""" + +roles = { + # language-dependent: fixed + '缩写': 'abbreviation', + '简称': 'acronym', + 'index (translation required)': 'index', + 'i (translation required)': 'index', + '下标': 'subscript', + '上标': 'superscript', + 'title-reference (translation required)': 'title-reference', + 'title (translation required)': 'title-reference', + 't (translation required)': 'title-reference', + 'pep-reference (translation required)': 'pep-reference', + 'pep (translation required)': 'pep-reference', + 'rfc-reference (translation required)': 'rfc-reference', + 'rfc (translation required)': 'rfc-reference', + '强调': 'emphasis', + '加粗': 'strong', + 'å­—é¢': 'literal', + 'named-reference (translation required)': 'named-reference', + 'anonymous-reference (translation required)': 'anonymous-reference', + 'footnote-reference (translation required)': 'footnote-reference', + 'citation-reference (translation required)': 'citation-reference', + 'substitution-reference (translation required)': 'substitution-reference', + 'target (translation required)': 'target', + 'uri-reference (translation required)': 'uri-reference', + 'uri (translation required)': 'uri-reference', + 'url (translation required)': 'uri-reference', + 'raw (translation required)': 'raw',} +"""Mapping of Traditional Chinese role names to canonical role names for +interpreted text.""" + +# Decode UTF-8 strings. (We cannot use unicode literals directly for +# Python 2.1 compatibility.) +for mapping in directives, roles: + for key, value in mapping.items(): + del mapping[key] + mapping[unicode(key, 'utf8')] = unicode(value, 'utf8') -- cgit v1.2.1 From 1f68707289264e7fd291feda677af3a85d37fc04 Mon Sep 17 00:00:00 2001 From: wiemann Date: Thu, 17 Nov 2005 20:12:33 +0000 Subject: replaced "traditional" with "simplified" git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@4064 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/zh_cn.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/zh_cn.py b/docutils/parsers/rst/languages/zh_cn.py index a8cf20f29..2d3a4679b 100644 --- a/docutils/parsers/rst/languages/zh_cn.py +++ b/docutils/parsers/rst/languages/zh_cn.py @@ -66,7 +66,7 @@ directives = { #'citations (translation required)': 'citations', 'target-notes (translation required)': 'target-notes', 'restructuredtext-test-directive': 'restructuredtext-test-directive'} -"""Traditional Chinese name to registered (in directives/__init__.py) +"""Simplified Chinese name to registered (in directives/__init__.py) directive name mapping.""" roles = { @@ -97,8 +97,8 @@ roles = { 'uri (translation required)': 'uri-reference', 'url (translation required)': 'uri-reference', 'raw (translation required)': 'raw',} -"""Mapping of Traditional Chinese role names to canonical role names for -interpreted text.""" +"""Mapping of Simplified Chinese role names to canonical role names +for interpreted text.""" # Decode UTF-8 strings. (We cannot use unicode literals directly for # Python 2.1 compatibility.) -- cgit v1.2.1 From 418442c57a552004a711983f75abebd8e3ec9da7 Mon Sep 17 00:00:00 2001 From: wiemann Date: Thu, 17 Nov 2005 20:32:29 +0000 Subject: added Japanese language files; thanks Hisashi Morita! git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@4065 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/ja.py | 104 +++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 docutils/parsers/rst/languages/ja.py (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/ja.py b/docutils/parsers/rst/languages/ja.py new file mode 100644 index 000000000..8131d94f9 --- /dev/null +++ b/docutils/parsers/rst/languages/ja.py @@ -0,0 +1,104 @@ +# Author: David Goodger +# Contact: goodger@users.sourceforge.net +# Revision: $Revision$ +# Date: $Date$ +# Copyright: This module has been placed in the public domain. + +# New language mappings are welcome. Before doing a new translation, please +# read . Two files must be +# translated for each language: one in docutils/languages, the other in +# docutils/parsers/rst/languages. + +""" +Japanese-language mappings for language-dependent features of +reStructuredText. +""" + +__docformat__ = 'reStructuredText' + + +directives = { + # language-dependent: fixed + 'attention (translation required)': 'attention', + 'caution (translation required)': 'caution', + 'danger (translation required)': 'danger', + 'error (translation required)': 'error', + 'hint (translation required)': 'hint', + 'important (translation required)': 'important', + 'note (translation required)': 'note', + 'tip (translation required)': 'tip', + 'warning (translation required)': 'warning', + 'admonition (translation required)': 'admonition', + 'sidebar (translation required)': 'sidebar', + 'topic (translation required)': 'topic', + 'line-block (translation required)': 'line-block', + 'parsed-literal (translation required)': 'parsed-literal', + 'rubric (translation required)': 'rubric', + 'epigraph (translation required)': 'epigraph', + 'highlights (translation required)': 'highlights', + 'pull-quote (translation required)': 'pull-quote', + 'compound (translation required)': 'compound', + 'container (translation required)': 'container', + #'questions (translation required)': 'questions', + 'table (translation required)': 'table', + 'csv-table (translation required)': 'csv-table', + 'list-table (translation required)': 'list-table', + #'qa (translation required)': 'questions', + #'faq (translation required)': 'questions', + 'meta (translation required)': 'meta', + #'imagemap (translation required)': 'imagemap', + 'image (translation required)': 'image', + 'figure (translation required)': 'figure', + 'include (translation required)': 'include', + 'raw (translation required)': 'raw', + 'replace (translation required)': 'replace', + 'unicode (translation required)': 'unicode', + 'class (translation required)': 'class', + 'role (translation required)': 'role', + 'default-role (translation required)': 'default-role', + 'title (translation required)': 'title', + 'contents (translation required)': 'contents', + 'sectnum (translation required)': 'sectnum', + 'section-numbering (translation required)': 'sectnum', + 'header (translation required)': 'header', + 'footer (translation required)': 'footer', + #'footnotes (translation required)': 'footnotes', + #'citations (translation required)': 'citations', + 'target-notes (translation required)': 'target-notes',} +"""Japanese name to registered (in directives/__init__.py) directive name +mapping.""" + +roles = { + # language-dependent: fixed + 'abbreviation (translation required)': 'abbreviation', + 'ab (translation required)': 'abbreviation', + 'acronym (translation required)': 'acronym', + 'ac (translation required)': 'acronym', + 'index (translation required)': 'index', + 'i (translation required)': 'index', + 'subscript (translation required)': 'subscript', + 'sub (translation required)': 'subscript', + 'superscript (translation required)': 'superscript', + 'sup (translation required)': 'superscript', + 'title-reference (translation required)': 'title-reference', + 'title (translation required)': 'title-reference', + 't (translation required)': 'title-reference', + 'pep-reference (translation required)': 'pep-reference', + 'pep (translation required)': 'pep-reference', + 'rfc-reference (translation required)': 'rfc-reference', + 'rfc (translation required)': 'rfc-reference', + 'emphasis (translation required)': 'emphasis', + 'strong (translation required)': 'strong', + 'literal (translation required)': 'literal', + 'named-reference (translation required)': 'named-reference', + 'anonymous-reference (translation required)': 'anonymous-reference', + 'footnote-reference (translation required)': 'footnote-reference', + 'citation-reference (translation required)': 'citation-reference', + 'substitution-reference (translation required)': 'substitution-reference', + 'target (translation required)': 'target', + 'uri-reference (translation required)': 'uri-reference', + 'uri (translation required)': 'uri-reference', + 'url (translation required)': 'uri-reference', + 'raw (translation required)': 'raw',} +"""Mapping of Japanese role names to canonical role names for interpreted +text.""" -- cgit v1.2.1 From ced6843a40a4b84b50b10c1106edfe80e088fbaa Mon Sep 17 00:00:00 2001 From: wiemann Date: Sat, 19 Nov 2005 23:48:04 +0000 Subject: allow escaped colons inside of fields git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@4083 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index be064db8a..3a9c49094 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1054,7 +1054,7 @@ class Body(RSTState): patterns = { 'bullet': r'[-+*]( +|$)', 'enumerator': r'(%(parens)s|%(rparen)s|%(period)s)( +|$)' % pats, - 'field_marker': r':[^: ]([^:]*[^: ])?:( +|$)', + 'field_marker': r':(?![: ])([^:\\]|\\.)*(?>>( +|$)', 'line_block': r'\|( +|$)', @@ -1367,8 +1367,8 @@ class Body(RSTState): def parse_field_marker(self, match): """Extract & return field name from a field marker match.""" - field = match.string[1:] # strip off leading ':' - field = field[:field.find(':')] # strip off trailing ':' etc. + field = match.group()[1:] # strip off leading ':' + field = field[:field.rfind(':')] # strip off trailing ':' etc. return field def parse_field_body(self, indented, offset, node): -- cgit v1.2.1 From 2ee75a675d5c74d75b587b2d28de459436ac25e6 Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 6 Dec 2005 01:06:33 +0000 Subject: Fixed bugs: list items with blank first lines; block quote attributions with indented second lines. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@4147 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 3a9c49094..b149c1888 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1114,6 +1114,7 @@ class Body(RSTState): Return a 3-tuple: (block quote lines, attribution lines, attribution offset). """ + #import pdb ; pdb.set_trace() blank = None nonblank_seen = None indent = 0 @@ -1130,8 +1131,10 @@ class Body(RSTState): indent = (len(indented[blank + 2]) - len(indented[blank + 2].lstrip())) for j in range(blank + 3, len(indented)): - if indent != (len(indented[j]) - - len(indented[j].lstrip())): # bad shape + if ( indented[j] # may be blank last line + and indent != (len(indented[j]) + - len(indented[j].lstrip()))): + # bad shape blank = None break if blank: @@ -1169,8 +1172,12 @@ class Body(RSTState): return [], next_state, [] def list_item(self, indent): - indented, line_offset, blank_finish = \ - self.state_machine.get_known_indented(indent) + if self.state_machine.line[indent:]: + indented, line_offset, blank_finish = ( + self.state_machine.get_known_indented(indent)) + else: + indented, indent, line_offset, blank_finish = ( + self.state_machine.get_first_known_indented(indent)) listitem = nodes.list_item('\n'.join(indented)) if indented: self.nested_parse(indented, input_offset=line_offset, -- cgit v1.2.1 From e571eb6f3616063e8cc1096b3451aa6f3e659858 Mon Sep 17 00:00:00 2001 From: goodger Date: Wed, 7 Dec 2005 23:46:30 +0000 Subject: added East Asian double-width character support; thanks to Frank Bennett for inspiration on ``docutils.utils.east_asian_column_width()`` git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@4152 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 14 +++++++++++--- docutils/parsers/rst/tableparser.py | 5 +++++ 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index b149c1888..66c4393b8 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -114,7 +114,7 @@ from docutils import ApplicationError, DataError from docutils.statemachine import StateMachineWS, StateWS from docutils.nodes import fully_normalize_name as normalize_name from docutils.nodes import whitespace_normalize_name -from docutils.utils import escape2null, unescape +from docutils.utils import escape2null, unescape, column_width from docutils.parsers.rst import directives, languages, tableparser, roles from docutils.parsers.rst.languages import en as _fallback_language_module @@ -995,6 +995,9 @@ class Body(RSTState): Generic classifier of the first line of a block. """ + double_width_pad_char = tableparser.TableParser.double_width_pad_char + """Padding character for East Asian double-width text.""" + enum = Struct() """Enumerated list parsing information.""" @@ -1592,6 +1595,8 @@ class Body(RSTState): source=source, line=lineno)) blank_finish = 0 block.disconnect() + # for East Asian chars: + block.pad_double_width(self.double_width_pad_char) width = len(block[0].strip()) for i in range(len(block)): block[i] = block[i].strip() @@ -1656,9 +1661,12 @@ class Body(RSTState): return [], messages, not extra self.state_machine.next_line(end - start) block = lines[start:end+1] + # for East Asian chars: + block.pad_double_width(self.double_width_pad_char) return block, [], end == limit or not lines[end+1].strip() def malformed_table(self, block, detail=''): + block.replace(self.double_width_pad_char, '') data = '\n'.join(block) message = 'Malformed table.' lineno = self.state_machine.abs_line_number() - len(block) + 1 @@ -2586,7 +2594,7 @@ class Text(RSTState): underline = match.string.rstrip() source = title + '\n' + underline messages = [] - if len(title) > len(underline): + if column_width(title) > len(underline): if len(underline) < 4: if self.state_machine.match_titles: msg = self.reporter.info( @@ -2825,7 +2833,7 @@ class Line(SpecializedText): return [], 'Body', [] title = title.rstrip() messages = [] - if len(title) > len(overline): + if column_width(title) > len(overline): blocktext = overline + '\n' + title + '\n' + underline if len(overline.rstrip()) < 4: self.short_overline(context, blocktext, lineno, 2) diff --git a/docutils/parsers/rst/tableparser.py b/docutils/parsers/rst/tableparser.py index 8529a65b0..1d5dc9dfd 100644 --- a/docutils/parsers/rst/tableparser.py +++ b/docutils/parsers/rst/tableparser.py @@ -39,6 +39,9 @@ class TableParser: head_body_separator_pat = None """Matches the row separator between head rows and body rows.""" + double_width_pad_char = '\x00' + """Padding character for East Asian double-width text.""" + def parse(self, block): """ Analyze the text `block` and return a table data structure. @@ -169,6 +172,7 @@ class GridTableParser(TableParser): cellblock = self.block.get_2D_block(top + 1, left + 1, bottom, right) cellblock.disconnect() # lines in cell can't sync with parent + cellblock.replace(self.double_width_pad_char, '') self.cells.append((top, left, bottom, right, cellblock)) corners.extend([(top, right), (bottom, left)]) corners.sort() @@ -469,6 +473,7 @@ class SimpleTableParser(TableParser): start, end = columns[i] cellblock = lines.get_2D_block(0, start, len(lines), end) cellblock.disconnect() # lines in cell can't sync with parent + cellblock.replace(self.double_width_pad_char, '') row[i][3] = cellblock self.table.append(row) -- cgit v1.2.1 From 118dd3d2aa36cf563590197e28830c1a905f9cd8 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 8 Dec 2005 04:43:13 +0000 Subject: merged branches/s5 changes r4011:4155 into trunk/docutils git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@4156 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/references.py | 4 +++ docutils/parsers/rst/include/s5defs.txt | 49 +++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 docutils/parsers/rst/include/s5defs.txt (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/references.py b/docutils/parsers/rst/directives/references.py index 92966140f..0406182b6 100644 --- a/docutils/parsers/rst/directives/references.py +++ b/docutils/parsers/rst/directives/references.py @@ -12,12 +12,16 @@ __docformat__ = 'reStructuredText' from docutils import nodes from docutils.transforms import references +from docutils.parsers.rst import directives def target_notes(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): """Target footnote generation.""" pending = nodes.pending(references.TargetNotes) + pending.details.update(options) state_machine.document.note_pending(pending) nodelist = [pending] return nodelist + +target_notes.options = {'class': directives.class_option} diff --git a/docutils/parsers/rst/include/s5defs.txt b/docutils/parsers/rst/include/s5defs.txt new file mode 100644 index 000000000..d5d3047ce --- /dev/null +++ b/docutils/parsers/rst/include/s5defs.txt @@ -0,0 +1,49 @@ +.. Definitions of interpreted text roles (classes) for S5/HTML data. +.. This data file has been placed in the public domain. + +.. Colours + ======= + +.. role:: black +.. role:: gray +.. role:: silver +.. role:: white + +.. role:: maroon +.. role:: red +.. role:: magenta +.. role:: fuchsia +.. role:: pink +.. role:: orange +.. role:: yellow +.. role:: lime +.. role:: green +.. role:: olive +.. role:: teal +.. role:: cyan +.. role:: aqua +.. role:: blue +.. role:: navy +.. role:: purple + + +.. Text Sizes + ========== + +.. role:: huge +.. role:: big +.. role:: small +.. role:: tiny + + +.. Print-Only + ========== + +.. role:: print-inline + + +.. Incremental Display + =================== + +.. role:: incremental +.. default-role:: incremental -- cgit v1.2.1 From 3a1b080aa1b9d900b8322f38e422f77f89b2c6f8 Mon Sep 17 00:00:00 2001 From: goodger Date: Sat, 10 Dec 2005 02:29:55 +0000 Subject: completed Japanese mappings git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@4167 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/ja.py | 166 +++++++++++++++++++---------------- 1 file changed, 88 insertions(+), 78 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/ja.py b/docutils/parsers/rst/languages/ja.py index 8131d94f9..2a05f1fec 100644 --- a/docutils/parsers/rst/languages/ja.py +++ b/docutils/parsers/rst/languages/ja.py @@ -1,5 +1,6 @@ +# -*- coding: utf-8 -*- # Author: David Goodger -# Contact: goodger@users.sourceforge.net +# Contact: goodger@python.org # Revision: $Revision$ # Date: $Date$ # Copyright: This module has been placed in the public domain. @@ -18,87 +19,96 @@ __docformat__ = 'reStructuredText' directives = { - # language-dependent: fixed - 'attention (translation required)': 'attention', - 'caution (translation required)': 'caution', - 'danger (translation required)': 'danger', - 'error (translation required)': 'error', - 'hint (translation required)': 'hint', - 'important (translation required)': 'important', - 'note (translation required)': 'note', - 'tip (translation required)': 'tip', - 'warning (translation required)': 'warning', - 'admonition (translation required)': 'admonition', - 'sidebar (translation required)': 'sidebar', - 'topic (translation required)': 'topic', - 'line-block (translation required)': 'line-block', - 'parsed-literal (translation required)': 'parsed-literal', - 'rubric (translation required)': 'rubric', - 'epigraph (translation required)': 'epigraph', - 'highlights (translation required)': 'highlights', - 'pull-quote (translation required)': 'pull-quote', - 'compound (translation required)': 'compound', - 'container (translation required)': 'container', - #'questions (translation required)': 'questions', - 'table (translation required)': 'table', - 'csv-table (translation required)': 'csv-table', - 'list-table (translation required)': 'list-table', - #'qa (translation required)': 'questions', - #'faq (translation required)': 'questions', - 'meta (translation required)': 'meta', - #'imagemap (translation required)': 'imagemap', - 'image (translation required)': 'image', - 'figure (translation required)': 'figure', - 'include (translation required)': 'include', - 'raw (translation required)': 'raw', - 'replace (translation required)': 'replace', - 'unicode (translation required)': 'unicode', - 'class (translation required)': 'class', - 'role (translation required)': 'role', - 'default-role (translation required)': 'default-role', - 'title (translation required)': 'title', - 'contents (translation required)': 'contents', - 'sectnum (translation required)': 'sectnum', - 'section-numbering (translation required)': 'sectnum', - 'header (translation required)': 'header', - 'footer (translation required)': 'footer', - #'footnotes (translation required)': 'footnotes', - #'citations (translation required)': 'citations', - 'target-notes (translation required)': 'target-notes',} + # language-dependent: fixed + u'注目': 'attention', + u'注æ„': 'caution', + u'å±é™º': 'danger', + u'エラー': 'error', + u'ヒント': 'hint', + u'é‡è¦': 'important', + u'備考': 'note', + u'通報': 'tip', + u'警告': 'warning', + u'戒告': 'admonition', + u'サイドãƒãƒ¼': 'sidebar', + u'トピック': 'topic', + u'ラインブロック': 'line-block', + u'パーズドリテラル': 'parsed-literal', + u'ルブリック': 'rubric', + u'エピグラフ': 'epigraph', + u'題言': 'epigraph', + u'ãƒã‚¤ãƒ©ã‚¤ãƒˆ': 'highlights', + u'見所': 'highlights', + u'プルクオート': 'pull-quote', + u'åˆæˆ': 'compound', + u'コンテナー': 'container', + u'容器': 'container', + u'表': 'table', + u'csv表': 'csv-table', + u'リスト表': 'list-table', + #u'質å•': 'questions', + #u'å•ç­”': 'questions', + #u'faq': 'questions', + u'メタ': 'meta', + #u'イメージマプ': 'imagemap', + u'イメージ': 'image', + u'ç”»åƒ': 'image', + u'フィグア': 'figure', + u'図版': 'figure', + u'インクルード': 'include', + u'å«ã‚€': 'include', + u'組ã¿è¾¼ã¿': 'include', + u'生': 'raw', + u'原': 'raw', + u'æ›ãˆã‚‹': 'replace', + u'å–りæ›ãˆã‚‹': 'replace', + u'æŽ›ã‘æ›¿ãˆã‚‹': 'replace', + u'ユニコード': 'unicode', + u'クラス': 'class', + u'ロール': 'role', + u'å½¹': 'role', + u'ディフォルトロール': 'default-role', + u'既定役': 'default-role', + u'タイトル': 'title', + u'題': 'title', # 題å 件å + u'目次': 'contents', + u'節数': 'sectnum', + u'ヘッダ': 'header', + u'フッタ': 'footer', + #u'脚注': 'footnotes', # 脚註? + #u'サイテーション': 'citations',   # 出典 引証 引用 + u'ターゲットノート': 'target-notes', # 的注 的脚注 + } """Japanese name to registered (in directives/__init__.py) directive name mapping.""" roles = { # language-dependent: fixed - 'abbreviation (translation required)': 'abbreviation', - 'ab (translation required)': 'abbreviation', - 'acronym (translation required)': 'acronym', - 'ac (translation required)': 'acronym', - 'index (translation required)': 'index', - 'i (translation required)': 'index', - 'subscript (translation required)': 'subscript', - 'sub (translation required)': 'subscript', - 'superscript (translation required)': 'superscript', - 'sup (translation required)': 'superscript', - 'title-reference (translation required)': 'title-reference', - 'title (translation required)': 'title-reference', - 't (translation required)': 'title-reference', - 'pep-reference (translation required)': 'pep-reference', - 'pep (translation required)': 'pep-reference', - 'rfc-reference (translation required)': 'rfc-reference', - 'rfc (translation required)': 'rfc-reference', - 'emphasis (translation required)': 'emphasis', - 'strong (translation required)': 'strong', - 'literal (translation required)': 'literal', - 'named-reference (translation required)': 'named-reference', - 'anonymous-reference (translation required)': 'anonymous-reference', - 'footnote-reference (translation required)': 'footnote-reference', - 'citation-reference (translation required)': 'citation-reference', - 'substitution-reference (translation required)': 'substitution-reference', - 'target (translation required)': 'target', - 'uri-reference (translation required)': 'uri-reference', - 'uri (translation required)': 'uri-reference', - 'url (translation required)': 'uri-reference', - 'raw (translation required)': 'raw',} + u'ç•¥': 'abbreviation', + u'頭字語': 'acronym', + u'インデックス': 'index', + u'索引': 'index', + u'添字': 'subscript', + u'下付': 'subscript', + u'下': 'subscript', + u'上付': 'superscript', + u'上': 'superscript', + u'題å‚ç…§': 'title-reference', + u'pepå‚ç…§': 'pep-reference', + u'rfcå‚ç…§': 'rfc-reference', + u'強調': 'emphasis', + u'å¼·ã„': 'strong', + u'リテラル': 'literal', + u'整形済ã¿': 'literal', + u'å付å‚ç…§': 'named-reference', + u'ç„¡åå‚ç…§': 'anonymous-reference', + u'脚注å‚ç…§': 'footnote-reference', + u'出典å‚ç…§': 'citation-reference', + u'代入å‚ç…§': 'substitution-reference', + u'çš„': 'target', + u'uriå‚ç…§': 'uri-reference', + u'uri': 'uri-reference', + u'url': 'uri-reference', + u'生': 'raw',} """Mapping of Japanese role names to canonical role names for interpreted text.""" -- cgit v1.2.1 From a8d73eb931977072a29c38c8182873cf265a93d0 Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 11 Dec 2005 21:01:11 +0000 Subject: added comments git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@4169 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/ja.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/ja.py b/docutils/parsers/rst/languages/ja.py index 2a05f1fec..7a14ee14d 100644 --- a/docutils/parsers/rst/languages/ja.py +++ b/docutils/parsers/rst/languages/ja.py @@ -17,6 +17,8 @@ reStructuredText. __docformat__ = 'reStructuredText' +# Corrections to these translations are welcome! +# é–“é•ã„ãŒã‚れã°ã€ã©ã†ãžæ­£ã—ã„翻訳を教ãˆã¦ä¸‹ã•ã„。 directives = { # language-dependent: fixed -- cgit v1.2.1 From 6878ee001099f900fb884e858c9155b21928fd50 Mon Sep 17 00:00:00 2001 From: goodger Date: Tue, 13 Dec 2005 00:28:58 +0000 Subject: updated conditional display roles git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@4184 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/include/s5defs.txt | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/include/s5defs.txt b/docutils/parsers/rst/include/s5defs.txt index d5d3047ce..dca77ca43 100644 --- a/docutils/parsers/rst/include/s5defs.txt +++ b/docutils/parsers/rst/include/s5defs.txt @@ -36,10 +36,23 @@ .. role:: tiny -.. Print-Only - ========== +.. Display in Slides (Presentation Mode) Only + ========================================== + +.. role:: slide + :class: slide-display + + +.. Display in Outline Mode Only + ============================ + +.. role:: outline + + +.. Display in Print Only + ===================== -.. role:: print-inline +.. role:: print .. Incremental Display -- cgit v1.2.1 From d85318163715c9cac0c3ed9d5db612d812e503e4 Mon Sep 17 00:00:00 2001 From: wiemann Date: Tue, 13 Dec 2005 22:28:42 +0000 Subject: use unicode literals git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@4203 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/zh_cn.py | 151 +++++++++++++++----------------- 1 file changed, 72 insertions(+), 79 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/zh_cn.py b/docutils/parsers/rst/languages/zh_cn.py index 2d3a4679b..929974790 100644 --- a/docutils/parsers/rst/languages/zh_cn.py +++ b/docutils/parsers/rst/languages/zh_cn.py @@ -20,89 +20,82 @@ __docformat__ = 'reStructuredText' directives = { # language-dependent: fixed - '注æ„': 'attention', - 'å°å¿ƒ': 'caution', - 'å±é™©': 'danger', - '错误': 'error', - 'æç¤º': 'hint', - 'é‡è¦': 'important', - '注解': 'note', - '技巧': 'tip', - '警告': 'warning', - '忠告': 'admonition', - '侧框': 'sidebar', - '主题': 'topic', - 'line-block (translation required)': 'line-block', - 'parsed-literal (translation required)': 'parsed-literal', - '醒目': 'rubric', - 'é“­æ–‡': 'epigraph', - 'è¦ç‚¹': 'highlights', - 'pull-quote (translation required)': 'pull-quote', - 'å¤åˆ': 'compound', - '容器': 'container', - #'questions (translation required)': 'questions', - '表格': 'table', - 'csv表格': 'csv-table', - '列表表格': 'list-table', - #'qa (translation required)': 'questions', - #'faq (translation required)': 'questions', - '元数æ®': 'meta', - #'imagemap (translation required)': 'imagemap', - '图象': 'image', - '图例': 'figure', - '包å«': 'include', - '原文': 'raw', - '代替': 'replace', - '统一ç ': 'unicode', - '类型': 'class', - '角色': 'role', - '默认角色': 'default-role', - '标题': 'title', - '目录': 'contents', - '章节åºå·': 'sectnum', - '题头': 'header', - '页脚': 'footer', - #'footnotes (translation required)': 'footnotes', - #'citations (translation required)': 'citations', - 'target-notes (translation required)': 'target-notes', - 'restructuredtext-test-directive': 'restructuredtext-test-directive'} + u'注æ„': 'attention', + u'å°å¿ƒ': 'caution', + u'å±é™©': 'danger', + u'错误': 'error', + u'æç¤º': 'hint', + u'é‡è¦': 'important', + u'注解': 'note', + u'技巧': 'tip', + u'警告': 'warning', + u'忠告': 'admonition', + u'侧框': 'sidebar', + u'主题': 'topic', + u'line-block (translation required)': 'line-block', + u'parsed-literal (translation required)': 'parsed-literal', + u'醒目': 'rubric', + u'é“­æ–‡': 'epigraph', + u'è¦ç‚¹': 'highlights', + u'pull-quote (translation required)': 'pull-quote', + u'å¤åˆ': 'compound', + u'容器': 'container', + #u'questions (translation required)': 'questions', + u'表格': 'table', + u'csv表格': 'csv-table', + u'列表表格': 'list-table', + #u'qa (translation required)': 'questions', + #u'faq (translation required)': 'questions', + u'元数æ®': 'meta', + #u'imagemap (translation required)': 'imagemap', + u'图象': 'image', + u'图例': 'figure', + u'包å«': 'include', + u'原文': 'raw', + u'代替': 'replace', + u'统一ç ': 'unicode', + u'类型': 'class', + u'角色': 'role', + u'默认角色': 'default-role', + u'标题': 'title', + u'目录': 'contents', + u'章节åºå·': 'sectnum', + u'题头': 'header', + u'页脚': 'footer', + #u'footnotes (translation required)': 'footnotes', + #u'citations (translation required)': 'citations', + u'target-notes (translation required)': 'target-notes', + u'restructuredtext-test-directive': 'restructuredtext-test-directive'} """Simplified Chinese name to registered (in directives/__init__.py) directive name mapping.""" roles = { # language-dependent: fixed - '缩写': 'abbreviation', - '简称': 'acronym', - 'index (translation required)': 'index', - 'i (translation required)': 'index', - '下标': 'subscript', - '上标': 'superscript', - 'title-reference (translation required)': 'title-reference', - 'title (translation required)': 'title-reference', - 't (translation required)': 'title-reference', - 'pep-reference (translation required)': 'pep-reference', - 'pep (translation required)': 'pep-reference', - 'rfc-reference (translation required)': 'rfc-reference', - 'rfc (translation required)': 'rfc-reference', - '强调': 'emphasis', - '加粗': 'strong', - 'å­—é¢': 'literal', - 'named-reference (translation required)': 'named-reference', - 'anonymous-reference (translation required)': 'anonymous-reference', - 'footnote-reference (translation required)': 'footnote-reference', - 'citation-reference (translation required)': 'citation-reference', - 'substitution-reference (translation required)': 'substitution-reference', - 'target (translation required)': 'target', - 'uri-reference (translation required)': 'uri-reference', - 'uri (translation required)': 'uri-reference', - 'url (translation required)': 'uri-reference', - 'raw (translation required)': 'raw',} + u'缩写': 'abbreviation', + u'简称': 'acronym', + u'index (translation required)': 'index', + u'i (translation required)': 'index', + u'下标': 'subscript', + u'上标': 'superscript', + u'title-reference (translation required)': 'title-reference', + u'title (translation required)': 'title-reference', + u't (translation required)': 'title-reference', + u'pep-reference (translation required)': 'pep-reference', + u'pep (translation required)': 'pep-reference', + u'rfc-reference (translation required)': 'rfc-reference', + u'rfc (translation required)': 'rfc-reference', + u'强调': 'emphasis', + u'加粗': 'strong', + u'å­—é¢': 'literal', + u'named-reference (translation required)': 'named-reference', + u'anonymous-reference (translation required)': 'anonymous-reference', + u'footnote-reference (translation required)': 'footnote-reference', + u'citation-reference (translation required)': 'citation-reference', + u'substitution-reference (translation required)': 'substitution-reference', + u'target (translation required)': 'target', + u'uri-reference (translation required)': 'uri-reference', + u'uri (translation required)': 'uri-reference', + u'url (translation required)': 'uri-reference', + u'raw (translation required)': 'raw',} """Mapping of Simplified Chinese role names to canonical role names for interpreted text.""" - -# Decode UTF-8 strings. (We cannot use unicode literals directly for -# Python 2.1 compatibility.) -for mapping in directives, roles: - for key, value in mapping.items(): - del mapping[key] - mapping[unicode(key, 'utf8')] = unicode(value, 'utf8') -- cgit v1.2.1 From 8a4a3988a2cd67973071f5d774c268ed88bf3cf5 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 22 Dec 2005 23:46:16 +0000 Subject: added "date" directive, tests, & translations git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@4229 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/__init__.py | 1 + docutils/parsers/rst/directives/misc.py | 15 +++++++++++++++ docutils/parsers/rst/languages/af.py | 1 + docutils/parsers/rst/languages/ca.py | 1 + docutils/parsers/rst/languages/cs.py | 1 + docutils/parsers/rst/languages/de.py | 1 + docutils/parsers/rst/languages/en.py | 1 + docutils/parsers/rst/languages/eo.py | 1 + docutils/parsers/rst/languages/es.py | 1 + docutils/parsers/rst/languages/fi.py | 1 + docutils/parsers/rst/languages/fr.py | 1 + docutils/parsers/rst/languages/it.py | 1 + docutils/parsers/rst/languages/ja.py | 1 + docutils/parsers/rst/languages/nl.py | 1 + docutils/parsers/rst/languages/pt_br.py | 1 + docutils/parsers/rst/languages/ru.py | 1 + docutils/parsers/rst/languages/sk.py | 1 + docutils/parsers/rst/languages/sv.py | 1 + docutils/parsers/rst/languages/zh_cn.py | 1 + docutils/parsers/rst/languages/zh_tw.py | 2 ++ 20 files changed, 35 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/__init__.py b/docutils/parsers/rst/directives/__init__.py index 1a7e680e0..998c391e3 100644 --- a/docutils/parsers/rst/directives/__init__.py +++ b/docutils/parsers/rst/directives/__init__.py @@ -134,6 +134,7 @@ _directive_registry = { 'role': ('misc', 'role'), 'default-role': ('misc', 'default_role'), 'title': ('misc', 'title'), + 'date': ('misc', 'date'), 'restructuredtext-test-directive': ('misc', 'directive_test_function'),} """Mapping of directive name to (module name, function name). The directive name is canonical & must be lowercase. Language-dependent names are defined diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py index 0eec557b5..42f642fee 100644 --- a/docutils/parsers/rst/directives/misc.py +++ b/docutils/parsers/rst/directives/misc.py @@ -11,6 +11,7 @@ __docformat__ = 'reStructuredText' import sys import os.path import re +import time from docutils import io, nodes, statemachine, utils from docutils.parsers.rst import directives, roles, states from docutils.transforms import misc @@ -373,6 +374,20 @@ def title(name, arguments, options, content, lineno, title.arguments = (1, 0, 1) +def date(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + if not isinstance(state, states.SubstitutionDef): + error = state_machine.reporter.error( + 'Invalid context: the "%s" directive can only be used within a ' + 'substitution definition.' % (name), + nodes.literal_block(block_text, block_text), line=lineno) + return [error] + format = '\n'.join(content) or '%Y-%m-%d' + text = time.strftime(format) + return [nodes.Text(text)] + +date.content = 1 + def directive_test_function(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): """This directive is useful only for testing purposes.""" diff --git a/docutils/parsers/rst/languages/af.py b/docutils/parsers/rst/languages/af.py index c9c636044..c2d8fd4c7 100644 --- a/docutils/parsers/rst/languages/af.py +++ b/docutils/parsers/rst/languages/af.py @@ -52,6 +52,7 @@ directives = { 'rou': 'raw', 'vervang': 'replace', 'unicode': 'unicode', # should this be translated? unikode + 'datum': 'date', 'klas': 'class', 'role (translation required)': 'role', 'default-role (translation required)': 'default-role', diff --git a/docutils/parsers/rst/languages/ca.py b/docutils/parsers/rst/languages/ca.py index dbee8c267..ed181668d 100644 --- a/docutils/parsers/rst/languages/ca.py +++ b/docutils/parsers/rst/languages/ca.py @@ -57,6 +57,7 @@ directives = { u'reempla\u00E7a': 'replace', u'reempla\u00E7ar': 'replace', u'unicode': 'unicode', + u'data': 'date', u'classe': 'class', u'rol': 'role', u'default-role (translation required)': 'default-role', diff --git a/docutils/parsers/rst/languages/cs.py b/docutils/parsers/rst/languages/cs.py index 80614fe99..169d2c4f7 100644 --- a/docutils/parsers/rst/languages/cs.py +++ b/docutils/parsers/rst/languages/cs.py @@ -53,6 +53,7 @@ directives = { u'raw (translation required)': 'raw', u'replace (translation required)': 'replace', u'unicode (translation required)': 'unicode', + u'datum': 'date', u't\u0159\u00EDda': 'class', u'role (translation required)': 'role', u'default-role (translation required)': 'default-role', diff --git a/docutils/parsers/rst/languages/de.py b/docutils/parsers/rst/languages/de.py index ab32eedac..da528a7be 100644 --- a/docutils/parsers/rst/languages/de.py +++ b/docutils/parsers/rst/languages/de.py @@ -55,6 +55,7 @@ directives = { 'ersetzen': 'replace', 'ersetze': 'replace', 'unicode': 'unicode', + 'datum': 'date', 'klasse': 'class', 'rolle': 'role', u'default-role (translation required)': 'default-role', diff --git a/docutils/parsers/rst/languages/en.py b/docutils/parsers/rst/languages/en.py index a38f08342..1c0d7edba 100644 --- a/docutils/parsers/rst/languages/en.py +++ b/docutils/parsers/rst/languages/en.py @@ -53,6 +53,7 @@ directives = { 'raw': 'raw', 'replace': 'replace', 'unicode': 'unicode', + 'date': 'date', 'class': 'class', 'role': 'role', 'default-role': 'default-role', diff --git a/docutils/parsers/rst/languages/eo.py b/docutils/parsers/rst/languages/eo.py index c25b8da25..2fe6d8e42 100644 --- a/docutils/parsers/rst/languages/eo.py +++ b/docutils/parsers/rst/languages/eo.py @@ -59,6 +59,7 @@ directives = { u'anstatauxi': 'replace', u'anstata\u016di': 'replace', u'unicode': 'unicode', + u'dato': 'date', u'klaso': 'class', u'rolo': 'role', u'preterlasita-rolo': 'default-role', diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index bdbc8c188..3703ddab9 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -61,6 +61,7 @@ directives = { u'sin-an\u00e1lisis': 'raw', u'reemplazar': 'replace', u'unicode': 'unicode', + u'fecha': 'date', u'clase': 'class', u'rol': 'role', u'rol-por-omision': 'default-role', diff --git a/docutils/parsers/rst/languages/fi.py b/docutils/parsers/rst/languages/fi.py index c36b37615..8f92a67ad 100644 --- a/docutils/parsers/rst/languages/fi.py +++ b/docutils/parsers/rst/languages/fi.py @@ -51,6 +51,7 @@ directives = { u'raaka': u'raw', u'korvaa': u'replace', u'unicode': u'unicode', + u'p\u00e4iv\u00e4ys': u'date', u'luokka': u'class', u'rooli': u'role', u'default-role (translation required)': 'default-role', diff --git a/docutils/parsers/rst/languages/fr.py b/docutils/parsers/rst/languages/fr.py index 8324da3fe..7520f743b 100644 --- a/docutils/parsers/rst/languages/fr.py +++ b/docutils/parsers/rst/languages/fr.py @@ -55,6 +55,7 @@ directives = { u'remplacer': 'replace', u'remplace': 'replace', u'unicode': 'unicode', + u'date': 'date', u'classe': 'class', u'role (translation required)': 'role', u'default-role (translation required)': 'default-role', diff --git a/docutils/parsers/rst/languages/it.py b/docutils/parsers/rst/languages/it.py index e5cc9a3ac..cc1701941 100644 --- a/docutils/parsers/rst/languages/it.py +++ b/docutils/parsers/rst/languages/it.py @@ -52,6 +52,7 @@ directives = { 'grezzo': 'raw', 'sostituisci': 'replace', 'unicode': 'unicode', + 'data': 'date', 'classe': 'class', 'ruolo': 'role', 'ruolo-predefinito': 'default-role', diff --git a/docutils/parsers/rst/languages/ja.py b/docutils/parsers/rst/languages/ja.py index 7a14ee14d..0bb701d85 100644 --- a/docutils/parsers/rst/languages/ja.py +++ b/docutils/parsers/rst/languages/ja.py @@ -66,6 +66,7 @@ directives = { u'å–りæ›ãˆã‚‹': 'replace', u'æŽ›ã‘æ›¿ãˆã‚‹': 'replace', u'ユニコード': 'unicode', + u'日付': 'date', u'クラス': 'class', u'ロール': 'role', u'å½¹': 'role', diff --git a/docutils/parsers/rst/languages/nl.py b/docutils/parsers/rst/languages/nl.py index a5d256464..baaf2ae70 100644 --- a/docutils/parsers/rst/languages/nl.py +++ b/docutils/parsers/rst/languages/nl.py @@ -54,6 +54,7 @@ directives = { 'vervang': 'replace', 'vervanging': 'replace', 'unicode': 'unicode', + 'datum': 'date', 'klasse': 'class', 'rol': 'role', u'default-role (translation required)': 'default-role', diff --git a/docutils/parsers/rst/languages/pt_br.py b/docutils/parsers/rst/languages/pt_br.py index 9eeb23820..43ebfaa3b 100644 --- a/docutils/parsers/rst/languages/pt_br.py +++ b/docutils/parsers/rst/languages/pt_br.py @@ -53,6 +53,7 @@ directives = { 'cru': 'raw', u'substitui\u00E7\u00E3o': 'replace', 'unicode': 'unicode', + 'data': 'date', 'classe': 'class', 'role (translation required)': 'role', u'default-role (translation required)': 'default-role', diff --git a/docutils/parsers/rst/languages/ru.py b/docutils/parsers/rst/languages/ru.py index db1eb8617..18354f738 100644 --- a/docutils/parsers/rst/languages/ru.py +++ b/docutils/parsers/rst/languages/ru.py @@ -35,6 +35,7 @@ directives = { u'\u0446\u0435\u043b\u0435\u0432\u044b\u0435-\u0441\u043d\u043e\u0441\u043a\u0438': u'target-notes', u'unicode': u'unicode', + u'\u0434\u0430\u0442\u0430': u'date', u'\u0431\u043e\u043a\u043e\u0432\u0430\u044f-\u043f\u043e\u043b\u043e\u0441\u0430': u'sidebar', u'\u0432\u0430\u0436\u043d\u043e': u'important', diff --git a/docutils/parsers/rst/languages/sk.py b/docutils/parsers/rst/languages/sk.py index f92ffedf1..513c432f4 100644 --- a/docutils/parsers/rst/languages/sk.py +++ b/docutils/parsers/rst/languages/sk.py @@ -52,6 +52,7 @@ directives = { u'raw (translation required)': 'raw', u'nahradi\x9d': 'replace', u'unicode': 'unicode', + u'd\u00E1tum': 'date', u'class (translation required)': 'class', u'role (translation required)': 'role', u'default-role (translation required)': 'default-role', diff --git a/docutils/parsers/rst/languages/sv.py b/docutils/parsers/rst/languages/sv.py index bbf749e30..8ffe76e50 100644 --- a/docutils/parsers/rst/languages/sv.py +++ b/docutils/parsers/rst/languages/sv.py @@ -52,6 +52,7 @@ directives = { u'r\u00e5': 'raw', # FIXME: Translation might be too literal. u'ers\u00e4tt': 'replace', u'unicode': 'unicode', + u'datum': 'date', u'class (translation required)': 'class', u'role (translation required)': 'role', u'default-role (translation required)': 'default-role', diff --git a/docutils/parsers/rst/languages/zh_cn.py b/docutils/parsers/rst/languages/zh_cn.py index 929974790..6afbec7a9 100644 --- a/docutils/parsers/rst/languages/zh_cn.py +++ b/docutils/parsers/rst/languages/zh_cn.py @@ -54,6 +54,7 @@ directives = { u'原文': 'raw', u'代替': 'replace', u'统一ç ': 'unicode', + u'日期': 'date', u'类型': 'class', u'角色': 'role', u'默认角色': 'default-role', diff --git a/docutils/parsers/rst/languages/zh_tw.py b/docutils/parsers/rst/languages/zh_tw.py index b1b83f5a1..77574b591 100644 --- a/docutils/parsers/rst/languages/zh_tw.py +++ b/docutils/parsers/rst/languages/zh_tw.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Author: David Goodger # Contact: goodger@users.sourceforge.net # Revision: $Revision$ @@ -53,6 +54,7 @@ directives = { 'raw (translation required)': 'raw', 'replace (translation required)': 'replace', 'unicode (translation required)': 'unicode', + u'日期': 'date', 'class (translation required)': 'class', 'role (translation required)': 'role', u'default-role (translation required)': 'default-role', -- cgit v1.2.1 From 45b9a8f82e1c89c5ddef5fd7a10827f77c107f49 Mon Sep 17 00:00:00 2001 From: richieadler Date: Fri, 23 Dec 2005 02:10:41 +0000 Subject: add new translation git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@4231 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/eo.py | 3 ++- docutils/parsers/rst/languages/es.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/eo.py b/docutils/parsers/rst/languages/eo.py index 2fe6d8e42..8565d6c8d 100644 --- a/docutils/parsers/rst/languages/eo.py +++ b/docutils/parsers/rst/languages/eo.py @@ -42,7 +42,8 @@ directives = { u'ekstera-cita\u0135o': 'pull-quote', u'kombinajxo': 'compound', u'kombina\u0135o': 'compound', - u'container (translation required)': 'container', + u'tekstingo': 'container', + u'enhavilo': 'container', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/parsers/rst/languages/es.py b/docutils/parsers/rst/languages/es.py index 3703ddab9..8e86bae37 100644 --- a/docutils/parsers/rst/languages/es.py +++ b/docutils/parsers/rst/languages/es.py @@ -44,7 +44,7 @@ directives = { u'cita-destacada': 'pull-quote', u'combinacion': 'compound', u'combinaci\u00f3n': 'compound', - u'container (translation required)': 'container', + u'contenedor': 'container', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', -- cgit v1.2.1 From 364683bdf6f3be7de65103d10e654afbc82221f5 Mon Sep 17 00:00:00 2001 From: goodger Date: Thu, 29 Dec 2005 01:14:21 +0000 Subject: Re-introduced ``Targetable.indirect_reference_name``, for MoinMoin/reST compatibility (removed in r3124/r3129; noticed by Matthew Gilbert). git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@4234 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/directives/images.py | 1 + docutils/parsers/rst/states.py | 1 + 2 files changed, 2 insertions(+) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/directives/images.py b/docutils/parsers/rst/directives/images.py index 8dc94af96..5aed4c01b 100644 --- a/docutils/parsers/rst/directives/images.py +++ b/docutils/parsers/rst/directives/images.py @@ -63,6 +63,7 @@ def image(name, arguments, options, content, lineno, reference_node = nodes.reference( refname=fully_normalize_name(data), name=whitespace_normalize_name(data)) + reference_node.indirect_reference_name = data state.document.note_refname(reference_node) else: # malformed target messages.append(data) # data is a system message diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 66c4393b8..5d0fd1c23 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -1838,6 +1838,7 @@ class Body(RSTState): target_type, data = self.parse_target(block, block_text, lineno) if target_type == 'refname': target = nodes.target(block_text, '', refname=normalize_name(data)) + target.indirect_reference_name = data self.add_target(target_name, '', target, lineno) self.document.note_indirect_target(target) return target -- cgit v1.2.1 From d1719d580ddec6676079d04702573e5760112581 Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 1 Jan 2006 02:35:00 +0000 Subject: correction from panjunyong git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@4237 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/languages/zh_cn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/languages/zh_cn.py b/docutils/parsers/rst/languages/zh_cn.py index 6afbec7a9..dee301ca6 100644 --- a/docutils/parsers/rst/languages/zh_cn.py +++ b/docutils/parsers/rst/languages/zh_cn.py @@ -48,7 +48,7 @@ directives = { #u'faq (translation required)': 'questions', u'元数æ®': 'meta', #u'imagemap (translation required)': 'imagemap', - u'图象': 'image', + u'图片': 'image', u'图例': 'figure', u'包å«': 'include', u'原文': 'raw', -- cgit v1.2.1 From d2bdd5c0e3514a7223cc454e89f6ab7d82b54beb Mon Sep 17 00:00:00 2001 From: wiemann Date: Mon, 9 Jan 2006 03:29:23 +0000 Subject: some cleanup: removed unnecessary tearDown method; removed unnecessary roles parameter to Inliner.__init__ git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@4258 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docutils/parsers/rst/states.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'docutils/parsers') diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py index 5d0fd1c23..363ef8fdd 100644 --- a/docutils/parsers/rst/states.py +++ b/docutils/parsers/rst/states.py @@ -443,12 +443,7 @@ class Inliner: Parse inline markup; call the `parse()` method. """ - def __init__(self, roles=None): - """ - `roles` is a mapping of canonical role name to role function or bound - method, which enables additional interpreted text roles. - """ - + def __init__(self): self.implicit_dispatch = [(self.patterns.uri, self.standalone_uri),] """List of (pattern, bound method) tuples, used by `self.implicit_inline`.""" -- cgit v1.2.1