Commit 11745516 authored by Andreas Jung's avatar Andreas Jung

docutils update

parent f17718be
# Author: David Goodger # Author: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:00 $ # Date: $Date: 2003/07/10 15:49:30 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
...@@ -23,12 +23,6 @@ Modules: ...@@ -23,12 +23,6 @@ Modules:
- nodes.py: Docutils document tree (doctree) node class library. - nodes.py: Docutils document tree (doctree) node class library.
- optik.py: Option parsing and command-line help; from Greg Ward's
http://optik.sf.net/ project, included for convenience.
- roman.py: Conversion to and from Roman numerals. Courtesy of Mark
Pilgrim (http://diveintopython.org/).
- statemachine.py: A finite state machine specialized for - statemachine.py: A finite state machine specialized for
regular-expression-based text filters. regular-expression-based text filters.
...@@ -55,12 +49,12 @@ Subpackages: ...@@ -55,12 +49,12 @@ Subpackages:
__docformat__ = 'reStructuredText' __docformat__ = 'reStructuredText'
__version__ = '0.2.8' __version__ = '0.3.0'
"""``major.minor.micro`` version number. The micro number is bumped any time """``major.minor.micro`` version number. The micro number is bumped any time
there's a change in the API incompatible with one of the front ends. The there's a change in the API incompatible with one of the front ends. The
minor number is bumped whenever there is a project release. The major number minor number is bumped whenever there is a project release. The major number
will be bumped when the project is complete, and perhaps if there is a major will be bumped when the project is feature-complete, and perhaps if there is a
change in the design.""" major change in the design."""
class ApplicationError(StandardError): pass class ApplicationError(StandardError): pass
...@@ -85,7 +79,11 @@ class SettingsSpec: ...@@ -85,7 +79,11 @@ class SettingsSpec:
and/or description may be `None`; no group title implies no group, just a and/or description may be `None`; no group title implies no group, just a
list of single options. Runtime settings names are derived implicitly list of single options. Runtime settings names are derived implicitly
from long option names ("--a-setting" becomes ``settings.a_setting``) or from long option names ("--a-setting" becomes ``settings.a_setting``) or
explicitly from the "destination" keyword argument.""" explicitly from the "dest" keyword argument."""
settings_defaults = None
"""A dictionary of defaults for internal or inaccessible (by command-line
or config file) settings. Override in subclasses."""
settings_default_overrides = None settings_default_overrides = None
"""A dictionary of auxiliary defaults, to override defaults for settings """A dictionary of auxiliary defaults, to override defaults for settings
......
# Authors: David Goodger # Authors: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:00 $ # Date: $Date: 2003/07/10 15:49:30 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
...@@ -15,9 +15,9 @@ custom component objects first, and pass *them* to ...@@ -15,9 +15,9 @@ custom component objects first, and pass *them* to
__docformat__ = 'reStructuredText' __docformat__ = 'reStructuredText'
import sys import sys
from docutils import Component from docutils import Component, __version__
from docutils import frontend, io, readers, parsers, writers from docutils import frontend, io, utils, readers, parsers, writers
from docutils.frontend import OptionParser, ConfigParser from docutils.frontend import OptionParser
class Publisher: class Publisher:
...@@ -87,14 +87,8 @@ class Publisher: ...@@ -87,14 +87,8 @@ class Publisher:
#@@@ Add self.source & self.destination to components in future? #@@@ Add self.source & self.destination to components in future?
option_parser = OptionParser( option_parser = OptionParser(
components=(settings_spec, self.parser, self.reader, self.writer), components=(settings_spec, self.parser, self.reader, self.writer),
defaults=defaults, read_config_files=1,
usage=usage, description=description) usage=usage, description=description)
config = ConfigParser()
config.read_standard_files()
config_settings = config.get_section('options')
frontend.make_paths_absolute(config_settings,
option_parser.relative_path_settings)
defaults.update(config_settings)
option_parser.set_defaults(**defaults)
return option_parser return option_parser
def get_settings(self, usage=None, description=None, def get_settings(self, usage=None, description=None,
...@@ -148,7 +142,8 @@ class Publisher: ...@@ -148,7 +142,8 @@ class Publisher:
self.settings._destination = destination_path self.settings._destination = destination_path
self.destination = self.destination_class( self.destination = self.destination_class(
destination=destination, destination_path=destination_path, destination=destination, destination_path=destination_path,
encoding=self.settings.output_encoding) encoding=self.settings.output_encoding,
error_handler=self.settings.output_encoding_error_handler)
def apply_transforms(self, document): def apply_transforms(self, document):
document.transformer.populate_from_components( document.transformer.populate_from_components(
...@@ -157,7 +152,8 @@ class Publisher: ...@@ -157,7 +152,8 @@ class Publisher:
document.transformer.apply_transforms() document.transformer.apply_transforms()
def publish(self, argv=None, usage=None, description=None, def publish(self, argv=None, usage=None, description=None,
settings_spec=None, settings_overrides=None): settings_spec=None, settings_overrides=None,
enable_exit=None):
""" """
Process command line options and arguments (if `self.settings` not Process command line options and arguments (if `self.settings` not
already set), run `self.reader` and then `self.writer`. Return already set), run `self.reader` and then `self.writer`. Return
...@@ -169,25 +165,52 @@ class Publisher: ...@@ -169,25 +165,52 @@ class Publisher:
elif settings_overrides: elif settings_overrides:
self.settings._update(settings_overrides, 'loose') self.settings._update(settings_overrides, 'loose')
self.set_io() self.set_io()
document = self.reader.read(self.source, self.parser, self.settings) exit = None
document = None
try:
document = self.reader.read(self.source, self.parser,
self.settings)
self.apply_transforms(document) self.apply_transforms(document)
output = self.writer.write(document, self.destination) output = self.writer.write(document, self.destination)
except utils.SystemMessage, error:
if self.settings.traceback:
raise
print >>sys.stderr, ('Exiting due to level-%s (%s) system message.'
% (error.level,
utils.Reporter.levels[error.level]))
exit = 1
except Exception, error:
if self.settings.traceback:
raise
print >>sys.stderr, error
print >>sys.stderr, ("""\
Exiting due to error. Use "--traceback" to diagnose.
Please report errors to <docutils-users@lists.sf.net>.
Include "--traceback" output, Docutils version (%s),
Python version (%s), your OS type & version, and the
command line used.""" % (__version__, sys.version.split()[0]))
exit = 1
if self.settings.dump_settings: if self.settings.dump_settings:
from pprint import pformat from pprint import pformat
print >>sys.stderr, '\n::: Runtime settings:' print >>sys.stderr, '\n::: Runtime settings:'
print >>sys.stderr, pformat(self.settings.__dict__) print >>sys.stderr, pformat(self.settings.__dict__)
if self.settings.dump_internals: if self.settings.dump_internals and document:
from pprint import pformat from pprint import pformat
print >>sys.stderr, '\n::: Document internals:' print >>sys.stderr, '\n::: Document internals:'
print >>sys.stderr, pformat(document.__dict__) print >>sys.stderr, pformat(document.__dict__)
if self.settings.dump_transforms: if self.settings.dump_transforms and document:
from pprint import pformat from pprint import pformat
print >>sys.stderr, '\n::: Transforms applied:' print >>sys.stderr, '\n::: Transforms applied:'
print >>sys.stderr, pformat(document.transformer.applied) print >>sys.stderr, pformat(document.transformer.applied)
if self.settings.dump_pseudo_xml: if self.settings.dump_pseudo_xml and document:
print >>sys.stderr, '\n::: Pseudo-XML:' print >>sys.stderr, '\n::: Pseudo-XML:'
print >>sys.stderr, document.pformat().encode( print >>sys.stderr, document.pformat().encode(
'raw_unicode_escape') 'raw_unicode_escape')
if enable_exit and document and (document.reporter.max_level
>= self.settings.exit_level):
sys.exit(document.reporter.max_level + 10)
elif exit:
sys.exit(1)
return output return output
...@@ -199,7 +222,7 @@ def publish_cmdline(reader=None, reader_name='standalone', ...@@ -199,7 +222,7 @@ def publish_cmdline(reader=None, reader_name='standalone',
parser=None, parser_name='restructuredtext', parser=None, parser_name='restructuredtext',
writer=None, writer_name='pseudoxml', writer=None, writer_name='pseudoxml',
settings=None, settings_spec=None, settings=None, settings_spec=None,
settings_overrides=None, argv=None, settings_overrides=None, enable_exit=1, argv=None,
usage=default_usage, description=default_description): usage=default_usage, description=default_description):
""" """
Set up & run a `Publisher`. For command-line front ends. Set up & run a `Publisher`. For command-line front ends.
...@@ -220,6 +243,7 @@ def publish_cmdline(reader=None, reader_name='standalone', ...@@ -220,6 +243,7 @@ def publish_cmdline(reader=None, reader_name='standalone',
subclass. Used only if no `settings` specified. subclass. Used only if no `settings` specified.
- `settings_overrides`: A dictionary containing program-specific overrides - `settings_overrides`: A dictionary containing program-specific overrides
of component settings. of component settings.
- `enable_exit`: Boolean; enable exit status at end of processing?
- `argv`: Command-line argument list to use instead of ``sys.argv[1:]``. - `argv`: Command-line argument list to use instead of ``sys.argv[1:]``.
- `usage`: Usage string, output if there's a problem parsing the command - `usage`: Usage string, output if there's a problem parsing the command
line. line.
...@@ -228,14 +252,16 @@ def publish_cmdline(reader=None, reader_name='standalone', ...@@ -228,14 +252,16 @@ def publish_cmdline(reader=None, reader_name='standalone',
""" """
pub = Publisher(reader, parser, writer, settings=settings) pub = Publisher(reader, parser, writer, settings=settings)
pub.set_components(reader_name, parser_name, writer_name) pub.set_components(reader_name, parser_name, writer_name)
pub.publish(argv, usage, description, settings_spec, settings_overrides) pub.publish(argv, usage, description, settings_spec, settings_overrides,
enable_exit=enable_exit)
def publish_file(source=None, source_path=None, def publish_file(source=None, source_path=None,
destination=None, destination_path=None, destination=None, destination_path=None,
reader=None, reader_name='standalone', reader=None, reader_name='standalone',
parser=None, parser_name='restructuredtext', parser=None, parser_name='restructuredtext',
writer=None, writer_name='pseudoxml', writer=None, writer_name='pseudoxml',
settings=None, settings_spec=None, settings_overrides=None): settings=None, settings_spec=None, settings_overrides=None,
enable_exit=None):
""" """
Set up & run a `Publisher`. For programmatic use with file-like I/O. Set up & run a `Publisher`. For programmatic use with file-like I/O.
...@@ -263,6 +289,7 @@ def publish_file(source=None, source_path=None, ...@@ -263,6 +289,7 @@ def publish_file(source=None, source_path=None,
subclass. Used only if no `settings` specified. subclass. Used only if no `settings` specified.
- `settings_overrides`: A dictionary containing program-specific overrides - `settings_overrides`: A dictionary containing program-specific overrides
of component settings. of component settings.
- `enable_exit`: Boolean; enable exit status at end of processing?
""" """
pub = Publisher(reader, parser, writer, settings=settings) pub = Publisher(reader, parser, writer, settings=settings)
pub.set_components(reader_name, parser_name, writer_name) pub.set_components(reader_name, parser_name, writer_name)
...@@ -272,21 +299,27 @@ def publish_file(source=None, source_path=None, ...@@ -272,21 +299,27 @@ def publish_file(source=None, source_path=None,
settings._update(settings_overrides, 'loose') settings._update(settings_overrides, 'loose')
pub.set_source(source, source_path) pub.set_source(source, source_path)
pub.set_destination(destination, destination_path) pub.set_destination(destination, destination_path)
pub.publish() pub.publish(enable_exit=enable_exit)
def publish_string(source, source_path=None, destination_path=None, def publish_string(source, source_path=None, destination_path=None,
reader=None, reader_name='standalone', reader=None, reader_name='standalone',
parser=None, parser_name='restructuredtext', parser=None, parser_name='restructuredtext',
writer=None, writer_name='pseudoxml', writer=None, writer_name='pseudoxml',
settings=None, settings_spec=None, settings=None, settings_spec=None,
settings_overrides=None): settings_overrides=None, enable_exit=None):
""" """
Set up & run a `Publisher`, and return the string output. Set up & run a `Publisher`, and return the string output.
For programmatic use with string I/O. For programmatic use with string I/O.
For encoded string output, be sure to set the "output_encoding" setting to For encoded string output, be sure to set the "output_encoding" setting to
the desired encoding. Set it to "unicode" for unencoded Unicode string the desired encoding. Set it to "unicode" for unencoded Unicode string
output. output. Here's how::
publish_string(..., settings_overrides={'output_encoding': 'unicode'})
Similarly for Unicode string input (`source`)::
publish_string(..., settings_overrides={'input_encoding': 'unicode'})
Parameters: Parameters:
...@@ -312,6 +345,7 @@ def publish_string(source, source_path=None, destination_path=None, ...@@ -312,6 +345,7 @@ def publish_string(source, source_path=None, destination_path=None,
subclass. Used only if no `settings` specified. subclass. Used only if no `settings` specified.
- `settings_overrides`: A dictionary containing program-specific overrides - `settings_overrides`: A dictionary containing program-specific overrides
of component settings. of component settings.
- `enable_exit`: Boolean; enable exit status at end of processing?
""" """
pub = Publisher(reader, parser, writer, settings=settings, pub = Publisher(reader, parser, writer, settings=settings,
source_class=io.StringInput, source_class=io.StringInput,
...@@ -323,4 +357,4 @@ def publish_string(source, source_path=None, destination_path=None, ...@@ -323,4 +357,4 @@ def publish_string(source, source_path=None, destination_path=None,
settings._update(settings_overrides, 'loose') settings._update(settings_overrides, 'loose')
pub.set_source(source, source_path) pub.set_source(source, source_path)
pub.set_destination(destination_path=destination_path) pub.set_destination(destination_path=destination_path)
return pub.publish() return pub.publish(enable_exit=enable_exit)
This diff is collapsed.
# Author: David Goodger # Author: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:00 $ # Date: $Date: 2003/07/10 15:49:30 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
...@@ -13,6 +13,7 @@ __docformat__ = 'reStructuredText' ...@@ -13,6 +13,7 @@ __docformat__ = 'reStructuredText'
import sys import sys
import locale import locale
from types import UnicodeType
from docutils import TransformSpec from docutils import TransformSpec
...@@ -26,20 +27,9 @@ class Input(TransformSpec): ...@@ -26,20 +27,9 @@ class Input(TransformSpec):
default_source_path = None default_source_path = None
def __init__(self, settings=None, source=None, source_path=None, def __init__(self, source=None, source_path=None, encoding=None):
encoding=None):
self.encoding = encoding self.encoding = encoding
"""The character encoding for the input source.""" """Text encoding for the input source."""
if settings:
if not encoding:
self.encoding = settings.input_encoding
import warnings, traceback
warnings.warn(
'Setting input encoding via a "settings" struct is '
'deprecated; send encoding directly instead.\n%s'
% ''.join(traceback.format_list(traceback.extract_stack()
[-3:-1])))
self.source = source self.source = source
"""The source of input data.""" """The source of input data."""
...@@ -67,7 +57,8 @@ class Input(TransformSpec): ...@@ -67,7 +57,8 @@ class Input(TransformSpec):
locale.setlocale(locale.LC_ALL, '') locale.setlocale(locale.LC_ALL, '')
""" """
if self.encoding and self.encoding.lower() == 'unicode': if (self.encoding and self.encoding.lower() == 'unicode'
or isinstance(data, UnicodeType)):
return unicode(data) return unicode(data)
encodings = [self.encoding, 'utf-8'] encodings = [self.encoding, 'utf-8']
try: try:
...@@ -87,8 +78,7 @@ class Input(TransformSpec): ...@@ -87,8 +78,7 @@ class Input(TransformSpec):
if not enc: if not enc:
continue continue
try: try:
decoded = unicode(data, enc) return unicode(data, enc)
return decoded
except (UnicodeError, LookupError): except (UnicodeError, LookupError):
pass pass
raise UnicodeError( raise UnicodeError(
...@@ -106,20 +96,13 @@ class Output(TransformSpec): ...@@ -106,20 +96,13 @@ class Output(TransformSpec):
default_destination_path = None default_destination_path = None
def __init__(self, settings=None, destination=None, destination_path=None, def __init__(self, destination=None, destination_path=None,
encoding=None): encoding=None, error_handler='strict'):
self.encoding = encoding self.encoding = encoding
"""The character encoding for the output destination.""" """Text encoding for the output destination."""
if settings: self.error_handler = error_handler or 'strict'
if not encoding: """Text encoding error handler."""
self.encoding = settings.output_encoding
import warnings, traceback
warnings.warn(
'Setting output encoding via a "settings" struct is '
'deprecated; send encoding directly instead.\n%s'
% ''.join(traceback.format_list(traceback.extract_stack()
[-3:-1])))
self.destination = destination self.destination = destination
"""The destination for output data.""" """The destination for output data."""
...@@ -141,7 +124,7 @@ class Output(TransformSpec): ...@@ -141,7 +124,7 @@ class Output(TransformSpec):
if self.encoding and self.encoding.lower() == 'unicode': if self.encoding and self.encoding.lower() == 'unicode':
return data return data
else: else:
return data.encode(self.encoding or '') return data.encode(self.encoding, self.error_handler)
class FileInput(Input): class FileInput(Input):
...@@ -150,8 +133,8 @@ class FileInput(Input): ...@@ -150,8 +133,8 @@ class FileInput(Input):
Input for single, simple file-like objects. Input for single, simple file-like objects.
""" """
def __init__(self, settings=None, source=None, source_path=None, def __init__(self, source=None, source_path=None,
encoding=None, autoclose=1): encoding=None, autoclose=1, handle_io_errors=1):
""" """
:Parameters: :Parameters:
- `source`: either a file-like object (which is read directly), or - `source`: either a file-like object (which is read directly), or
...@@ -160,11 +143,22 @@ class FileInput(Input): ...@@ -160,11 +143,22 @@ class FileInput(Input):
- `autoclose`: close automatically after read (boolean); always - `autoclose`: close automatically after read (boolean); always
false if `sys.stdin` is the source. false if `sys.stdin` is the source.
""" """
Input.__init__(self, settings, source, source_path, encoding) Input.__init__(self, source, source_path, encoding)
self.autoclose = autoclose self.autoclose = autoclose
self.handle_io_errors = handle_io_errors
if source is None: if source is None:
if source_path: if source_path:
try:
self.source = open(source_path) self.source = open(source_path)
except IOError, error:
if not handle_io_errors:
raise
print >>sys.stderr, '%s: %s' % (error.__class__.__name__,
error)
print >>sys.stderr, (
'Unable to open source file for reading (%s). Exiting.'
% source_path)
sys.exit(1)
else: else:
self.source = sys.stdin self.source = sys.stdin
self.autoclose = None self.autoclose = None
...@@ -191,8 +185,9 @@ class FileOutput(Output): ...@@ -191,8 +185,9 @@ class FileOutput(Output):
Output for single, simple file-like objects. Output for single, simple file-like objects.
""" """
def __init__(self, settings=None, destination=None, destination_path=None, def __init__(self, destination=None, destination_path=None,
encoding=None, autoclose=1): encoding=None, error_handler='strict', autoclose=1,
handle_io_errors=1):
""" """
:Parameters: :Parameters:
- `destination`: either a file-like object (which is written - `destination`: either a file-like object (which is written
...@@ -203,10 +198,11 @@ class FileOutput(Output): ...@@ -203,10 +198,11 @@ class FileOutput(Output):
- `autoclose`: close automatically after write (boolean); always - `autoclose`: close automatically after write (boolean); always
false if `sys.stdout` is the destination. false if `sys.stdout` is the destination.
""" """
Output.__init__(self, settings, destination, destination_path, Output.__init__(self, destination, destination_path,
encoding) encoding, error_handler)
self.opened = 1 self.opened = 1
self.autoclose = autoclose self.autoclose = autoclose
self.handle_io_errors = handle_io_errors
if destination is None: if destination is None:
if destination_path: if destination_path:
self.opened = None self.opened = None
...@@ -220,7 +216,16 @@ class FileOutput(Output): ...@@ -220,7 +216,16 @@ class FileOutput(Output):
pass pass
def open(self): def open(self):
try:
self.destination = open(self.destination_path, 'w') self.destination = open(self.destination_path, 'w')
except IOError, error:
if not self.handle_io_errors:
raise
print >>sys.stderr, '%s: %s' % (error.__class__.__name__,
error)
print >>sys.stderr, ('Unable to open destination file for writing '
'(%s). Exiting.' % source_path)
sys.exit(1)
self.opened = 1 self.opened = 1
def write(self, data): def write(self, data):
......
# Author: David Goodger # Author: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:02 $ # Date: $Date: 2003/07/10 15:49:34 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
# Internationalization details are documented in
# <http://docutils.sf.net/spec/howto/i18n.html>.
""" """
This package contains modules for language-dependent features of Docutils. This package contains modules for language-dependent features of Docutils.
""" """
......
# Author: Jannie Hofmeyr
# Contact: jhsh@sun.ac.za
# Revision: $Revision: 1.1 $
# Date: $Date: 2003/07/10 15:49:34 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/spec/howto/i18n.html>. 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 Docutils.
"""
__docformat__ = 'reStructuredText'
labels = {
'author': 'Auteur',
'authors': 'Auteurs',
'organization': 'Organisasie',
'address': 'Adres',
'contact': 'Kontak',
'version': 'Weergawe',
'revision': 'Revisie',
'status': 'Status',
'date': 'Datum',
'copyright': 'Kopiereg',
'dedication': 'Opdrag',
'abstract': 'Opsomming',
'attention': 'Aandag!',
'caution': 'Wees versigtig!',
'danger': '!GEVAAR!',
'error': 'Fout',
'hint': 'Wenk',
'important': 'Belangrik',
'note': 'Nota',
'tip': 'Tip', # hint and tip both have the same translation: wenk
'warning': 'Waarskuwing',
'contents': 'Inhoud'}
"""Mapping of node class name to label text."""
bibliographic_fields = {
'auteur': 'author',
'auteurs': 'authors',
'organisasie': 'organization',
'adres': 'address',
'kontak': 'contact',
'weergawe': 'version',
'revisie': 'revision',
'status': 'status',
'datum': 'date',
'kopiereg': 'copyright',
'opdrag': 'dedication',
'opsomming': 'abstract'}
"""Afrikaans (lowcased) to canonical name mapping for bibliographic fields."""
author_separators = [';', ',']
"""List of separator strings for the 'Authors' bibliographic field. Tried in
order."""
# Authors: David Goodger; Gunnar Schwant # Authors: David Goodger; Gunnar Schwant
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:03 $ # Date: $Date: 2003/07/10 15:49:34 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/spec/howto/i18n.html>. 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 Docutils. German language mappings for language-dependent features of Docutils.
""" """
__docformat__ = 'reStructuredText' __docformat__ = 'reStructuredText'
from docutils import nodes
labels = { labels = {
'author': 'Autor', 'author': 'Autor',
'authors': 'Autoren', 'authors': 'Autoren',
...@@ -39,20 +41,19 @@ labels = { ...@@ -39,20 +41,19 @@ labels = {
"""Mapping of node class name to label text.""" """Mapping of node class name to label text."""
bibliographic_fields = { bibliographic_fields = {
'autor': nodes.author, 'autor': 'author',
'autoren': nodes.authors, 'autoren': 'authors',
'organisation': nodes.organization, 'organisation': 'organization',
'adresse': nodes.address, 'adresse': 'address',
'kontakt': nodes.contact, 'kontakt': 'contact',
'version': nodes.version, 'version': 'version',
'revision': nodes.revision, 'revision': 'revision',
'status': nodes.status, 'status': 'status',
'datum': nodes.date, 'datum': 'date',
'copyright': nodes.copyright, 'copyright': 'copyright',
'widmung': nodes.topic, 'widmung': 'dedication',
'zusammenfassung': nodes.topic} 'zusammenfassung': 'abstract'}
"""Field name (lowcased) to node class name mapping for bibliographic fields """German (lowcased) to canonical name mapping for bibliographic fields."""
(field_list)."""
author_separators = [';', ','] author_separators = [';', ',']
"""List of separator strings for the 'Authors' bibliographic field. Tried in """List of separator strings for the 'Authors' bibliographic field. Tried in
......
# Author: David Goodger # Author: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:03 $ # Date: $Date: 2003/07/10 15:49:34 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/spec/howto/i18n.html>. 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 Docutils. English-language mappings for language-dependent features of Docutils.
""" """
__docformat__ = 'reStructuredText' __docformat__ = 'reStructuredText'
from docutils import nodes
labels = { labels = {
# fixed: language-dependent
'author': 'Author', 'author': 'Author',
'authors': 'Authors', 'authors': 'Authors',
'organization': 'Organization', 'organization': 'Organization',
...@@ -40,20 +42,20 @@ labels = { ...@@ -40,20 +42,20 @@ labels = {
"""Mapping of node class name to label text.""" """Mapping of node class name to label text."""
bibliographic_fields = { bibliographic_fields = {
'author': nodes.author, # language-dependent: fixed
'authors': nodes.authors, 'author': 'author',
'organization': nodes.organization, 'authors': 'authors',
'address': nodes.address, 'organization': 'organization',
'contact': nodes.contact, 'address': 'address',
'version': nodes.version, 'contact': 'contact',
'revision': nodes.revision, 'version': 'version',
'status': nodes.status, 'revision': 'revision',
'date': nodes.date, 'status': 'status',
'copyright': nodes.copyright, 'date': 'date',
'dedication': nodes.topic, 'copyright': 'copyright',
'abstract': nodes.topic} 'dedication': 'dedication',
"""Field name (lowcased) to node class name mapping for bibliographic fields 'abstract': 'abstract'}
(field_list).""" """English (lowcased) to canonical name mapping for bibliographic fields."""
author_separators = [';', ','] author_separators = [';', ',']
"""List of separator strings for the 'Authors' bibliographic field. Tried in """List of separator strings for the 'Authors' bibliographic field. Tried in
......
# Author: Marcelo Huerta San Martn
# Contact: mghsm@uol.com.ar
# Revision: $Revision: 1.1 $
# Date: $Date: 2003/07/10 15:49:34 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/spec/howto/i18n.html>. 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 Docutils.
"""
__docformat__ = 'reStructuredText'
labels = {
'author': u'Autor',
'authors': u'Autores',
'organization': u'Organizaci\u00f3n',
'address': u'Direcci\u00f3n',
'contact': u'Contacto',
'version': u'Versi\u00f3n',
'revision': u'Revisi\u00f3n',
'status': u'Estado',
'date': u'Fecha',
'copyright': u'Copyright',
'dedication': u'Dedicatoria',
'abstract': u'Resumen',
'attention': u'\u00a1Atenci\u00f3n!',
'caution': u'\u00a1Precauci\u00f3n!',
'danger': u'\u00a1PELIGRO!',
'error': u'Error',
'hint': u'Sugerencia',
'important': u'Importante',
'note': u'Nota',
'tip': u'Consejo',
'warning': u'Advertencia',
'contents': u'Contenido'}
"""Mapping of node class name to label text."""
bibliographic_fields = {
u'autor': 'author',
u'autores': 'authors',
u'organizaci\u00f3n': 'organization',
u'direcci\u00f3n': 'address',
u'contacto': 'contact',
u'versi\u00f3n': 'version',
u'revisi\u00f3n': 'revision',
u'estado': 'status',
u'fecha': 'date',
u'copyright': 'copyright',
u'dedicatoria': 'dedication',
u'resumen': 'abstract'}
"""Spanish (lowcased) to canonical name mapping for bibliographic fields."""
author_separators = [';', ',']
"""List of separator strings for the 'Authors' bibliographic field. Tried in
order."""
# Author: Stefane Fermigier # Author: Stefane Fermigier
# Contact: sf@fermigier.com # Contact: sf@fermigier.com
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:03 $ # Date: $Date: 2003/07/10 15:49:34 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/spec/howto/i18n.html>. 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 Docutils. French-language mappings for language-dependent features of Docutils.
""" """
__docformat__ = 'reStructuredText' __docformat__ = 'reStructuredText'
from docutils import nodes
labels = { labels = {
'author': 'Auteur', u'author': u'Auteur',
'authors': 'Auteurs', u'authors': u'Auteurs',
'organization': 'Organisation', u'organization': u'Organisation',
'address': 'Adresse', u'address': u'Adresse',
'contact': 'Contact', u'contact': u'Contact',
'version': 'Version', u'version': u'Version',
'revision': 'R\u00e9vision', u'revision': u'R\u00e9vision',
'status': 'Statut', u'status': u'Statut',
'date': 'Date', u'date': u'Date',
'copyright': 'Copyright', u'copyright': u'Copyright',
'dedication': 'D\u00e9dicace', u'dedication': u'D\u00e9dicace',
'abstract': 'R\u00e9sum\u00e9', u'abstract': u'R\u00e9sum\u00e9',
'attention': 'Attention!', u'attention': u'Attention!',
'caution': 'Avertissement!', u'caution': u'Avertissement!',
'danger': '!DANGER!', u'danger': u'!DANGER!',
'error': 'Erreur', u'error': u'Erreur',
'hint': 'Indication', u'hint': u'Indication',
'important': 'Important', u'important': u'Important',
'note': 'Note', u'note': u'Note',
'tip': 'Astuce', u'tip': u'Astuce',
'warning': 'Avertissement', u'warning': u'Avis',
'contents': 'Contenu'} u'contents': u'Sommaire'}
"""Mapping of node class name to label text.""" """Mapping of node class name to label text."""
bibliographic_fields = { bibliographic_fields = {
'auteur': nodes.author, u'auteur': u'author',
'auteurs': nodes.authors, u'auteurs': u'authors',
'organisation': nodes.organization, u'organisation': u'organization',
'adresse': nodes.address, u'adresse': u'address',
'contact': nodes.contact, u'contact': u'contact',
'version': nodes.version, u'version': u'version',
'r\u00e9vision': nodes.revision, u'r\u00e9vision': u'revision',
'status': nodes.status, u'statut': u'status',
'date': nodes.date, u'date': u'date',
'copyright': nodes.copyright, u'copyright': u'copyright',
'd\u00e9dicace': nodes.topic, u'd\u00e9dicace': u'dedication',
'r\u00e9sum\u00e9': nodes.topic} u'r\u00e9sum\u00e9': u'abstract'}
"""Field name (lowcased) to node class name mapping for bibliographic fields """French (lowcased) to canonical name mapping for bibliographic fields."""
(field_list)."""
author_separators = [';', ','] author_separators = [';', ',']
"""List of separator strings for the 'Authors' bibliographic field. Tried in """List of separator strings for the 'Authors' bibliographic field. Tried in
......
# Author: Nicola Larosa # Author: Nicola Larosa
# Contact: docutils@tekNico.net # Contact: docutils@tekNico.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:03 $ # Date: $Date: 2003/07/10 15:49:34 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/spec/howto/i18n.html>. 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 Docutils. Italian-language mappings for language-dependent features of Docutils.
""" """
__docformat__ = 'reStructuredText' __docformat__ = 'reStructuredText'
from docutils import nodes
labels = { labels = {
'author': 'Autore', 'author': 'Autore',
'authors': 'Autori', 'authors': 'Autori',
...@@ -40,20 +41,19 @@ labels = { ...@@ -40,20 +41,19 @@ labels = {
"""Mapping of node class name to label text.""" """Mapping of node class name to label text."""
bibliographic_fields = { bibliographic_fields = {
'autore': nodes.author, 'autore': 'author',
'autori': nodes.authors, 'autori': 'authors',
'organizzazione': nodes.organization, 'organizzazione': 'organization',
'indirizzo': nodes.address, 'indirizzo': 'address',
'contatti': nodes.contact, 'contatti': 'contact',
'versione': nodes.version, 'versione': 'version',
'revisione': nodes.revision, 'revisione': 'revision',
'status': nodes.status, 'status': 'status',
'data': nodes.date, 'data': 'date',
'copyright': nodes.copyright, 'copyright': 'copyright',
'dedica': nodes.topic, 'dedica': 'dedication',
'riassunto': nodes.topic} 'riassunto': 'abstract'}
"""Field name (lowcased) to node class name mapping for bibliographic fields """Italian (lowcased) to canonical name mapping for bibliographic fields."""
(field_list)."""
author_separators = [';', ','] author_separators = [';', ',']
"""List of separator strings for the 'Authors' bibliographic field. Tried in """List of separator strings for the 'Authors' bibliographic field. Tried in
......
# Author: Roman Suzi
# Contact: rnd@onego.ru
# Revision: $Revision: 1.1 $
# Date: $Date: 2003/07/10 15:49:34 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/spec/howto/i18n.html>. 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 Docutils.
"""
__docformat__ = 'reStructuredText'
labels = {
u'abstract': u'\u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f',
u'address': u'\u0410\u0434\u0440\u0435\u0441',
u'attention': u'\u0412\u043d\u0438\u043c\u0430\u043d\u0438\u0435!',
u'author': u'\u0410\u0432\u0442\u043e\u0440',
u'authors': u'\u0410\u0432\u0442\u043e\u0440\u044b',
u'caution': u'\u041e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e!',
u'contact': u'\u041a\u043e\u043d\u0442\u0430\u043a\u0442',
u'contents':
u'\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435',
u'copyright': u'\u041f\u0440\u0430\u0432\u0430 '
u'\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f',
u'danger': u'\u041e\u041f\u0410\u0421\u041d\u041e!',
u'date': u'\u0414\u0430\u0442\u0430',
u'dedication':
u'\u041f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u0438\u0435',
u'error': u'\u041e\u0448\u0438\u0431\u043a\u0430',
u'hint': u'\u0421\u043e\u0432\u0435\u0442',
u'important': u'\u0412\u0430\u0436\u043d\u043e',
u'note': u'\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435',
u'organization':
u'\u041e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u044f',
u'revision': u'\u0420\u0435\u0434\u0430\u043a\u0446\u0438\u044f',
u'status': u'\u0421\u0442\u0430\u0442\u0443\u0441',
u'tip': u'\u041f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430',
u'version': u'\u0412\u0435\u0440\u0441\u0438\u044f',
u'warning': u'\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436'
u'\u0434\u0435\u043d\u0438\u0435'}
"""Mapping of node class name to label text."""
bibliographic_fields = {
u'\u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f': u'abstract',
u'\u0410\u0434\u0440\u0435\u0441': u'address',
u'\u0410\u0432\u0442\u043e\u0440': u'author',
u'\u0410\u0432\u0442\u043e\u0440\u044b': u'authors',
u'\u041a\u043e\u043d\u0442\u0430\u043a\u0442': u'contact',
u'\u041f\u0440\u0430\u0432\u0430 \u043a\u043e\u043f\u0438\u0440\u043e'
u'\u0432\u0430\u043d\u0438\u044f': u'copyright',
u'\u0414\u0430\u0442\u0430': u'date',
u'\u041f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u0438\u0435':
u'dedication',
u'\u041e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u044f':
u'organization',
u'\u0420\u0435\u0434\u0430\u043a\u0446\u0438\u044f': u'revision',
u'\u0421\u0442\u0430\u0442\u0443\u0441': u'status',
u'\u0412\u0435\u0440\u0441\u0438\u044f': u'version'}
"""Russian (lowcased) to canonical name mapping for bibliographic fields."""
author_separators = [';', ',']
"""List of separator strings for the 'Authors' bibliographic field. Tried in
order."""
# :Author: Miroslav Vasko # :Author: Miroslav Vasko
# :Contact: zemiak@zoznam.sk # :Contact: zemiak@zoznam.sk
# :Revision: $Revision: 1.2 $ # :Revision: $Revision: 1.3 $
# :Date: $Date: 2003/02/01 09:26:03 $ # :Date: $Date: 2003/07/10 15:49:34 $
# :Copyright: This module has been placed in the public domain. # :Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/spec/howto/i18n.html>. 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 Docutils. Slovak-language mappings for language-dependent features of Docutils.
""" """
__docformat__ = 'reStructuredText' __docformat__ = 'reStructuredText'
from docutils import nodes
labels = { labels = {
'author': u'Autor', 'author': u'Autor',
'authors': u'Autori', 'authors': u'Autori',
...@@ -40,20 +41,19 @@ labels = { ...@@ -40,20 +41,19 @@ labels = {
"""Mapping of node class name to label text.""" """Mapping of node class name to label text."""
bibliographic_fields = { bibliographic_fields = {
u'autor': nodes.author, u'autor': 'author',
u'autori': nodes.authors, u'autori': 'authors',
u'organiz\u00E1cia': nodes.organization, u'organiz\u00E1cia': 'organization',
u'adresa': nodes.address, u'adresa': 'address',
u'kontakt': nodes.contact, u'kontakt': 'contact',
u'verzia': nodes.version, u'verzia': 'version',
u'rev\u00EDzia': nodes.revision, u'rev\u00EDzia': 'revision',
u'stav': nodes.status, u'stav': 'status',
u'D\u00E1tum': nodes.date, u'd\u00E1tum': 'date',
u'copyright': nodes.copyright, u'copyright': 'copyright',
u'venovanie': nodes.topic, u'venovanie': 'dedication',
u'abstraktne': nodes.topic} u'abstraktne': 'abstract'}
"""Field name (lowcased) to node class name mapping for bibliographic fields """Slovak (lowcased) to canonical name mapping for bibliographic fields."""
(field_list)."""
author_separators = [';', ','] author_separators = [';', ',']
"""List of separator strings for the 'Authors' bibliographic field. Tried in """List of separator strings for the 'Authors' bibliographic field. Tried in
......
# Author: Adam Chodorowski # Author: Adam Chodorowski
# Contact: chodorowski@users.sourceforge.net # Contact: chodorowski@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:03 $ # Date: $Date: 2003/07/10 15:49:34 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/spec/howto/i18n.html>. 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 Docutils. Swedish language mappings for language-dependent features of Docutils.
""" """
__docformat__ = 'reStructuredText' __docformat__ = 'reStructuredText'
from docutils import nodes
labels = { labels = {
'author': u'F\u00f6rfattare', 'author': u'F\u00f6rfattare',
'authors': u'F\u00f6rfattare', 'authors': u'F\u00f6rfattare',
...@@ -41,19 +42,19 @@ labels = { ...@@ -41,19 +42,19 @@ labels = {
bibliographic_fields = { bibliographic_fields = {
# 'Author' and 'Authors' identical in Swedish; assume the plural: # 'Author' and 'Authors' identical in Swedish; assume the plural:
u'f\u00f6rfattare': nodes.authors, u'f\u00f6rfattare': 'authors',
u'organisation': nodes.organization, u' n/a': 'author',
u'adress': nodes.address, u'organisation': 'organization',
u'kontakt': nodes.contact, u'adress': 'address',
u'version': nodes.version, u'kontakt': 'contact',
u'revision': nodes.revision, u'version': 'version',
u'status': nodes.status, u'revision': 'revision',
u'datum': nodes.date, u'status': 'status',
u'copyright': nodes.copyright, u'datum': 'date',
u'dedikation': nodes.topic, u'copyright': 'copyright',
u'sammanfattning': nodes.topic } u'dedikation': 'dedication',
"""Field name (lowcased) to node class name mapping for bibliographic fields u'sammanfattning': 'abstract' }
(field_list).""" """Swedish (lowcased) to canonical name mapping for bibliographic fields."""
author_separators = [';', ','] author_separators = [';', ',']
"""List of separator strings for the 'Authors' bibliographic field. Tried in """List of separator strings for the 'Authors' bibliographic field. Tried in
......
This diff is collapsed.
# Author: David Goodger # Author: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:05 $ # Date: $Date: 2003/07/10 15:49:39 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
......
# Author: David Goodger # Author: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:07 $ # Date: $Date: 2003/07/10 15:49:40 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
...@@ -95,7 +95,10 @@ class Parser(docutils.parsers.Parser): ...@@ -95,7 +95,10 @@ class Parser(docutils.parsers.Parser):
{'action': 'store_true'}), {'action': 'store_true'}),
('Set number of spaces for tab expansion (default 8).', ('Set number of spaces for tab expansion (default 8).',
['--tab-width'], ['--tab-width'],
{'metavar': '<width>', 'type': 'int', 'default': 8}),)) {'metavar': '<width>', 'type': 'int', 'default': 8}),
('Remove spaces before footnote references.',
['--trim-footnote-reference-space'],
{'action': 'store_true'}),))
def __init__(self, rfc2822=None, inliner=None): def __init__(self, rfc2822=None, inliner=None):
if rfc2822: if rfc2822:
......
# Author: David Goodger # Author: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:09 $ # Date: $Date: 2003/07/10 15:49:44 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
...@@ -60,7 +60,8 @@ directive function): ...@@ -60,7 +60,8 @@ directive function):
- ``options``: A dictionary, mapping known option names to conversion - ``options``: A dictionary, mapping known option names to conversion
functions such as `int` or `float`. ``None`` or an empty dict implies no 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 - ``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 the case where content is required but not supplied (an empty content list
...@@ -92,9 +93,15 @@ _directive_registry = { ...@@ -92,9 +93,15 @@ _directive_registry = {
'tip': ('admonitions', 'tip'), 'tip': ('admonitions', 'tip'),
'hint': ('admonitions', 'hint'), 'hint': ('admonitions', 'hint'),
'warning': ('admonitions', 'warning'), 'warning': ('admonitions', 'warning'),
'admonition': ('admonitions', 'admonition'),
'sidebar': ('body', 'sidebar'),
'topic': ('body', 'topic'), 'topic': ('body', 'topic'),
'line-block': ('body', 'line_block'), 'line-block': ('body', 'line_block'),
'parsed-literal': ('body', 'parsed_literal'), 'parsed-literal': ('body', 'parsed_literal'),
'rubric': ('body', 'rubric'),
'epigraph': ('body', 'epigraph'),
'highlights': ('body', 'highlights'),
'pull-quote': ('body', 'pull_quote'),
#'questions': ('body', 'question_list'), #'questions': ('body', 'question_list'),
'image': ('images', 'image'), 'image': ('images', 'image'),
'figure': ('images', 'figure'), 'figure': ('images', 'figure'),
...@@ -108,6 +115,8 @@ _directive_registry = { ...@@ -108,6 +115,8 @@ _directive_registry = {
'raw': ('misc', 'raw'), 'raw': ('misc', 'raw'),
'include': ('misc', 'include'), 'include': ('misc', 'include'),
'replace': ('misc', 'replace'), 'replace': ('misc', 'replace'),
'unicode': ('misc', 'unicode_directive'),
'class': ('misc', 'class_directive'),
'restructuredtext-test-directive': ('misc', 'directive_test_function'),} 'restructuredtext-test-directive': ('misc', 'directive_test_function'),}
"""Mapping of directive name to (module name, function name). The directive """Mapping of directive name to (module name, function name). The directive
name is canonical & must be lowercase. Language-dependent names are defined name is canonical & must be lowercase. Language-dependent names are defined
...@@ -171,9 +180,14 @@ def directive(directive_name, language_module, document): ...@@ -171,9 +180,14 @@ def directive(directive_name, language_module, document):
return None, messages return None, messages
return function, messages return function, messages
def register_directive(name, directive):
"""Register a nonstandard application-defined directive function."""
_directives[name] = directive
def flag(argument): def flag(argument):
""" """
Check for a valid flag option (no argument) and return ``None``. Check for a valid flag option (no argument) and return ``None``.
(Directive option conversion function.)
Raise ``ValueError`` if an argument is found. Raise ``ValueError`` if an argument is found.
""" """
...@@ -182,9 +196,10 @@ def flag(argument): ...@@ -182,9 +196,10 @@ def flag(argument):
else: else:
return None 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. Raise ``ValueError`` if no argument is found.
""" """
...@@ -193,9 +208,22 @@ def unchanged(argument): ...@@ -193,9 +208,22 @@ def unchanged(argument):
else: else:
return argument # unchanged! 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): def path(argument):
""" """
Return the path argument unwrapped (with newlines removed). Return the path argument unwrapped (with newlines removed).
(Directive option conversion function.)
Raise ``ValueError`` if no argument is found or if the path contains Raise ``ValueError`` if no argument is found or if the path contains
internal whitespace. internal whitespace.
...@@ -212,17 +240,44 @@ def path(argument): ...@@ -212,17 +240,44 @@ def path(argument):
def nonnegative_int(argument): def nonnegative_int(argument):
""" """
Check for a nonnegative integer argument; raise ``ValueError`` if not. Check for a nonnegative integer argument; raise ``ValueError`` if not.
(Directive option conversion function.)
""" """
value = int(argument) value = int(argument)
if value < 0: if value < 0:
raise ValueError('negative value; must be positive or zero') raise ValueError('negative value; must be positive or zero')
return value 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): def format_values(values):
return '%s, or "%s"' % (', '.join(['"%s"' % s for s in values[:-1]]), return '%s, or "%s"' % (', '.join(['"%s"' % s for s in values[:-1]]),
values[-1]) values[-1])
def choice(argument, values): 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: try:
value = argument.lower().strip() value = argument.lower().strip()
except AttributeError: except AttributeError:
......
# Author: David Goodger # Author: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:09 $ # Date: $Date: 2003/07/10 15:49:44 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
...@@ -11,64 +11,80 @@ Admonition directives. ...@@ -11,64 +11,80 @@ Admonition directives.
__docformat__ = 'reStructuredText' __docformat__ = 'reStructuredText'
from docutils.parsers.rst import states from docutils.parsers.rst import states, directives
from docutils import nodes from docutils import nodes
def admonition(node_class, name, arguments, options, content, lineno, def make_admonition(node_class, name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine): content_offset, block_text, state, state_machine):
text = '\n'.join(content) if not content:
admonition_node = node_class(text)
if text:
state.nested_parse(content, content_offset, admonition_node)
return [admonition_node]
else:
error = state_machine.reporter.error( 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) nodes.literal_block(block_text, block_text), line=lineno)
return [error] 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): def attention(*args):
return admonition(nodes.attention, *args) return make_admonition(nodes.attention, *args)
attention.content = 1 attention.content = 1
def caution(*args): def caution(*args):
return admonition(nodes.caution, *args) return make_admonition(nodes.caution, *args)
caution.content = 1 caution.content = 1
def danger(*args): def danger(*args):
return admonition(nodes.danger, *args) return make_admonition(nodes.danger, *args)
danger.content = 1 danger.content = 1
def error(*args): def error(*args):
return admonition(nodes.error, *args) return make_admonition(nodes.error, *args)
error.content = 1 error.content = 1
def hint(*args):
return make_admonition(nodes.hint, *args)
hint.content = 1
def important(*args): def important(*args):
return admonition(nodes.important, *args) return make_admonition(nodes.important, *args)
important.content = 1 important.content = 1
def note(*args): def note(*args):
return admonition(nodes.note, *args) return make_admonition(nodes.note, *args)
note.content = 1 note.content = 1
def tip(*args): def tip(*args):
return admonition(nodes.tip, *args) return make_admonition(nodes.tip, *args)
tip.content = 1 tip.content = 1
def hint(*args):
return admonition(nodes.hint, *args)
hint.content = 1
def warning(*args): def warning(*args):
return admonition(nodes.warning, *args) return make_admonition(nodes.warning, *args)
warning.content = 1 warning.content = 1
# Author: David Goodger # Author: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:09 $ # Date: $Date: 2003/07/10 15:49:44 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
...@@ -13,13 +13,16 @@ __docformat__ = 'reStructuredText' ...@@ -13,13 +13,16 @@ __docformat__ = 'reStructuredText'
import sys import sys
from docutils import nodes from docutils import nodes
from docutils.parsers.rst import directives
def topic(name, arguments, options, content, lineno, 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: if not state_machine.match_titles:
error = state_machine.reporter.error( 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) nodes.literal_block(block_text, block_text), line=lineno)
return [error] return [error]
if not content: if not content:
...@@ -30,16 +33,35 @@ def topic(name, arguments, options, content, lineno, ...@@ -30,16 +33,35 @@ def topic(name, arguments, options, content, lineno,
return [warning] return [warning]
title_text = arguments[0] title_text = arguments[0]
textnodes, messages = state.inline_text(title_text, lineno) 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) text = '\n'.join(content)
topic_node = nodes.topic(text, title, *messages) node = node_class(text, *(titles + messages))
if options.has_key('class'):
node.set_class(options['class'])
if text: if text:
state.nested_parse(content, content_offset, topic_node) state.nested_parse(content, content_offset, node)
return [topic_node] return [node]
topic.arguments = (1, 0, 1) topic.arguments = (1, 0, 1)
topic.options = {'class': directives.class_option}
topic.content = 1 topic.content = 1
def sidebar(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):
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_required,
'class': directives.class_option}
sidebar.content = 1
def line_block(name, arguments, options, content, lineno, def line_block(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine, content_offset, block_text, state, state_machine,
node_class=nodes.line_block): node_class=nodes.line_block):
...@@ -50,9 +72,10 @@ def line_block(name, arguments, options, content, lineno, ...@@ -50,9 +72,10 @@ def line_block(name, arguments, options, content, lineno,
return [warning] return [warning]
text = '\n'.join(content) text = '\n'.join(content)
text_nodes, messages = state.inline_text(text, lineno) text_nodes, messages = state.inline_text(text, lineno)
node = node_class(text, '', *text_nodes) node = node_class(text, '', *text_nodes, **options)
return [node] + messages return [node] + messages
line_block.options = {'class': directives.class_option}
line_block.content = 1 line_block.content = 1
def parsed_literal(name, arguments, options, content, lineno, def parsed_literal(name, arguments, options, content, lineno,
...@@ -61,4 +84,39 @@ def parsed_literal(name, arguments, options, content, lineno, ...@@ -61,4 +84,39 @@ def parsed_literal(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine, content_offset, block_text, state, state_machine,
node_class=nodes.literal_block) node_class=nodes.literal_block)
parsed_literal.options = {'class': directives.class_option}
parsed_literal.content = 1 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
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
# Author: David Goodger # Author: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:09 $ # Date: $Date: 2003/07/10 15:49:44 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
......
# Author: David Goodger # Author: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:09 $ # Date: $Date: 2003/07/10 15:49:44 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
...@@ -15,6 +15,10 @@ import sys ...@@ -15,6 +15,10 @@ import sys
from docutils import nodes, utils from docutils import nodes, utils
from docutils.parsers.rst import directives from docutils.parsers.rst import directives
try:
import Image # PIL
except ImportError:
Image = None
align_values = ('top', 'middle', 'bottom', 'left', 'center', 'right') align_values = ('top', 'middle', 'bottom', 'left', 'center', 'right')
...@@ -38,15 +42,33 @@ image.options = {'alt': directives.unchanged, ...@@ -38,15 +42,33 @@ image.options = {'alt': directives.unchanged,
'height': directives.nonnegative_int, 'height': directives.nonnegative_int,
'width': directives.nonnegative_int, 'width': directives.nonnegative_int,
'scale': directives.nonnegative_int, 'scale': directives.nonnegative_int,
'align': align} 'align': align,
'class': directives.class_option}
def figure(name, arguments, options, content, lineno, def figure(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine): 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, (image_node,) = image(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine) content_offset, block_text, state, state_machine)
if isinstance(image_node, nodes.system_message): if isinstance(image_node, nodes.system_message):
return [image_node] return [image_node]
figure_node = nodes.figure('', 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 figclass:
figure_node.set_class(figclass)
if content: if content:
node = nodes.Element() # anonymous container for parsing node = nodes.Element() # anonymous container for parsing
state.nested_parse(content, content_offset, node) state.nested_parse(content, content_offset, node)
...@@ -65,6 +87,14 @@ def figure(name, arguments, options, content, lineno, ...@@ -65,6 +87,14 @@ def figure(name, arguments, options, content, lineno,
figure_node += nodes.legend('', *node[1:]) figure_node += nodes.legend('', *node[1:])
return [figure_node] 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.arguments = (1, 0, 1)
figure.options = image.options figure.options = {'figwidth': figwidth_value,
'figclass': directives.class_option}
figure.options.update(image.options)
figure.content = 1 figure.content = 1
# Authors: David Goodger, Dethe Elza # Authors: David Goodger, Dethe Elza
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:09 $ # Date: $Date: 2003/07/10 15:49:44 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
"""Miscellaneous directives.""" """Miscellaneous directives."""
...@@ -10,9 +10,11 @@ __docformat__ = 'reStructuredText' ...@@ -10,9 +10,11 @@ __docformat__ = 'reStructuredText'
import sys import sys
import os.path import os.path
import re
from urllib2 import urlopen, URLError from urllib2 import urlopen, URLError
from docutils import io, nodes, statemachine, utils from docutils import io, nodes, statemachine, utils
from docutils.parsers.rst import directives, states from docutils.parsers.rst import directives, states
from docutils.transforms import misc
def include(name, arguments, options, content, lineno, def include(name, arguments, options, content, lineno,
...@@ -31,10 +33,12 @@ def include(name, arguments, options, content, lineno, ...@@ -31,10 +33,12 @@ def include(name, arguments, options, content, lineno,
path = utils.relative_path(None, path) path = utils.relative_path(None, path)
try: try:
include_file = io.FileInput( 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: except IOError, error:
severe = state_machine.reporter.severe( 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) nodes.literal_block(block_text, block_text), line=lineno)
return [severe] return [severe]
include_text = include_file.read() include_text = include_file.read()
...@@ -151,6 +155,65 @@ def replace(name, arguments, options, content, lineno, ...@@ -151,6 +155,65 @@ def replace(name, arguments, options, content, lineno,
replace.content = 1 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+``, ``u``, or ``\u``; e.g. ``U+262E``), or XML-style numeric character
entities (e.g. ``&#x262E;``). 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(
'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('.. ')[0].split()
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, 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)([0-9a-f]+)$|&#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, def directive_test_function(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine): content_offset, block_text, state, state_machine):
if content: if content:
...@@ -166,5 +229,5 @@ def directive_test_function(name, arguments, options, content, lineno, ...@@ -166,5 +229,5 @@ def directive_test_function(name, arguments, options, content, lineno,
return [info] return [info]
directive_test_function.arguments = (0, 1, 1) 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 directive_test_function.content = 1
# Author: David Goodger, Dmitry Jemerov # Author: David Goodger, Dmitry Jemerov
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:09 $ # Date: $Date: 2003/07/10 15:49:44 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
...@@ -42,7 +42,8 @@ def contents(name, arguments, options, content, lineno, ...@@ -42,7 +42,8 @@ def contents(name, arguments, options, content, lineno,
contents.arguments = (0, 1, 1) contents.arguments = (0, 1, 1)
contents.options = {'depth': directives.nonnegative_int, contents.options = {'depth': directives.nonnegative_int,
'local': directives.flag, 'local': directives.flag,
'backlinks': backlinks} 'backlinks': backlinks,
'class': directives.class_option}
def sectnum(name, arguments, options, content, lineno, def sectnum(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine): content_offset, block_text, state, state_machine):
......
# Author: David Goodger, Dmitry Jemerov # Author: David Goodger, Dmitry Jemerov
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:09 $ # Date: $Date: 2003/07/10 15:49:44 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
......
# Author: David Goodger # Author: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:13 $ # Date: $Date: 2003/07/10 15:49:49 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
# Internationalization details are documented in
# <http://docutils.sf.net/spec/howto/i18n.html>.
""" """
This package contains modules for language-dependent features of This package contains modules for language-dependent features of
reStructuredText. reStructuredText.
......
# Author: Jannie Hofmeyr
# Contact: jhsh@sun.ac.za
# Revision: $Revision: 1.1 $
# Date: $Date: 2003/07/10 15:49:49 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/spec/howto/i18n.html>. 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.
"""
# -*- coding: iso-8859-1 -*-
# Author: Engelbert Gruber # Author: Engelbert Gruber
# Contact: grubert@users.sourceforge.net # Contact: grubert@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:13 $ # Date: $Date: 2003/07/10 15:49:49 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/spec/howto/i18n.html>. 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 German-language mappings for language-dependent features of
reStructuredText. reStructuredText.
...@@ -22,9 +28,15 @@ directives = { ...@@ -22,9 +28,15 @@ directives = {
'notiz': 'note', 'notiz': 'note',
'tip': 'tip', 'tip': 'tip',
'warnung': 'warning', 'warnung': 'warning',
'topic': 'topic', # berbegriff 'ermahnung': 'admonition',
'kasten': 'sidebar', # seitenkasten ?
'thema': 'topic',
'line-block': 'line-block', 'line-block': 'line-block',
'parsed-literal': 'parsed-literal', 'parsed-literal': 'parsed-literal',
'rubrik': 'rubric',
'epigraph (translation required)': 'epigraph',
'highlights (translation required)': 'highlights',
'pull-quote (translation required)': 'pull-quote', # kasten too ?
#'questions': 'questions', #'questions': 'questions',
#'qa': 'questions', #'qa': 'questions',
#'faq': 'questions', #'faq': 'questions',
...@@ -35,7 +47,9 @@ directives = { ...@@ -35,7 +47,9 @@ directives = {
'raw': 'raw', # unbearbeitet 'raw': 'raw', # unbearbeitet
'include': 'include', # einfügen, "füge ein" would be more like a command. 'include': 'include', # einfügen, "füge ein" would be more like a command.
# einfügung would be the noun. # einfügung would be the noun.
'replace': 'replace', # ersetzen, ersetze 'ersetzung': 'replace', # ersetzen, ersetze
'unicode': 'unicode',
'klasse': 'class', # offer class too ?
'inhalt': 'contents', 'inhalt': 'contents',
'sectnum': 'sectnum', 'sectnum': 'sectnum',
'section-numbering': 'sectnum', 'section-numbering': 'sectnum',
...@@ -43,5 +57,27 @@ directives = { ...@@ -43,5 +57,27 @@ directives = {
#'footnotes': 'footnotes', #'footnotes': 'footnotes',
#'citations': 'citations', #'citations': 'citations',
'restructuredtext-test-directive': 'restructuredtext-test-directive'} '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.""" 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.
"""
# Author: David Goodger # Author: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:13 $ # Date: $Date: 2003/07/10 15:49:49 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/spec/howto/i18n.html>. 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 English-language mappings for language-dependent features of
reStructuredText. reStructuredText.
...@@ -13,6 +18,7 @@ __docformat__ = 'reStructuredText' ...@@ -13,6 +18,7 @@ __docformat__ = 'reStructuredText'
directives = { directives = {
# language-dependent: fixed
'attention': 'attention', 'attention': 'attention',
'caution': 'caution', 'caution': 'caution',
'danger': 'danger', 'danger': 'danger',
...@@ -22,9 +28,15 @@ directives = { ...@@ -22,9 +28,15 @@ directives = {
'note': 'note', 'note': 'note',
'tip': 'tip', 'tip': 'tip',
'warning': 'warning', 'warning': 'warning',
'admonition': 'admonition',
'sidebar': 'sidebar',
'topic': 'topic', 'topic': 'topic',
'line-block': 'line-block', 'line-block': 'line-block',
'parsed-literal': 'parsed-literal', 'parsed-literal': 'parsed-literal',
'rubric': 'rubric',
'epigraph': 'epigraph',
'highlights': 'highlights',
'pull-quote': 'pull-quote',
#'questions': 'questions', #'questions': 'questions',
#'qa': 'questions', #'qa': 'questions',
#'faq': 'questions', #'faq': 'questions',
...@@ -35,23 +47,30 @@ directives = { ...@@ -35,23 +47,30 @@ directives = {
'include': 'include', 'include': 'include',
'raw': 'raw', 'raw': 'raw',
'replace': 'replace', 'replace': 'replace',
'unicode': 'unicode',
'class': 'class',
'contents': 'contents', 'contents': 'contents',
'sectnum': 'sectnum', 'sectnum': 'sectnum',
'section-numbering': 'sectnum', 'section-numbering': 'sectnum',
'target-notes': 'target-notes',
#'footnotes': 'footnotes', #'footnotes': 'footnotes',
#'citations': 'citations', #'citations': 'citations',
'target-notes': 'target-notes',
'restructuredtext-test-directive': 'restructuredtext-test-directive'} 'restructuredtext-test-directive': 'restructuredtext-test-directive'}
"""English name to registered (in directives/__init__.py) directive name """English name to registered (in directives/__init__.py) directive name
mapping.""" mapping."""
roles = { roles = {
# language-dependent: fixed
'abbreviation': 'abbreviation', 'abbreviation': 'abbreviation',
'ab': 'abbreviation', 'ab': 'abbreviation',
'acronym': 'acronym', 'acronym': 'acronym',
'ac': 'acronym', 'ac': 'acronym',
'index': 'index', 'index': 'index',
'i': 'index', 'i': 'index',
'subscript': 'subscript',
'sub': 'subscript',
'superscript': 'superscript',
'sup': 'superscript',
'title-reference': 'title-reference', 'title-reference': 'title-reference',
'title': 'title-reference', 'title': 'title-reference',
't': 'title-reference', 't': 'title-reference',
...@@ -70,7 +89,6 @@ roles = { ...@@ -70,7 +89,6 @@ roles = {
'target': 'target', 'target': 'target',
'uri-reference': 'uri-reference', 'uri-reference': 'uri-reference',
'uri': 'uri-reference', 'uri': 'uri-reference',
'url': 'uri-reference', 'url': 'uri-reference',}
}
"""Mapping of English role names to canonical role names for interpreted text. """Mapping of English role names to canonical role names for interpreted text.
""" """
# Author: Marcelo Huerta San Martn
# Contact: mghsm@uol.com.ar
# Revision: $Revision: 1.1 $
# Date: $Date: 2003/07/10 15:49:49 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/spec/howto/i18n.html>. 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.
"""
__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'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'firma': 'rubric',
u'ep\u00edgrafe': 'epigraph',
u'epigrafe': 'epigraph',
u'destacado': 'highlights',
u'cita-destacada': 'pull-quote',
#'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'clase': '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'}
"""Spanish 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'subscript (translation required)': 'subscript',
u'superscript (translation required)': 'superscript',
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.
"""
# Author: your name here! # Authors: David Goodger; William Dode
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:13 $ # Date: $Date: 2003/07/10 15:49:49 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/spec/howto/i18n.html>. 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 French-language mappings for language-dependent features of
reStructuredText. reStructuredText.
...@@ -13,34 +18,72 @@ __docformat__ = 'reStructuredText' ...@@ -13,34 +18,72 @@ __docformat__ = 'reStructuredText'
directives = { directives = {
'attention (translation required)': 'attention', u'attention': 'attention',
'caution (translation required)': 'caution', u'pr\u00E9caution': 'caution',
'danger (translation required)': 'danger', u'danger': 'danger',
'error (translation required)': 'error', u'erreur': 'error',
'hint (translation required)': 'hint', u'conseil': 'hint',
'important (translation required)': 'important', u'important': 'important',
'note (translation required)': 'note', u'note': 'note',
'tip (translation required)': 'tip', u'astuce': 'tip',
'warning (translation required)': 'warning', u'avertissement': 'warning',
'topic (translation required)': 'topic', u'admonition': 'admonition',
'line-block (translation required)': 'line-block', u'encadr\u00E9': 'sidebar',
'parsed-literal (translation required)': 'parsed-literal', u'sujet': 'topic',
#'questions (translation required)': 'questions', u'bloc-textuel': 'line-block',
#'qa (translation required)': 'questions', u'bloc-interpr\u00E9t\u00E9': 'parsed-literal',
#'faq (translation required)': 'questions', u'code-interpr\u00E9t\u00E9': 'parsed-literal',
'meta (translation required)': 'meta', u'intertitre': 'rubric',
#'imagemap (translation required)': 'imagemap', u'exergue': 'epigraph',
'image (translation required)': 'image', u'\u00E9pigraphe': 'epigraph',
'figure (translation required)': 'figure', u'chapeau': 'highlights',
'include (translation required)': 'include', u'accroche': 'pull-quote',
'raw (translation required)': 'raw', #u'questions': 'questions',
'replace (translation required)': 'replace', #u'qr': 'questions',
'contents (translation required)': 'contents', #u'faq': 'questions',
'sectnum (translation required)': 'sectnum', u'm\u00E9ta': 'meta',
'section-numbering (translation required)': 'sectnum', #u'imagemap (translation required)': 'imagemap',
'target-notes (translation required)': 'target-notes', u'image': 'image',
#'footnotes (translation required)': 'footnotes', u'figure': 'figure',
#'citations (translation required)': 'citations', u'inclure': 'include',
u'brut': 'raw',
u'remplacer': 'replace',
u'remplace': '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 """French name to registered (in directives/__init__.py) directive name
mapping.""" mapping."""
roles = {
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'fort': '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.
"""
# Author: Nicola Larosa # Author: Nicola Larosa
# Contact: docutils@tekNico.net # Contact: docutils@tekNico.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:13 $ # Date: $Date: 2003/07/10 15:49:49 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/spec/howto/i18n.html>. 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 Italian-language mappings for language-dependent features of
reStructuredText. reStructuredText.
...@@ -22,9 +27,15 @@ directives = { ...@@ -22,9 +27,15 @@ directives = {
'nota': 'note', 'nota': 'note',
'consiglio': 'tip', 'consiglio': 'tip',
'avvertenza': 'warning', 'avvertenza': 'warning',
'admonition (translation required)': 'admonition',
'sidebar (translation required)': 'sidebar',
'argomento': 'topic', 'argomento': 'topic',
'blocco di linee': 'line-block', 'blocco di linee': 'line-block',
'parsed-literal': 'parsed-literal', 'parsed-literal': 'parsed-literal',
'rubric (translation required)': 'rubric',
'epigraph (translation required)': 'epigraph',
'highlights (translation required)': 'highlights',
'pull-quote (translation required)': 'pull-quote',
#'questions': 'questions', #'questions': 'questions',
#'qa': 'questions', #'qa': 'questions',
#'faq': 'questions', #'faq': 'questions',
...@@ -35,6 +46,8 @@ directives = { ...@@ -35,6 +46,8 @@ directives = {
'includi': 'include', 'includi': 'include',
'grezzo': 'raw', 'grezzo': 'raw',
'sostituisci': 'replace', 'sostituisci': 'replace',
'unicode': 'unicode',
'class (translation required)': 'class',
'indice': 'contents', 'indice': 'contents',
'seznum': 'sectnum', 'seznum': 'sectnum',
'section-numbering': 'sectnum', 'section-numbering': 'sectnum',
...@@ -42,5 +55,27 @@ directives = { ...@@ -42,5 +55,27 @@ directives = {
#'footnotes': 'footnotes', #'footnotes': 'footnotes',
#'citations': 'citations', #'citations': 'citations',
'restructuredtext-test-directive': 'restructuredtext-test-directive'} '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.""" 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.
"""
# Author: Roman Suzi
# Contact: rnd@onego.ru
# Revision: $Revision: 1.1 $
# Date: $Date: 2003/07/10 15:49:49 $
# Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/spec/howto/i18n.html>. 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'\u0431\u043b\u043e\u043a-\u0441\u0442\u0440\u043e\u043a': u'line-block',
u'meta': u'meta',
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\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',
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'\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'\u0446\u0435\u043b\u044c': 'target'}
"""Mapping of Russian role names to canonical role names for interpreted text.
"""
# Author: Miroslav Vasko # Author: Miroslav Vasko
# Contact: zemiak@zoznam.sk # Contact: zemiak@zoznam.sk
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:13 $ # Date: $Date: 2003/07/10 15:49:49 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/spec/howto/i18n.html>. 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 Slovak-language mappings for language-dependent features of
reStructuredText. reStructuredText.
...@@ -22,9 +27,15 @@ directives = { ...@@ -22,9 +27,15 @@ directives = {
u'pozn\xe1mka': 'note', u'pozn\xe1mka': 'note',
u'tip': 'tip', u'tip': 'tip',
u'varovanie': 'warning', u'varovanie': 'warning',
u'admonition (translation required)': 'admonition',
u'sidebar (translation required)': 'sidebar',
u't\xe9ma': 'topic', u't\xe9ma': 'topic',
u'blok-riadkov': 'line-block', u'blok-riadkov': 'line-block',
u'parsed-literal': 'parsed-literal', u'parsed-literal': 'parsed-literal',
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'questions': 'questions',
#u'qa': 'questions', #u'qa': 'questions',
#u'faq': 'questions', #u'faq': 'questions',
...@@ -35,6 +46,8 @@ directives = { ...@@ -35,6 +46,8 @@ directives = {
u'vlo\x9ei\x9d': 'include', u'vlo\x9ei\x9d': 'include',
u'raw': 'raw', u'raw': 'raw',
u'nahradi\x9d': 'replace', u'nahradi\x9d': 'replace',
u'unicode': 'unicode',
u'class (translation required)': 'class',
u'obsah': 'contents', u'obsah': 'contents',
u'\xe8as\x9d': 'sectnum', u'\xe8as\x9d': 'sectnum',
u'\xe8as\x9d-\xe8\xedslovanie': 'sectnum', u'\xe8as\x9d-\xe8\xedslovanie': 'sectnum',
...@@ -44,3 +57,25 @@ directives = { ...@@ -44,3 +57,25 @@ directives = {
} }
"""Slovak name to registered (in directives/__init__.py) directive name """Slovak name to registered (in directives/__init__.py) directive name
mapping.""" 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.
"""
# Author: Adam Chodorowski # Author: Adam Chodorowski
# Contact: chodorowski@users.sourceforge.net # Contact: chodorowski@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:13 $ # Date: $Date: 2003/07/10 15:49:49 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/spec/howto/i18n.html>. 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. Swedish language mappings for language-dependent features of reStructuredText.
""" """
...@@ -21,9 +26,15 @@ directives = { ...@@ -21,9 +26,15 @@ directives = {
u'notera': 'note', u'notera': 'note',
u'tips': 'tip', u'tips': 'tip',
u'varning': 'warning', u'varning': 'warning',
u'admonition (translation required)': 'admonition',
u'sidebar (translation required)': 'sidebar',
u'\u00e4mne': 'topic', u'\u00e4mne': 'topic',
'line-block (translation required)': 'line-block', u'line-block (translation required)': 'line-block',
'parsed-literal (translation required)': 'parsed-literal', u'parsed-literal (translation required)': 'parsed-literal',
u'mellanrubrik': 'rubric',
u'epigraph (translation required)': 'epigraph',
u'highlights (translation required)': 'highlights',
u'pull-quote (translation required)': 'pull-quote',
# u'fr\u00e5gor': 'questions', # u'fr\u00e5gor': 'questions',
# NOTE: A bit long, but recommended by 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'fr\u00e5gor-och-svar': 'questions',
...@@ -32,15 +43,38 @@ directives = { ...@@ -32,15 +43,38 @@ directives = {
# u'bildkarta': 'imagemap', # FIXME: Translation might be too literal. # u'bildkarta': 'imagemap', # FIXME: Translation might be too literal.
u'bild': 'image', u'bild': 'image',
u'figur': 'figure', u'figur': 'figure',
'include (translation required)': 'include', u'inkludera': 'include',
u'r\u00e5': 'raw', # FIXME: Translation might be too literal. u'r\u00e5': 'raw', # FIXME: Translation might be too literal.
'replace (translation required)': 'replace', u'ers\u00e4tt': 'replace',
u'unicode': 'unicode',
u'class (translation required)': 'class',
u'inneh\u00e5ll': 'contents', u'inneh\u00e5ll': 'contents',
'sectnum (translation required)': 'sectnum', u'sektionsnumrering': 'sectnum',
'section-numbering (translation required)': 'sectnum', u'target-notes (translation required)': 'target-notes',
'target-notes (translation required)': 'target-notes',
# u'fotnoter': 'footnotes', # u'fotnoter': 'footnotes',
# u'citeringar': 'citations', # u'citeringar': 'citations',
} }
"""Swedish name to registered (in directives/__init__.py) directive name """Swedish name to registered (in directives/__init__.py) directive name
mapping.""" 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.
"""
"""Convert to and from Roman numerals"""
__author__ = "Mark Pilgrim (f8dy@diveintopython.org)"
__version__ = "1.4"
__date__ = "8 August 2001"
__copyright__ = """Copyright (c) 2001 Mark Pilgrim
This program is part of "Dive Into Python", a free Python tutorial for
experienced programmers. Visit http://diveintopython.org/ for the
latest version.
This program is free software; you can redistribute it and/or modify
it under the terms of the Python 2.1.1 license, available at
http://www.python.org/2.1.1/license.html
"""
import re
#Define exceptions
class RomanError(Exception): pass
class OutOfRangeError(RomanError): pass
class NotIntegerError(RomanError): pass
class InvalidRomanNumeralError(RomanError): pass
#Define digit mapping
romanNumeralMap = (('M', 1000),
('CM', 900),
('D', 500),
('CD', 400),
('C', 100),
('XC', 90),
('L', 50),
('XL', 40),
('X', 10),
('IX', 9),
('V', 5),
('IV', 4),
('I', 1))
def toRoman(n):
"""convert integer to Roman numeral"""
if not (0 < n < 5000):
raise OutOfRangeError, "number out of range (must be 1..4999)"
if int(n) <> n:
raise NotIntegerError, "decimals can not be converted"
result = ""
for numeral, integer in romanNumeralMap:
while n >= integer:
result += numeral
n -= integer
return result
#Define pattern to detect valid Roman numerals
romanNumeralPattern = re.compile('''
^ # beginning of string
M{0,4} # thousands - 0 to 4 M's
(CM|CD|D?C{0,3}) # hundreds - 900 (CM), 400 (CD), 0-300 (0 to 3 C's),
# or 500-800 (D, followed by 0 to 3 C's)
(XC|XL|L?X{0,3}) # tens - 90 (XC), 40 (XL), 0-30 (0 to 3 X's),
# or 50-80 (L, followed by 0 to 3 X's)
(IX|IV|V?I{0,3}) # ones - 9 (IX), 4 (IV), 0-3 (0 to 3 I's),
# or 5-8 (V, followed by 0 to 3 I's)
$ # end of string
''' ,re.VERBOSE)
def fromRoman(s):
"""convert Roman numeral to integer"""
if not s:
raise InvalidRomanNumeralError, 'Input can not be blank'
if not romanNumeralPattern.search(s):
raise InvalidRomanNumeralError, 'Invalid Roman numeral: %s' % s
result = 0
index = 0
for numeral, integer in romanNumeralMap:
while s[index:index+len(numeral)] == numeral:
result += integer
index += len(numeral)
return result
This diff is collapsed.
# Author: David Goodger # Author: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:07 $ # Date: $Date: 2003/07/10 15:49:41 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
...@@ -131,7 +131,8 @@ class GridTableParser(TableParser): ...@@ -131,7 +131,8 @@ class GridTableParser(TableParser):
head_body_separator_pat = re.compile(r'\+=[=+]+=\+ *$') head_body_separator_pat = re.compile(r'\+=[=+]+=\+ *$')
def setup(self, block): 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() # don't propagate changes to parent
self.bottom = len(block) - 1 self.bottom = len(block) - 1
self.right = len(block[0]) - 1 self.right = len(block[0]) - 1
self.head_body_sep = None self.head_body_sep = None
...@@ -165,7 +166,9 @@ class GridTableParser(TableParser): ...@@ -165,7 +166,9 @@ class GridTableParser(TableParser):
update_dict_of_lists(self.rowseps, rowseps) update_dict_of_lists(self.rowseps, rowseps)
update_dict_of_lists(self.colseps, colseps) update_dict_of_lists(self.colseps, colseps)
self.mark_done(top, left, bottom, right) 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)
cellblock.disconnect() # lines in cell can't sync with parent
self.cells.append((top, left, bottom, right, cellblock)) self.cells.append((top, left, bottom, right, cellblock))
corners.extend([(top, right), (bottom, left)]) corners.extend([(top, right), (bottom, left)])
corners.sort() corners.sort()
...@@ -188,19 +191,6 @@ class GridTableParser(TableParser): ...@@ -188,19 +191,6 @@ class GridTableParser(TableParser):
return None return None
return 1 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): def scan_cell(self, top, left):
"""Starting at the top-left corner, start tracing out a cell.""" """Starting at the top-left corner, start tracing out a cell."""
assert self.block[top][left] == '+' assert self.block[top][left] == '+'
...@@ -278,7 +268,7 @@ class GridTableParser(TableParser): ...@@ -278,7 +268,7 @@ class GridTableParser(TableParser):
def structure_from_cells(self): 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. structure.
""" """
rowseps = self.rowseps.keys() # list of row boundaries rowseps = self.rowseps.keys() # list of row boundaries
...@@ -371,7 +361,8 @@ class SimpleTableParser(TableParser): ...@@ -371,7 +361,8 @@ class SimpleTableParser(TableParser):
span_pat = re.compile('-[ -]*$') span_pat = re.compile('-[ -]*$')
def setup(self, block): 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() # don't propagate changes to parent
# Convert top & bottom borders to column span underlines: # Convert top & bottom borders to column span underlines:
self.block[0] = self.block[0].replace('=', '-') self.block[0] = self.block[0].replace('=', '-')
self.block[-1] = self.block[-1].replace('=', '-') self.block[-1] = self.block[-1].replace('=', '-')
...@@ -394,25 +385,26 @@ class SimpleTableParser(TableParser): ...@@ -394,25 +385,26 @@ class SimpleTableParser(TableParser):
self.columns = self.parse_columns(self.block[0], 0) self.columns = self.parse_columns(self.block[0], 0)
self.border_end = self.columns[-1][1] self.border_end = self.columns[-1][1]
firststart, firstend = self.columns[0] firststart, firstend = self.columns[0]
block = self.block[1:] offset = 1 # skip top border
offset = 0 start = 1
# Container for accumulating text lines until a row is complete: text_found = None
rowlines = [] while offset < len(self.block):
while block: line = self.block[offset]
line = block.pop(0)
offset += 1
if self.span_pat.match(line): if self.span_pat.match(line):
# Column span underline or border; row is complete. # Column span underline or border; row is complete.
self.parse_row(rowlines, (line.rstrip(), offset)) self.parse_row(self.block[start:offset], start,
rowlines = [] (line.rstrip(), offset))
start = offset + 1
text_found = None
elif line[firststart:firstend].strip(): elif line[firststart:firstend].strip():
# First column not blank, therefore it's a new row. # First column not blank, therefore it's a new row.
if rowlines: if text_found and offset != start:
self.parse_row(rowlines) self.parse_row(self.block[start:offset], start)
rowlines = [(line.rstrip(), offset)] start = offset
else: text_found = 1
# Accumulate lines of incomplete row. elif not text_found:
rowlines.append((line.rstrip(), offset)) start = offset + 1
offset += 1
def parse_columns(self, line, offset): def parse_columns(self, line, offset):
""" """
...@@ -448,12 +440,12 @@ class SimpleTableParser(TableParser): ...@@ -448,12 +440,12 @@ class SimpleTableParser(TableParser):
morecols += 1 morecols += 1
except (AssertionError, IndexError): except (AssertionError, IndexError):
raise TableMarkupError('Column span alignment problem at ' raise TableMarkupError('Column span alignment problem at '
'line offset %s.' % offset) 'line offset %s.' % (offset + 1))
cells.append((0, morecols, offset, [])) cells.append([0, morecols, offset, []])
i += 1 i += 1
return cells 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`. Given the text `lines` of a row, parse it and append to `self.table`.
...@@ -462,20 +454,30 @@ class SimpleTableParser(TableParser): ...@@ -462,20 +454,30 @@ class SimpleTableParser(TableParser):
text from each line, and check for text in column margins. Finally, text from each line, and check for text in column margins. Finally,
adjust for insigificant whitespace. adjust for insigificant whitespace.
""" """
while lines and not lines[-1][0]: if not (lines or spanline):
lines.pop() # Remove blank trailing lines.
if lines:
offset = lines[0][1]
elif spanline:
offset = spanline[1]
else:
# No new row, just blank lines. # No new row, just blank lines.
return return
if spanline: if spanline:
columns = self.parse_columns(*spanline) columns = self.parse_columns(*spanline)
span_offset = spanline[1]
else: else:
columns = self.columns[:] 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)
cellblock.disconnect() # lines in cell can't sync with parent
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 # "Infinite" value for a dummy last column's beginning, used to
# check for text overflow: # check for text overflow:
columns.append((sys.maxint, None)) columns.append((sys.maxint, None))
...@@ -483,30 +485,20 @@ class SimpleTableParser(TableParser): ...@@ -483,30 +485,20 @@ class SimpleTableParser(TableParser):
for i in range(len(columns) - 1): for i in range(len(columns) - 1):
start, end = columns[i] start, end = columns[i]
nextstart = columns[i+1][0] nextstart = columns[i+1][0]
block = [] offset = 0
margin = sys.maxint for line in lines:
for line, offset in lines:
if i == lastcol and line[end:].strip(): if i == lastcol and line[end:].strip():
text = line[start:].rstrip() text = line[start:].rstrip()
columns[lastcol] = (start, start + len(text)) new_end = start + len(text)
self.adjust_last_column(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(): elif line[end:nextstart].strip():
raise TableMarkupError('Text in column margin at line ' raise TableMarkupError('Text in column margin at line '
'offset %s.' % offset) 'offset %s.' % (first_line + offset))
else: offset += 1
text = line[start:end].rstrip() columns.pop()
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): def structure_from_cells(self):
colspecs = [end - start for start, end in self.columns] colspecs = [end - start for start, end in self.columns]
......
# Authors: David Goodger; Ueli Schlaepfer # Authors: David Goodger; Ueli Schlaepfer
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:15 $ # Date: $Date: 2003/07/10 15:49:54 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
......
# Author: David Goodger # Author: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:15 $ # Date: $Date: 2003/07/10 15:49:54 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
...@@ -11,10 +11,6 @@ Python Enhancement Proposal (PEP) Reader. ...@@ -11,10 +11,6 @@ Python Enhancement Proposal (PEP) Reader.
__docformat__ = 'reStructuredText' __docformat__ = 'reStructuredText'
import sys
import os
import re
from docutils import nodes
from docutils.readers import standalone from docutils.readers import standalone
from docutils.transforms import peps, references from docutils.transforms import peps, references
from docutils.parsers import rst from docutils.parsers import rst
...@@ -23,7 +19,7 @@ from docutils.parsers import rst ...@@ -23,7 +19,7 @@ from docutils.parsers import rst
class Inliner(rst.states.Inliner): class Inliner(rst.states.Inliner):
""" """
Extend `rst.Inliner` to for local PEP references. Extend `rst.Inliner` for local PEP references.
""" """
pep_url = rst.states.Inliner.pep_url_local pep_url = rst.states.Inliner.pep_url_local
......
# Author: David Goodger
# Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.1 $
# Date: $Date: 2003/07/10 15:49:58 $
# Copyright: This module has been placed in the public domain.
"""
This package contains the Python Source Reader modules.
"""
__docformat__ = 'reStructuredText'
import sys
import docutils.readers
class Reader(docutils.readers.Reader):
pass
This diff is collapsed.
# Author: David Goodger # Author: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:15 $ # Date: $Date: 2003/07/10 15:49:54 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
...@@ -25,6 +25,19 @@ class Reader(readers.Reader): ...@@ -25,6 +25,19 @@ class Reader(readers.Reader):
document = None document = None
"""A single document tree.""" """A single document tree."""
settings_spec = (
'Standalone Reader',
None,
(('Disable the promotion of a lone top-level section title to '
'document title (and subsequent section title to document '
'subtitle promotion; enabled by default).',
['--no-doc-title'],
{'dest': 'doctitle_xform', 'action': 'store_false', 'default': 1}),
('Disable the bibliographic field list transform (enabled by '
'default).',
['--no-doc-info'],
{'dest': 'docinfo_xform', 'action': 'store_false', 'default': 1}),))
default_transforms = (references.Substitutions, default_transforms = (references.Substitutions,
frontmatter.DocTitle, frontmatter.DocTitle,
frontmatter.DocInfo, frontmatter.DocInfo,
......
# Author: David Goodger # Author: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:00 $ # Date: $Date: 2003/07/10 15:49:30 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
...@@ -266,6 +266,7 @@ class StateMachine: ...@@ -266,6 +266,7 @@ class StateMachine:
transitions = None transitions = None
state = self.get_state(next_state) state = self.get_state(next_state)
except: except:
if self.debug:
self.error() self.error()
raise raise
self.observers = [] self.observers = []
...@@ -1294,11 +1295,11 @@ class StringList(ViewList): ...@@ -1294,11 +1295,11 @@ class StringList(ViewList):
"""A `ViewList` with string-specific methods.""" """A `ViewList` with string-specific methods."""
def strip_indent(self, length, start=0, end=sys.maxint): def trim_left(self, length, start=0, end=sys.maxint):
""" """
Strip `length` characters off the beginning of each item, in-place, Trim `length` characters off the beginning of each item, in-place,
from index `start` to `end`. No whitespace-checking is done on the from index `start` to `end`. No whitespace-checking is done on the
stripped text. Does not affect slice parent. trimmed text. Does not affect slice parent.
""" """
self.data[start:end] = [line[length:] self.data[start:end] = [line[length:]
for line in self.data[start:end]] for line in self.data[start:end]]
...@@ -1381,9 +1382,20 @@ class StringList(ViewList): ...@@ -1381,9 +1382,20 @@ class StringList(ViewList):
if first_indent is not None and block: if first_indent is not None and block:
block.data[0] = block.data[0][first_indent:] block.data[0] = block.data[0][first_indent:]
if indent and strip_indent: if indent and strip_indent:
block.strip_indent(indent, start=(first_indent is not None)) block.trim_left(indent, start=(first_indent is not None))
return block, indent or 0, blank_finish return block, indent or 0, blank_finish
def get_2D_block(self, top, left, bottom, right, strip_indent=1):
block = self[top:bottom]
indent = right
for i in range(len(block.data)):
block.data[i] = line = block.data[i][left:right].rstrip()
if line:
indent = min(indent, len(line) - len(line.lstrip()))
if strip_indent and 0 < indent < right:
block.data = [line[indent:] for line in block.data]
return block
class StateMachineError(Exception): pass class StateMachineError(Exception): pass
class UnknownStateError(StateMachineError): pass class UnknownStateError(StateMachineError): pass
......
# Authors: David Goodger, Ueli Schlaepfer # Authors: David Goodger, Ueli Schlaepfer
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:17 $ # Date: $Date: 2003/07/10 15:50:00 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
......
# Author: David Goodger # Author: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:17 $ # Date: $Date: 2003/07/10 15:50:00 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
......
# Authors: David Goodger, Ueli Schlaepfer # Authors: David Goodger, Ueli Schlaepfer
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:17 $ # Date: $Date: 2003/07/10 15:50:00 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
...@@ -105,6 +105,8 @@ class DocTitle(Transform): ...@@ -105,6 +105,8 @@ class DocTitle(Transform):
default_priority = 320 default_priority = 320
def apply(self): def apply(self):
if not getattr(self.document.settings, 'doctitle_xform', 1):
return
if self.promote_document_title(): if self.promote_document_title():
self.promote_document_subtitle() self.promote_document_subtitle()
...@@ -229,7 +231,25 @@ class DocInfo(Transform): ...@@ -229,7 +231,25 @@ class DocInfo(Transform):
default_priority = 340 default_priority = 340
biblio_nodes = {
'author': nodes.author,
'authors': nodes.authors,
'organization': nodes.organization,
'address': nodes.address,
'contact': nodes.contact,
'version': nodes.version,
'revision': nodes.revision,
'status': nodes.status,
'date': nodes.date,
'copyright': nodes.copyright,
'dedication': nodes.topic,
'abstract': nodes.topic}
"""Canonical field name (lowcased) to node class name mapping for
bibliographic fields (field_list)."""
def apply(self): def apply(self):
if not getattr(self.document.settings, 'docinfo_xform', 1):
return
document = self.document document = self.document
index = document.first_child_not_matching_class( index = document.first_child_not_matching_class(
nodes.PreBibliographic) nodes.PreBibliographic)
...@@ -252,29 +272,29 @@ class DocInfo(Transform): ...@@ -252,29 +272,29 @@ class DocInfo(Transform):
for field in field_list: for field in field_list:
try: try:
name = field[0][0].astext() name = field[0][0].astext()
normedname = utils.normalize_name(name) normedname = nodes.fully_normalize_name(name)
if not (len(field) == 2 and bibliofields.has_key(normedname) if not (len(field) == 2 and bibliofields.has_key(normedname)
and self.check_empty_biblio_field(field, name)): and self.check_empty_biblio_field(field, name)):
raise TransformError raise TransformError
biblioclass = bibliofields[normedname] canonical = bibliofields[normedname]
biblioclass = self.biblio_nodes[canonical]
if issubclass(biblioclass, nodes.TextElement): if issubclass(biblioclass, nodes.TextElement):
if not self.check_compound_biblio_field(field, name): if not self.check_compound_biblio_field(field, name):
raise TransformError raise TransformError
utils.clean_rcs_keywords( utils.clean_rcs_keywords(
field[1][0], self.rcs_keyword_substitutions) field[1][0], self.rcs_keyword_substitutions)
docinfo.append(biblioclass('', '', *field[1][0])) docinfo.append(biblioclass('', '', *field[1][0]))
else: # multiple body elements possible elif issubclass(biblioclass, nodes.authors):
if issubclass(biblioclass, nodes.authors):
self.extract_authors(field, name, docinfo) self.extract_authors(field, name, docinfo)
elif issubclass(biblioclass, nodes.topic): elif issubclass(biblioclass, nodes.topic):
if topics[normedname]: if topics[canonical]:
field[-1] += self.document.reporter.warning( field[-1] += self.document.reporter.warning(
'There can only be one "%s" field.' % name, 'There can only be one "%s" field.' % name,
base_node=field) base_node=field)
raise TransformError raise TransformError
title = nodes.title(name, labels[normedname]) title = nodes.title(name, labels[canonical])
topics[normedname] = biblioclass( topics[canonical] = biblioclass(
'', title, CLASS=normedname, *field[1].children) '', title, CLASS=canonical, *field[1].children)
else: else:
docinfo.append(biblioclass('', *field[1].children)) docinfo.append(biblioclass('', *field[1].children))
except TransformError: except TransformError:
...@@ -283,7 +303,6 @@ class DocInfo(Transform): ...@@ -283,7 +303,6 @@ class DocInfo(Transform):
utils.clean_rcs_keywords( utils.clean_rcs_keywords(
field[-1][0], self.rcs_keyword_substitutions) field[-1][0], self.rcs_keyword_substitutions)
docinfo.append(field) docinfo.append(field)
continue
nodelist = [] nodelist = []
if len(docinfo) != 0: if len(docinfo) != 0:
nodelist.append(docinfo) nodelist.append(docinfo)
......
# Author: David Goodger # Author: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:17 $ # Date: $Date: 2003/07/10 15:50:00 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
...@@ -10,6 +10,7 @@ Miscellaneous transforms. ...@@ -10,6 +10,7 @@ Miscellaneous transforms.
__docformat__ = 'reStructuredText' __docformat__ = 'reStructuredText'
from docutils import nodes
from docutils.transforms import Transform, TransformError from docutils.transforms import Transform, TransformError
...@@ -31,3 +32,31 @@ class CallBack(Transform): ...@@ -31,3 +32,31 @@ class CallBack(Transform):
pending = self.startnode pending = self.startnode
pending.details['callback'](pending) pending.details['callback'](pending)
pending.parent.remove(pending) pending.parent.remove(pending)
class ClassAttribute(Transform):
default_priority = 210
def apply(self):
pending = self.startnode
class_value = pending.details['class']
parent = pending.parent
child = pending
while parent:
for index in range(parent.index(child) + 1, len(parent)):
element = parent[index]
if isinstance(element, nodes.comment):
continue
element.set_class(class_value)
pending.parent.remove(pending)
return
else:
child = parent
parent = parent.parent
error = self.document.reporter.error(
'No suitable element following "%s" directive'
% pending.details['directive'],
nodes.literal_block(pending.rawsource, pending.rawsource),
line=pending.line)
pending.parent.replace(pending, error)
# Authors: David Goodger, Ueli Schlaepfer, Dmitry Jemerov # Authors: David Goodger, Ueli Schlaepfer, Dmitry Jemerov
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:17 $ # Date: $Date: 2003/07/10 15:50:00 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
...@@ -73,8 +73,11 @@ class Contents(Transform): ...@@ -73,8 +73,11 @@ class Contents(Transform):
def apply(self): def apply(self):
topic = nodes.topic(CLASS='contents') topic = nodes.topic(CLASS='contents')
title = self.startnode.details['title'] details = self.startnode.details
if self.startnode.details.has_key('local'): if details.has_key('class'):
topic.set_class(details['class'])
title = details['title']
if details.has_key('local'):
startnode = self.startnode.parent startnode = self.startnode.parent
# @@@ generate an error if the startnode (directive) not at # @@@ generate an error if the startnode (directive) not at
# section/document top-level? Drag it up until it is? # section/document top-level? Drag it up until it is?
...@@ -89,13 +92,13 @@ class Contents(Transform): ...@@ -89,13 +92,13 @@ class Contents(Transform):
topic += title topic += title
else: else:
name = self.language.labels['contents'] name = self.language.labels['contents']
name = utils.normalize_name(name) name = nodes.fully_normalize_name(name)
if not self.document.has_name(name): if not self.document.has_name(name):
topic['name'] = name topic['name'] = name
self.document.note_implicit_target(topic) self.document.note_implicit_target(topic)
self.toc_id = topic['id'] self.toc_id = topic['id']
if self.startnode.details.has_key('backlinks'): if details.has_key('backlinks'):
self.backlinks = self.startnode.details['backlinks'] self.backlinks = details['backlinks']
else: else:
self.backlinks = self.document.settings.toc_backlinks self.backlinks = self.document.settings.toc_backlinks
contents = self.build_contents(startnode) contents = self.build_contents(startnode)
......
# Author: David Goodger # Author: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:17 $ # Date: $Date: 2003/07/10 15:50:00 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
......
# Author: David Goodger # Author: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:17 $ # Date: $Date: 2003/07/10 15:50:00 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
...@@ -668,11 +668,17 @@ class Substitutions(Transform): ...@@ -668,11 +668,17 @@ class Substitutions(Transform):
def apply(self): def apply(self):
defs = self.document.substitution_defs defs = self.document.substitution_defs
normed = self.document.substitution_names
for refname, refs in self.document.substitution_refs.items(): for refname, refs in self.document.substitution_refs.items():
for ref in refs: for ref in refs:
key = None
if defs.has_key(refname): if defs.has_key(refname):
ref.parent.replace(ref, defs[refname].get_children()) key = refname
else: else:
normed_name = refname.lower()
if normed.has_key(normed_name):
key = normed[normed_name]
if key is None:
msg = self.document.reporter.error( msg = self.document.reporter.error(
'Undefined substitution referenced: "%s".' 'Undefined substitution referenced: "%s".'
% refname, base_node=ref) % refname, base_node=ref)
...@@ -682,6 +688,8 @@ class Substitutions(Transform): ...@@ -682,6 +688,8 @@ class Substitutions(Transform):
prbid = self.document.set_id(prb) prbid = self.document.set_id(prb)
msg.add_backref(prbid) msg.add_backref(prbid)
ref.parent.replace(ref, prb) ref.parent.replace(ref, prb)
else:
ref.parent.replace(ref, defs[key].get_children())
self.document.substitution_refs = None # release replaced references self.document.substitution_refs = None # release replaced references
...@@ -747,6 +755,8 @@ class TargetNotes(Transform): ...@@ -747,6 +755,8 @@ class TargetNotes(Transform):
self.document.note_autofootnote_ref(refnode) self.document.note_autofootnote_ref(refnode)
self.document.note_footnote_ref(refnode) self.document.note_footnote_ref(refnode)
index = ref.parent.index(ref) + 1 index = ref.parent.index(ref) + 1
reflist = [nodes.Text(' '), refnode] reflist = [refnode]
if not self.document.settings.trim_footnote_reference_space:
reflist.insert(0, nodes.Text(' '))
ref.parent.insert(index, reflist) ref.parent.insert(index, reflist)
return footnote return footnote
# Authors: David Goodger, Ueli Schlaepfer # Authors: David Goodger, Ueli Schlaepfer
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:17 $ # Date: $Date: 2003/07/10 15:50:00 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
...@@ -102,7 +102,7 @@ class Messages(Transform): ...@@ -102,7 +102,7 @@ class Messages(Transform):
for msg in unfiltered: for msg in unfiltered:
if msg['level'] >= threshold and not msg.parent: if msg['level'] >= threshold and not msg.parent:
messages.append(msg) messages.append(msg)
if len(messages) > 0: if messages:
section = nodes.section(CLASS='system-messages') section = nodes.section(CLASS='system-messages')
# @@@ get this from the language module? # @@@ get this from the language module?
section += nodes.title('', 'Docutils System Messages') section += nodes.title('', 'Docutils System Messages')
......
This diff is collapsed.
# Authors: David Goodger # Authors: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:20 $ # Date: $Date: 2003/07/10 15:50:05 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
...@@ -68,6 +68,7 @@ class Writer(Component): ...@@ -68,6 +68,7 @@ class Writer(Component):
_writer_aliases = { _writer_aliases = {
'html': 'html4css1', 'html': 'html4css1',
'latex': 'latex2e',
'pprint': 'pseudoxml', 'pprint': 'pseudoxml',
'pformat': 'pseudoxml', 'pformat': 'pseudoxml',
'pdf': 'rlpdf', 'pdf': 'rlpdf',
......
# Authors: David Goodger # Authors: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:20 $ # Date: $Date: 2003/07/10 15:50:05 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
......
This diff is collapsed.
# Author: Andreas Jung # Author: Andreas Jung
# Contact: andreas@andreas-jung.com # Contact: andreas@andreas-jung.com
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:20 $ # Date: $Date: 2003/07/10 15:50:05 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
......
This diff is collapsed.
# Author: David Goodger # Author: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:20 $ # Date: $Date: 2003/07/10 15:50:05 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
...@@ -13,7 +13,7 @@ __docformat__ = 'reStructuredText' ...@@ -13,7 +13,7 @@ __docformat__ = 'reStructuredText'
import sys import sys
import docutils import docutils
from docutils import nodes, optik, utils from docutils import nodes, frontend, utils
from docutils.writers import html4css1 from docutils.writers import html4css1
...@@ -44,7 +44,7 @@ class Writer(html4css1.Writer): ...@@ -44,7 +44,7 @@ class Writer(html4css1.Writer):
{'default': '.', 'metavar': '<URL>'}), {'default': '.', 'metavar': '<URL>'}),
# Workaround for SourceForge's broken Python # Workaround for SourceForge's broken Python
# (``import random`` causes a segfault). # (``import random`` causes a segfault).
(optik.SUPPRESS_HELP, (frontend.SUPPRESS_HELP,
['--no-random'], {'action': 'store_true'}),)) ['--no-random'], {'action': 'store_true'}),))
settings_default_overrides = {'footnote_references': 'brackets'} settings_default_overrides = {'footnote_references': 'brackets'}
......
# Authors: David Goodger # Authors: David Goodger
# Contact: goodger@users.sourceforge.net # Contact: goodger@users.sourceforge.net
# Revision: $Revision: 1.2 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/02/01 09:26:20 $ # Date: $Date: 2003/07/10 15:50:05 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment