-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmep.py
59 lines (43 loc) · 1.65 KB
/
mep.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Author: David Goodger
# Contact: [email protected]
# Revision: $Revision$
# Date: $Date$
# Copyright: This module has been placed in the public domain.
"""
Mozart Enhancement Proposal (MEP) Reader.
"""
__docformat__ = 'reStructuredText'
from docutils.readers import standalone
import meps
from docutils.transforms import references
from docutils.parsers import rst
class Inliner(rst.states.Inliner):
"""
Extend `rst.Inliner` for local MEP references.
"""
mep_url = rst.states.Inliner.pep_url
class Reader(standalone.Reader):
supported = ('mep',)
"""Contexts this reader supports."""
settings_spec = (
'MEP Reader Option Defaults',
'The --mep-references and --rfc-references options (for the '
'reStructuredText parser) are on by default.',
())
default_transforms = (references.Substitutions,
meps.Headers,
meps.Contents,
references.ChainedTargets,
references.AnonymousHyperlinks,
references.IndirectHyperlinks,
meps.TargetNotes,
references.Footnotes,
references.ExternalTargets,
references.InternalTargets,)
settings_default_overrides = {'mep_references': 1, 'rfc_references': 1}
inliner_class = Inliner
def __init__(self, parser=None, parser_name=None):
"""`parser` should be ``None``."""
if parser is None:
parser = rst.Parser(rfc2822=1, inliner=self.inliner_class())
standalone.Reader.__init__(self, parser, '')