android-notify 1.59.4__py3-none-any.whl → 1.60.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of android-notify might be problematic. Click here for more details.
- android_notify/__init__.py +4 -4
- android_notify/__main__.py +24 -0
- android_notify/an_types.py +226 -91
- android_notify/an_utils.py +129 -18
- android_notify/base.py +97 -90
- android_notify/config.py +145 -0
- android_notify/core.py +227 -139
- android_notify/styles.py +25 -22
- android_notify/sword.py +1043 -992
- {android_notify-1.59.4.dist-info → android_notify-1.60.0.dist-info}/METADATA +73 -28
- android_notify-1.60.0.dist-info/RECORD +1350 -0
- android_notify-1.60.0.dist-info/entry_points.txt +2 -0
- {android_notify-1.59.4.dist-info → android_notify-1.60.0.dist-info}/top_level.txt +2 -0
- docs/examples/flet-working/src/core.py +221 -0
- docs/examples/flet-working/src/main.py +68 -0
- docs/tests/flet/adv/main.py +97 -0
- docs/tests/flet/adv/tests/__init__.py +0 -0
- docs/tests/flet/adv/tests/test_android_notify_full.py +199 -0
- docs/tests/flet/basic/src/core.py +221 -0
- docs/tests/flet/basic/src/main.py +112 -0
- docs/website/src/pages/data/laner_Sent.py +24 -0
- venv/Lib/site-packages/__editable___android_notify_1_60_0_finder.py +85 -0
- venv/Lib/site-packages/build/__init__.py +39 -0
- venv/Lib/site-packages/build/__main__.py +486 -0
- venv/Lib/site-packages/build/_builder.py +355 -0
- venv/Lib/site-packages/build/_compat/__init__.py +0 -0
- venv/Lib/site-packages/build/_compat/importlib.py +22 -0
- venv/Lib/site-packages/build/_compat/tarfile.py +31 -0
- venv/Lib/site-packages/build/_compat/tomllib.py +16 -0
- venv/Lib/site-packages/build/_ctx.py +99 -0
- venv/Lib/site-packages/build/_exceptions.py +65 -0
- venv/Lib/site-packages/build/_types.py +19 -0
- venv/Lib/site-packages/build/_util.py +63 -0
- venv/Lib/site-packages/build/env.py +393 -0
- venv/Lib/site-packages/build/py.typed +0 -0
- venv/Lib/site-packages/build/util.py +63 -0
- venv/Lib/site-packages/certifi/__init__.py +4 -0
- venv/Lib/site-packages/certifi/__main__.py +12 -0
- venv/Lib/site-packages/certifi/core.py +83 -0
- venv/Lib/site-packages/certifi/py.typed +0 -0
- venv/Lib/site-packages/charset_normalizer/__init__.py +48 -0
- venv/Lib/site-packages/charset_normalizer/__main__.py +6 -0
- venv/Lib/site-packages/charset_normalizer/api.py +669 -0
- venv/Lib/site-packages/charset_normalizer/cd.py +395 -0
- venv/Lib/site-packages/charset_normalizer/cli/__init__.py +8 -0
- venv/Lib/site-packages/charset_normalizer/cli/__main__.py +381 -0
- venv/Lib/site-packages/charset_normalizer/constant.py +2015 -0
- venv/Lib/site-packages/charset_normalizer/legacy.py +80 -0
- venv/Lib/site-packages/charset_normalizer/md.py +635 -0
- venv/Lib/site-packages/charset_normalizer/models.py +360 -0
- venv/Lib/site-packages/charset_normalizer/py.typed +0 -0
- venv/Lib/site-packages/charset_normalizer/utils.py +414 -0
- venv/Lib/site-packages/charset_normalizer/version.py +8 -0
- venv/Lib/site-packages/colorama/__init__.py +7 -0
- venv/Lib/site-packages/colorama/ansi.py +102 -0
- venv/Lib/site-packages/colorama/ansitowin32.py +277 -0
- venv/Lib/site-packages/colorama/initialise.py +121 -0
- venv/Lib/site-packages/colorama/tests/__init__.py +1 -0
- venv/Lib/site-packages/colorama/tests/ansi_test.py +76 -0
- venv/Lib/site-packages/colorama/tests/ansitowin32_test.py +294 -0
- venv/Lib/site-packages/colorama/tests/initialise_test.py +189 -0
- venv/Lib/site-packages/colorama/tests/isatty_test.py +57 -0
- venv/Lib/site-packages/colorama/tests/utils.py +49 -0
- venv/Lib/site-packages/colorama/tests/winterm_test.py +131 -0
- venv/Lib/site-packages/colorama/win32.py +180 -0
- venv/Lib/site-packages/colorama/winterm.py +195 -0
- venv/Lib/site-packages/docutils/__init__.py +341 -0
- venv/Lib/site-packages/docutils/__main__.py +103 -0
- venv/Lib/site-packages/docutils/core.py +855 -0
- venv/Lib/site-packages/docutils/examples.py +123 -0
- venv/Lib/site-packages/docutils/frontend.py +1178 -0
- venv/Lib/site-packages/docutils/io.py +718 -0
- venv/Lib/site-packages/docutils/languages/__init__.py +117 -0
- venv/Lib/site-packages/docutils/languages/af.py +58 -0
- venv/Lib/site-packages/docutils/languages/ar.py +60 -0
- venv/Lib/site-packages/docutils/languages/ca.py +65 -0
- venv/Lib/site-packages/docutils/languages/cs.py +60 -0
- venv/Lib/site-packages/docutils/languages/da.py +61 -0
- venv/Lib/site-packages/docutils/languages/de.py +58 -0
- venv/Lib/site-packages/docutils/languages/en.py +60 -0
- venv/Lib/site-packages/docutils/languages/eo.py +61 -0
- venv/Lib/site-packages/docutils/languages/es.py +58 -0
- venv/Lib/site-packages/docutils/languages/fa.py +60 -0
- venv/Lib/site-packages/docutils/languages/fi.py +60 -0
- venv/Lib/site-packages/docutils/languages/fr.py +58 -0
- venv/Lib/site-packages/docutils/languages/gl.py +62 -0
- venv/Lib/site-packages/docutils/languages/he.py +62 -0
- venv/Lib/site-packages/docutils/languages/it.py +58 -0
- venv/Lib/site-packages/docutils/languages/ja.py +60 -0
- venv/Lib/site-packages/docutils/languages/ka.py +58 -0
- venv/Lib/site-packages/docutils/languages/ko.py +60 -0
- venv/Lib/site-packages/docutils/languages/lt.py +60 -0
- venv/Lib/site-packages/docutils/languages/lv.py +59 -0
- venv/Lib/site-packages/docutils/languages/nl.py +60 -0
- venv/Lib/site-packages/docutils/languages/pl.py +60 -0
- venv/Lib/site-packages/docutils/languages/pt_br.py +60 -0
- venv/Lib/site-packages/docutils/languages/ru.py +58 -0
- venv/Lib/site-packages/docutils/languages/sk.py +58 -0
- venv/Lib/site-packages/docutils/languages/sv.py +59 -0
- venv/Lib/site-packages/docutils/languages/uk.py +58 -0
- venv/Lib/site-packages/docutils/languages/zh_cn.py +62 -0
- venv/Lib/site-packages/docutils/languages/zh_tw.py +61 -0
- venv/Lib/site-packages/docutils/nodes.py +3341 -0
- venv/Lib/site-packages/docutils/parsers/__init__.py +115 -0
- venv/Lib/site-packages/docutils/parsers/commonmark_wrapper.py +56 -0
- venv/Lib/site-packages/docutils/parsers/docutils_xml.py +194 -0
- venv/Lib/site-packages/docutils/parsers/null.py +24 -0
- venv/Lib/site-packages/docutils/parsers/recommonmark_wrapper.py +174 -0
- venv/Lib/site-packages/docutils/parsers/rst/__init__.py +414 -0
- venv/Lib/site-packages/docutils/parsers/rst/directives/__init__.py +480 -0
- venv/Lib/site-packages/docutils/parsers/rst/directives/admonitions.py +101 -0
- venv/Lib/site-packages/docutils/parsers/rst/directives/body.py +318 -0
- venv/Lib/site-packages/docutils/parsers/rst/directives/html.py +21 -0
- venv/Lib/site-packages/docutils/parsers/rst/directives/images.py +186 -0
- venv/Lib/site-packages/docutils/parsers/rst/directives/misc.py +690 -0
- venv/Lib/site-packages/docutils/parsers/rst/directives/parts.py +126 -0
- venv/Lib/site-packages/docutils/parsers/rst/directives/references.py +28 -0
- venv/Lib/site-packages/docutils/parsers/rst/directives/tables.py +523 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/__init__.py +63 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/af.py +107 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/ar.py +99 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/ca.py +130 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/cs.py +110 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/da.py +113 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/de.py +106 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/en.py +115 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/eo.py +118 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/es.py +121 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/fa.py +102 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/fi.py +98 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/fr.py +107 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/gl.py +106 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/he.py +110 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/it.py +98 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/ja.py +119 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/ka.py +89 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/ko.py +111 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/lt.py +109 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/lv.py +108 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/nl.py +113 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/pl.py +100 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/pt_br.py +109 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/ru.py +90 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/sk.py +96 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/sv.py +96 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/uk.py +91 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/zh_cn.py +104 -0
- venv/Lib/site-packages/docutils/parsers/rst/languages/zh_tw.py +109 -0
- venv/Lib/site-packages/docutils/parsers/rst/roles.py +450 -0
- venv/Lib/site-packages/docutils/parsers/rst/states.py +3255 -0
- venv/Lib/site-packages/docutils/parsers/rst/tableparser.py +540 -0
- venv/Lib/site-packages/docutils/readers/__init__.py +135 -0
- venv/Lib/site-packages/docutils/readers/doctree.py +50 -0
- venv/Lib/site-packages/docutils/readers/pep.py +55 -0
- venv/Lib/site-packages/docutils/readers/standalone.py +65 -0
- venv/Lib/site-packages/docutils/statemachine.py +1534 -0
- venv/Lib/site-packages/docutils/transforms/__init__.py +196 -0
- venv/Lib/site-packages/docutils/transforms/components.py +56 -0
- venv/Lib/site-packages/docutils/transforms/frontmatter.py +548 -0
- venv/Lib/site-packages/docutils/transforms/misc.py +151 -0
- venv/Lib/site-packages/docutils/transforms/parts.py +175 -0
- venv/Lib/site-packages/docutils/transforms/peps.py +315 -0
- venv/Lib/site-packages/docutils/transforms/references.py +990 -0
- venv/Lib/site-packages/docutils/transforms/universal.py +364 -0
- venv/Lib/site-packages/docutils/transforms/writer_aux.py +57 -0
- venv/Lib/site-packages/docutils/utils/__init__.py +853 -0
- venv/Lib/site-packages/docutils/utils/_roman_numerals.py +264 -0
- venv/Lib/site-packages/docutils/utils/_typing.py +39 -0
- venv/Lib/site-packages/docutils/utils/code_analyzer.py +140 -0
- venv/Lib/site-packages/docutils/utils/math/__init__.py +77 -0
- venv/Lib/site-packages/docutils/utils/math/latex2mathml.py +1252 -0
- venv/Lib/site-packages/docutils/utils/math/math2html.py +3166 -0
- venv/Lib/site-packages/docutils/utils/math/mathalphabet2unichar.py +892 -0
- venv/Lib/site-packages/docutils/utils/math/mathml_elements.py +482 -0
- venv/Lib/site-packages/docutils/utils/math/tex2mathml_extern.py +263 -0
- venv/Lib/site-packages/docutils/utils/math/tex2unichar.py +730 -0
- venv/Lib/site-packages/docutils/utils/math/unichar2tex.py +808 -0
- venv/Lib/site-packages/docutils/utils/punctuation_chars.py +123 -0
- venv/Lib/site-packages/docutils/utils/smartquotes.py +1006 -0
- venv/Lib/site-packages/docutils/utils/urischemes.py +138 -0
- venv/Lib/site-packages/docutils/writers/__init__.py +277 -0
- venv/Lib/site-packages/docutils/writers/_html_base.py +1885 -0
- venv/Lib/site-packages/docutils/writers/docutils_xml.py +191 -0
- venv/Lib/site-packages/docutils/writers/html4css1/__init__.py +964 -0
- venv/Lib/site-packages/docutils/writers/html5_polyglot/__init__.py +396 -0
- venv/Lib/site-packages/docutils/writers/latex2e/__init__.py +3419 -0
- venv/Lib/site-packages/docutils/writers/manpage.py +1353 -0
- venv/Lib/site-packages/docutils/writers/null.py +28 -0
- venv/Lib/site-packages/docutils/writers/odf_odt/__init__.py +3461 -0
- venv/Lib/site-packages/docutils/writers/odf_odt/prepstyles.py +80 -0
- venv/Lib/site-packages/docutils/writers/odf_odt/pygmentsformatter.py +106 -0
- venv/Lib/site-packages/docutils/writers/pep_html/__init__.py +102 -0
- venv/Lib/site-packages/docutils/writers/pseudoxml.py +41 -0
- venv/Lib/site-packages/docutils/writers/s5_html/__init__.py +354 -0
- venv/Lib/site-packages/docutils/writers/xetex/__init__.py +168 -0
- venv/Lib/site-packages/id/__init__.py +91 -0
- venv/Lib/site-packages/id/__main__.py +88 -0
- venv/Lib/site-packages/id/_internal/oidc/__init__.py +13 -0
- venv/Lib/site-packages/id/_internal/oidc/ambient.py +328 -0
- venv/Lib/site-packages/idna/__init__.py +45 -0
- venv/Lib/site-packages/idna/codec.py +122 -0
- venv/Lib/site-packages/idna/compat.py +15 -0
- venv/Lib/site-packages/idna/core.py +437 -0
- venv/Lib/site-packages/idna/idnadata.py +4309 -0
- venv/Lib/site-packages/idna/intranges.py +57 -0
- venv/Lib/site-packages/idna/package_data.py +1 -0
- venv/Lib/site-packages/idna/py.typed +0 -0
- venv/Lib/site-packages/idna/uts46data.py +8841 -0
- venv/Lib/site-packages/jaraco/classes/__init__.py +0 -0
- venv/Lib/site-packages/jaraco/classes/ancestry.py +76 -0
- venv/Lib/site-packages/jaraco/classes/meta.py +85 -0
- venv/Lib/site-packages/jaraco/classes/properties.py +241 -0
- venv/Lib/site-packages/jaraco/classes/py.typed +0 -0
- venv/Lib/site-packages/jaraco/context/__init__.py +356 -0
- venv/Lib/site-packages/jaraco/context/py.typed +0 -0
- venv/Lib/site-packages/jaraco/functools/__init__.py +714 -0
- venv/Lib/site-packages/jaraco/functools/__init__.pyi +123 -0
- venv/Lib/site-packages/jaraco/functools/py.typed +0 -0
- venv/Lib/site-packages/jnius/__init__.py +89 -0
- venv/Lib/site-packages/jnius/env.py +378 -0
- venv/Lib/site-packages/jnius/reflect.py +440 -0
- venv/Lib/site-packages/jnius/signatures.py +105 -0
- venv/Lib/site-packages/jnius_config.py +112 -0
- venv/Lib/site-packages/keyring/__init__.py +17 -0
- venv/Lib/site-packages/keyring/__main__.py +4 -0
- venv/Lib/site-packages/keyring/backend.py +300 -0
- venv/Lib/site-packages/keyring/backends/SecretService.py +120 -0
- venv/Lib/site-packages/keyring/backends/Windows.py +168 -0
- venv/Lib/site-packages/keyring/backends/__init__.py +0 -0
- venv/Lib/site-packages/keyring/backends/chainer.py +71 -0
- venv/Lib/site-packages/keyring/backends/fail.py +30 -0
- venv/Lib/site-packages/keyring/backends/kwallet.py +164 -0
- venv/Lib/site-packages/keyring/backends/libsecret.py +155 -0
- venv/Lib/site-packages/keyring/backends/macOS/__init__.py +85 -0
- venv/Lib/site-packages/keyring/backends/macOS/api.py +184 -0
- venv/Lib/site-packages/keyring/backends/null.py +20 -0
- venv/Lib/site-packages/keyring/cli.py +220 -0
- venv/Lib/site-packages/keyring/compat/__init__.py +7 -0
- venv/Lib/site-packages/keyring/compat/properties.py +169 -0
- venv/Lib/site-packages/keyring/compat/py312.py +9 -0
- venv/Lib/site-packages/keyring/compat/py38.py +9 -0
- venv/Lib/site-packages/keyring/completion.py +56 -0
- venv/Lib/site-packages/keyring/core.py +200 -0
- venv/Lib/site-packages/keyring/credentials.py +85 -0
- venv/Lib/site-packages/keyring/devpi_client.py +29 -0
- venv/Lib/site-packages/keyring/errors.py +67 -0
- venv/Lib/site-packages/keyring/http.py +39 -0
- venv/Lib/site-packages/keyring/py.typed +0 -0
- venv/Lib/site-packages/keyring/testing/__init__.py +0 -0
- venv/Lib/site-packages/keyring/testing/backend.py +200 -0
- venv/Lib/site-packages/keyring/testing/util.py +68 -0
- venv/Lib/site-packages/keyring/util/__init__.py +11 -0
- venv/Lib/site-packages/keyring/util/platform_.py +40 -0
- venv/Lib/site-packages/markdown_it/__init__.py +6 -0
- venv/Lib/site-packages/markdown_it/_compat.py +1 -0
- venv/Lib/site-packages/markdown_it/_punycode.py +67 -0
- venv/Lib/site-packages/markdown_it/cli/__init__.py +0 -0
- venv/Lib/site-packages/markdown_it/cli/parse.py +110 -0
- venv/Lib/site-packages/markdown_it/common/__init__.py +0 -0
- venv/Lib/site-packages/markdown_it/common/entities.py +5 -0
- venv/Lib/site-packages/markdown_it/common/html_blocks.py +69 -0
- venv/Lib/site-packages/markdown_it/common/html_re.py +39 -0
- venv/Lib/site-packages/markdown_it/common/normalize_url.py +81 -0
- venv/Lib/site-packages/markdown_it/common/utils.py +313 -0
- venv/Lib/site-packages/markdown_it/helpers/__init__.py +6 -0
- venv/Lib/site-packages/markdown_it/helpers/parse_link_destination.py +83 -0
- venv/Lib/site-packages/markdown_it/helpers/parse_link_label.py +44 -0
- venv/Lib/site-packages/markdown_it/helpers/parse_link_title.py +75 -0
- venv/Lib/site-packages/markdown_it/main.py +350 -0
- venv/Lib/site-packages/markdown_it/parser_block.py +113 -0
- venv/Lib/site-packages/markdown_it/parser_core.py +46 -0
- venv/Lib/site-packages/markdown_it/parser_inline.py +148 -0
- venv/Lib/site-packages/markdown_it/presets/__init__.py +28 -0
- venv/Lib/site-packages/markdown_it/presets/commonmark.py +75 -0
- venv/Lib/site-packages/markdown_it/presets/default.py +36 -0
- venv/Lib/site-packages/markdown_it/presets/zero.py +44 -0
- venv/Lib/site-packages/markdown_it/py.typed +1 -0
- venv/Lib/site-packages/markdown_it/renderer.py +336 -0
- venv/Lib/site-packages/markdown_it/ruler.py +275 -0
- venv/Lib/site-packages/markdown_it/rules_block/__init__.py +27 -0
- venv/Lib/site-packages/markdown_it/rules_block/blockquote.py +299 -0
- venv/Lib/site-packages/markdown_it/rules_block/code.py +36 -0
- venv/Lib/site-packages/markdown_it/rules_block/fence.py +101 -0
- venv/Lib/site-packages/markdown_it/rules_block/heading.py +69 -0
- venv/Lib/site-packages/markdown_it/rules_block/hr.py +56 -0
- venv/Lib/site-packages/markdown_it/rules_block/html_block.py +90 -0
- venv/Lib/site-packages/markdown_it/rules_block/lheading.py +86 -0
- venv/Lib/site-packages/markdown_it/rules_block/list.py +345 -0
- venv/Lib/site-packages/markdown_it/rules_block/paragraph.py +66 -0
- venv/Lib/site-packages/markdown_it/rules_block/reference.py +235 -0
- venv/Lib/site-packages/markdown_it/rules_block/state_block.py +261 -0
- venv/Lib/site-packages/markdown_it/rules_block/table.py +250 -0
- venv/Lib/site-packages/markdown_it/rules_core/__init__.py +19 -0
- venv/Lib/site-packages/markdown_it/rules_core/block.py +13 -0
- venv/Lib/site-packages/markdown_it/rules_core/inline.py +10 -0
- venv/Lib/site-packages/markdown_it/rules_core/linkify.py +149 -0
- venv/Lib/site-packages/markdown_it/rules_core/normalize.py +19 -0
- venv/Lib/site-packages/markdown_it/rules_core/replacements.py +127 -0
- venv/Lib/site-packages/markdown_it/rules_core/smartquotes.py +202 -0
- venv/Lib/site-packages/markdown_it/rules_core/state_core.py +25 -0
- venv/Lib/site-packages/markdown_it/rules_core/text_join.py +35 -0
- venv/Lib/site-packages/markdown_it/rules_inline/__init__.py +31 -0
- venv/Lib/site-packages/markdown_it/rules_inline/autolink.py +77 -0
- venv/Lib/site-packages/markdown_it/rules_inline/backticks.py +72 -0
- venv/Lib/site-packages/markdown_it/rules_inline/balance_pairs.py +138 -0
- venv/Lib/site-packages/markdown_it/rules_inline/emphasis.py +102 -0
- venv/Lib/site-packages/markdown_it/rules_inline/entity.py +53 -0
- venv/Lib/site-packages/markdown_it/rules_inline/escape.py +93 -0
- venv/Lib/site-packages/markdown_it/rules_inline/fragments_join.py +43 -0
- venv/Lib/site-packages/markdown_it/rules_inline/html_inline.py +43 -0
- venv/Lib/site-packages/markdown_it/rules_inline/image.py +148 -0
- venv/Lib/site-packages/markdown_it/rules_inline/link.py +149 -0
- venv/Lib/site-packages/markdown_it/rules_inline/linkify.py +62 -0
- venv/Lib/site-packages/markdown_it/rules_inline/newline.py +44 -0
- venv/Lib/site-packages/markdown_it/rules_inline/state_inline.py +165 -0
- venv/Lib/site-packages/markdown_it/rules_inline/strikethrough.py +127 -0
- venv/Lib/site-packages/markdown_it/rules_inline/text.py +62 -0
- venv/Lib/site-packages/markdown_it/token.py +178 -0
- venv/Lib/site-packages/markdown_it/tree.py +333 -0
- venv/Lib/site-packages/markdown_it/utils.py +186 -0
- venv/Lib/site-packages/mdurl/__init__.py +18 -0
- venv/Lib/site-packages/mdurl/_decode.py +104 -0
- venv/Lib/site-packages/mdurl/_encode.py +85 -0
- venv/Lib/site-packages/mdurl/_format.py +27 -0
- venv/Lib/site-packages/mdurl/_parse.py +304 -0
- venv/Lib/site-packages/mdurl/_url.py +14 -0
- venv/Lib/site-packages/mdurl/py.typed +1 -0
- venv/Lib/site-packages/more_itertools/__init__.py +6 -0
- venv/Lib/site-packages/more_itertools/__init__.pyi +2 -0
- venv/Lib/site-packages/more_itertools/more.py +5303 -0
- venv/Lib/site-packages/more_itertools/more.pyi +949 -0
- venv/Lib/site-packages/more_itertools/py.typed +0 -0
- venv/Lib/site-packages/more_itertools/recipes.py +1471 -0
- venv/Lib/site-packages/more_itertools/recipes.pyi +205 -0
- venv/Lib/site-packages/nh3/__init__.py +5 -0
- venv/Lib/site-packages/nh3/__init__.pyi +41 -0
- venv/Lib/site-packages/nh3/py.typed +0 -0
- venv/Lib/site-packages/packaging/__init__.py +15 -0
- venv/Lib/site-packages/packaging/_elffile.py +109 -0
- venv/Lib/site-packages/packaging/_manylinux.py +262 -0
- venv/Lib/site-packages/packaging/_musllinux.py +85 -0
- venv/Lib/site-packages/packaging/_parser.py +353 -0
- venv/Lib/site-packages/packaging/_structures.py +61 -0
- venv/Lib/site-packages/packaging/_tokenizer.py +195 -0
- venv/Lib/site-packages/packaging/licenses/__init__.py +145 -0
- venv/Lib/site-packages/packaging/licenses/_spdx.py +759 -0
- venv/Lib/site-packages/packaging/markers.py +362 -0
- venv/Lib/site-packages/packaging/metadata.py +862 -0
- venv/Lib/site-packages/packaging/py.typed +0 -0
- venv/Lib/site-packages/packaging/requirements.py +91 -0
- venv/Lib/site-packages/packaging/specifiers.py +1019 -0
- venv/Lib/site-packages/packaging/tags.py +656 -0
- venv/Lib/site-packages/packaging/utils.py +163 -0
- venv/Lib/site-packages/packaging/version.py +582 -0
- venv/Lib/site-packages/pip/__init__.py +13 -0
- venv/Lib/site-packages/pip/__main__.py +24 -0
- venv/Lib/site-packages/pip/__pip-runner__.py +50 -0
- venv/Lib/site-packages/pip/_internal/__init__.py +18 -0
- venv/Lib/site-packages/pip/_internal/build_env.py +417 -0
- venv/Lib/site-packages/pip/_internal/cache.py +291 -0
- venv/Lib/site-packages/pip/_internal/cli/__init__.py +3 -0
- venv/Lib/site-packages/pip/_internal/cli/autocompletion.py +184 -0
- venv/Lib/site-packages/pip/_internal/cli/base_command.py +244 -0
- venv/Lib/site-packages/pip/_internal/cli/cmdoptions.py +1110 -0
- venv/Lib/site-packages/pip/_internal/cli/command_context.py +28 -0
- venv/Lib/site-packages/pip/_internal/cli/index_command.py +175 -0
- venv/Lib/site-packages/pip/_internal/cli/main.py +80 -0
- venv/Lib/site-packages/pip/_internal/cli/main_parser.py +134 -0
- venv/Lib/site-packages/pip/_internal/cli/parser.py +298 -0
- venv/Lib/site-packages/pip/_internal/cli/progress_bars.py +151 -0
- venv/Lib/site-packages/pip/_internal/cli/req_command.py +371 -0
- venv/Lib/site-packages/pip/_internal/cli/spinners.py +235 -0
- venv/Lib/site-packages/pip/_internal/cli/status_codes.py +6 -0
- venv/Lib/site-packages/pip/_internal/commands/__init__.py +139 -0
- venv/Lib/site-packages/pip/_internal/commands/cache.py +231 -0
- venv/Lib/site-packages/pip/_internal/commands/check.py +66 -0
- venv/Lib/site-packages/pip/_internal/commands/completion.py +135 -0
- venv/Lib/site-packages/pip/_internal/commands/configuration.py +288 -0
- venv/Lib/site-packages/pip/_internal/commands/debug.py +203 -0
- venv/Lib/site-packages/pip/_internal/commands/download.py +142 -0
- venv/Lib/site-packages/pip/_internal/commands/freeze.py +107 -0
- venv/Lib/site-packages/pip/_internal/commands/hash.py +58 -0
- venv/Lib/site-packages/pip/_internal/commands/help.py +40 -0
- venv/Lib/site-packages/pip/_internal/commands/index.py +159 -0
- venv/Lib/site-packages/pip/_internal/commands/inspect.py +92 -0
- venv/Lib/site-packages/pip/_internal/commands/install.py +803 -0
- venv/Lib/site-packages/pip/_internal/commands/list.py +400 -0
- venv/Lib/site-packages/pip/_internal/commands/lock.py +167 -0
- venv/Lib/site-packages/pip/_internal/commands/search.py +178 -0
- venv/Lib/site-packages/pip/_internal/commands/show.py +231 -0
- venv/Lib/site-packages/pip/_internal/commands/uninstall.py +113 -0
- venv/Lib/site-packages/pip/_internal/commands/wheel.py +176 -0
- venv/Lib/site-packages/pip/_internal/configuration.py +396 -0
- venv/Lib/site-packages/pip/_internal/distributions/__init__.py +21 -0
- venv/Lib/site-packages/pip/_internal/distributions/base.py +55 -0
- venv/Lib/site-packages/pip/_internal/distributions/installed.py +33 -0
- venv/Lib/site-packages/pip/_internal/distributions/sdist.py +164 -0
- venv/Lib/site-packages/pip/_internal/distributions/wheel.py +44 -0
- venv/Lib/site-packages/pip/_internal/exceptions.py +898 -0
- venv/Lib/site-packages/pip/_internal/index/__init__.py +1 -0
- venv/Lib/site-packages/pip/_internal/index/collector.py +489 -0
- venv/Lib/site-packages/pip/_internal/index/package_finder.py +1059 -0
- venv/Lib/site-packages/pip/_internal/index/sources.py +287 -0
- venv/Lib/site-packages/pip/_internal/locations/__init__.py +441 -0
- venv/Lib/site-packages/pip/_internal/locations/_distutils.py +173 -0
- venv/Lib/site-packages/pip/_internal/locations/_sysconfig.py +215 -0
- venv/Lib/site-packages/pip/_internal/locations/base.py +82 -0
- venv/Lib/site-packages/pip/_internal/main.py +12 -0
- venv/Lib/site-packages/pip/_internal/metadata/__init__.py +169 -0
- venv/Lib/site-packages/pip/_internal/metadata/_json.py +87 -0
- venv/Lib/site-packages/pip/_internal/metadata/base.py +685 -0
- venv/Lib/site-packages/pip/_internal/metadata/importlib/__init__.py +6 -0
- venv/Lib/site-packages/pip/_internal/metadata/importlib/_compat.py +87 -0
- venv/Lib/site-packages/pip/_internal/metadata/importlib/_dists.py +229 -0
- venv/Lib/site-packages/pip/_internal/metadata/importlib/_envs.py +143 -0
- venv/Lib/site-packages/pip/_internal/metadata/pkg_resources.py +298 -0
- venv/Lib/site-packages/pip/_internal/models/__init__.py +1 -0
- venv/Lib/site-packages/pip/_internal/models/candidate.py +25 -0
- venv/Lib/site-packages/pip/_internal/models/direct_url.py +227 -0
- venv/Lib/site-packages/pip/_internal/models/format_control.py +78 -0
- venv/Lib/site-packages/pip/_internal/models/index.py +28 -0
- venv/Lib/site-packages/pip/_internal/models/installation_report.py +57 -0
- venv/Lib/site-packages/pip/_internal/models/link.py +613 -0
- venv/Lib/site-packages/pip/_internal/models/pylock.py +188 -0
- venv/Lib/site-packages/pip/_internal/models/scheme.py +25 -0
- venv/Lib/site-packages/pip/_internal/models/search_scope.py +126 -0
- venv/Lib/site-packages/pip/_internal/models/selection_prefs.py +53 -0
- venv/Lib/site-packages/pip/_internal/models/target_python.py +122 -0
- venv/Lib/site-packages/pip/_internal/models/wheel.py +80 -0
- venv/Lib/site-packages/pip/_internal/network/__init__.py +1 -0
- venv/Lib/site-packages/pip/_internal/network/auth.py +564 -0
- venv/Lib/site-packages/pip/_internal/network/cache.py +128 -0
- venv/Lib/site-packages/pip/_internal/network/download.py +342 -0
- venv/Lib/site-packages/pip/_internal/network/lazy_wheel.py +215 -0
- venv/Lib/site-packages/pip/_internal/network/session.py +528 -0
- venv/Lib/site-packages/pip/_internal/network/utils.py +98 -0
- venv/Lib/site-packages/pip/_internal/network/xmlrpc.py +61 -0
- venv/Lib/site-packages/pip/_internal/operations/__init__.py +0 -0
- venv/Lib/site-packages/pip/_internal/operations/build/__init__.py +0 -0
- venv/Lib/site-packages/pip/_internal/operations/build/build_tracker.py +140 -0
- venv/Lib/site-packages/pip/_internal/operations/build/metadata.py +38 -0
- venv/Lib/site-packages/pip/_internal/operations/build/metadata_editable.py +41 -0
- venv/Lib/site-packages/pip/_internal/operations/build/wheel.py +38 -0
- venv/Lib/site-packages/pip/_internal/operations/build/wheel_editable.py +47 -0
- venv/Lib/site-packages/pip/_internal/operations/check.py +175 -0
- venv/Lib/site-packages/pip/_internal/operations/freeze.py +259 -0
- venv/Lib/site-packages/pip/_internal/operations/install/__init__.py +1 -0
- venv/Lib/site-packages/pip/_internal/operations/install/wheel.py +746 -0
- venv/Lib/site-packages/pip/_internal/operations/prepare.py +748 -0
- venv/Lib/site-packages/pip/_internal/pyproject.py +123 -0
- venv/Lib/site-packages/pip/_internal/req/__init__.py +103 -0
- venv/Lib/site-packages/pip/_internal/req/constructors.py +566 -0
- venv/Lib/site-packages/pip/_internal/req/req_dependency_group.py +75 -0
- venv/Lib/site-packages/pip/_internal/req/req_file.py +619 -0
- venv/Lib/site-packages/pip/_internal/req/req_install.py +828 -0
- venv/Lib/site-packages/pip/_internal/req/req_set.py +81 -0
- venv/Lib/site-packages/pip/_internal/req/req_uninstall.py +639 -0
- venv/Lib/site-packages/pip/_internal/resolution/__init__.py +0 -0
- venv/Lib/site-packages/pip/_internal/resolution/base.py +20 -0
- venv/Lib/site-packages/pip/_internal/resolution/legacy/__init__.py +0 -0
- venv/Lib/site-packages/pip/_internal/resolution/legacy/resolver.py +598 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/__init__.py +0 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/base.py +142 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/candidates.py +591 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/factory.py +845 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py +166 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/provider.py +285 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/reporter.py +98 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/requirements.py +247 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/resolver.py +332 -0
- venv/Lib/site-packages/pip/_internal/self_outdated_check.py +262 -0
- venv/Lib/site-packages/pip/_internal/utils/__init__.py +0 -0
- venv/Lib/site-packages/pip/_internal/utils/_jaraco_text.py +109 -0
- venv/Lib/site-packages/pip/_internal/utils/_log.py +38 -0
- venv/Lib/site-packages/pip/_internal/utils/appdirs.py +52 -0
- venv/Lib/site-packages/pip/_internal/utils/compat.py +85 -0
- venv/Lib/site-packages/pip/_internal/utils/compatibility_tags.py +201 -0
- venv/Lib/site-packages/pip/_internal/utils/datetime.py +10 -0
- venv/Lib/site-packages/pip/_internal/utils/deprecation.py +126 -0
- venv/Lib/site-packages/pip/_internal/utils/direct_url_helpers.py +87 -0
- venv/Lib/site-packages/pip/_internal/utils/egg_link.py +81 -0
- venv/Lib/site-packages/pip/_internal/utils/entrypoints.py +88 -0
- venv/Lib/site-packages/pip/_internal/utils/filesystem.py +164 -0
- venv/Lib/site-packages/pip/_internal/utils/filetypes.py +24 -0
- venv/Lib/site-packages/pip/_internal/utils/glibc.py +102 -0
- venv/Lib/site-packages/pip/_internal/utils/hashes.py +150 -0
- venv/Lib/site-packages/pip/_internal/utils/logging.py +364 -0
- venv/Lib/site-packages/pip/_internal/utils/misc.py +765 -0
- venv/Lib/site-packages/pip/_internal/utils/packaging.py +44 -0
- venv/Lib/site-packages/pip/_internal/utils/retry.py +45 -0
- venv/Lib/site-packages/pip/_internal/utils/subprocess.py +248 -0
- venv/Lib/site-packages/pip/_internal/utils/temp_dir.py +294 -0
- venv/Lib/site-packages/pip/_internal/utils/unpacking.py +362 -0
- venv/Lib/site-packages/pip/_internal/utils/urls.py +55 -0
- venv/Lib/site-packages/pip/_internal/utils/virtualenv.py +105 -0
- venv/Lib/site-packages/pip/_internal/utils/wheel.py +132 -0
- venv/Lib/site-packages/pip/_internal/vcs/__init__.py +15 -0
- venv/Lib/site-packages/pip/_internal/vcs/bazaar.py +130 -0
- venv/Lib/site-packages/pip/_internal/vcs/git.py +571 -0
- venv/Lib/site-packages/pip/_internal/vcs/mercurial.py +186 -0
- venv/Lib/site-packages/pip/_internal/vcs/subversion.py +335 -0
- venv/Lib/site-packages/pip/_internal/vcs/versioncontrol.py +693 -0
- venv/Lib/site-packages/pip/_internal/wheel_builder.py +261 -0
- venv/Lib/site-packages/pip/_vendor/__init__.py +117 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/__init__.py +29 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/_cmd.py +70 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/adapter.py +168 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/cache.py +75 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/caches/__init__.py +8 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/caches/file_cache.py +145 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/caches/redis_cache.py +48 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/controller.py +511 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/filewrapper.py +119 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/heuristics.py +157 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/py.typed +0 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/serialize.py +146 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/wrapper.py +43 -0
- venv/Lib/site-packages/pip/_vendor/certifi/__init__.py +4 -0
- venv/Lib/site-packages/pip/_vendor/certifi/__main__.py +12 -0
- venv/Lib/site-packages/pip/_vendor/certifi/core.py +83 -0
- venv/Lib/site-packages/pip/_vendor/certifi/py.typed +0 -0
- venv/Lib/site-packages/pip/_vendor/dependency_groups/__init__.py +13 -0
- venv/Lib/site-packages/pip/_vendor/dependency_groups/__main__.py +65 -0
- venv/Lib/site-packages/pip/_vendor/dependency_groups/_implementation.py +209 -0
- venv/Lib/site-packages/pip/_vendor/dependency_groups/_lint_dependency_groups.py +59 -0
- venv/Lib/site-packages/pip/_vendor/dependency_groups/_pip_wrapper.py +62 -0
- venv/Lib/site-packages/pip/_vendor/dependency_groups/_toml_compat.py +9 -0
- venv/Lib/site-packages/pip/_vendor/dependency_groups/py.typed +0 -0
- venv/Lib/site-packages/pip/_vendor/distlib/__init__.py +33 -0
- venv/Lib/site-packages/pip/_vendor/distlib/compat.py +1137 -0
- venv/Lib/site-packages/pip/_vendor/distlib/resources.py +358 -0
- venv/Lib/site-packages/pip/_vendor/distlib/scripts.py +447 -0
- venv/Lib/site-packages/pip/_vendor/distlib/util.py +1984 -0
- venv/Lib/site-packages/pip/_vendor/distro/__init__.py +54 -0
- venv/Lib/site-packages/pip/_vendor/distro/__main__.py +4 -0
- venv/Lib/site-packages/pip/_vendor/distro/distro.py +1403 -0
- venv/Lib/site-packages/pip/_vendor/distro/py.typed +0 -0
- venv/Lib/site-packages/pip/_vendor/idna/__init__.py +45 -0
- venv/Lib/site-packages/pip/_vendor/idna/codec.py +122 -0
- venv/Lib/site-packages/pip/_vendor/idna/compat.py +15 -0
- venv/Lib/site-packages/pip/_vendor/idna/core.py +437 -0
- venv/Lib/site-packages/pip/_vendor/idna/idnadata.py +4243 -0
- venv/Lib/site-packages/pip/_vendor/idna/intranges.py +57 -0
- venv/Lib/site-packages/pip/_vendor/idna/package_data.py +1 -0
- venv/Lib/site-packages/pip/_vendor/idna/py.typed +0 -0
- venv/Lib/site-packages/pip/_vendor/idna/uts46data.py +8681 -0
- venv/Lib/site-packages/pip/_vendor/msgpack/__init__.py +55 -0
- venv/Lib/site-packages/pip/_vendor/msgpack/exceptions.py +48 -0
- venv/Lib/site-packages/pip/_vendor/msgpack/ext.py +170 -0
- venv/Lib/site-packages/pip/_vendor/msgpack/fallback.py +929 -0
- venv/Lib/site-packages/pip/_vendor/packaging/__init__.py +15 -0
- venv/Lib/site-packages/pip/_vendor/packaging/_elffile.py +109 -0
- venv/Lib/site-packages/pip/_vendor/packaging/_manylinux.py +262 -0
- venv/Lib/site-packages/pip/_vendor/packaging/_musllinux.py +85 -0
- venv/Lib/site-packages/pip/_vendor/packaging/_parser.py +353 -0
- venv/Lib/site-packages/pip/_vendor/packaging/_structures.py +61 -0
- venv/Lib/site-packages/pip/_vendor/packaging/_tokenizer.py +195 -0
- venv/Lib/site-packages/pip/_vendor/packaging/licenses/__init__.py +145 -0
- venv/Lib/site-packages/pip/_vendor/packaging/licenses/_spdx.py +759 -0
- venv/Lib/site-packages/pip/_vendor/packaging/markers.py +362 -0
- venv/Lib/site-packages/pip/_vendor/packaging/metadata.py +862 -0
- venv/Lib/site-packages/pip/_vendor/packaging/py.typed +0 -0
- venv/Lib/site-packages/pip/_vendor/packaging/requirements.py +91 -0
- venv/Lib/site-packages/pip/_vendor/packaging/specifiers.py +1019 -0
- venv/Lib/site-packages/pip/_vendor/packaging/tags.py +656 -0
- venv/Lib/site-packages/pip/_vendor/packaging/utils.py +163 -0
- venv/Lib/site-packages/pip/_vendor/packaging/version.py +582 -0
- venv/Lib/site-packages/pip/_vendor/pkg_resources/__init__.py +3676 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/__init__.py +631 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/__main__.py +55 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/android.py +249 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/api.py +299 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/macos.py +146 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/py.typed +0 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/unix.py +272 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/version.py +34 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/windows.py +272 -0
- venv/Lib/site-packages/pip/_vendor/pygments/__init__.py +82 -0
- venv/Lib/site-packages/pip/_vendor/pygments/__main__.py +17 -0
- venv/Lib/site-packages/pip/_vendor/pygments/console.py +70 -0
- venv/Lib/site-packages/pip/_vendor/pygments/filter.py +70 -0
- venv/Lib/site-packages/pip/_vendor/pygments/filters/__init__.py +940 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatter.py +129 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/__init__.py +157 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/_mapping.py +23 -0
- venv/Lib/site-packages/pip/_vendor/pygments/lexer.py +963 -0
- venv/Lib/site-packages/pip/_vendor/pygments/lexers/__init__.py +362 -0
- venv/Lib/site-packages/pip/_vendor/pygments/lexers/_mapping.py +602 -0
- venv/Lib/site-packages/pip/_vendor/pygments/lexers/python.py +1201 -0
- venv/Lib/site-packages/pip/_vendor/pygments/modeline.py +43 -0
- venv/Lib/site-packages/pip/_vendor/pygments/plugin.py +72 -0
- venv/Lib/site-packages/pip/_vendor/pygments/regexopt.py +91 -0
- venv/Lib/site-packages/pip/_vendor/pygments/scanner.py +104 -0
- venv/Lib/site-packages/pip/_vendor/pygments/sphinxext.py +247 -0
- venv/Lib/site-packages/pip/_vendor/pygments/style.py +203 -0
- venv/Lib/site-packages/pip/_vendor/pygments/styles/__init__.py +61 -0
- venv/Lib/site-packages/pip/_vendor/pygments/styles/_mapping.py +54 -0
- venv/Lib/site-packages/pip/_vendor/pygments/token.py +214 -0
- venv/Lib/site-packages/pip/_vendor/pygments/unistring.py +153 -0
- venv/Lib/site-packages/pip/_vendor/pygments/util.py +324 -0
- venv/Lib/site-packages/pip/_vendor/pyproject_hooks/__init__.py +31 -0
- venv/Lib/site-packages/pip/_vendor/pyproject_hooks/_impl.py +410 -0
- venv/Lib/site-packages/pip/_vendor/pyproject_hooks/_in_process/__init__.py +21 -0
- venv/Lib/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py +389 -0
- venv/Lib/site-packages/pip/_vendor/pyproject_hooks/py.typed +0 -0
- venv/Lib/site-packages/pip/_vendor/requests/__init__.py +179 -0
- venv/Lib/site-packages/pip/_vendor/requests/__version__.py +14 -0
- venv/Lib/site-packages/pip/_vendor/requests/_internal_utils.py +50 -0
- venv/Lib/site-packages/pip/_vendor/requests/adapters.py +696 -0
- venv/Lib/site-packages/pip/_vendor/requests/api.py +157 -0
- venv/Lib/site-packages/pip/_vendor/requests/auth.py +314 -0
- venv/Lib/site-packages/pip/_vendor/requests/certs.py +17 -0
- venv/Lib/site-packages/pip/_vendor/requests/compat.py +90 -0
- venv/Lib/site-packages/pip/_vendor/requests/cookies.py +561 -0
- venv/Lib/site-packages/pip/_vendor/requests/exceptions.py +151 -0
- venv/Lib/site-packages/pip/_vendor/requests/help.py +127 -0
- venv/Lib/site-packages/pip/_vendor/requests/hooks.py +33 -0
- venv/Lib/site-packages/pip/_vendor/requests/models.py +1039 -0
- venv/Lib/site-packages/pip/_vendor/requests/packages.py +25 -0
- venv/Lib/site-packages/pip/_vendor/requests/sessions.py +831 -0
- venv/Lib/site-packages/pip/_vendor/requests/status_codes.py +128 -0
- venv/Lib/site-packages/pip/_vendor/requests/structures.py +99 -0
- venv/Lib/site-packages/pip/_vendor/requests/utils.py +1086 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/__init__.py +27 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/providers.py +196 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/py.typed +0 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/reporters.py +55 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/resolvers/__init__.py +27 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/resolvers/abstract.py +47 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/resolvers/criterion.py +48 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/resolvers/exceptions.py +57 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/resolvers/resolution.py +627 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/structs.py +209 -0
- venv/Lib/site-packages/pip/_vendor/rich/__init__.py +177 -0
- venv/Lib/site-packages/pip/_vendor/rich/__main__.py +245 -0
- venv/Lib/site-packages/pip/_vendor/rich/_cell_widths.py +454 -0
- venv/Lib/site-packages/pip/_vendor/rich/_emoji_codes.py +3610 -0
- venv/Lib/site-packages/pip/_vendor/rich/_emoji_replace.py +32 -0
- venv/Lib/site-packages/pip/_vendor/rich/_export_format.py +76 -0
- venv/Lib/site-packages/pip/_vendor/rich/_extension.py +10 -0
- venv/Lib/site-packages/pip/_vendor/rich/_fileno.py +24 -0
- venv/Lib/site-packages/pip/_vendor/rich/_inspect.py +268 -0
- venv/Lib/site-packages/pip/_vendor/rich/_log_render.py +94 -0
- venv/Lib/site-packages/pip/_vendor/rich/_loop.py +43 -0
- venv/Lib/site-packages/pip/_vendor/rich/_null_file.py +69 -0
- venv/Lib/site-packages/pip/_vendor/rich/_palettes.py +309 -0
- venv/Lib/site-packages/pip/_vendor/rich/_pick.py +17 -0
- venv/Lib/site-packages/pip/_vendor/rich/_ratio.py +153 -0
- venv/Lib/site-packages/pip/_vendor/rich/_spinners.py +482 -0
- venv/Lib/site-packages/pip/_vendor/rich/_stack.py +16 -0
- venv/Lib/site-packages/pip/_vendor/rich/_timer.py +19 -0
- venv/Lib/site-packages/pip/_vendor/rich/_win32_console.py +661 -0
- venv/Lib/site-packages/pip/_vendor/rich/_windows.py +71 -0
- venv/Lib/site-packages/pip/_vendor/rich/_windows_renderer.py +56 -0
- venv/Lib/site-packages/pip/_vendor/rich/_wrap.py +93 -0
- venv/Lib/site-packages/pip/_vendor/rich/abc.py +33 -0
- venv/Lib/site-packages/pip/_vendor/rich/align.py +306 -0
- venv/Lib/site-packages/pip/_vendor/rich/ansi.py +241 -0
- venv/Lib/site-packages/pip/_vendor/rich/bar.py +93 -0
- venv/Lib/site-packages/pip/_vendor/rich/box.py +474 -0
- venv/Lib/site-packages/pip/_vendor/rich/cells.py +174 -0
- venv/Lib/site-packages/pip/_vendor/rich/color.py +621 -0
- venv/Lib/site-packages/pip/_vendor/rich/color_triplet.py +38 -0
- venv/Lib/site-packages/pip/_vendor/rich/columns.py +187 -0
- venv/Lib/site-packages/pip/_vendor/rich/console.py +2680 -0
- venv/Lib/site-packages/pip/_vendor/rich/constrain.py +37 -0
- venv/Lib/site-packages/pip/_vendor/rich/containers.py +167 -0
- venv/Lib/site-packages/pip/_vendor/rich/control.py +219 -0
- venv/Lib/site-packages/pip/_vendor/rich/default_styles.py +193 -0
- venv/Lib/site-packages/pip/_vendor/rich/diagnose.py +39 -0
- venv/Lib/site-packages/pip/_vendor/rich/emoji.py +91 -0
- venv/Lib/site-packages/pip/_vendor/rich/errors.py +34 -0
- venv/Lib/site-packages/pip/_vendor/rich/file_proxy.py +57 -0
- venv/Lib/site-packages/pip/_vendor/rich/filesize.py +88 -0
- venv/Lib/site-packages/pip/_vendor/rich/highlighter.py +232 -0
- venv/Lib/site-packages/pip/_vendor/rich/json.py +139 -0
- venv/Lib/site-packages/pip/_vendor/rich/jupyter.py +101 -0
- venv/Lib/site-packages/pip/_vendor/rich/layout.py +442 -0
- venv/Lib/site-packages/pip/_vendor/rich/live.py +400 -0
- venv/Lib/site-packages/pip/_vendor/rich/live_render.py +106 -0
- venv/Lib/site-packages/pip/_vendor/rich/logging.py +297 -0
- venv/Lib/site-packages/pip/_vendor/rich/markup.py +251 -0
- venv/Lib/site-packages/pip/_vendor/rich/measure.py +151 -0
- venv/Lib/site-packages/pip/_vendor/rich/padding.py +141 -0
- venv/Lib/site-packages/pip/_vendor/rich/pager.py +34 -0
- venv/Lib/site-packages/pip/_vendor/rich/palette.py +100 -0
- venv/Lib/site-packages/pip/_vendor/rich/panel.py +317 -0
- venv/Lib/site-packages/pip/_vendor/rich/pretty.py +1016 -0
- venv/Lib/site-packages/pip/_vendor/rich/progress.py +1715 -0
- venv/Lib/site-packages/pip/_vendor/rich/progress_bar.py +223 -0
- venv/Lib/site-packages/pip/_vendor/rich/prompt.py +400 -0
- venv/Lib/site-packages/pip/_vendor/rich/protocol.py +42 -0
- venv/Lib/site-packages/pip/_vendor/rich/py.typed +0 -0
- venv/Lib/site-packages/pip/_vendor/rich/region.py +10 -0
- venv/Lib/site-packages/pip/_vendor/rich/repr.py +149 -0
- venv/Lib/site-packages/pip/_vendor/rich/rule.py +130 -0
- venv/Lib/site-packages/pip/_vendor/rich/scope.py +86 -0
- venv/Lib/site-packages/pip/_vendor/rich/screen.py +54 -0
- venv/Lib/site-packages/pip/_vendor/rich/segment.py +752 -0
- venv/Lib/site-packages/pip/_vendor/rich/spinner.py +132 -0
- venv/Lib/site-packages/pip/_vendor/rich/status.py +131 -0
- venv/Lib/site-packages/pip/_vendor/rich/style.py +792 -0
- venv/Lib/site-packages/pip/_vendor/rich/styled.py +42 -0
- venv/Lib/site-packages/pip/_vendor/rich/syntax.py +985 -0
- venv/Lib/site-packages/pip/_vendor/rich/table.py +1006 -0
- venv/Lib/site-packages/pip/_vendor/rich/terminal_theme.py +153 -0
- venv/Lib/site-packages/pip/_vendor/rich/text.py +1361 -0
- venv/Lib/site-packages/pip/_vendor/rich/theme.py +115 -0
- venv/Lib/site-packages/pip/_vendor/rich/themes.py +5 -0
- venv/Lib/site-packages/pip/_vendor/rich/traceback.py +899 -0
- venv/Lib/site-packages/pip/_vendor/rich/tree.py +257 -0
- venv/Lib/site-packages/pip/_vendor/tomli/__init__.py +8 -0
- venv/Lib/site-packages/pip/_vendor/tomli/_parser.py +777 -0
- venv/Lib/site-packages/pip/_vendor/tomli/_re.py +115 -0
- venv/Lib/site-packages/pip/_vendor/tomli/_types.py +10 -0
- venv/Lib/site-packages/pip/_vendor/tomli/py.typed +1 -0
- venv/Lib/site-packages/pip/_vendor/tomli_w/__init__.py +4 -0
- venv/Lib/site-packages/pip/_vendor/tomli_w/_writer.py +229 -0
- venv/Lib/site-packages/pip/_vendor/tomli_w/py.typed +1 -0
- venv/Lib/site-packages/pip/_vendor/truststore/__init__.py +36 -0
- venv/Lib/site-packages/pip/_vendor/truststore/_api.py +341 -0
- venv/Lib/site-packages/pip/_vendor/truststore/_macos.py +571 -0
- venv/Lib/site-packages/pip/_vendor/truststore/_openssl.py +68 -0
- venv/Lib/site-packages/pip/_vendor/truststore/_ssl_constants.py +31 -0
- venv/Lib/site-packages/pip/_vendor/truststore/_windows.py +567 -0
- venv/Lib/site-packages/pip/_vendor/truststore/py.typed +0 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/__init__.py +102 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/_collections.py +355 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/_version.py +2 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/connection.py +572 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/connectionpool.py +1140 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/__init__.py +0 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/_appengine_environ.py +36 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/_securetransport/__init__.py +0 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/_securetransport/bindings.py +519 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/_securetransport/low_level.py +397 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/appengine.py +314 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/ntlmpool.py +130 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py +518 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/securetransport.py +920 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/socks.py +216 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/exceptions.py +323 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/fields.py +274 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/filepost.py +98 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/packages/__init__.py +0 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/packages/backports/__init__.py +0 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/packages/backports/makefile.py +51 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/packages/backports/weakref_finalize.py +155 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/packages/six.py +1076 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/poolmanager.py +540 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/request.py +191 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/response.py +879 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/__init__.py +49 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/connection.py +149 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/proxy.py +57 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/queue.py +22 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/request.py +137 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/response.py +107 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/retry.py +622 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/ssl_.py +504 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/ssl_match_hostname.py +159 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/ssltransport.py +221 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/timeout.py +271 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/url.py +435 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/wait.py +152 -0
- venv/Lib/site-packages/pip/py.typed +4 -0
- venv/Lib/site-packages/pygments/__init__.py +82 -0
- venv/Lib/site-packages/pygments/__main__.py +17 -0
- venv/Lib/site-packages/pygments/cmdline.py +668 -0
- venv/Lib/site-packages/pygments/console.py +70 -0
- venv/Lib/site-packages/pygments/filter.py +70 -0
- venv/Lib/site-packages/pygments/filters/__init__.py +940 -0
- venv/Lib/site-packages/pygments/formatter.py +129 -0
- venv/Lib/site-packages/pygments/formatters/__init__.py +157 -0
- venv/Lib/site-packages/pygments/formatters/_mapping.py +23 -0
- venv/Lib/site-packages/pygments/formatters/bbcode.py +108 -0
- venv/Lib/site-packages/pygments/formatters/groff.py +170 -0
- venv/Lib/site-packages/pygments/formatters/html.py +995 -0
- venv/Lib/site-packages/pygments/formatters/img.py +686 -0
- venv/Lib/site-packages/pygments/formatters/irc.py +154 -0
- venv/Lib/site-packages/pygments/formatters/latex.py +518 -0
- venv/Lib/site-packages/pygments/formatters/other.py +160 -0
- venv/Lib/site-packages/pygments/formatters/pangomarkup.py +83 -0
- venv/Lib/site-packages/pygments/formatters/rtf.py +349 -0
- venv/Lib/site-packages/pygments/formatters/svg.py +185 -0
- venv/Lib/site-packages/pygments/formatters/terminal.py +127 -0
- venv/Lib/site-packages/pygments/formatters/terminal256.py +338 -0
- venv/Lib/site-packages/pygments/lexer.py +961 -0
- venv/Lib/site-packages/pygments/lexers/__init__.py +362 -0
- venv/Lib/site-packages/pygments/lexers/_ada_builtins.py +103 -0
- venv/Lib/site-packages/pygments/lexers/_asy_builtins.py +1644 -0
- venv/Lib/site-packages/pygments/lexers/_cl_builtins.py +231 -0
- venv/Lib/site-packages/pygments/lexers/_cocoa_builtins.py +75 -0
- venv/Lib/site-packages/pygments/lexers/_csound_builtins.py +1780 -0
- venv/Lib/site-packages/pygments/lexers/_css_builtins.py +558 -0
- venv/Lib/site-packages/pygments/lexers/_googlesql_builtins.py +918 -0
- venv/Lib/site-packages/pygments/lexers/_julia_builtins.py +411 -0
- venv/Lib/site-packages/pygments/lexers/_lasso_builtins.py +5326 -0
- venv/Lib/site-packages/pygments/lexers/_lilypond_builtins.py +4932 -0
- venv/Lib/site-packages/pygments/lexers/_lua_builtins.py +285 -0
- venv/Lib/site-packages/pygments/lexers/_luau_builtins.py +62 -0
- venv/Lib/site-packages/pygments/lexers/_mapping.py +602 -0
- venv/Lib/site-packages/pygments/lexers/_mql_builtins.py +1171 -0
- venv/Lib/site-packages/pygments/lexers/_mysql_builtins.py +1335 -0
- venv/Lib/site-packages/pygments/lexers/_openedge_builtins.py +2600 -0
- venv/Lib/site-packages/pygments/lexers/_php_builtins.py +3325 -0
- venv/Lib/site-packages/pygments/lexers/_postgres_builtins.py +739 -0
- venv/Lib/site-packages/pygments/lexers/_qlik_builtins.py +666 -0
- venv/Lib/site-packages/pygments/lexers/_scheme_builtins.py +1609 -0
- venv/Lib/site-packages/pygments/lexers/_scilab_builtins.py +3093 -0
- venv/Lib/site-packages/pygments/lexers/_sourcemod_builtins.py +1151 -0
- venv/Lib/site-packages/pygments/lexers/_sql_builtins.py +106 -0
- venv/Lib/site-packages/pygments/lexers/_stan_builtins.py +648 -0
- venv/Lib/site-packages/pygments/lexers/_stata_builtins.py +457 -0
- venv/Lib/site-packages/pygments/lexers/_tsql_builtins.py +1003 -0
- venv/Lib/site-packages/pygments/lexers/_usd_builtins.py +112 -0
- venv/Lib/site-packages/pygments/lexers/_vbscript_builtins.py +279 -0
- venv/Lib/site-packages/pygments/lexers/_vim_builtins.py +1938 -0
- venv/Lib/site-packages/pygments/lexers/actionscript.py +243 -0
- venv/Lib/site-packages/pygments/lexers/ada.py +144 -0
- venv/Lib/site-packages/pygments/lexers/agile.py +25 -0
- venv/Lib/site-packages/pygments/lexers/algebra.py +299 -0
- venv/Lib/site-packages/pygments/lexers/ambient.py +75 -0
- venv/Lib/site-packages/pygments/lexers/amdgpu.py +54 -0
- venv/Lib/site-packages/pygments/lexers/ampl.py +87 -0
- venv/Lib/site-packages/pygments/lexers/apdlexer.py +593 -0
- venv/Lib/site-packages/pygments/lexers/apl.py +103 -0
- venv/Lib/site-packages/pygments/lexers/archetype.py +315 -0
- venv/Lib/site-packages/pygments/lexers/arrow.py +116 -0
- venv/Lib/site-packages/pygments/lexers/arturo.py +249 -0
- venv/Lib/site-packages/pygments/lexers/asc.py +55 -0
- venv/Lib/site-packages/pygments/lexers/asm.py +1051 -0
- venv/Lib/site-packages/pygments/lexers/asn1.py +178 -0
- venv/Lib/site-packages/pygments/lexers/automation.py +379 -0
- venv/Lib/site-packages/pygments/lexers/bare.py +101 -0
- venv/Lib/site-packages/pygments/lexers/basic.py +656 -0
- venv/Lib/site-packages/pygments/lexers/bdd.py +57 -0
- venv/Lib/site-packages/pygments/lexers/berry.py +99 -0
- venv/Lib/site-packages/pygments/lexers/bibtex.py +159 -0
- venv/Lib/site-packages/pygments/lexers/blueprint.py +173 -0
- venv/Lib/site-packages/pygments/lexers/boa.py +97 -0
- venv/Lib/site-packages/pygments/lexers/bqn.py +112 -0
- venv/Lib/site-packages/pygments/lexers/business.py +625 -0
- venv/Lib/site-packages/pygments/lexers/c_cpp.py +414 -0
- venv/Lib/site-packages/pygments/lexers/c_like.py +738 -0
- venv/Lib/site-packages/pygments/lexers/capnproto.py +74 -0
- venv/Lib/site-packages/pygments/lexers/carbon.py +95 -0
- venv/Lib/site-packages/pygments/lexers/cddl.py +172 -0
- venv/Lib/site-packages/pygments/lexers/chapel.py +139 -0
- venv/Lib/site-packages/pygments/lexers/clean.py +180 -0
- venv/Lib/site-packages/pygments/lexers/codeql.py +80 -0
- venv/Lib/site-packages/pygments/lexers/comal.py +81 -0
- venv/Lib/site-packages/pygments/lexers/compiled.py +35 -0
- venv/Lib/site-packages/pygments/lexers/configs.py +1433 -0
- venv/Lib/site-packages/pygments/lexers/console.py +114 -0
- venv/Lib/site-packages/pygments/lexers/cplint.py +43 -0
- venv/Lib/site-packages/pygments/lexers/crystal.py +364 -0
- venv/Lib/site-packages/pygments/lexers/csound.py +466 -0
- venv/Lib/site-packages/pygments/lexers/css.py +602 -0
- venv/Lib/site-packages/pygments/lexers/d.py +259 -0
- venv/Lib/site-packages/pygments/lexers/dalvik.py +126 -0
- venv/Lib/site-packages/pygments/lexers/data.py +763 -0
- venv/Lib/site-packages/pygments/lexers/dax.py +135 -0
- venv/Lib/site-packages/pygments/lexers/devicetree.py +108 -0
- venv/Lib/site-packages/pygments/lexers/diff.py +169 -0
- venv/Lib/site-packages/pygments/lexers/dns.py +109 -0
- venv/Lib/site-packages/pygments/lexers/dotnet.py +873 -0
- venv/Lib/site-packages/pygments/lexers/dsls.py +970 -0
- venv/Lib/site-packages/pygments/lexers/dylan.py +279 -0
- venv/Lib/site-packages/pygments/lexers/ecl.py +144 -0
- venv/Lib/site-packages/pygments/lexers/eiffel.py +68 -0
- venv/Lib/site-packages/pygments/lexers/elm.py +123 -0
- venv/Lib/site-packages/pygments/lexers/elpi.py +175 -0
- venv/Lib/site-packages/pygments/lexers/email.py +132 -0
- venv/Lib/site-packages/pygments/lexers/erlang.py +526 -0
- venv/Lib/site-packages/pygments/lexers/esoteric.py +300 -0
- venv/Lib/site-packages/pygments/lexers/ezhil.py +76 -0
- venv/Lib/site-packages/pygments/lexers/factor.py +363 -0
- venv/Lib/site-packages/pygments/lexers/fantom.py +251 -0
- venv/Lib/site-packages/pygments/lexers/felix.py +275 -0
- venv/Lib/site-packages/pygments/lexers/fift.py +68 -0
- venv/Lib/site-packages/pygments/lexers/floscript.py +81 -0
- venv/Lib/site-packages/pygments/lexers/forth.py +178 -0
- venv/Lib/site-packages/pygments/lexers/fortran.py +212 -0
- venv/Lib/site-packages/pygments/lexers/foxpro.py +427 -0
- venv/Lib/site-packages/pygments/lexers/freefem.py +893 -0
- venv/Lib/site-packages/pygments/lexers/func.py +110 -0
- venv/Lib/site-packages/pygments/lexers/functional.py +21 -0
- venv/Lib/site-packages/pygments/lexers/futhark.py +105 -0
- venv/Lib/site-packages/pygments/lexers/gcodelexer.py +35 -0
- venv/Lib/site-packages/pygments/lexers/gdscript.py +189 -0
- venv/Lib/site-packages/pygments/lexers/gleam.py +74 -0
- venv/Lib/site-packages/pygments/lexers/go.py +97 -0
- venv/Lib/site-packages/pygments/lexers/grammar_notation.py +262 -0
- venv/Lib/site-packages/pygments/lexers/graph.py +108 -0
- venv/Lib/site-packages/pygments/lexers/graphics.py +794 -0
- venv/Lib/site-packages/pygments/lexers/graphql.py +176 -0
- venv/Lib/site-packages/pygments/lexers/graphviz.py +58 -0
- venv/Lib/site-packages/pygments/lexers/gsql.py +103 -0
- venv/Lib/site-packages/pygments/lexers/hare.py +73 -0
- venv/Lib/site-packages/pygments/lexers/haskell.py +866 -0
- venv/Lib/site-packages/pygments/lexers/haxe.py +935 -0
- venv/Lib/site-packages/pygments/lexers/hdl.py +466 -0
- venv/Lib/site-packages/pygments/lexers/hexdump.py +102 -0
- venv/Lib/site-packages/pygments/lexers/html.py +670 -0
- venv/Lib/site-packages/pygments/lexers/idl.py +284 -0
- venv/Lib/site-packages/pygments/lexers/igor.py +435 -0
- venv/Lib/site-packages/pygments/lexers/inferno.py +95 -0
- venv/Lib/site-packages/pygments/lexers/installers.py +352 -0
- venv/Lib/site-packages/pygments/lexers/int_fiction.py +1370 -0
- venv/Lib/site-packages/pygments/lexers/iolang.py +61 -0
- venv/Lib/site-packages/pygments/lexers/j.py +151 -0
- venv/Lib/site-packages/pygments/lexers/javascript.py +1591 -0
- venv/Lib/site-packages/pygments/lexers/jmespath.py +69 -0
- venv/Lib/site-packages/pygments/lexers/jslt.py +94 -0
- venv/Lib/site-packages/pygments/lexers/json5.py +83 -0
- venv/Lib/site-packages/pygments/lexers/jsonnet.py +169 -0
- venv/Lib/site-packages/pygments/lexers/jsx.py +100 -0
- venv/Lib/site-packages/pygments/lexers/julia.py +294 -0
- venv/Lib/site-packages/pygments/lexers/jvm.py +1802 -0
- venv/Lib/site-packages/pygments/lexers/kuin.py +332 -0
- venv/Lib/site-packages/pygments/lexers/kusto.py +93 -0
- venv/Lib/site-packages/pygments/lexers/ldap.py +155 -0
- venv/Lib/site-packages/pygments/lexers/lean.py +241 -0
- venv/Lib/site-packages/pygments/lexers/lilypond.py +225 -0
- venv/Lib/site-packages/pygments/lexers/lisp.py +3146 -0
- venv/Lib/site-packages/pygments/lexers/macaulay2.py +1814 -0
- venv/Lib/site-packages/pygments/lexers/make.py +212 -0
- venv/Lib/site-packages/pygments/lexers/maple.py +291 -0
- venv/Lib/site-packages/pygments/lexers/markup.py +1654 -0
- venv/Lib/site-packages/pygments/lexers/math.py +21 -0
- venv/Lib/site-packages/pygments/lexers/matlab.py +3307 -0
- venv/Lib/site-packages/pygments/lexers/maxima.py +84 -0
- venv/Lib/site-packages/pygments/lexers/meson.py +139 -0
- venv/Lib/site-packages/pygments/lexers/mime.py +210 -0
- venv/Lib/site-packages/pygments/lexers/minecraft.py +391 -0
- venv/Lib/site-packages/pygments/lexers/mips.py +130 -0
- venv/Lib/site-packages/pygments/lexers/ml.py +958 -0
- venv/Lib/site-packages/pygments/lexers/modeling.py +366 -0
- venv/Lib/site-packages/pygments/lexers/modula2.py +1579 -0
- venv/Lib/site-packages/pygments/lexers/mojo.py +707 -0
- venv/Lib/site-packages/pygments/lexers/monte.py +203 -0
- venv/Lib/site-packages/pygments/lexers/mosel.py +447 -0
- venv/Lib/site-packages/pygments/lexers/ncl.py +894 -0
- venv/Lib/site-packages/pygments/lexers/nimrod.py +199 -0
- venv/Lib/site-packages/pygments/lexers/nit.py +63 -0
- venv/Lib/site-packages/pygments/lexers/nix.py +144 -0
- venv/Lib/site-packages/pygments/lexers/numbair.py +63 -0
- venv/Lib/site-packages/pygments/lexers/oberon.py +120 -0
- venv/Lib/site-packages/pygments/lexers/objective.py +513 -0
- venv/Lib/site-packages/pygments/lexers/ooc.py +84 -0
- venv/Lib/site-packages/pygments/lexers/openscad.py +96 -0
- venv/Lib/site-packages/pygments/lexers/other.py +41 -0
- venv/Lib/site-packages/pygments/lexers/parasail.py +78 -0
- venv/Lib/site-packages/pygments/lexers/parsers.py +798 -0
- venv/Lib/site-packages/pygments/lexers/pascal.py +644 -0
- venv/Lib/site-packages/pygments/lexers/pawn.py +202 -0
- venv/Lib/site-packages/pygments/lexers/pddl.py +82 -0
- venv/Lib/site-packages/pygments/lexers/perl.py +733 -0
- venv/Lib/site-packages/pygments/lexers/phix.py +363 -0
- venv/Lib/site-packages/pygments/lexers/php.py +334 -0
- venv/Lib/site-packages/pygments/lexers/pointless.py +70 -0
- venv/Lib/site-packages/pygments/lexers/pony.py +93 -0
- venv/Lib/site-packages/pygments/lexers/praat.py +303 -0
- venv/Lib/site-packages/pygments/lexers/procfile.py +41 -0
- venv/Lib/site-packages/pygments/lexers/prolog.py +318 -0
- venv/Lib/site-packages/pygments/lexers/promql.py +176 -0
- venv/Lib/site-packages/pygments/lexers/prql.py +251 -0
- venv/Lib/site-packages/pygments/lexers/ptx.py +119 -0
- venv/Lib/site-packages/pygments/lexers/python.py +1201 -0
- venv/Lib/site-packages/pygments/lexers/q.py +187 -0
- venv/Lib/site-packages/pygments/lexers/qlik.py +117 -0
- venv/Lib/site-packages/pygments/lexers/qvt.py +153 -0
- venv/Lib/site-packages/pygments/lexers/r.py +196 -0
- venv/Lib/site-packages/pygments/lexers/rdf.py +468 -0
- venv/Lib/site-packages/pygments/lexers/rebol.py +419 -0
- venv/Lib/site-packages/pygments/lexers/rego.py +57 -0
- venv/Lib/site-packages/pygments/lexers/resource.py +83 -0
- venv/Lib/site-packages/pygments/lexers/ride.py +138 -0
- venv/Lib/site-packages/pygments/lexers/rita.py +42 -0
- venv/Lib/site-packages/pygments/lexers/rnc.py +66 -0
- venv/Lib/site-packages/pygments/lexers/roboconf.py +81 -0
- venv/Lib/site-packages/pygments/lexers/robotframework.py +551 -0
- venv/Lib/site-packages/pygments/lexers/ruby.py +518 -0
- venv/Lib/site-packages/pygments/lexers/rust.py +222 -0
- venv/Lib/site-packages/pygments/lexers/sas.py +227 -0
- venv/Lib/site-packages/pygments/lexers/savi.py +171 -0
- venv/Lib/site-packages/pygments/lexers/scdoc.py +85 -0
- venv/Lib/site-packages/pygments/lexers/scripting.py +1616 -0
- venv/Lib/site-packages/pygments/lexers/sgf.py +59 -0
- venv/Lib/site-packages/pygments/lexers/shell.py +902 -0
- venv/Lib/site-packages/pygments/lexers/sieve.py +78 -0
- venv/Lib/site-packages/pygments/lexers/slash.py +183 -0
- venv/Lib/site-packages/pygments/lexers/smalltalk.py +194 -0
- venv/Lib/site-packages/pygments/lexers/smithy.py +77 -0
- venv/Lib/site-packages/pygments/lexers/smv.py +78 -0
- venv/Lib/site-packages/pygments/lexers/snobol.py +82 -0
- venv/Lib/site-packages/pygments/lexers/solidity.py +87 -0
- venv/Lib/site-packages/pygments/lexers/soong.py +78 -0
- venv/Lib/site-packages/pygments/lexers/sophia.py +102 -0
- venv/Lib/site-packages/pygments/lexers/special.py +122 -0
- venv/Lib/site-packages/pygments/lexers/spice.py +70 -0
- venv/Lib/site-packages/pygments/lexers/sql.py +1109 -0
- venv/Lib/site-packages/pygments/lexers/srcinfo.py +62 -0
- venv/Lib/site-packages/pygments/lexers/stata.py +170 -0
- venv/Lib/site-packages/pygments/lexers/supercollider.py +94 -0
- venv/Lib/site-packages/pygments/lexers/tablegen.py +177 -0
- venv/Lib/site-packages/pygments/lexers/tact.py +303 -0
- venv/Lib/site-packages/pygments/lexers/tal.py +77 -0
- venv/Lib/site-packages/pygments/lexers/tcl.py +148 -0
- venv/Lib/site-packages/pygments/lexers/teal.py +88 -0
- venv/Lib/site-packages/pygments/lexers/templates.py +2355 -0
- venv/Lib/site-packages/pygments/lexers/teraterm.py +325 -0
- venv/Lib/site-packages/pygments/lexers/testing.py +209 -0
- venv/Lib/site-packages/pygments/lexers/text.py +27 -0
- venv/Lib/site-packages/pygments/lexers/textedit.py +205 -0
- venv/Lib/site-packages/pygments/lexers/textfmts.py +436 -0
- venv/Lib/site-packages/pygments/lexers/theorem.py +410 -0
- venv/Lib/site-packages/pygments/lexers/thingsdb.py +140 -0
- venv/Lib/site-packages/pygments/lexers/tlb.py +59 -0
- venv/Lib/site-packages/pygments/lexers/tls.py +54 -0
- venv/Lib/site-packages/pygments/lexers/tnt.py +270 -0
- venv/Lib/site-packages/pygments/lexers/trafficscript.py +51 -0
- venv/Lib/site-packages/pygments/lexers/typoscript.py +216 -0
- venv/Lib/site-packages/pygments/lexers/typst.py +160 -0
- venv/Lib/site-packages/pygments/lexers/ul4.py +309 -0
- venv/Lib/site-packages/pygments/lexers/unicon.py +413 -0
- venv/Lib/site-packages/pygments/lexers/urbi.py +145 -0
- venv/Lib/site-packages/pygments/lexers/usd.py +85 -0
- venv/Lib/site-packages/pygments/lexers/varnish.py +189 -0
- venv/Lib/site-packages/pygments/lexers/verification.py +113 -0
- venv/Lib/site-packages/pygments/lexers/verifpal.py +65 -0
- venv/Lib/site-packages/pygments/lexers/vip.py +150 -0
- venv/Lib/site-packages/pygments/lexers/vyper.py +140 -0
- venv/Lib/site-packages/pygments/lexers/web.py +24 -0
- venv/Lib/site-packages/pygments/lexers/webassembly.py +119 -0
- venv/Lib/site-packages/pygments/lexers/webidl.py +298 -0
- venv/Lib/site-packages/pygments/lexers/webmisc.py +1006 -0
- venv/Lib/site-packages/pygments/lexers/wgsl.py +406 -0
- venv/Lib/site-packages/pygments/lexers/whiley.py +115 -0
- venv/Lib/site-packages/pygments/lexers/wowtoc.py +120 -0
- venv/Lib/site-packages/pygments/lexers/wren.py +98 -0
- venv/Lib/site-packages/pygments/lexers/x10.py +66 -0
- venv/Lib/site-packages/pygments/lexers/xorg.py +38 -0
- venv/Lib/site-packages/pygments/lexers/yang.py +103 -0
- venv/Lib/site-packages/pygments/lexers/yara.py +69 -0
- venv/Lib/site-packages/pygments/lexers/zig.py +125 -0
- venv/Lib/site-packages/pygments/modeline.py +43 -0
- venv/Lib/site-packages/pygments/plugin.py +72 -0
- venv/Lib/site-packages/pygments/regexopt.py +91 -0
- venv/Lib/site-packages/pygments/scanner.py +104 -0
- venv/Lib/site-packages/pygments/sphinxext.py +247 -0
- venv/Lib/site-packages/pygments/style.py +203 -0
- venv/Lib/site-packages/pygments/styles/__init__.py +61 -0
- venv/Lib/site-packages/pygments/styles/_mapping.py +54 -0
- venv/Lib/site-packages/pygments/styles/abap.py +32 -0
- venv/Lib/site-packages/pygments/styles/algol.py +65 -0
- venv/Lib/site-packages/pygments/styles/algol_nu.py +65 -0
- venv/Lib/site-packages/pygments/styles/arduino.py +100 -0
- venv/Lib/site-packages/pygments/styles/autumn.py +67 -0
- venv/Lib/site-packages/pygments/styles/borland.py +53 -0
- venv/Lib/site-packages/pygments/styles/bw.py +52 -0
- venv/Lib/site-packages/pygments/styles/coffee.py +80 -0
- venv/Lib/site-packages/pygments/styles/colorful.py +83 -0
- venv/Lib/site-packages/pygments/styles/default.py +76 -0
- venv/Lib/site-packages/pygments/styles/dracula.py +90 -0
- venv/Lib/site-packages/pygments/styles/emacs.py +75 -0
- venv/Lib/site-packages/pygments/styles/friendly.py +76 -0
- venv/Lib/site-packages/pygments/styles/friendly_grayscale.py +80 -0
- venv/Lib/site-packages/pygments/styles/fruity.py +47 -0
- venv/Lib/site-packages/pygments/styles/gh_dark.py +113 -0
- venv/Lib/site-packages/pygments/styles/gruvbox.py +118 -0
- venv/Lib/site-packages/pygments/styles/igor.py +32 -0
- venv/Lib/site-packages/pygments/styles/inkpot.py +72 -0
- venv/Lib/site-packages/pygments/styles/lightbulb.py +110 -0
- venv/Lib/site-packages/pygments/styles/lilypond.py +62 -0
- venv/Lib/site-packages/pygments/styles/lovelace.py +100 -0
- venv/Lib/site-packages/pygments/styles/manni.py +79 -0
- venv/Lib/site-packages/pygments/styles/material.py +124 -0
- venv/Lib/site-packages/pygments/styles/monokai.py +112 -0
- venv/Lib/site-packages/pygments/styles/murphy.py +82 -0
- venv/Lib/site-packages/pygments/styles/native.py +70 -0
- venv/Lib/site-packages/pygments/styles/nord.py +156 -0
- venv/Lib/site-packages/pygments/styles/onedark.py +63 -0
- venv/Lib/site-packages/pygments/styles/paraiso_dark.py +124 -0
- venv/Lib/site-packages/pygments/styles/paraiso_light.py +124 -0
- venv/Lib/site-packages/pygments/styles/pastie.py +78 -0
- venv/Lib/site-packages/pygments/styles/perldoc.py +73 -0
- venv/Lib/site-packages/pygments/styles/rainbow_dash.py +95 -0
- venv/Lib/site-packages/pygments/styles/rrt.py +40 -0
- venv/Lib/site-packages/pygments/styles/sas.py +46 -0
- venv/Lib/site-packages/pygments/styles/solarized.py +144 -0
- venv/Lib/site-packages/pygments/styles/staroffice.py +31 -0
- venv/Lib/site-packages/pygments/styles/stata_dark.py +42 -0
- venv/Lib/site-packages/pygments/styles/stata_light.py +42 -0
- venv/Lib/site-packages/pygments/styles/tango.py +143 -0
- venv/Lib/site-packages/pygments/styles/trac.py +66 -0
- venv/Lib/site-packages/pygments/styles/vim.py +67 -0
- venv/Lib/site-packages/pygments/styles/vs.py +41 -0
- venv/Lib/site-packages/pygments/styles/xcode.py +53 -0
- venv/Lib/site-packages/pygments/styles/zenburn.py +83 -0
- venv/Lib/site-packages/pygments/token.py +214 -0
- venv/Lib/site-packages/pygments/unistring.py +153 -0
- venv/Lib/site-packages/pygments/util.py +324 -0
- venv/Lib/site-packages/pyproject_hooks/__init__.py +31 -0
- venv/Lib/site-packages/pyproject_hooks/_impl.py +410 -0
- venv/Lib/site-packages/pyproject_hooks/_in_process/__init__.py +21 -0
- venv/Lib/site-packages/pyproject_hooks/_in_process/_in_process.py +389 -0
- venv/Lib/site-packages/pyproject_hooks/py.typed +0 -0
- venv/Lib/site-packages/readme_renderer/__init__.py +13 -0
- venv/Lib/site-packages/readme_renderer/__main__.py +66 -0
- venv/Lib/site-packages/readme_renderer/clean.py +89 -0
- venv/Lib/site-packages/readme_renderer/markdown.py +123 -0
- venv/Lib/site-packages/readme_renderer/py.typed +0 -0
- venv/Lib/site-packages/readme_renderer/rst.py +135 -0
- venv/Lib/site-packages/readme_renderer/txt.py +24 -0
- venv/Lib/site-packages/requests/__init__.py +184 -0
- venv/Lib/site-packages/requests/__version__.py +14 -0
- venv/Lib/site-packages/requests/_internal_utils.py +50 -0
- venv/Lib/site-packages/requests/adapters.py +696 -0
- venv/Lib/site-packages/requests/api.py +157 -0
- venv/Lib/site-packages/requests/auth.py +314 -0
- venv/Lib/site-packages/requests/certs.py +17 -0
- venv/Lib/site-packages/requests/compat.py +106 -0
- venv/Lib/site-packages/requests/cookies.py +561 -0
- venv/Lib/site-packages/requests/exceptions.py +151 -0
- venv/Lib/site-packages/requests/help.py +134 -0
- venv/Lib/site-packages/requests/hooks.py +33 -0
- venv/Lib/site-packages/requests/models.py +1039 -0
- venv/Lib/site-packages/requests/packages.py +23 -0
- venv/Lib/site-packages/requests/sessions.py +831 -0
- venv/Lib/site-packages/requests/status_codes.py +128 -0
- venv/Lib/site-packages/requests/structures.py +99 -0
- venv/Lib/site-packages/requests/utils.py +1086 -0
- venv/Lib/site-packages/requests_toolbelt/__init__.py +34 -0
- venv/Lib/site-packages/requests_toolbelt/_compat.py +302 -0
- venv/Lib/site-packages/requests_toolbelt/adapters/__init__.py +15 -0
- venv/Lib/site-packages/requests_toolbelt/adapters/appengine.py +206 -0
- venv/Lib/site-packages/requests_toolbelt/adapters/fingerprint.py +48 -0
- venv/Lib/site-packages/requests_toolbelt/adapters/host_header_ssl.py +43 -0
- venv/Lib/site-packages/requests_toolbelt/adapters/socket_options.py +129 -0
- venv/Lib/site-packages/requests_toolbelt/adapters/source.py +67 -0
- venv/Lib/site-packages/requests_toolbelt/adapters/ssl.py +66 -0
- venv/Lib/site-packages/requests_toolbelt/adapters/x509.py +196 -0
- venv/Lib/site-packages/requests_toolbelt/auth/__init__.py +0 -0
- venv/Lib/site-packages/requests_toolbelt/auth/_digest_auth_compat.py +29 -0
- venv/Lib/site-packages/requests_toolbelt/auth/guess.py +146 -0
- venv/Lib/site-packages/requests_toolbelt/auth/handler.py +142 -0
- venv/Lib/site-packages/requests_toolbelt/auth/http_proxy_digest.py +103 -0
- venv/Lib/site-packages/requests_toolbelt/cookies/__init__.py +0 -0
- venv/Lib/site-packages/requests_toolbelt/cookies/forgetful.py +7 -0
- venv/Lib/site-packages/requests_toolbelt/downloadutils/__init__.py +0 -0
- venv/Lib/site-packages/requests_toolbelt/downloadutils/stream.py +176 -0
- venv/Lib/site-packages/requests_toolbelt/downloadutils/tee.py +123 -0
- venv/Lib/site-packages/requests_toolbelt/exceptions.py +25 -0
- venv/Lib/site-packages/requests_toolbelt/multipart/__init__.py +31 -0
- venv/Lib/site-packages/requests_toolbelt/multipart/decoder.py +156 -0
- venv/Lib/site-packages/requests_toolbelt/multipart/encoder.py +655 -0
- venv/Lib/site-packages/requests_toolbelt/sessions.py +89 -0
- venv/Lib/site-packages/requests_toolbelt/streaming_iterator.py +116 -0
- venv/Lib/site-packages/requests_toolbelt/threaded/__init__.py +97 -0
- venv/Lib/site-packages/requests_toolbelt/threaded/pool.py +211 -0
- venv/Lib/site-packages/requests_toolbelt/threaded/thread.py +53 -0
- venv/Lib/site-packages/requests_toolbelt/utils/__init__.py +0 -0
- venv/Lib/site-packages/requests_toolbelt/utils/deprecated.py +91 -0
- venv/Lib/site-packages/requests_toolbelt/utils/dump.py +198 -0
- venv/Lib/site-packages/requests_toolbelt/utils/formdata.py +108 -0
- venv/Lib/site-packages/requests_toolbelt/utils/user_agent.py +143 -0
- venv/Lib/site-packages/rfc3986/__init__.py +53 -0
- venv/Lib/site-packages/rfc3986/_mixin.py +373 -0
- venv/Lib/site-packages/rfc3986/abnf_regexp.py +275 -0
- venv/Lib/site-packages/rfc3986/api.py +104 -0
- venv/Lib/site-packages/rfc3986/builder.py +388 -0
- venv/Lib/site-packages/rfc3986/compat.py +59 -0
- venv/Lib/site-packages/rfc3986/exceptions.py +120 -0
- venv/Lib/site-packages/rfc3986/iri.py +161 -0
- venv/Lib/site-packages/rfc3986/misc.py +131 -0
- venv/Lib/site-packages/rfc3986/normalizers.py +171 -0
- venv/Lib/site-packages/rfc3986/parseresult.py +474 -0
- venv/Lib/site-packages/rfc3986/uri.py +160 -0
- venv/Lib/site-packages/rfc3986/validators.py +440 -0
- venv/Lib/site-packages/rich/__init__.py +177 -0
- venv/Lib/site-packages/rich/__main__.py +245 -0
- venv/Lib/site-packages/rich/_cell_widths.py +454 -0
- venv/Lib/site-packages/rich/_emoji_codes.py +3610 -0
- venv/Lib/site-packages/rich/_emoji_replace.py +32 -0
- venv/Lib/site-packages/rich/_export_format.py +76 -0
- venv/Lib/site-packages/rich/_extension.py +10 -0
- venv/Lib/site-packages/rich/_fileno.py +24 -0
- venv/Lib/site-packages/rich/_inspect.py +268 -0
- venv/Lib/site-packages/rich/_log_render.py +94 -0
- venv/Lib/site-packages/rich/_loop.py +43 -0
- venv/Lib/site-packages/rich/_null_file.py +69 -0
- venv/Lib/site-packages/rich/_palettes.py +309 -0
- venv/Lib/site-packages/rich/_pick.py +17 -0
- venv/Lib/site-packages/rich/_ratio.py +153 -0
- venv/Lib/site-packages/rich/_spinners.py +482 -0
- venv/Lib/site-packages/rich/_stack.py +16 -0
- venv/Lib/site-packages/rich/_timer.py +19 -0
- venv/Lib/site-packages/rich/_win32_console.py +661 -0
- venv/Lib/site-packages/rich/_windows.py +71 -0
- venv/Lib/site-packages/rich/_windows_renderer.py +56 -0
- venv/Lib/site-packages/rich/_wrap.py +93 -0
- venv/Lib/site-packages/rich/abc.py +33 -0
- venv/Lib/site-packages/rich/align.py +306 -0
- venv/Lib/site-packages/rich/ansi.py +241 -0
- venv/Lib/site-packages/rich/bar.py +93 -0
- venv/Lib/site-packages/rich/box.py +474 -0
- venv/Lib/site-packages/rich/cells.py +174 -0
- venv/Lib/site-packages/rich/color.py +621 -0
- venv/Lib/site-packages/rich/color_triplet.py +38 -0
- venv/Lib/site-packages/rich/columns.py +187 -0
- venv/Lib/site-packages/rich/console.py +2680 -0
- venv/Lib/site-packages/rich/constrain.py +37 -0
- venv/Lib/site-packages/rich/containers.py +167 -0
- venv/Lib/site-packages/rich/control.py +219 -0
- venv/Lib/site-packages/rich/default_styles.py +193 -0
- venv/Lib/site-packages/rich/diagnose.py +39 -0
- venv/Lib/site-packages/rich/emoji.py +91 -0
- venv/Lib/site-packages/rich/errors.py +34 -0
- venv/Lib/site-packages/rich/file_proxy.py +57 -0
- venv/Lib/site-packages/rich/filesize.py +88 -0
- venv/Lib/site-packages/rich/highlighter.py +232 -0
- venv/Lib/site-packages/rich/json.py +139 -0
- venv/Lib/site-packages/rich/jupyter.py +101 -0
- venv/Lib/site-packages/rich/layout.py +442 -0
- venv/Lib/site-packages/rich/live.py +400 -0
- venv/Lib/site-packages/rich/live_render.py +106 -0
- venv/Lib/site-packages/rich/logging.py +297 -0
- venv/Lib/site-packages/rich/markdown.py +779 -0
- venv/Lib/site-packages/rich/markup.py +251 -0
- venv/Lib/site-packages/rich/measure.py +151 -0
- venv/Lib/site-packages/rich/padding.py +141 -0
- venv/Lib/site-packages/rich/pager.py +34 -0
- venv/Lib/site-packages/rich/palette.py +100 -0
- venv/Lib/site-packages/rich/panel.py +317 -0
- venv/Lib/site-packages/rich/pretty.py +1016 -0
- venv/Lib/site-packages/rich/progress.py +1715 -0
- venv/Lib/site-packages/rich/progress_bar.py +223 -0
- venv/Lib/site-packages/rich/prompt.py +400 -0
- venv/Lib/site-packages/rich/protocol.py +42 -0
- venv/Lib/site-packages/rich/py.typed +0 -0
- venv/Lib/site-packages/rich/region.py +10 -0
- venv/Lib/site-packages/rich/repr.py +149 -0
- venv/Lib/site-packages/rich/rule.py +130 -0
- venv/Lib/site-packages/rich/scope.py +86 -0
- venv/Lib/site-packages/rich/screen.py +54 -0
- venv/Lib/site-packages/rich/segment.py +752 -0
- venv/Lib/site-packages/rich/spinner.py +132 -0
- venv/Lib/site-packages/rich/status.py +131 -0
- venv/Lib/site-packages/rich/style.py +792 -0
- venv/Lib/site-packages/rich/styled.py +42 -0
- venv/Lib/site-packages/rich/syntax.py +985 -0
- venv/Lib/site-packages/rich/table.py +1006 -0
- venv/Lib/site-packages/rich/terminal_theme.py +153 -0
- venv/Lib/site-packages/rich/text.py +1361 -0
- venv/Lib/site-packages/rich/theme.py +115 -0
- venv/Lib/site-packages/rich/themes.py +5 -0
- venv/Lib/site-packages/rich/traceback.py +899 -0
- venv/Lib/site-packages/rich/tree.py +257 -0
- venv/Lib/site-packages/setup_sdist.py +69 -0
- venv/Lib/site-packages/twine/__init__.py +54 -0
- venv/Lib/site-packages/twine/__main__.py +54 -0
- venv/Lib/site-packages/twine/auth.py +307 -0
- venv/Lib/site-packages/twine/cli.py +139 -0
- venv/Lib/site-packages/twine/commands/__init__.py +93 -0
- venv/Lib/site-packages/twine/commands/check.py +195 -0
- venv/Lib/site-packages/twine/commands/register.py +87 -0
- venv/Lib/site-packages/twine/commands/upload.py +253 -0
- venv/Lib/site-packages/twine/distribution.py +8 -0
- venv/Lib/site-packages/twine/exceptions.py +175 -0
- venv/Lib/site-packages/twine/package.py +403 -0
- venv/Lib/site-packages/twine/py.typed +0 -0
- venv/Lib/site-packages/twine/repository.py +246 -0
- venv/Lib/site-packages/twine/sdist.py +83 -0
- venv/Lib/site-packages/twine/settings.py +360 -0
- venv/Lib/site-packages/twine/utils.py +387 -0
- venv/Lib/site-packages/twine/wheel.py +81 -0
- venv/Lib/site-packages/urllib3/__init__.py +211 -0
- venv/Lib/site-packages/urllib3/_base_connection.py +165 -0
- venv/Lib/site-packages/urllib3/_collections.py +479 -0
- venv/Lib/site-packages/urllib3/_request_methods.py +278 -0
- venv/Lib/site-packages/urllib3/_version.py +21 -0
- venv/Lib/site-packages/urllib3/connection.py +1093 -0
- venv/Lib/site-packages/urllib3/connectionpool.py +1178 -0
- venv/Lib/site-packages/urllib3/contrib/__init__.py +0 -0
- venv/Lib/site-packages/urllib3/contrib/emscripten/__init__.py +16 -0
- venv/Lib/site-packages/urllib3/contrib/emscripten/connection.py +255 -0
- venv/Lib/site-packages/urllib3/contrib/emscripten/fetch.py +728 -0
- venv/Lib/site-packages/urllib3/contrib/emscripten/request.py +22 -0
- venv/Lib/site-packages/urllib3/contrib/emscripten/response.py +277 -0
- venv/Lib/site-packages/urllib3/contrib/pyopenssl.py +564 -0
- venv/Lib/site-packages/urllib3/contrib/socks.py +228 -0
- venv/Lib/site-packages/urllib3/exceptions.py +335 -0
- venv/Lib/site-packages/urllib3/fields.py +341 -0
- venv/Lib/site-packages/urllib3/filepost.py +89 -0
- venv/Lib/site-packages/urllib3/http2/__init__.py +53 -0
- venv/Lib/site-packages/urllib3/http2/connection.py +356 -0
- venv/Lib/site-packages/urllib3/http2/probe.py +87 -0
- venv/Lib/site-packages/urllib3/poolmanager.py +653 -0
- venv/Lib/site-packages/urllib3/py.typed +2 -0
- venv/Lib/site-packages/urllib3/response.py +1307 -0
- venv/Lib/site-packages/urllib3/util/__init__.py +42 -0
- venv/Lib/site-packages/urllib3/util/connection.py +137 -0
- venv/Lib/site-packages/urllib3/util/proxy.py +43 -0
- venv/Lib/site-packages/urllib3/util/request.py +266 -0
- venv/Lib/site-packages/urllib3/util/response.py +101 -0
- venv/Lib/site-packages/urllib3/util/retry.py +533 -0
- venv/Lib/site-packages/urllib3/util/ssl_.py +524 -0
- venv/Lib/site-packages/urllib3/util/ssl_match_hostname.py +159 -0
- venv/Lib/site-packages/urllib3/util/ssltransport.py +271 -0
- venv/Lib/site-packages/urllib3/util/timeout.py +275 -0
- venv/Lib/site-packages/urllib3/util/url.py +469 -0
- venv/Lib/site-packages/urllib3/util/util.py +42 -0
- venv/Lib/site-packages/urllib3/util/wait.py +124 -0
- venv/Lib/site-packages/win32ctypes/__init__.py +8 -0
- venv/Lib/site-packages/win32ctypes/core/__init__.py +60 -0
- venv/Lib/site-packages/win32ctypes/core/_winerrors.py +9 -0
- venv/Lib/site-packages/win32ctypes/core/cffi/__init__.py +11 -0
- venv/Lib/site-packages/win32ctypes/core/cffi/_authentication.py +172 -0
- venv/Lib/site-packages/win32ctypes/core/cffi/_common.py +29 -0
- venv/Lib/site-packages/win32ctypes/core/cffi/_dll.py +30 -0
- venv/Lib/site-packages/win32ctypes/core/cffi/_nl_support.py +18 -0
- venv/Lib/site-packages/win32ctypes/core/cffi/_resource.py +132 -0
- venv/Lib/site-packages/win32ctypes/core/cffi/_system_information.py +32 -0
- venv/Lib/site-packages/win32ctypes/core/cffi/_time.py +18 -0
- venv/Lib/site-packages/win32ctypes/core/cffi/_util.py +105 -0
- venv/Lib/site-packages/win32ctypes/core/compat.py +10 -0
- venv/Lib/site-packages/win32ctypes/core/ctypes/__init__.py +11 -0
- venv/Lib/site-packages/win32ctypes/core/ctypes/_authentication.py +122 -0
- venv/Lib/site-packages/win32ctypes/core/ctypes/_common.py +53 -0
- venv/Lib/site-packages/win32ctypes/core/ctypes/_dll.py +21 -0
- venv/Lib/site-packages/win32ctypes/core/ctypes/_nl_support.py +12 -0
- venv/Lib/site-packages/win32ctypes/core/ctypes/_resource.py +148 -0
- venv/Lib/site-packages/win32ctypes/core/ctypes/_system_information.py +36 -0
- venv/Lib/site-packages/win32ctypes/core/ctypes/_time.py +15 -0
- venv/Lib/site-packages/win32ctypes/core/ctypes/_util.py +78 -0
- venv/Lib/site-packages/win32ctypes/pywin32/__init__.py +12 -0
- venv/Lib/site-packages/win32ctypes/pywin32/pywintypes.py +67 -0
- venv/Lib/site-packages/win32ctypes/pywin32/win32api.py +294 -0
- venv/Lib/site-packages/win32ctypes/pywin32/win32cred.py +145 -0
- venv/Lib/site-packages/win32ctypes/pywintypes.py +13 -0
- venv/Lib/site-packages/win32ctypes/tests/__init__.py +21 -0
- venv/Lib/site-packages/win32ctypes/tests/test_backends.py +36 -0
- venv/Lib/site-packages/win32ctypes/tests/test_win32api.py +304 -0
- venv/Lib/site-packages/win32ctypes/tests/test_win32cred.py +230 -0
- venv/Lib/site-packages/win32ctypes/version.py +1 -0
- venv/Lib/site-packages/win32ctypes/win32api.py +13 -0
- venv/Lib/site-packages/win32ctypes/win32cred.py +13 -0
- android_notify-1.59.4.dist-info/RECORD +0 -12
- {android_notify-1.59.4.dist-info → android_notify-1.60.0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,3255 @@
|
|
|
1
|
+
# $Id: states.py 10231 2025-09-11 14:16:33Z milde $
|
|
2
|
+
# Author: David Goodger <goodger@python.org>
|
|
3
|
+
# Copyright: This module has been placed in the public domain.
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
This is the ``docutils.parsers.rst.states`` module, the core of
|
|
7
|
+
the reStructuredText parser. It defines the following:
|
|
8
|
+
|
|
9
|
+
:Classes:
|
|
10
|
+
- `RSTStateMachine`: reStructuredText parser's entry point.
|
|
11
|
+
- `NestedStateMachine`: recursive StateMachine.
|
|
12
|
+
- `RSTState`: reStructuredText State superclass.
|
|
13
|
+
- `Inliner`: For parsing inline markup.
|
|
14
|
+
- `Body`: Generic classifier of the first line of a block.
|
|
15
|
+
- `SpecializedBody`: Superclass for compound element members.
|
|
16
|
+
- `BulletList`: Second and subsequent bullet_list list_items
|
|
17
|
+
- `DefinitionList`: Second+ definition_list_items.
|
|
18
|
+
- `EnumeratedList`: Second+ enumerated_list list_items.
|
|
19
|
+
- `FieldList`: Second+ fields.
|
|
20
|
+
- `OptionList`: Second+ option_list_items.
|
|
21
|
+
- `RFC2822List`: Second+ RFC2822-style fields.
|
|
22
|
+
- `ExtensionOptions`: Parses directive option fields.
|
|
23
|
+
- `Explicit`: Second+ explicit markup constructs.
|
|
24
|
+
- `SubstitutionDef`: For embedded directives in substitution definitions.
|
|
25
|
+
- `Text`: Classifier of second line of a text block.
|
|
26
|
+
- `SpecializedText`: Superclass for continuation lines of Text-variants.
|
|
27
|
+
- `Definition`: Second line of potential definition_list_item.
|
|
28
|
+
- `Line`: Second line of overlined section title or transition marker.
|
|
29
|
+
- `Struct`: obsolete, use `types.SimpleNamespace`.
|
|
30
|
+
|
|
31
|
+
:Exception classes:
|
|
32
|
+
- `MarkupError`
|
|
33
|
+
- `ParserError`
|
|
34
|
+
- `MarkupMismatch`
|
|
35
|
+
|
|
36
|
+
:Functions:
|
|
37
|
+
- `escape2null()`: Return a string, escape-backslashes converted to nulls.
|
|
38
|
+
- `unescape()`: Return a string, nulls removed or restored to backslashes.
|
|
39
|
+
|
|
40
|
+
:Attributes:
|
|
41
|
+
- `state_classes`: set of State classes used with `RSTStateMachine`.
|
|
42
|
+
|
|
43
|
+
Parser Overview
|
|
44
|
+
===============
|
|
45
|
+
|
|
46
|
+
The reStructuredText parser is implemented as a recursive state machine,
|
|
47
|
+
examining its input one line at a time. To understand how the parser works,
|
|
48
|
+
please first become familiar with the `docutils.statemachine` module. In the
|
|
49
|
+
description below, references are made to classes defined in this module;
|
|
50
|
+
please see the individual classes for details.
|
|
51
|
+
|
|
52
|
+
Parsing proceeds as follows:
|
|
53
|
+
|
|
54
|
+
1. The state machine examines each line of input, checking each of the
|
|
55
|
+
transition patterns of the state `Body`, in order, looking for a match.
|
|
56
|
+
The implicit transitions (blank lines and indentation) are checked before
|
|
57
|
+
any others. The 'text' transition is a catch-all (matches anything).
|
|
58
|
+
|
|
59
|
+
2. The method associated with the matched transition pattern is called.
|
|
60
|
+
|
|
61
|
+
A. Some transition methods are self-contained, appending elements to the
|
|
62
|
+
document tree (`Body.doctest` parses a doctest block). The parser's
|
|
63
|
+
current line index is advanced to the end of the element, and parsing
|
|
64
|
+
continues with step 1.
|
|
65
|
+
|
|
66
|
+
B. Other transition methods trigger the creation of a nested state machine,
|
|
67
|
+
whose job is to parse a compound construct ('indent' does a block quote,
|
|
68
|
+
'bullet' does a bullet list, 'overline' does a section [first checking
|
|
69
|
+
for a valid section header], etc.).
|
|
70
|
+
|
|
71
|
+
- In the case of lists and explicit markup, a one-off state machine is
|
|
72
|
+
created and run to parse contents of the first item.
|
|
73
|
+
|
|
74
|
+
- A new state machine is created and its initial state is set to the
|
|
75
|
+
appropriate specialized state (`BulletList` in the case of the
|
|
76
|
+
'bullet' transition; see `SpecializedBody` for more detail). This
|
|
77
|
+
state machine is run to parse the compound element (or series of
|
|
78
|
+
explicit markup elements), and returns as soon as a non-member element
|
|
79
|
+
is encountered. For example, the `BulletList` state machine ends as
|
|
80
|
+
soon as it encounters an element which is not a list item of that
|
|
81
|
+
bullet list. The optional omission of inter-element blank lines is
|
|
82
|
+
enabled by this nested state machine.
|
|
83
|
+
|
|
84
|
+
- The current line index is advanced to the end of the elements parsed,
|
|
85
|
+
and parsing continues with step 1.
|
|
86
|
+
|
|
87
|
+
C. The result of the 'text' transition depends on the next line of text.
|
|
88
|
+
The current state is changed to `Text`, under which the second line is
|
|
89
|
+
examined. If the second line is:
|
|
90
|
+
|
|
91
|
+
- Indented: The element is a definition list item, and parsing proceeds
|
|
92
|
+
similarly to step 2.B, using the `DefinitionList` state.
|
|
93
|
+
|
|
94
|
+
- A line of uniform punctuation characters: The element is a section
|
|
95
|
+
header; again, parsing proceeds as in step 2.B, and `Body` is still
|
|
96
|
+
used.
|
|
97
|
+
|
|
98
|
+
- Anything else: The element is a paragraph, which is examined for
|
|
99
|
+
inline markup and appended to the parent element. Processing
|
|
100
|
+
continues with step 1.
|
|
101
|
+
"""
|
|
102
|
+
|
|
103
|
+
from __future__ import annotations
|
|
104
|
+
|
|
105
|
+
__docformat__ = 'reStructuredText'
|
|
106
|
+
|
|
107
|
+
import re
|
|
108
|
+
from types import FunctionType, MethodType
|
|
109
|
+
from types import SimpleNamespace as Struct
|
|
110
|
+
import warnings
|
|
111
|
+
|
|
112
|
+
from docutils import nodes, statemachine, utils
|
|
113
|
+
from docutils import ApplicationError, DataError
|
|
114
|
+
from docutils.statemachine import StateMachineWS, StateWS
|
|
115
|
+
from docutils.nodes import fully_normalize_name as normalize_name
|
|
116
|
+
from docutils.nodes import unescape, whitespace_normalize_name
|
|
117
|
+
import docutils.parsers.rst
|
|
118
|
+
from docutils.parsers.rst import directives, languages, tableparser, roles
|
|
119
|
+
from docutils.utils import escape2null, column_width
|
|
120
|
+
from docutils.utils import punctuation_chars, urischemes
|
|
121
|
+
from docutils.utils import split_escaped_whitespace
|
|
122
|
+
from docutils.utils._roman_numerals import (InvalidRomanNumeralError,
|
|
123
|
+
RomanNumeral)
|
|
124
|
+
|
|
125
|
+
TYPE_CHECKING = False
|
|
126
|
+
if TYPE_CHECKING:
|
|
127
|
+
from docutils.statemachine import StringList
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
class MarkupError(DataError): pass
|
|
131
|
+
class UnknownInterpretedRoleError(DataError): pass
|
|
132
|
+
class InterpretedRoleNotImplementedError(DataError): pass
|
|
133
|
+
class ParserError(ApplicationError): pass
|
|
134
|
+
class MarkupMismatch(Exception): pass
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
class RSTStateMachine(StateMachineWS):
|
|
138
|
+
|
|
139
|
+
"""
|
|
140
|
+
reStructuredText's master StateMachine.
|
|
141
|
+
|
|
142
|
+
The entry point to reStructuredText parsing is the `run()` method.
|
|
143
|
+
"""
|
|
144
|
+
section_level_offset: int = 0
|
|
145
|
+
"""Correction term for section level determination in nested parsing.
|
|
146
|
+
|
|
147
|
+
Updated by `RSTState.nested_parse()` and used in
|
|
148
|
+
`RSTState.check_subsection()` to compensate differences when
|
|
149
|
+
nested parsing uses a detached base node with a document-wide
|
|
150
|
+
section title style hierarchy or the current node with a new,
|
|
151
|
+
independent title style hierarchy.
|
|
152
|
+
"""
|
|
153
|
+
|
|
154
|
+
def run(self, input_lines, document, input_offset=0, match_titles=True,
|
|
155
|
+
inliner=None) -> None:
|
|
156
|
+
"""
|
|
157
|
+
Parse `input_lines` and modify the `document` node in place.
|
|
158
|
+
|
|
159
|
+
Extend `StateMachineWS.run()`: set up parse-global data and
|
|
160
|
+
run the StateMachine.
|
|
161
|
+
"""
|
|
162
|
+
self.language = languages.get_language(
|
|
163
|
+
document.settings.language_code, document.reporter)
|
|
164
|
+
self.match_titles = match_titles
|
|
165
|
+
if inliner is None:
|
|
166
|
+
inliner = Inliner()
|
|
167
|
+
inliner.init_customizations(document.settings)
|
|
168
|
+
# A collection of objects to share with nested parsers.
|
|
169
|
+
# The attributes `reporter`, `section_level`, and
|
|
170
|
+
# `section_bubble_up_kludge` will be removed in Docutils 2.0
|
|
171
|
+
self.memo = Struct(document=document,
|
|
172
|
+
reporter=document.reporter, # ignored
|
|
173
|
+
language=self.language,
|
|
174
|
+
title_styles=[],
|
|
175
|
+
section_level=0, # ignored
|
|
176
|
+
section_bubble_up_kludge=False, # ignored
|
|
177
|
+
inliner=inliner)
|
|
178
|
+
self.document = document
|
|
179
|
+
self.attach_observer(document.note_source)
|
|
180
|
+
self.reporter = self.document.reporter
|
|
181
|
+
self.node = document
|
|
182
|
+
results = StateMachineWS.run(self, input_lines, input_offset,
|
|
183
|
+
input_source=document['source'])
|
|
184
|
+
assert results == [], 'RSTStateMachine.run() results should be empty!'
|
|
185
|
+
self.node = self.memo = None # remove unneeded references
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
class NestedStateMachine(RSTStateMachine):
|
|
189
|
+
"""
|
|
190
|
+
StateMachine run from within other StateMachine runs, to parse nested
|
|
191
|
+
document structures.
|
|
192
|
+
"""
|
|
193
|
+
|
|
194
|
+
def __init__(self, state_classes, initial_state,
|
|
195
|
+
debug=False, parent_state_machine=None) -> None:
|
|
196
|
+
|
|
197
|
+
self.parent_state_machine = parent_state_machine
|
|
198
|
+
"""The instance of the parent state machine."""
|
|
199
|
+
|
|
200
|
+
super().__init__(state_classes, initial_state, debug)
|
|
201
|
+
|
|
202
|
+
def run(self, input_lines, input_offset, memo, node, match_titles=True):
|
|
203
|
+
"""
|
|
204
|
+
Parse `input_lines` and populate `node`.
|
|
205
|
+
|
|
206
|
+
Extend `StateMachineWS.run()`: set up document-wide data.
|
|
207
|
+
"""
|
|
208
|
+
self.match_titles = match_titles
|
|
209
|
+
self.memo = memo
|
|
210
|
+
self.document = memo.document
|
|
211
|
+
self.attach_observer(self.document.note_source)
|
|
212
|
+
self.language = memo.language
|
|
213
|
+
self.reporter = self.document.reporter
|
|
214
|
+
self.node = node
|
|
215
|
+
results = StateMachineWS.run(self, input_lines, input_offset)
|
|
216
|
+
assert results == [], ('NestedStateMachine.run() results should be '
|
|
217
|
+
'empty!')
|
|
218
|
+
return results
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
class RSTState(StateWS):
|
|
222
|
+
|
|
223
|
+
"""
|
|
224
|
+
reStructuredText State superclass.
|
|
225
|
+
|
|
226
|
+
Contains methods used by all State subclasses.
|
|
227
|
+
"""
|
|
228
|
+
|
|
229
|
+
nested_sm = NestedStateMachine
|
|
230
|
+
nested_sm_cache = []
|
|
231
|
+
|
|
232
|
+
def __init__(self, state_machine: RSTStateMachine, debug=False) -> None:
|
|
233
|
+
self.nested_sm_kwargs = {'state_classes': state_classes,
|
|
234
|
+
'initial_state': 'Body'}
|
|
235
|
+
StateWS.__init__(self, state_machine, debug)
|
|
236
|
+
|
|
237
|
+
def runtime_init(self) -> None:
|
|
238
|
+
StateWS.runtime_init(self)
|
|
239
|
+
memo = self.state_machine.memo
|
|
240
|
+
self.memo = memo
|
|
241
|
+
self.document = memo.document
|
|
242
|
+
self.inliner = memo.inliner
|
|
243
|
+
self.reporter = self.document.reporter
|
|
244
|
+
# enable the reporter to determine source and source-line
|
|
245
|
+
if not hasattr(self.reporter, 'get_source_and_line'):
|
|
246
|
+
self.reporter.get_source_and_line = self.state_machine.get_source_and_line # noqa:E501
|
|
247
|
+
|
|
248
|
+
@property
|
|
249
|
+
def parent(self) -> nodes.Element | None:
|
|
250
|
+
return self.state_machine.node
|
|
251
|
+
|
|
252
|
+
@parent.setter
|
|
253
|
+
def parent(self, value: nodes.Element):
|
|
254
|
+
self.state_machine.node = value
|
|
255
|
+
|
|
256
|
+
def goto_line(self, abs_line_offset) -> None:
|
|
257
|
+
"""
|
|
258
|
+
Jump to input line `abs_line_offset`, ignoring jumps past the end.
|
|
259
|
+
"""
|
|
260
|
+
try:
|
|
261
|
+
self.state_machine.goto_line(abs_line_offset)
|
|
262
|
+
except EOFError:
|
|
263
|
+
pass
|
|
264
|
+
|
|
265
|
+
def no_match(self, context, transitions):
|
|
266
|
+
"""
|
|
267
|
+
Override `StateWS.no_match` to generate a system message.
|
|
268
|
+
|
|
269
|
+
This code should never be run.
|
|
270
|
+
"""
|
|
271
|
+
self.reporter.severe(
|
|
272
|
+
'Internal error: no transition pattern match. State: "%s"; '
|
|
273
|
+
'transitions: %s; context: %s; current line: %r.'
|
|
274
|
+
% (self.__class__.__name__, transitions, context,
|
|
275
|
+
self.state_machine.line))
|
|
276
|
+
return context, None, []
|
|
277
|
+
|
|
278
|
+
def bof(self, context):
|
|
279
|
+
"""Called at beginning of file."""
|
|
280
|
+
return [], []
|
|
281
|
+
|
|
282
|
+
def nested_parse(self,
|
|
283
|
+
block: StringList,
|
|
284
|
+
input_offset: int,
|
|
285
|
+
node: nodes.Element|None = None,
|
|
286
|
+
match_titles: bool = False,
|
|
287
|
+
state_machine_class: StateMachineWS|None = None,
|
|
288
|
+
state_machine_kwargs: dict|None = None
|
|
289
|
+
) -> int:
|
|
290
|
+
"""
|
|
291
|
+
Parse the input `block` with a nested state-machine rooted at `node`.
|
|
292
|
+
|
|
293
|
+
:block:
|
|
294
|
+
reStructuredText source extract.
|
|
295
|
+
:input_offset:
|
|
296
|
+
Line number at start of the block.
|
|
297
|
+
:node:
|
|
298
|
+
Base node. Generated nodes will be appended to this node.
|
|
299
|
+
Default: the "current node" (`self.state_machine.node`).
|
|
300
|
+
:match_titles:
|
|
301
|
+
Allow section titles?
|
|
302
|
+
Caution: With a custom base node, this may lead to an invalid
|
|
303
|
+
or mixed up document tree. [#]_
|
|
304
|
+
:state_machine_class:
|
|
305
|
+
Default: `NestedStateMachine`.
|
|
306
|
+
:state_machine_kwargs:
|
|
307
|
+
Keyword arguments for the state-machine instantiation.
|
|
308
|
+
Default: `self.nested_sm_kwargs`.
|
|
309
|
+
|
|
310
|
+
Create a new state-machine instance if required.
|
|
311
|
+
Return new offset.
|
|
312
|
+
|
|
313
|
+
.. [#] See also ``test_parsers/test_rst/test_nested_parsing.py``
|
|
314
|
+
and Sphinx's `nested_parse_to_nodes()`__.
|
|
315
|
+
|
|
316
|
+
__ https://www.sphinx-doc.org/en/master/extdev/utils.html
|
|
317
|
+
#sphinx.util.parsing.nested_parse_to_nodes
|
|
318
|
+
"""
|
|
319
|
+
if node is None:
|
|
320
|
+
node = self.state_machine.node
|
|
321
|
+
use_default = 0
|
|
322
|
+
if state_machine_class is None:
|
|
323
|
+
state_machine_class = self.nested_sm
|
|
324
|
+
use_default += 1
|
|
325
|
+
if state_machine_kwargs is None:
|
|
326
|
+
state_machine_kwargs = self.nested_sm_kwargs
|
|
327
|
+
use_default += 1
|
|
328
|
+
my_state_machine = None
|
|
329
|
+
if use_default == 2:
|
|
330
|
+
try:
|
|
331
|
+
# get cached state machine, prevent others from using it
|
|
332
|
+
my_state_machine = self.nested_sm_cache.pop()
|
|
333
|
+
except IndexError:
|
|
334
|
+
pass
|
|
335
|
+
if not my_state_machine:
|
|
336
|
+
my_state_machine = state_machine_class(
|
|
337
|
+
debug=self.debug,
|
|
338
|
+
parent_state_machine=self.state_machine,
|
|
339
|
+
**state_machine_kwargs)
|
|
340
|
+
# Check if we may use sections (with a caveat for custom nodes
|
|
341
|
+
# that may be dummies to collect children):
|
|
342
|
+
if (node == self.state_machine.node
|
|
343
|
+
and not isinstance(node, (nodes.document, nodes.section))):
|
|
344
|
+
match_titles = False # avoid invalid sections
|
|
345
|
+
if match_titles:
|
|
346
|
+
# Compensate mismatch of known title styles and number of
|
|
347
|
+
# parent sections of the base node if the document wide
|
|
348
|
+
# title styles are used with a detached base node or
|
|
349
|
+
# a new list of title styles with the current parent node:
|
|
350
|
+
l_node = len(node.section_hierarchy())
|
|
351
|
+
l_start = min(len(self.parent.section_hierarchy()),
|
|
352
|
+
len(self.memo.title_styles))
|
|
353
|
+
my_state_machine.section_level_offset = l_start - l_node
|
|
354
|
+
|
|
355
|
+
# run the state machine and populate `node`:
|
|
356
|
+
block_length = len(block)
|
|
357
|
+
my_state_machine.run(block, input_offset, self.memo,
|
|
358
|
+
node, match_titles)
|
|
359
|
+
|
|
360
|
+
if match_titles:
|
|
361
|
+
if node == self.state_machine.node:
|
|
362
|
+
# Pass on the new "current node" to parent state machines:
|
|
363
|
+
sm = self.state_machine
|
|
364
|
+
try:
|
|
365
|
+
while True:
|
|
366
|
+
sm.node = my_state_machine.node
|
|
367
|
+
sm = sm.parent_state_machine
|
|
368
|
+
except AttributeError:
|
|
369
|
+
pass
|
|
370
|
+
# clean up
|
|
371
|
+
new_offset = my_state_machine.abs_line_offset()
|
|
372
|
+
if use_default == 2:
|
|
373
|
+
self.nested_sm_cache.append(my_state_machine)
|
|
374
|
+
else:
|
|
375
|
+
my_state_machine.unlink()
|
|
376
|
+
# No `block.parent` implies disconnected -- lines aren't in sync:
|
|
377
|
+
if block.parent and (len(block) - block_length) != 0:
|
|
378
|
+
# Adjustment for block if modified in nested parse:
|
|
379
|
+
self.state_machine.next_line(len(block) - block_length)
|
|
380
|
+
return new_offset
|
|
381
|
+
|
|
382
|
+
def nested_list_parse(self, block, input_offset, node, initial_state,
|
|
383
|
+
blank_finish,
|
|
384
|
+
blank_finish_state=None,
|
|
385
|
+
extra_settings={},
|
|
386
|
+
match_titles=False, # deprecated, will be removed
|
|
387
|
+
state_machine_class=None,
|
|
388
|
+
state_machine_kwargs=None):
|
|
389
|
+
"""
|
|
390
|
+
Parse the input `block` with a nested state-machine rooted at `node`.
|
|
391
|
+
|
|
392
|
+
Create a new StateMachine rooted at `node` and run it over the
|
|
393
|
+
input `block` (see also `nested_parse()`).
|
|
394
|
+
Also keep track of optional intermediate blank lines and the
|
|
395
|
+
required final one.
|
|
396
|
+
|
|
397
|
+
Return new offset and a boolean indicating whether there was a
|
|
398
|
+
blank final line.
|
|
399
|
+
"""
|
|
400
|
+
if match_titles:
|
|
401
|
+
warnings.warn('The "match_titles" argument of '
|
|
402
|
+
'parsers.rst.states.RSTState.nested_list_parse() '
|
|
403
|
+
'will be ignored in Docutils 1.0 '
|
|
404
|
+
'and removed in Docutils 2.0.',
|
|
405
|
+
PendingDeprecationWarning, stacklevel=2)
|
|
406
|
+
if state_machine_class is None:
|
|
407
|
+
state_machine_class = self.nested_sm
|
|
408
|
+
if state_machine_kwargs is None:
|
|
409
|
+
state_machine_kwargs = self.nested_sm_kwargs.copy()
|
|
410
|
+
state_machine_kwargs['initial_state'] = initial_state
|
|
411
|
+
my_state_machine = state_machine_class(
|
|
412
|
+
debug=self.debug,
|
|
413
|
+
parent_state_machine=self.state_machine,
|
|
414
|
+
**state_machine_kwargs)
|
|
415
|
+
if blank_finish_state is None:
|
|
416
|
+
blank_finish_state = initial_state
|
|
417
|
+
my_state_machine.states[blank_finish_state].blank_finish = blank_finish
|
|
418
|
+
for key, value in extra_settings.items():
|
|
419
|
+
setattr(my_state_machine.states[initial_state], key, value)
|
|
420
|
+
my_state_machine.run(block, input_offset, memo=self.memo,
|
|
421
|
+
node=node, match_titles=match_titles)
|
|
422
|
+
blank_finish = my_state_machine.states[blank_finish_state].blank_finish
|
|
423
|
+
my_state_machine.unlink()
|
|
424
|
+
return my_state_machine.abs_line_offset(), blank_finish
|
|
425
|
+
|
|
426
|
+
def section(self, title, source, style, lineno, messages) -> None:
|
|
427
|
+
"""Check for a valid subsection and create one if it checks out."""
|
|
428
|
+
if self.check_subsection(source, style, lineno):
|
|
429
|
+
self.new_subsection(title, lineno, messages)
|
|
430
|
+
|
|
431
|
+
def check_subsection(self, source, style, lineno) -> bool:
|
|
432
|
+
"""
|
|
433
|
+
Check for a valid subsection header. Update section data in `memo`.
|
|
434
|
+
|
|
435
|
+
When a new section is reached that isn't a subsection of the current
|
|
436
|
+
section, set `self.parent` to the new section's parent section
|
|
437
|
+
(or the root node if the new section is a top-level section).
|
|
438
|
+
"""
|
|
439
|
+
title_styles = self.memo.title_styles
|
|
440
|
+
parent_sections = self.parent.section_hierarchy()
|
|
441
|
+
# current section level: (0 root, 1 section, 2 subsection, ...)
|
|
442
|
+
oldlevel = (len(parent_sections)
|
|
443
|
+
+ self.state_machine.section_level_offset)
|
|
444
|
+
# new section level:
|
|
445
|
+
try: # check for existing title style
|
|
446
|
+
newlevel = title_styles.index(style) + 1
|
|
447
|
+
except ValueError: # new title style
|
|
448
|
+
newlevel = len(title_styles) + 1
|
|
449
|
+
# The new level must not be deeper than an immediate child
|
|
450
|
+
# of the current level:
|
|
451
|
+
if newlevel > oldlevel + 1:
|
|
452
|
+
styles = ' '.join('/'.join(style) for style in title_styles)
|
|
453
|
+
self.parent += self.reporter.error(
|
|
454
|
+
'Inconsistent title style:'
|
|
455
|
+
f' skip from level {oldlevel} to {newlevel}.',
|
|
456
|
+
nodes.literal_block('', source),
|
|
457
|
+
nodes.paragraph('', f'Established title styles: {styles}'),
|
|
458
|
+
line=lineno)
|
|
459
|
+
return False
|
|
460
|
+
if newlevel <= oldlevel:
|
|
461
|
+
# new section is sibling or higher up in the section hierarchy
|
|
462
|
+
try:
|
|
463
|
+
new_parent = parent_sections[newlevel-oldlevel-1].parent
|
|
464
|
+
except IndexError:
|
|
465
|
+
styles = ' '.join('/'.join(style) for style in title_styles)
|
|
466
|
+
details = (f'The parent of level {newlevel} sections cannot'
|
|
467
|
+
' be reached. The parser is at section level'
|
|
468
|
+
f' {oldlevel} but the current node has only'
|
|
469
|
+
f' {len(parent_sections)} parent section(s).'
|
|
470
|
+
'\nOne reason may be a high level'
|
|
471
|
+
' section used in a directive that parses its'
|
|
472
|
+
' content into a base node not attached to'
|
|
473
|
+
' the document\n(up to Docutils 0.21,'
|
|
474
|
+
' these sections were silently dropped).')
|
|
475
|
+
self.parent += self.reporter.error(
|
|
476
|
+
f'A level {newlevel} section cannot be used here.',
|
|
477
|
+
nodes.literal_block('', source),
|
|
478
|
+
nodes.paragraph('', f'Established title styles: {styles}'),
|
|
479
|
+
nodes.paragraph('', details),
|
|
480
|
+
line=lineno)
|
|
481
|
+
return False
|
|
482
|
+
self.parent = new_parent
|
|
483
|
+
self.memo.section_level = newlevel - 1
|
|
484
|
+
if newlevel > len(title_styles):
|
|
485
|
+
title_styles.append(style)
|
|
486
|
+
return True
|
|
487
|
+
|
|
488
|
+
def title_inconsistent(self, sourcetext, lineno):
|
|
489
|
+
# Ignored. Will be removed in Docutils 2.0.
|
|
490
|
+
error = self.reporter.error(
|
|
491
|
+
'Title level inconsistent:', nodes.literal_block('', sourcetext),
|
|
492
|
+
line=lineno)
|
|
493
|
+
return error
|
|
494
|
+
|
|
495
|
+
def new_subsection(self, title, lineno, messages):
|
|
496
|
+
"""Append new subsection to document tree."""
|
|
497
|
+
section_node = nodes.section()
|
|
498
|
+
self.parent += section_node
|
|
499
|
+
textnodes, title_messages = self.inline_text(title, lineno)
|
|
500
|
+
titlenode = nodes.title(title, '', *textnodes)
|
|
501
|
+
name = normalize_name(titlenode.astext())
|
|
502
|
+
section_node['names'].append(name)
|
|
503
|
+
section_node += titlenode
|
|
504
|
+
section_node += messages
|
|
505
|
+
section_node += title_messages
|
|
506
|
+
self.document.note_implicit_target(section_node, section_node)
|
|
507
|
+
# Update state:
|
|
508
|
+
self.parent = section_node
|
|
509
|
+
self.memo.section_level += 1
|
|
510
|
+
|
|
511
|
+
def paragraph(self, lines, lineno):
|
|
512
|
+
"""
|
|
513
|
+
Return a list (paragraph & messages) & a boolean: literal_block next?
|
|
514
|
+
"""
|
|
515
|
+
data = '\n'.join(lines).rstrip()
|
|
516
|
+
if re.search(r'(?<!\\)(\\\\)*::$', data):
|
|
517
|
+
if len(data) == 2:
|
|
518
|
+
return [], 1
|
|
519
|
+
elif data[-3] in ' \n':
|
|
520
|
+
text = data[:-3].rstrip()
|
|
521
|
+
else:
|
|
522
|
+
text = data[:-1]
|
|
523
|
+
literalnext = 1
|
|
524
|
+
else:
|
|
525
|
+
text = data
|
|
526
|
+
literalnext = 0
|
|
527
|
+
textnodes, messages = self.inline_text(text, lineno)
|
|
528
|
+
p = nodes.paragraph(data, '', *textnodes)
|
|
529
|
+
p.source, p.line = self.state_machine.get_source_and_line(lineno)
|
|
530
|
+
return [p] + messages, literalnext
|
|
531
|
+
|
|
532
|
+
def inline_text(self, text, lineno):
|
|
533
|
+
"""
|
|
534
|
+
Return 2 lists: nodes (text and inline elements), and system_messages.
|
|
535
|
+
"""
|
|
536
|
+
nodes, messages = self.inliner.parse(text, lineno,
|
|
537
|
+
self.memo, self.parent)
|
|
538
|
+
return nodes, messages
|
|
539
|
+
|
|
540
|
+
def unindent_warning(self, node_name):
|
|
541
|
+
# the actual problem is one line below the current line
|
|
542
|
+
lineno = self.state_machine.abs_line_number() + 1
|
|
543
|
+
return self.reporter.warning('%s ends without a blank line; '
|
|
544
|
+
'unexpected unindent.' % node_name,
|
|
545
|
+
line=lineno)
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
def build_regexp(definition, compile_patterns=True):
|
|
549
|
+
"""
|
|
550
|
+
Build, compile and return a regular expression based on `definition`.
|
|
551
|
+
|
|
552
|
+
:Parameter: `definition`: a 4-tuple (group name, prefix, suffix, parts),
|
|
553
|
+
where "parts" is a list of regular expressions and/or regular
|
|
554
|
+
expression definitions to be joined into an or-group.
|
|
555
|
+
"""
|
|
556
|
+
name, prefix, suffix, parts = definition
|
|
557
|
+
part_strings = []
|
|
558
|
+
for part in parts:
|
|
559
|
+
if isinstance(part, tuple):
|
|
560
|
+
part_strings.append(build_regexp(part, None))
|
|
561
|
+
else:
|
|
562
|
+
part_strings.append(part)
|
|
563
|
+
or_group = '|'.join(part_strings)
|
|
564
|
+
regexp = '%(prefix)s(?P<%(name)s>%(or_group)s)%(suffix)s' % locals()
|
|
565
|
+
if compile_patterns:
|
|
566
|
+
return re.compile(regexp)
|
|
567
|
+
else:
|
|
568
|
+
return regexp
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
class Inliner:
|
|
572
|
+
|
|
573
|
+
"""
|
|
574
|
+
Parse inline markup; call the `parse()` method.
|
|
575
|
+
"""
|
|
576
|
+
|
|
577
|
+
def __init__(self) -> None:
|
|
578
|
+
self.implicit_dispatch = []
|
|
579
|
+
"""List of (pattern, bound method) tuples, used by
|
|
580
|
+
`self.implicit_inline`."""
|
|
581
|
+
|
|
582
|
+
def init_customizations(self, settings) -> None:
|
|
583
|
+
# lookahead and look-behind expressions for inline markup rules
|
|
584
|
+
if getattr(settings, 'character_level_inline_markup', False):
|
|
585
|
+
start_string_prefix = '(^|(?<!\x00))'
|
|
586
|
+
end_string_suffix = ''
|
|
587
|
+
else:
|
|
588
|
+
start_string_prefix = ('(^|(?<=\\s|[%s%s]))' %
|
|
589
|
+
(punctuation_chars.openers,
|
|
590
|
+
punctuation_chars.delimiters))
|
|
591
|
+
end_string_suffix = ('($|(?=\\s|[\x00%s%s%s]))' %
|
|
592
|
+
(punctuation_chars.closing_delimiters,
|
|
593
|
+
punctuation_chars.delimiters,
|
|
594
|
+
punctuation_chars.closers))
|
|
595
|
+
args = locals().copy()
|
|
596
|
+
args.update(vars(self.__class__))
|
|
597
|
+
|
|
598
|
+
parts = ('initial_inline', start_string_prefix, '',
|
|
599
|
+
[
|
|
600
|
+
('start', '', self.non_whitespace_after, # simple start-strings
|
|
601
|
+
[r'\*\*', # strong
|
|
602
|
+
r'\*(?!\*)', # emphasis but not strong
|
|
603
|
+
r'``', # literal
|
|
604
|
+
r'_`', # inline internal target
|
|
605
|
+
r'\|(?!\|)'] # substitution reference
|
|
606
|
+
),
|
|
607
|
+
('whole', '', end_string_suffix, # whole constructs
|
|
608
|
+
[ # reference name & end-string
|
|
609
|
+
r'(?P<refname>%s)(?P<refend>__?)' % self.simplename,
|
|
610
|
+
('footnotelabel', r'\[', r'(?P<fnend>\]_)',
|
|
611
|
+
[r'[0-9]+', # manually numbered
|
|
612
|
+
r'\#(%s)?' % self.simplename, # auto-numbered (w/ label?)
|
|
613
|
+
r'\*', # auto-symbol
|
|
614
|
+
r'(?P<citationlabel>%s)' % self.simplename, # citation ref
|
|
615
|
+
]
|
|
616
|
+
)
|
|
617
|
+
]
|
|
618
|
+
),
|
|
619
|
+
('backquote', # interpreted text or phrase reference
|
|
620
|
+
'(?P<role>(:%s:)?)' % self.simplename, # optional role
|
|
621
|
+
self.non_whitespace_after,
|
|
622
|
+
['`(?!`)'] # but not literal
|
|
623
|
+
)
|
|
624
|
+
]
|
|
625
|
+
)
|
|
626
|
+
self.start_string_prefix = start_string_prefix
|
|
627
|
+
self.end_string_suffix = end_string_suffix
|
|
628
|
+
self.parts = parts
|
|
629
|
+
|
|
630
|
+
self.patterns = Struct(
|
|
631
|
+
initial=build_regexp(parts),
|
|
632
|
+
emphasis=re.compile(self.non_whitespace_escape_before
|
|
633
|
+
+ r'(\*)' + end_string_suffix),
|
|
634
|
+
strong=re.compile(self.non_whitespace_escape_before
|
|
635
|
+
+ r'(\*\*)' + end_string_suffix),
|
|
636
|
+
interpreted_or_phrase_ref=re.compile(
|
|
637
|
+
r"""
|
|
638
|
+
%(non_unescaped_whitespace_escape_before)s
|
|
639
|
+
(
|
|
640
|
+
`
|
|
641
|
+
(?P<suffix>
|
|
642
|
+
(?P<role>:%(simplename)s:)?
|
|
643
|
+
(?P<refend>__?)?
|
|
644
|
+
)
|
|
645
|
+
)
|
|
646
|
+
%(end_string_suffix)s
|
|
647
|
+
""" % args, re.VERBOSE),
|
|
648
|
+
embedded_link=re.compile(
|
|
649
|
+
r"""
|
|
650
|
+
(
|
|
651
|
+
(?:[ \n]+|^) # spaces or beginning of line/string
|
|
652
|
+
< # open bracket
|
|
653
|
+
%(non_whitespace_after)s
|
|
654
|
+
(([^<>]|\x00[<>])+) # anything but unescaped angle brackets
|
|
655
|
+
%(non_whitespace_escape_before)s
|
|
656
|
+
> # close bracket
|
|
657
|
+
)
|
|
658
|
+
$ # end of string
|
|
659
|
+
""" % args, re.VERBOSE),
|
|
660
|
+
literal=re.compile(self.non_whitespace_before + '(``)'
|
|
661
|
+
+ end_string_suffix),
|
|
662
|
+
target=re.compile(self.non_whitespace_escape_before
|
|
663
|
+
+ r'(`)' + end_string_suffix),
|
|
664
|
+
substitution_ref=re.compile(self.non_whitespace_escape_before
|
|
665
|
+
+ r'(\|_{0,2})'
|
|
666
|
+
+ end_string_suffix),
|
|
667
|
+
email=re.compile(self.email_pattern % args + '$',
|
|
668
|
+
re.VERBOSE),
|
|
669
|
+
uri=re.compile(
|
|
670
|
+
(r"""
|
|
671
|
+
%(start_string_prefix)s
|
|
672
|
+
(?P<whole>
|
|
673
|
+
(?P<absolute> # absolute URI
|
|
674
|
+
(?P<scheme> # scheme (http, ftp, mailto)
|
|
675
|
+
[a-zA-Z][a-zA-Z0-9.+-]*
|
|
676
|
+
)
|
|
677
|
+
:
|
|
678
|
+
(
|
|
679
|
+
( # either:
|
|
680
|
+
(//?)? # hierarchical URI
|
|
681
|
+
%(uric)s* # URI characters
|
|
682
|
+
%(uri_end)s # final URI char
|
|
683
|
+
)
|
|
684
|
+
( # optional query
|
|
685
|
+
\?%(uric)s*
|
|
686
|
+
%(uri_end)s
|
|
687
|
+
)?
|
|
688
|
+
( # optional fragment
|
|
689
|
+
\#%(uric)s*
|
|
690
|
+
%(uri_end)s
|
|
691
|
+
)?
|
|
692
|
+
)
|
|
693
|
+
)
|
|
694
|
+
| # *OR*
|
|
695
|
+
(?P<email> # email address
|
|
696
|
+
""" + self.email_pattern + r"""
|
|
697
|
+
)
|
|
698
|
+
)
|
|
699
|
+
%(end_string_suffix)s
|
|
700
|
+
""") % args, re.VERBOSE),
|
|
701
|
+
pep=re.compile(
|
|
702
|
+
r"""
|
|
703
|
+
%(start_string_prefix)s
|
|
704
|
+
(
|
|
705
|
+
(pep-(?P<pepnum1>\d+)(.txt)?) # reference to source file
|
|
706
|
+
|
|
|
707
|
+
(PEP\s+(?P<pepnum2>\d+)) # reference by name
|
|
708
|
+
)
|
|
709
|
+
%(end_string_suffix)s""" % args, re.VERBOSE),
|
|
710
|
+
rfc=re.compile(
|
|
711
|
+
r"""
|
|
712
|
+
%(start_string_prefix)s
|
|
713
|
+
(RFC(-|\s+)?(?P<rfcnum>\d+))
|
|
714
|
+
%(end_string_suffix)s""" % args, re.VERBOSE))
|
|
715
|
+
|
|
716
|
+
self.implicit_dispatch.append((self.patterns.uri,
|
|
717
|
+
self.standalone_uri))
|
|
718
|
+
if settings.pep_references:
|
|
719
|
+
self.implicit_dispatch.append((self.patterns.pep,
|
|
720
|
+
self.pep_reference))
|
|
721
|
+
if settings.rfc_references:
|
|
722
|
+
self.implicit_dispatch.append((self.patterns.rfc,
|
|
723
|
+
self.rfc_reference))
|
|
724
|
+
|
|
725
|
+
def parse(self, text, lineno, memo, parent):
|
|
726
|
+
# Needs to be refactored for nested inline markup.
|
|
727
|
+
# Add nested_parse() method?
|
|
728
|
+
"""
|
|
729
|
+
Return 2 lists: nodes (text and inline elements), and system_messages.
|
|
730
|
+
|
|
731
|
+
Using `self.patterns.initial`, a pattern which matches start-strings
|
|
732
|
+
(emphasis, strong, interpreted, phrase reference, literal,
|
|
733
|
+
substitution reference, and inline target) and complete constructs
|
|
734
|
+
(simple reference, footnote reference), search for a candidate. When
|
|
735
|
+
one is found, check for validity (e.g., not a quoted '*' character).
|
|
736
|
+
If valid, search for the corresponding end string if applicable, and
|
|
737
|
+
check it for validity. If not found or invalid, generate a warning
|
|
738
|
+
and ignore the start-string. Implicit inline markup (e.g. standalone
|
|
739
|
+
URIs) is found last.
|
|
740
|
+
|
|
741
|
+
:text: source string
|
|
742
|
+
:lineno: absolute line number, cf. `statemachine.get_source_and_line()`
|
|
743
|
+
"""
|
|
744
|
+
self.document = memo.document
|
|
745
|
+
self.language = memo.language
|
|
746
|
+
self.reporter = self.document.reporter
|
|
747
|
+
self.parent = parent
|
|
748
|
+
pattern_search = self.patterns.initial.search
|
|
749
|
+
dispatch = self.dispatch
|
|
750
|
+
remaining = escape2null(text)
|
|
751
|
+
processed = []
|
|
752
|
+
unprocessed = []
|
|
753
|
+
messages = []
|
|
754
|
+
while remaining:
|
|
755
|
+
match = pattern_search(remaining)
|
|
756
|
+
if match:
|
|
757
|
+
groups = match.groupdict()
|
|
758
|
+
method = dispatch[groups['start'] or groups['backquote']
|
|
759
|
+
or groups['refend'] or groups['fnend']]
|
|
760
|
+
before, inlines, remaining, sysmessages = method(self, match,
|
|
761
|
+
lineno)
|
|
762
|
+
unprocessed.append(before)
|
|
763
|
+
messages += sysmessages
|
|
764
|
+
if inlines:
|
|
765
|
+
processed += self.implicit_inline(''.join(unprocessed),
|
|
766
|
+
lineno)
|
|
767
|
+
processed += inlines
|
|
768
|
+
unprocessed = []
|
|
769
|
+
else:
|
|
770
|
+
break
|
|
771
|
+
remaining = ''.join(unprocessed) + remaining
|
|
772
|
+
if remaining:
|
|
773
|
+
processed += self.implicit_inline(remaining, lineno)
|
|
774
|
+
return processed, messages
|
|
775
|
+
|
|
776
|
+
# Inline object recognition
|
|
777
|
+
# -------------------------
|
|
778
|
+
# See also init_customizations().
|
|
779
|
+
non_whitespace_before = r'(?<!\s)'
|
|
780
|
+
non_whitespace_escape_before = r'(?<![\s\x00])'
|
|
781
|
+
non_unescaped_whitespace_escape_before = r'(?<!(?<!\x00)[\s\x00])'
|
|
782
|
+
non_whitespace_after = r'(?!\s)'
|
|
783
|
+
# Alphanumerics with isolated internal [-._+:] chars (i.e. not 2 together):
|
|
784
|
+
simplename = r'(?:(?!_)\w)+(?:[-._+:](?:(?!_)\w)+)*'
|
|
785
|
+
# Valid URI characters (see RFC 2396 & RFC 2732);
|
|
786
|
+
# final \x00 allows backslash escapes in URIs:
|
|
787
|
+
uric = r"""[-_.!~*'()[\];/:@&=+$,%a-zA-Z0-9\x00]"""
|
|
788
|
+
# Delimiter indicating the end of a URI (not part of the URI):
|
|
789
|
+
uri_end_delim = r"""[>]"""
|
|
790
|
+
# Last URI character; same as uric but no punctuation:
|
|
791
|
+
urilast = r"""[_~*/=+a-zA-Z0-9]"""
|
|
792
|
+
# End of a URI (either 'urilast' or 'uric followed by a
|
|
793
|
+
# uri_end_delim'):
|
|
794
|
+
uri_end = r"""(?:%(urilast)s|%(uric)s(?=%(uri_end_delim)s))""" % locals()
|
|
795
|
+
emailc = r"""[-_!~*'{|}/#?^`&=+$%a-zA-Z0-9\x00]"""
|
|
796
|
+
email_pattern = r"""
|
|
797
|
+
%(emailc)s+(?:\.%(emailc)s+)* # name
|
|
798
|
+
(?<!\x00)@ # at
|
|
799
|
+
%(emailc)s+(?:\.%(emailc)s*)* # host
|
|
800
|
+
%(uri_end)s # final URI char
|
|
801
|
+
"""
|
|
802
|
+
|
|
803
|
+
def quoted_start(self, match):
|
|
804
|
+
"""Test if inline markup start-string is 'quoted'.
|
|
805
|
+
|
|
806
|
+
'Quoted' in this context means the start-string is enclosed in a pair
|
|
807
|
+
of matching opening/closing delimiters (not necessarily quotes)
|
|
808
|
+
or at the end of the match.
|
|
809
|
+
"""
|
|
810
|
+
string = match.string
|
|
811
|
+
start = match.start()
|
|
812
|
+
if start == 0: # start-string at beginning of text
|
|
813
|
+
return False
|
|
814
|
+
prestart = string[start - 1]
|
|
815
|
+
try:
|
|
816
|
+
poststart = string[match.end()]
|
|
817
|
+
except IndexError: # start-string at end of text
|
|
818
|
+
return True # not "quoted" but no markup start-string either
|
|
819
|
+
return punctuation_chars.match_chars(prestart, poststart)
|
|
820
|
+
|
|
821
|
+
def inline_obj(self, match, lineno, end_pattern, nodeclass,
|
|
822
|
+
restore_backslashes=False):
|
|
823
|
+
string = match.string
|
|
824
|
+
matchstart = match.start('start')
|
|
825
|
+
matchend = match.end('start')
|
|
826
|
+
if self.quoted_start(match):
|
|
827
|
+
return string[:matchend], [], string[matchend:], [], ''
|
|
828
|
+
endmatch = end_pattern.search(string[matchend:])
|
|
829
|
+
if endmatch and endmatch.start(1): # 1 or more chars
|
|
830
|
+
text = endmatch.string[:endmatch.start(1)]
|
|
831
|
+
if restore_backslashes:
|
|
832
|
+
text = unescape(text, True)
|
|
833
|
+
textend = matchend + endmatch.end(1)
|
|
834
|
+
rawsource = unescape(string[matchstart:textend], True)
|
|
835
|
+
node = nodeclass(rawsource, text)
|
|
836
|
+
return (string[:matchstart], [node],
|
|
837
|
+
string[textend:], [], endmatch.group(1))
|
|
838
|
+
msg = self.reporter.warning(
|
|
839
|
+
'Inline %s start-string without end-string.'
|
|
840
|
+
% nodeclass.__name__, line=lineno)
|
|
841
|
+
text = unescape(string[matchstart:matchend], True)
|
|
842
|
+
prb = self.problematic(text, text, msg)
|
|
843
|
+
return string[:matchstart], [prb], string[matchend:], [msg], ''
|
|
844
|
+
|
|
845
|
+
def problematic(self, text, rawsource, message):
|
|
846
|
+
msgid = self.document.set_id(message, self.parent)
|
|
847
|
+
problematic = nodes.problematic(rawsource, text, refid=msgid)
|
|
848
|
+
prbid = self.document.set_id(problematic)
|
|
849
|
+
message.add_backref(prbid)
|
|
850
|
+
return problematic
|
|
851
|
+
|
|
852
|
+
def emphasis(self, match, lineno):
|
|
853
|
+
before, inlines, remaining, sysmessages, endstring = self.inline_obj(
|
|
854
|
+
match, lineno, self.patterns.emphasis, nodes.emphasis)
|
|
855
|
+
return before, inlines, remaining, sysmessages
|
|
856
|
+
|
|
857
|
+
def strong(self, match, lineno):
|
|
858
|
+
before, inlines, remaining, sysmessages, endstring = self.inline_obj(
|
|
859
|
+
match, lineno, self.patterns.strong, nodes.strong)
|
|
860
|
+
return before, inlines, remaining, sysmessages
|
|
861
|
+
|
|
862
|
+
def interpreted_or_phrase_ref(self, match, lineno):
|
|
863
|
+
end_pattern = self.patterns.interpreted_or_phrase_ref
|
|
864
|
+
string = match.string
|
|
865
|
+
matchstart = match.start('backquote')
|
|
866
|
+
matchend = match.end('backquote')
|
|
867
|
+
rolestart = match.start('role')
|
|
868
|
+
role = match.group('role')
|
|
869
|
+
position = ''
|
|
870
|
+
if role:
|
|
871
|
+
role = role[1:-1]
|
|
872
|
+
position = 'prefix'
|
|
873
|
+
elif self.quoted_start(match):
|
|
874
|
+
return string[:matchend], [], string[matchend:], []
|
|
875
|
+
endmatch = end_pattern.search(string[matchend:])
|
|
876
|
+
if endmatch and endmatch.start(1): # 1 or more chars
|
|
877
|
+
textend = matchend + endmatch.end()
|
|
878
|
+
if endmatch.group('role'):
|
|
879
|
+
if role:
|
|
880
|
+
msg = self.reporter.warning(
|
|
881
|
+
'Multiple roles in interpreted text (both '
|
|
882
|
+
'prefix and suffix present; only one allowed).',
|
|
883
|
+
line=lineno)
|
|
884
|
+
text = unescape(string[rolestart:textend], True)
|
|
885
|
+
prb = self.problematic(text, text, msg)
|
|
886
|
+
return string[:rolestart], [prb], string[textend:], [msg]
|
|
887
|
+
role = endmatch.group('suffix')[1:-1]
|
|
888
|
+
position = 'suffix'
|
|
889
|
+
escaped = endmatch.string[:endmatch.start(1)]
|
|
890
|
+
rawsource = unescape(string[matchstart:textend], True)
|
|
891
|
+
if rawsource[-1:] == '_':
|
|
892
|
+
if role:
|
|
893
|
+
msg = self.reporter.warning(
|
|
894
|
+
'Mismatch: both interpreted text role %s and '
|
|
895
|
+
'reference suffix.' % position, line=lineno)
|
|
896
|
+
text = unescape(string[rolestart:textend], True)
|
|
897
|
+
prb = self.problematic(text, text, msg)
|
|
898
|
+
return string[:rolestart], [prb], string[textend:], [msg]
|
|
899
|
+
return self.phrase_ref(string[:matchstart], string[textend:],
|
|
900
|
+
rawsource, escaped)
|
|
901
|
+
else:
|
|
902
|
+
rawsource = unescape(string[rolestart:textend], True)
|
|
903
|
+
nodelist, messages = self.interpreted(rawsource, escaped, role,
|
|
904
|
+
lineno)
|
|
905
|
+
return (string[:rolestart], nodelist,
|
|
906
|
+
string[textend:], messages)
|
|
907
|
+
msg = self.reporter.warning(
|
|
908
|
+
'Inline interpreted text or phrase reference start-string '
|
|
909
|
+
'without end-string.', line=lineno)
|
|
910
|
+
text = unescape(string[matchstart:matchend], True)
|
|
911
|
+
prb = self.problematic(text, text, msg)
|
|
912
|
+
return string[:matchstart], [prb], string[matchend:], [msg]
|
|
913
|
+
|
|
914
|
+
def phrase_ref(self, before, after, rawsource, escaped, text=None):
|
|
915
|
+
# `text` is ignored (since 0.16)
|
|
916
|
+
match = self.patterns.embedded_link.search(escaped)
|
|
917
|
+
if match: # embedded <URI> or <alias_>
|
|
918
|
+
text = escaped[:match.start(0)]
|
|
919
|
+
unescaped = unescape(text)
|
|
920
|
+
rawtext = unescape(text, True)
|
|
921
|
+
aliastext = match.group(2)
|
|
922
|
+
rawaliastext = unescape(aliastext, True)
|
|
923
|
+
underscore_escaped = rawaliastext.endswith(r'\_')
|
|
924
|
+
if (aliastext.endswith('_')
|
|
925
|
+
and not (underscore_escaped
|
|
926
|
+
or self.patterns.uri.match(aliastext))):
|
|
927
|
+
aliastype = 'name'
|
|
928
|
+
alias = normalize_name(unescape(aliastext[:-1]))
|
|
929
|
+
target = nodes.target(match.group(1), refname=alias)
|
|
930
|
+
target.indirect_reference_name = whitespace_normalize_name(
|
|
931
|
+
unescape(aliastext[:-1]))
|
|
932
|
+
else:
|
|
933
|
+
aliastype = 'uri'
|
|
934
|
+
# remove unescaped whitespace
|
|
935
|
+
alias_parts = split_escaped_whitespace(match.group(2))
|
|
936
|
+
alias = ' '.join(''.join(part.split())
|
|
937
|
+
for part in alias_parts)
|
|
938
|
+
alias = self.adjust_uri(unescape(alias))
|
|
939
|
+
if alias.endswith(r'\_'):
|
|
940
|
+
alias = alias[:-2] + '_'
|
|
941
|
+
target = nodes.target(match.group(1), refuri=alias)
|
|
942
|
+
target.referenced = 1
|
|
943
|
+
if not aliastext:
|
|
944
|
+
raise ApplicationError('problem with embedded link: %r'
|
|
945
|
+
% aliastext)
|
|
946
|
+
if not text:
|
|
947
|
+
text = alias
|
|
948
|
+
unescaped = unescape(text)
|
|
949
|
+
rawtext = rawaliastext
|
|
950
|
+
else:
|
|
951
|
+
text = escaped
|
|
952
|
+
unescaped = unescape(text)
|
|
953
|
+
target = None
|
|
954
|
+
rawtext = unescape(escaped, True)
|
|
955
|
+
|
|
956
|
+
refname = normalize_name(unescaped)
|
|
957
|
+
reference = nodes.reference(rawsource, text,
|
|
958
|
+
name=whitespace_normalize_name(unescaped))
|
|
959
|
+
reference[0].rawsource = rawtext
|
|
960
|
+
|
|
961
|
+
node_list = [reference]
|
|
962
|
+
|
|
963
|
+
if rawsource[-2:] == '__':
|
|
964
|
+
if target and (aliastype == 'name'):
|
|
965
|
+
reference['refname'] = alias
|
|
966
|
+
self.document.note_refname(reference)
|
|
967
|
+
# self.document.note_indirect_target(target) # required?
|
|
968
|
+
elif target and (aliastype == 'uri'):
|
|
969
|
+
reference['refuri'] = alias
|
|
970
|
+
else:
|
|
971
|
+
reference['anonymous'] = True
|
|
972
|
+
else:
|
|
973
|
+
if target:
|
|
974
|
+
target['names'].append(refname)
|
|
975
|
+
if aliastype == 'name':
|
|
976
|
+
reference['refname'] = alias
|
|
977
|
+
self.document.note_indirect_target(target)
|
|
978
|
+
self.document.note_refname(reference)
|
|
979
|
+
else:
|
|
980
|
+
reference['refuri'] = alias
|
|
981
|
+
# target.note_referenced_by(name=refname)
|
|
982
|
+
self.document.note_implicit_target(target, self.parent)
|
|
983
|
+
node_list.append(target)
|
|
984
|
+
else:
|
|
985
|
+
reference['refname'] = refname
|
|
986
|
+
self.document.note_refname(reference)
|
|
987
|
+
return before, node_list, after, []
|
|
988
|
+
|
|
989
|
+
def adjust_uri(self, uri):
|
|
990
|
+
match = self.patterns.email.match(uri)
|
|
991
|
+
if match:
|
|
992
|
+
return 'mailto:' + uri
|
|
993
|
+
else:
|
|
994
|
+
return uri
|
|
995
|
+
|
|
996
|
+
def interpreted(self, rawsource, text, role, lineno):
|
|
997
|
+
role_fn, messages = roles.role(role, self.language, lineno,
|
|
998
|
+
self.reporter)
|
|
999
|
+
if role_fn:
|
|
1000
|
+
nodes, messages2 = role_fn(role, rawsource, text, lineno, self)
|
|
1001
|
+
return nodes, messages + messages2
|
|
1002
|
+
else:
|
|
1003
|
+
msg = self.reporter.error(
|
|
1004
|
+
'Unknown interpreted text role "%s".' % role,
|
|
1005
|
+
line=lineno)
|
|
1006
|
+
return ([self.problematic(rawsource, rawsource, msg)],
|
|
1007
|
+
messages + [msg])
|
|
1008
|
+
|
|
1009
|
+
def literal(self, match, lineno):
|
|
1010
|
+
before, inlines, remaining, sysmessages, endstring = self.inline_obj(
|
|
1011
|
+
match, lineno, self.patterns.literal, nodes.literal,
|
|
1012
|
+
restore_backslashes=True)
|
|
1013
|
+
return before, inlines, remaining, sysmessages
|
|
1014
|
+
|
|
1015
|
+
def inline_internal_target(self, match, lineno):
|
|
1016
|
+
before, inlines, remaining, sysmessages, endstring = self.inline_obj(
|
|
1017
|
+
match, lineno, self.patterns.target, nodes.target)
|
|
1018
|
+
if inlines and isinstance(inlines[0], nodes.target):
|
|
1019
|
+
assert len(inlines) == 1
|
|
1020
|
+
target = inlines[0]
|
|
1021
|
+
name = normalize_name(target.astext())
|
|
1022
|
+
target['names'].append(name)
|
|
1023
|
+
self.document.note_explicit_target(target, self.parent)
|
|
1024
|
+
return before, inlines, remaining, sysmessages
|
|
1025
|
+
|
|
1026
|
+
def substitution_reference(self, match, lineno):
|
|
1027
|
+
before, inlines, remaining, sysmessages, endstring = self.inline_obj(
|
|
1028
|
+
match, lineno, self.patterns.substitution_ref,
|
|
1029
|
+
nodes.substitution_reference)
|
|
1030
|
+
if len(inlines) == 1:
|
|
1031
|
+
subref_node = inlines[0]
|
|
1032
|
+
if isinstance(subref_node, nodes.substitution_reference):
|
|
1033
|
+
subref_text = subref_node.astext()
|
|
1034
|
+
self.document.note_substitution_ref(subref_node, subref_text)
|
|
1035
|
+
if endstring[-1:] == '_':
|
|
1036
|
+
reference_node = nodes.reference(
|
|
1037
|
+
'|%s%s' % (subref_text, endstring), '')
|
|
1038
|
+
if endstring[-2:] == '__':
|
|
1039
|
+
reference_node['anonymous'] = True
|
|
1040
|
+
else:
|
|
1041
|
+
reference_node['refname'] = normalize_name(subref_text)
|
|
1042
|
+
self.document.note_refname(reference_node)
|
|
1043
|
+
reference_node += subref_node
|
|
1044
|
+
inlines = [reference_node]
|
|
1045
|
+
return before, inlines, remaining, sysmessages
|
|
1046
|
+
|
|
1047
|
+
def footnote_reference(self, match, lineno):
|
|
1048
|
+
"""
|
|
1049
|
+
Handles `nodes.footnote_reference` and `nodes.citation_reference`
|
|
1050
|
+
elements.
|
|
1051
|
+
"""
|
|
1052
|
+
label = match.group('footnotelabel')
|
|
1053
|
+
refname = normalize_name(label)
|
|
1054
|
+
string = match.string
|
|
1055
|
+
before = string[:match.start('whole')]
|
|
1056
|
+
remaining = string[match.end('whole'):]
|
|
1057
|
+
if match.group('citationlabel'):
|
|
1058
|
+
refnode = nodes.citation_reference('[%s]_' % label,
|
|
1059
|
+
refname=refname)
|
|
1060
|
+
refnode += nodes.Text(label)
|
|
1061
|
+
self.document.note_citation_ref(refnode)
|
|
1062
|
+
else:
|
|
1063
|
+
refnode = nodes.footnote_reference('[%s]_' % label)
|
|
1064
|
+
if refname[0] == '#':
|
|
1065
|
+
refname = refname[1:]
|
|
1066
|
+
refnode['auto'] = 1
|
|
1067
|
+
self.document.note_autofootnote_ref(refnode)
|
|
1068
|
+
elif refname == '*':
|
|
1069
|
+
refname = ''
|
|
1070
|
+
refnode['auto'] = '*'
|
|
1071
|
+
self.document.note_symbol_footnote_ref(
|
|
1072
|
+
refnode)
|
|
1073
|
+
else:
|
|
1074
|
+
refnode += nodes.Text(label)
|
|
1075
|
+
if refname:
|
|
1076
|
+
refnode['refname'] = refname
|
|
1077
|
+
self.document.note_footnote_ref(refnode)
|
|
1078
|
+
if utils.get_trim_footnote_ref_space(self.document.settings):
|
|
1079
|
+
before = before.rstrip()
|
|
1080
|
+
return before, [refnode], remaining, []
|
|
1081
|
+
|
|
1082
|
+
def reference(self, match, lineno, anonymous=False):
|
|
1083
|
+
referencename = match.group('refname')
|
|
1084
|
+
refname = normalize_name(referencename)
|
|
1085
|
+
referencenode = nodes.reference(
|
|
1086
|
+
referencename + match.group('refend'), referencename,
|
|
1087
|
+
name=whitespace_normalize_name(referencename))
|
|
1088
|
+
referencenode[0].rawsource = referencename
|
|
1089
|
+
if anonymous:
|
|
1090
|
+
referencenode['anonymous'] = True
|
|
1091
|
+
else:
|
|
1092
|
+
referencenode['refname'] = refname
|
|
1093
|
+
self.document.note_refname(referencenode)
|
|
1094
|
+
string = match.string
|
|
1095
|
+
matchstart = match.start('whole')
|
|
1096
|
+
matchend = match.end('whole')
|
|
1097
|
+
return string[:matchstart], [referencenode], string[matchend:], []
|
|
1098
|
+
|
|
1099
|
+
def anonymous_reference(self, match, lineno):
|
|
1100
|
+
return self.reference(match, lineno, anonymous=True)
|
|
1101
|
+
|
|
1102
|
+
def standalone_uri(self, match, lineno):
|
|
1103
|
+
if (not match.group('scheme')
|
|
1104
|
+
or match.group('scheme').lower() in urischemes.schemes):
|
|
1105
|
+
if match.group('email'):
|
|
1106
|
+
addscheme = 'mailto:'
|
|
1107
|
+
else:
|
|
1108
|
+
addscheme = ''
|
|
1109
|
+
text = match.group('whole')
|
|
1110
|
+
refuri = addscheme + unescape(text)
|
|
1111
|
+
reference = nodes.reference(unescape(text, True), text,
|
|
1112
|
+
refuri=refuri)
|
|
1113
|
+
return [reference]
|
|
1114
|
+
else: # not a valid scheme
|
|
1115
|
+
raise MarkupMismatch
|
|
1116
|
+
|
|
1117
|
+
def pep_reference(self, match, lineno):
|
|
1118
|
+
text = match.group(0)
|
|
1119
|
+
if text.startswith('pep-'):
|
|
1120
|
+
pepnum = int(unescape(match.group('pepnum1')))
|
|
1121
|
+
elif text.startswith('PEP'):
|
|
1122
|
+
pepnum = int(unescape(match.group('pepnum2')))
|
|
1123
|
+
else:
|
|
1124
|
+
raise MarkupMismatch
|
|
1125
|
+
ref = (self.document.settings.pep_base_url
|
|
1126
|
+
+ self.document.settings.pep_file_url_template % pepnum)
|
|
1127
|
+
return [nodes.reference(unescape(text, True), text, refuri=ref)]
|
|
1128
|
+
|
|
1129
|
+
rfc_url = 'rfc%d.html'
|
|
1130
|
+
|
|
1131
|
+
def rfc_reference(self, match, lineno):
|
|
1132
|
+
text = match.group(0)
|
|
1133
|
+
if text.startswith('RFC'):
|
|
1134
|
+
rfcnum = int(unescape(match.group('rfcnum')))
|
|
1135
|
+
ref = self.document.settings.rfc_base_url + self.rfc_url % rfcnum
|
|
1136
|
+
else:
|
|
1137
|
+
raise MarkupMismatch
|
|
1138
|
+
return [nodes.reference(unescape(text, True), text, refuri=ref)]
|
|
1139
|
+
|
|
1140
|
+
def implicit_inline(self, text, lineno):
|
|
1141
|
+
"""
|
|
1142
|
+
Check each of the patterns in `self.implicit_dispatch` for a match,
|
|
1143
|
+
and dispatch to the stored method for the pattern. Recursively check
|
|
1144
|
+
the text before and after the match. Return a list of `nodes.Text`
|
|
1145
|
+
and inline element nodes.
|
|
1146
|
+
"""
|
|
1147
|
+
if not text:
|
|
1148
|
+
return []
|
|
1149
|
+
for pattern, method in self.implicit_dispatch:
|
|
1150
|
+
match = pattern.search(text)
|
|
1151
|
+
if match:
|
|
1152
|
+
try:
|
|
1153
|
+
# Must recurse on strings before *and* after the match;
|
|
1154
|
+
# there may be multiple patterns.
|
|
1155
|
+
return (self.implicit_inline(text[:match.start()], lineno)
|
|
1156
|
+
+ method(match, lineno)
|
|
1157
|
+
+ self.implicit_inline(text[match.end():], lineno))
|
|
1158
|
+
except MarkupMismatch:
|
|
1159
|
+
pass
|
|
1160
|
+
return [nodes.Text(text)]
|
|
1161
|
+
|
|
1162
|
+
dispatch = {'*': emphasis,
|
|
1163
|
+
'**': strong,
|
|
1164
|
+
'`': interpreted_or_phrase_ref,
|
|
1165
|
+
'``': literal,
|
|
1166
|
+
'_`': inline_internal_target,
|
|
1167
|
+
']_': footnote_reference,
|
|
1168
|
+
'|': substitution_reference,
|
|
1169
|
+
'_': reference,
|
|
1170
|
+
'__': anonymous_reference}
|
|
1171
|
+
|
|
1172
|
+
|
|
1173
|
+
def _loweralpha_to_int(s, _zero=(ord('a')-1)):
|
|
1174
|
+
return ord(s) - _zero
|
|
1175
|
+
|
|
1176
|
+
|
|
1177
|
+
def _upperalpha_to_int(s, _zero=(ord('A')-1)):
|
|
1178
|
+
return ord(s) - _zero
|
|
1179
|
+
|
|
1180
|
+
|
|
1181
|
+
class Body(RSTState):
|
|
1182
|
+
|
|
1183
|
+
"""
|
|
1184
|
+
Generic classifier of the first line of a block.
|
|
1185
|
+
"""
|
|
1186
|
+
|
|
1187
|
+
double_width_pad_char = tableparser.TableParser.double_width_pad_char
|
|
1188
|
+
"""Padding character for East Asian double-width text."""
|
|
1189
|
+
|
|
1190
|
+
enum = Struct()
|
|
1191
|
+
"""Enumerated list parsing information."""
|
|
1192
|
+
|
|
1193
|
+
enum.formatinfo = {
|
|
1194
|
+
'parens': Struct(prefix='(', suffix=')', start=1, end=-1),
|
|
1195
|
+
'rparen': Struct(prefix='', suffix=')', start=0, end=-1),
|
|
1196
|
+
'period': Struct(prefix='', suffix='.', start=0, end=-1)}
|
|
1197
|
+
enum.formats = enum.formatinfo.keys()
|
|
1198
|
+
enum.sequences = ['arabic', 'loweralpha', 'upperalpha',
|
|
1199
|
+
'lowerroman', 'upperroman'] # ORDERED!
|
|
1200
|
+
enum.sequencepats = {'arabic': '[0-9]+',
|
|
1201
|
+
'loweralpha': '[a-z]',
|
|
1202
|
+
'upperalpha': '[A-Z]',
|
|
1203
|
+
'lowerroman': '[ivxlcdm]+',
|
|
1204
|
+
'upperroman': '[IVXLCDM]+'}
|
|
1205
|
+
enum.converters = {'arabic': int,
|
|
1206
|
+
'loweralpha': _loweralpha_to_int,
|
|
1207
|
+
'upperalpha': _upperalpha_to_int,
|
|
1208
|
+
'lowerroman': RomanNumeral.from_string,
|
|
1209
|
+
'upperroman': RomanNumeral.from_string}
|
|
1210
|
+
|
|
1211
|
+
enum.sequenceregexps = {}
|
|
1212
|
+
for sequence in enum.sequences:
|
|
1213
|
+
enum.sequenceregexps[sequence] = re.compile(
|
|
1214
|
+
enum.sequencepats[sequence] + '$')
|
|
1215
|
+
|
|
1216
|
+
grid_table_top_pat = re.compile(r'\+-[-+]+-\+ *$')
|
|
1217
|
+
"""Matches the top (& bottom) of a full table)."""
|
|
1218
|
+
|
|
1219
|
+
simple_table_top_pat = re.compile('=+( +=+)+ *$')
|
|
1220
|
+
"""Matches the top of a simple table."""
|
|
1221
|
+
|
|
1222
|
+
simple_table_border_pat = re.compile('=+[ =]*$')
|
|
1223
|
+
"""Matches the bottom & header bottom of a simple table."""
|
|
1224
|
+
|
|
1225
|
+
pats = {}
|
|
1226
|
+
"""Fragments of patterns used by transitions."""
|
|
1227
|
+
|
|
1228
|
+
pats['nonalphanum7bit'] = '[!-/:-@[-`{-~]'
|
|
1229
|
+
pats['alpha'] = '[a-zA-Z]'
|
|
1230
|
+
pats['alphanum'] = '[a-zA-Z0-9]'
|
|
1231
|
+
pats['alphanumplus'] = '[a-zA-Z0-9_-]'
|
|
1232
|
+
pats['enum'] = ('(%(arabic)s|%(loweralpha)s|%(upperalpha)s|%(lowerroman)s'
|
|
1233
|
+
'|%(upperroman)s|#)' % enum.sequencepats)
|
|
1234
|
+
pats['optname'] = '%(alphanum)s%(alphanumplus)s*' % pats
|
|
1235
|
+
# @@@ Loosen up the pattern? Allow Unicode?
|
|
1236
|
+
pats['optarg'] = '(%(alpha)s%(alphanumplus)s*|<[^<>]+>)' % pats
|
|
1237
|
+
pats['shortopt'] = r'(-|\+)%(alphanum)s( ?%(optarg)s)?' % pats
|
|
1238
|
+
pats['longopt'] = r'(--|/)%(optname)s([ =]%(optarg)s)?' % pats
|
|
1239
|
+
pats['option'] = r'(%(shortopt)s|%(longopt)s)' % pats
|
|
1240
|
+
|
|
1241
|
+
for format in enum.formats:
|
|
1242
|
+
pats[format] = '(?P<%s>%s%s%s)' % (
|
|
1243
|
+
format, re.escape(enum.formatinfo[format].prefix),
|
|
1244
|
+
pats['enum'], re.escape(enum.formatinfo[format].suffix))
|
|
1245
|
+
|
|
1246
|
+
patterns = {
|
|
1247
|
+
'bullet': '[-+*\u2022\u2023\u2043]( +|$)',
|
|
1248
|
+
'enumerator': r'(%(parens)s|%(rparen)s|%(period)s)( +|$)' % pats,
|
|
1249
|
+
'field_marker': r':(?![: ])([^:\\]|\\.|:(?!([ `]|$)))*(?<! ):( +|$)',
|
|
1250
|
+
'option_marker': r'%(option)s(, %(option)s)*( +| ?$)' % pats,
|
|
1251
|
+
'doctest': r'>>>( +|$)',
|
|
1252
|
+
'line_block': r'\|( +|$)',
|
|
1253
|
+
'grid_table_top': grid_table_top_pat,
|
|
1254
|
+
'simple_table_top': simple_table_top_pat,
|
|
1255
|
+
'explicit_markup': r'\.\.( +|$)',
|
|
1256
|
+
'anonymous': r'__( +|$)',
|
|
1257
|
+
'line': r'(%(nonalphanum7bit)s)\1* *$' % pats,
|
|
1258
|
+
'text': r''}
|
|
1259
|
+
initial_transitions = (
|
|
1260
|
+
'bullet',
|
|
1261
|
+
'enumerator',
|
|
1262
|
+
'field_marker',
|
|
1263
|
+
'option_marker',
|
|
1264
|
+
'doctest',
|
|
1265
|
+
'line_block',
|
|
1266
|
+
'grid_table_top',
|
|
1267
|
+
'simple_table_top',
|
|
1268
|
+
'explicit_markup',
|
|
1269
|
+
'anonymous',
|
|
1270
|
+
'line',
|
|
1271
|
+
'text')
|
|
1272
|
+
|
|
1273
|
+
def indent(self, match, context, next_state):
|
|
1274
|
+
"""Block quote."""
|
|
1275
|
+
(indented, indent, line_offset, blank_finish
|
|
1276
|
+
) = self.state_machine.get_indented()
|
|
1277
|
+
elements = self.block_quote(indented, line_offset)
|
|
1278
|
+
self.parent += elements
|
|
1279
|
+
if not blank_finish:
|
|
1280
|
+
self.parent += self.unindent_warning('Block quote')
|
|
1281
|
+
return context, next_state, []
|
|
1282
|
+
|
|
1283
|
+
def block_quote(self, indented, line_offset):
|
|
1284
|
+
elements = []
|
|
1285
|
+
while indented:
|
|
1286
|
+
blockquote = nodes.block_quote(rawsource='\n'.join(indented))
|
|
1287
|
+
(blockquote.source, blockquote.line
|
|
1288
|
+
) = self.state_machine.get_source_and_line(line_offset+1)
|
|
1289
|
+
(blockquote_lines,
|
|
1290
|
+
attribution_lines,
|
|
1291
|
+
attribution_offset,
|
|
1292
|
+
indented,
|
|
1293
|
+
new_line_offset) = self.split_attribution(indented, line_offset)
|
|
1294
|
+
self.nested_parse(blockquote_lines, line_offset, blockquote)
|
|
1295
|
+
elements.append(blockquote)
|
|
1296
|
+
if attribution_lines:
|
|
1297
|
+
attribution, messages = self.parse_attribution(
|
|
1298
|
+
attribution_lines, line_offset+attribution_offset)
|
|
1299
|
+
blockquote += attribution
|
|
1300
|
+
elements += messages
|
|
1301
|
+
line_offset = new_line_offset
|
|
1302
|
+
while indented and not indented[0]:
|
|
1303
|
+
indented = indented[1:]
|
|
1304
|
+
line_offset += 1
|
|
1305
|
+
return elements
|
|
1306
|
+
|
|
1307
|
+
# U+2014 is an em-dash:
|
|
1308
|
+
attribution_pattern = re.compile('(---?(?!-)|\u2014) *(?=[^ \\n])')
|
|
1309
|
+
|
|
1310
|
+
def split_attribution(self, indented, line_offset):
|
|
1311
|
+
"""
|
|
1312
|
+
Check for a block quote attribution and split it off:
|
|
1313
|
+
|
|
1314
|
+
* First line after a blank line must begin with a dash ("--", "---",
|
|
1315
|
+
em-dash; matches `self.attribution_pattern`).
|
|
1316
|
+
* Every line after that must have consistent indentation.
|
|
1317
|
+
* Attributions must be preceded by block quote content.
|
|
1318
|
+
|
|
1319
|
+
Return a tuple of: (block quote content lines, attribution lines,
|
|
1320
|
+
attribution offset, remaining indented lines, remaining lines offset).
|
|
1321
|
+
"""
|
|
1322
|
+
blank = None
|
|
1323
|
+
nonblank_seen = False
|
|
1324
|
+
for i in range(len(indented)):
|
|
1325
|
+
line = indented[i].rstrip()
|
|
1326
|
+
if line:
|
|
1327
|
+
if nonblank_seen and blank == i - 1: # last line blank
|
|
1328
|
+
match = self.attribution_pattern.match(line)
|
|
1329
|
+
if match:
|
|
1330
|
+
attribution_end, indent = self.check_attribution(
|
|
1331
|
+
indented, i)
|
|
1332
|
+
if attribution_end:
|
|
1333
|
+
a_lines = indented[i:attribution_end]
|
|
1334
|
+
a_lines.trim_left(match.end(), end=1)
|
|
1335
|
+
a_lines.trim_left(indent, start=1)
|
|
1336
|
+
return (indented[:i], a_lines,
|
|
1337
|
+
i, indented[attribution_end:],
|
|
1338
|
+
line_offset + attribution_end)
|
|
1339
|
+
nonblank_seen = True
|
|
1340
|
+
else:
|
|
1341
|
+
blank = i
|
|
1342
|
+
else:
|
|
1343
|
+
return indented, None, None, None, None
|
|
1344
|
+
|
|
1345
|
+
def check_attribution(self, indented, attribution_start):
|
|
1346
|
+
"""
|
|
1347
|
+
Check attribution shape.
|
|
1348
|
+
Return the index past the end of the attribution, and the indent.
|
|
1349
|
+
"""
|
|
1350
|
+
indent = None
|
|
1351
|
+
i = attribution_start + 1
|
|
1352
|
+
for i in range(attribution_start + 1, len(indented)):
|
|
1353
|
+
line = indented[i].rstrip()
|
|
1354
|
+
if not line:
|
|
1355
|
+
break
|
|
1356
|
+
if indent is None:
|
|
1357
|
+
indent = len(line) - len(line.lstrip())
|
|
1358
|
+
elif len(line) - len(line.lstrip()) != indent:
|
|
1359
|
+
return None, None # bad shape; not an attribution
|
|
1360
|
+
else:
|
|
1361
|
+
# return index of line after last attribution line:
|
|
1362
|
+
i += 1
|
|
1363
|
+
return i, (indent or 0)
|
|
1364
|
+
|
|
1365
|
+
def parse_attribution(self, indented, line_offset):
|
|
1366
|
+
text = '\n'.join(indented).rstrip()
|
|
1367
|
+
lineno = 1 + line_offset # line_offset is zero-based
|
|
1368
|
+
textnodes, messages = self.inline_text(text, lineno)
|
|
1369
|
+
node = nodes.attribution(text, '', *textnodes)
|
|
1370
|
+
node.source, node.line = self.state_machine.get_source_and_line(lineno)
|
|
1371
|
+
return node, messages
|
|
1372
|
+
|
|
1373
|
+
def bullet(self, match, context, next_state):
|
|
1374
|
+
"""Bullet list item."""
|
|
1375
|
+
ul = nodes.bullet_list()
|
|
1376
|
+
ul.source, ul.line = self.state_machine.get_source_and_line()
|
|
1377
|
+
self.parent += ul
|
|
1378
|
+
ul['bullet'] = match.string[0]
|
|
1379
|
+
i, blank_finish = self.list_item(match.end())
|
|
1380
|
+
ul += i
|
|
1381
|
+
offset = self.state_machine.line_offset + 1 # next line
|
|
1382
|
+
new_line_offset, blank_finish = self.nested_list_parse(
|
|
1383
|
+
self.state_machine.input_lines[offset:],
|
|
1384
|
+
input_offset=self.state_machine.abs_line_offset() + 1,
|
|
1385
|
+
node=ul, initial_state='BulletList',
|
|
1386
|
+
blank_finish=blank_finish)
|
|
1387
|
+
self.goto_line(new_line_offset)
|
|
1388
|
+
if not blank_finish:
|
|
1389
|
+
self.parent += self.unindent_warning('Bullet list')
|
|
1390
|
+
return [], next_state, []
|
|
1391
|
+
|
|
1392
|
+
def list_item(self, indent):
|
|
1393
|
+
src, srcline = self.state_machine.get_source_and_line()
|
|
1394
|
+
if self.state_machine.line[indent:]:
|
|
1395
|
+
indented, line_offset, blank_finish = (
|
|
1396
|
+
self.state_machine.get_known_indented(indent))
|
|
1397
|
+
else:
|
|
1398
|
+
indented, indent, line_offset, blank_finish = (
|
|
1399
|
+
self.state_machine.get_first_known_indented(indent))
|
|
1400
|
+
listitem = nodes.list_item('\n'.join(indented))
|
|
1401
|
+
listitem.source, listitem.line = src, srcline
|
|
1402
|
+
if indented:
|
|
1403
|
+
self.nested_parse(indented, input_offset=line_offset,
|
|
1404
|
+
node=listitem)
|
|
1405
|
+
return listitem, blank_finish
|
|
1406
|
+
|
|
1407
|
+
def enumerator(self, match, context, next_state):
|
|
1408
|
+
"""Enumerated List Item"""
|
|
1409
|
+
format, sequence, text, ordinal = self.parse_enumerator(match)
|
|
1410
|
+
if not self.is_enumerated_list_item(ordinal, sequence, format):
|
|
1411
|
+
raise statemachine.TransitionCorrection('text')
|
|
1412
|
+
enumlist = nodes.enumerated_list()
|
|
1413
|
+
(enumlist.source,
|
|
1414
|
+
enumlist.line) = self.state_machine.get_source_and_line()
|
|
1415
|
+
self.parent += enumlist
|
|
1416
|
+
if sequence == '#':
|
|
1417
|
+
enumlist['enumtype'] = 'arabic'
|
|
1418
|
+
else:
|
|
1419
|
+
enumlist['enumtype'] = sequence
|
|
1420
|
+
enumlist['prefix'] = self.enum.formatinfo[format].prefix
|
|
1421
|
+
enumlist['suffix'] = self.enum.formatinfo[format].suffix
|
|
1422
|
+
if ordinal != 1:
|
|
1423
|
+
enumlist['start'] = ordinal
|
|
1424
|
+
msg = self.reporter.info(
|
|
1425
|
+
'Enumerated list start value not ordinal-1: "%s" (ordinal %s)'
|
|
1426
|
+
% (text, ordinal), base_node=enumlist)
|
|
1427
|
+
self.parent += msg
|
|
1428
|
+
listitem, blank_finish = self.list_item(match.end())
|
|
1429
|
+
enumlist += listitem
|
|
1430
|
+
offset = self.state_machine.line_offset + 1 # next line
|
|
1431
|
+
newline_offset, blank_finish = self.nested_list_parse(
|
|
1432
|
+
self.state_machine.input_lines[offset:],
|
|
1433
|
+
input_offset=self.state_machine.abs_line_offset() + 1,
|
|
1434
|
+
node=enumlist, initial_state='EnumeratedList',
|
|
1435
|
+
blank_finish=blank_finish,
|
|
1436
|
+
extra_settings={'lastordinal': ordinal,
|
|
1437
|
+
'format': format,
|
|
1438
|
+
'auto': sequence == '#'})
|
|
1439
|
+
self.goto_line(newline_offset)
|
|
1440
|
+
if not blank_finish:
|
|
1441
|
+
self.parent += self.unindent_warning('Enumerated list')
|
|
1442
|
+
return [], next_state, []
|
|
1443
|
+
|
|
1444
|
+
def parse_enumerator(self, match, expected_sequence=None):
|
|
1445
|
+
"""
|
|
1446
|
+
Analyze an enumerator and return the results.
|
|
1447
|
+
|
|
1448
|
+
:Return:
|
|
1449
|
+
- the enumerator format ('period', 'parens', or 'rparen'),
|
|
1450
|
+
- the sequence used ('arabic', 'loweralpha', 'upperroman', etc.),
|
|
1451
|
+
- the text of the enumerator, stripped of formatting, and
|
|
1452
|
+
- the ordinal value of the enumerator ('a' -> 1, 'ii' -> 2, etc.;
|
|
1453
|
+
``None`` is returned for invalid enumerator text).
|
|
1454
|
+
|
|
1455
|
+
The enumerator format has already been determined by the regular
|
|
1456
|
+
expression match. If `expected_sequence` is given, that sequence is
|
|
1457
|
+
tried first. If not, we check for Roman numeral 1. This way,
|
|
1458
|
+
single-character Roman numerals (which are also alphabetical) can be
|
|
1459
|
+
matched. If no sequence has been matched, all sequences are checked in
|
|
1460
|
+
order.
|
|
1461
|
+
"""
|
|
1462
|
+
groupdict = match.groupdict()
|
|
1463
|
+
sequence = ''
|
|
1464
|
+
for format in self.enum.formats:
|
|
1465
|
+
if groupdict[format]: # was this the format matched?
|
|
1466
|
+
break # yes; keep `format`
|
|
1467
|
+
else: # shouldn't happen
|
|
1468
|
+
raise ParserError('enumerator format not matched')
|
|
1469
|
+
text = groupdict[format][self.enum.formatinfo[format].start # noqa: E203,E501
|
|
1470
|
+
: self.enum.formatinfo[format].end]
|
|
1471
|
+
if text == '#':
|
|
1472
|
+
sequence = '#'
|
|
1473
|
+
elif expected_sequence:
|
|
1474
|
+
try:
|
|
1475
|
+
if self.enum.sequenceregexps[expected_sequence].match(text):
|
|
1476
|
+
sequence = expected_sequence
|
|
1477
|
+
except KeyError: # shouldn't happen
|
|
1478
|
+
raise ParserError('unknown enumerator sequence: %s'
|
|
1479
|
+
% sequence)
|
|
1480
|
+
elif text == 'i':
|
|
1481
|
+
sequence = 'lowerroman'
|
|
1482
|
+
elif text == 'I':
|
|
1483
|
+
sequence = 'upperroman'
|
|
1484
|
+
if not sequence:
|
|
1485
|
+
for sequence in self.enum.sequences:
|
|
1486
|
+
if self.enum.sequenceregexps[sequence].match(text):
|
|
1487
|
+
break
|
|
1488
|
+
else: # shouldn't happen
|
|
1489
|
+
raise ParserError('enumerator sequence not matched')
|
|
1490
|
+
if sequence == '#':
|
|
1491
|
+
ordinal = 1
|
|
1492
|
+
else:
|
|
1493
|
+
try:
|
|
1494
|
+
ordinal = int(self.enum.converters[sequence](text))
|
|
1495
|
+
except InvalidRomanNumeralError:
|
|
1496
|
+
ordinal = None
|
|
1497
|
+
return format, sequence, text, ordinal
|
|
1498
|
+
|
|
1499
|
+
def is_enumerated_list_item(self, ordinal, sequence, format):
|
|
1500
|
+
"""
|
|
1501
|
+
Check validity based on the ordinal value and the second line.
|
|
1502
|
+
|
|
1503
|
+
Return true if the ordinal is valid and the second line is blank,
|
|
1504
|
+
indented, or starts with the next enumerator or an auto-enumerator.
|
|
1505
|
+
"""
|
|
1506
|
+
if ordinal is None:
|
|
1507
|
+
return None
|
|
1508
|
+
try:
|
|
1509
|
+
next_line = self.state_machine.next_line()
|
|
1510
|
+
except EOFError: # end of input lines
|
|
1511
|
+
self.state_machine.previous_line()
|
|
1512
|
+
return 1
|
|
1513
|
+
else:
|
|
1514
|
+
self.state_machine.previous_line()
|
|
1515
|
+
if not next_line[:1].strip(): # blank or indented
|
|
1516
|
+
return 1
|
|
1517
|
+
result = self.make_enumerator(ordinal + 1, sequence, format)
|
|
1518
|
+
if result:
|
|
1519
|
+
next_enumerator, auto_enumerator = result
|
|
1520
|
+
try:
|
|
1521
|
+
if next_line.startswith((next_enumerator, auto_enumerator)):
|
|
1522
|
+
return 1
|
|
1523
|
+
except TypeError:
|
|
1524
|
+
pass
|
|
1525
|
+
return None
|
|
1526
|
+
|
|
1527
|
+
def make_enumerator(self, ordinal, sequence, format):
|
|
1528
|
+
"""
|
|
1529
|
+
Construct and return the next enumerated list item marker, and an
|
|
1530
|
+
auto-enumerator ("#" instead of the regular enumerator).
|
|
1531
|
+
|
|
1532
|
+
Return ``None`` for invalid (out of range) ordinals.
|
|
1533
|
+
"""
|
|
1534
|
+
if sequence == '#':
|
|
1535
|
+
enumerator = '#'
|
|
1536
|
+
elif sequence == 'arabic':
|
|
1537
|
+
enumerator = str(ordinal)
|
|
1538
|
+
else:
|
|
1539
|
+
if sequence.endswith('alpha'):
|
|
1540
|
+
if ordinal > 26:
|
|
1541
|
+
return None
|
|
1542
|
+
enumerator = chr(ordinal + ord('a') - 1)
|
|
1543
|
+
elif sequence.endswith('roman'):
|
|
1544
|
+
try:
|
|
1545
|
+
enumerator = RomanNumeral(ordinal).to_uppercase()
|
|
1546
|
+
except TypeError:
|
|
1547
|
+
return None
|
|
1548
|
+
else: # shouldn't happen
|
|
1549
|
+
raise ParserError('unknown enumerator sequence: "%s"'
|
|
1550
|
+
% sequence)
|
|
1551
|
+
if sequence.startswith('lower'):
|
|
1552
|
+
enumerator = enumerator.lower()
|
|
1553
|
+
elif sequence.startswith('upper'):
|
|
1554
|
+
enumerator = enumerator.upper()
|
|
1555
|
+
else: # shouldn't happen
|
|
1556
|
+
raise ParserError('unknown enumerator sequence: "%s"'
|
|
1557
|
+
% sequence)
|
|
1558
|
+
formatinfo = self.enum.formatinfo[format]
|
|
1559
|
+
next_enumerator = (formatinfo.prefix + enumerator + formatinfo.suffix
|
|
1560
|
+
+ ' ')
|
|
1561
|
+
auto_enumerator = formatinfo.prefix + '#' + formatinfo.suffix + ' '
|
|
1562
|
+
return next_enumerator, auto_enumerator
|
|
1563
|
+
|
|
1564
|
+
def field_marker(self, match, context, next_state):
|
|
1565
|
+
"""Field list item."""
|
|
1566
|
+
field_list = nodes.field_list()
|
|
1567
|
+
self.parent += field_list
|
|
1568
|
+
field, blank_finish = self.field(match)
|
|
1569
|
+
field_list += field
|
|
1570
|
+
offset = self.state_machine.line_offset + 1 # next line
|
|
1571
|
+
newline_offset, blank_finish = self.nested_list_parse(
|
|
1572
|
+
self.state_machine.input_lines[offset:],
|
|
1573
|
+
input_offset=self.state_machine.abs_line_offset() + 1,
|
|
1574
|
+
node=field_list, initial_state='FieldList',
|
|
1575
|
+
blank_finish=blank_finish)
|
|
1576
|
+
self.goto_line(newline_offset)
|
|
1577
|
+
if not blank_finish:
|
|
1578
|
+
self.parent += self.unindent_warning('Field list')
|
|
1579
|
+
return [], next_state, []
|
|
1580
|
+
|
|
1581
|
+
def field(self, match):
|
|
1582
|
+
name = self.parse_field_marker(match)
|
|
1583
|
+
src, srcline = self.state_machine.get_source_and_line()
|
|
1584
|
+
lineno = self.state_machine.abs_line_number()
|
|
1585
|
+
(indented, indent, line_offset, blank_finish
|
|
1586
|
+
) = self.state_machine.get_first_known_indented(match.end())
|
|
1587
|
+
field_node = nodes.field()
|
|
1588
|
+
field_node.source = src
|
|
1589
|
+
field_node.line = srcline
|
|
1590
|
+
name_nodes, name_messages = self.inline_text(name, lineno)
|
|
1591
|
+
field_node += nodes.field_name(name, '', *name_nodes)
|
|
1592
|
+
field_body = nodes.field_body('\n'.join(indented), *name_messages)
|
|
1593
|
+
field_node += field_body
|
|
1594
|
+
if indented:
|
|
1595
|
+
self.parse_field_body(indented, line_offset, field_body)
|
|
1596
|
+
return field_node, blank_finish
|
|
1597
|
+
|
|
1598
|
+
def parse_field_marker(self, match):
|
|
1599
|
+
"""Extract & return field name from a field marker match."""
|
|
1600
|
+
field = match.group()[1:] # strip off leading ':'
|
|
1601
|
+
field = field[:field.rfind(':')] # strip off trailing ':' etc.
|
|
1602
|
+
return field
|
|
1603
|
+
|
|
1604
|
+
def parse_field_body(self, indented, offset, node) -> None:
|
|
1605
|
+
self.nested_parse(indented, input_offset=offset, node=node)
|
|
1606
|
+
|
|
1607
|
+
def option_marker(self, match, context, next_state):
|
|
1608
|
+
"""Option list item."""
|
|
1609
|
+
optionlist = nodes.option_list()
|
|
1610
|
+
(optionlist.source, optionlist.line
|
|
1611
|
+
) = self.state_machine.get_source_and_line()
|
|
1612
|
+
try:
|
|
1613
|
+
listitem, blank_finish = self.option_list_item(match)
|
|
1614
|
+
except MarkupError as error:
|
|
1615
|
+
# This shouldn't happen; pattern won't match.
|
|
1616
|
+
msg = self.reporter.error('Invalid option list marker: %s'
|
|
1617
|
+
% error)
|
|
1618
|
+
self.parent += msg
|
|
1619
|
+
(indented, indent, line_offset, blank_finish
|
|
1620
|
+
) = self.state_machine.get_first_known_indented(match.end())
|
|
1621
|
+
elements = self.block_quote(indented, line_offset)
|
|
1622
|
+
self.parent += elements
|
|
1623
|
+
if not blank_finish:
|
|
1624
|
+
self.parent += self.unindent_warning('Option list')
|
|
1625
|
+
return [], next_state, []
|
|
1626
|
+
self.parent += optionlist
|
|
1627
|
+
optionlist += listitem
|
|
1628
|
+
offset = self.state_machine.line_offset + 1 # next line
|
|
1629
|
+
newline_offset, blank_finish = self.nested_list_parse(
|
|
1630
|
+
self.state_machine.input_lines[offset:],
|
|
1631
|
+
input_offset=self.state_machine.abs_line_offset() + 1,
|
|
1632
|
+
node=optionlist, initial_state='OptionList',
|
|
1633
|
+
blank_finish=blank_finish)
|
|
1634
|
+
self.goto_line(newline_offset)
|
|
1635
|
+
if not blank_finish:
|
|
1636
|
+
self.parent += self.unindent_warning('Option list')
|
|
1637
|
+
return [], next_state, []
|
|
1638
|
+
|
|
1639
|
+
def option_list_item(self, match):
|
|
1640
|
+
offset = self.state_machine.abs_line_offset()
|
|
1641
|
+
options = self.parse_option_marker(match)
|
|
1642
|
+
(indented, indent, line_offset, blank_finish
|
|
1643
|
+
) = self.state_machine.get_first_known_indented(match.end())
|
|
1644
|
+
if not indented: # not an option list item
|
|
1645
|
+
self.goto_line(offset)
|
|
1646
|
+
raise statemachine.TransitionCorrection('text')
|
|
1647
|
+
option_group = nodes.option_group('', *options)
|
|
1648
|
+
description = nodes.description('\n'.join(indented))
|
|
1649
|
+
option_list_item = nodes.option_list_item('', option_group,
|
|
1650
|
+
description)
|
|
1651
|
+
if indented:
|
|
1652
|
+
self.nested_parse(indented, input_offset=line_offset,
|
|
1653
|
+
node=description)
|
|
1654
|
+
return option_list_item, blank_finish
|
|
1655
|
+
|
|
1656
|
+
def parse_option_marker(self, match):
|
|
1657
|
+
"""
|
|
1658
|
+
Return a list of `node.option` and `node.option_argument` objects,
|
|
1659
|
+
parsed from an option marker match.
|
|
1660
|
+
|
|
1661
|
+
:Exception: `MarkupError` for invalid option markers.
|
|
1662
|
+
"""
|
|
1663
|
+
optlist = []
|
|
1664
|
+
# split at ", ", except inside < > (complex arguments)
|
|
1665
|
+
optionstrings = re.split(r', (?![^<]*>)', match.group().rstrip())
|
|
1666
|
+
for optionstring in optionstrings:
|
|
1667
|
+
tokens = optionstring.split()
|
|
1668
|
+
delimiter = ' '
|
|
1669
|
+
firstopt = tokens[0].split('=', 1)
|
|
1670
|
+
if len(firstopt) > 1:
|
|
1671
|
+
# "--opt=value" form
|
|
1672
|
+
tokens[:1] = firstopt
|
|
1673
|
+
delimiter = '='
|
|
1674
|
+
elif (len(tokens[0]) > 2
|
|
1675
|
+
and ((tokens[0].startswith('-')
|
|
1676
|
+
and not tokens[0].startswith('--'))
|
|
1677
|
+
or tokens[0].startswith('+'))):
|
|
1678
|
+
# "-ovalue" form
|
|
1679
|
+
tokens[:1] = [tokens[0][:2], tokens[0][2:]]
|
|
1680
|
+
delimiter = ''
|
|
1681
|
+
if len(tokens) > 1 and (tokens[1].startswith('<')
|
|
1682
|
+
and tokens[-1].endswith('>')):
|
|
1683
|
+
# "-o <value1 value2>" form; join all values into one token
|
|
1684
|
+
tokens[1:] = [' '.join(tokens[1:])]
|
|
1685
|
+
if 0 < len(tokens) <= 2:
|
|
1686
|
+
option = nodes.option(optionstring)
|
|
1687
|
+
option += nodes.option_string(tokens[0], tokens[0])
|
|
1688
|
+
if len(tokens) > 1:
|
|
1689
|
+
option += nodes.option_argument(tokens[1], tokens[1],
|
|
1690
|
+
delimiter=delimiter)
|
|
1691
|
+
optlist.append(option)
|
|
1692
|
+
else:
|
|
1693
|
+
raise MarkupError(
|
|
1694
|
+
'wrong number of option tokens (=%s), should be 1 or 2: '
|
|
1695
|
+
'"%s"' % (len(tokens), optionstring))
|
|
1696
|
+
return optlist
|
|
1697
|
+
|
|
1698
|
+
def doctest(self, match, context, next_state):
|
|
1699
|
+
line = self.document.current_line
|
|
1700
|
+
data = '\n'.join(self.state_machine.get_text_block())
|
|
1701
|
+
# TODO: Parse with `directives.body.CodeBlock` with
|
|
1702
|
+
# argument 'pycon' (Python Console) in Docutils 1.0.
|
|
1703
|
+
n = nodes.doctest_block(data, data)
|
|
1704
|
+
n.line = line
|
|
1705
|
+
self.parent += n
|
|
1706
|
+
return [], next_state, []
|
|
1707
|
+
|
|
1708
|
+
def line_block(self, match, context, next_state):
|
|
1709
|
+
"""First line of a line block."""
|
|
1710
|
+
block = nodes.line_block()
|
|
1711
|
+
self.parent += block
|
|
1712
|
+
lineno = self.state_machine.abs_line_number()
|
|
1713
|
+
(block.source,
|
|
1714
|
+
block.line) = self.state_machine.get_source_and_line(lineno)
|
|
1715
|
+
line, messages, blank_finish = self.line_block_line(match, lineno)
|
|
1716
|
+
block += line
|
|
1717
|
+
self.parent += messages
|
|
1718
|
+
if not blank_finish:
|
|
1719
|
+
offset = self.state_machine.line_offset + 1 # next line
|
|
1720
|
+
new_line_offset, blank_finish = self.nested_list_parse(
|
|
1721
|
+
self.state_machine.input_lines[offset:],
|
|
1722
|
+
input_offset=self.state_machine.abs_line_offset() + 1,
|
|
1723
|
+
node=block, initial_state='LineBlock',
|
|
1724
|
+
blank_finish=False)
|
|
1725
|
+
self.goto_line(new_line_offset)
|
|
1726
|
+
if not blank_finish:
|
|
1727
|
+
self.parent += self.reporter.warning(
|
|
1728
|
+
'Line block ends without a blank line.',
|
|
1729
|
+
line=lineno+1)
|
|
1730
|
+
if len(block):
|
|
1731
|
+
if block[0].indent is None:
|
|
1732
|
+
block[0].indent = 0
|
|
1733
|
+
self.nest_line_block_lines(block)
|
|
1734
|
+
return [], next_state, []
|
|
1735
|
+
|
|
1736
|
+
def line_block_line(self, match, lineno):
|
|
1737
|
+
"""Return one line element of a line_block."""
|
|
1738
|
+
(indented, indent, line_offset, blank_finish
|
|
1739
|
+
) = self.state_machine.get_first_known_indented(match.end(),
|
|
1740
|
+
until_blank=True)
|
|
1741
|
+
text = '\n'.join(indented)
|
|
1742
|
+
text_nodes, messages = self.inline_text(text, lineno)
|
|
1743
|
+
line = nodes.line(text, '', *text_nodes)
|
|
1744
|
+
(line.source,
|
|
1745
|
+
line.line) = self.state_machine.get_source_and_line(lineno)
|
|
1746
|
+
if match.string.rstrip() != '|': # not empty
|
|
1747
|
+
line.indent = len(match.group(1)) - 1
|
|
1748
|
+
return line, messages, blank_finish
|
|
1749
|
+
|
|
1750
|
+
def nest_line_block_lines(self, block) -> None:
|
|
1751
|
+
for index in range(1, len(block)):
|
|
1752
|
+
if block[index].indent is None:
|
|
1753
|
+
block[index].indent = block[index - 1].indent
|
|
1754
|
+
self.nest_line_block_segment(block)
|
|
1755
|
+
|
|
1756
|
+
def nest_line_block_segment(self, block) -> None:
|
|
1757
|
+
indents = [item.indent for item in block]
|
|
1758
|
+
least = min(indents)
|
|
1759
|
+
new_items = []
|
|
1760
|
+
new_block = nodes.line_block()
|
|
1761
|
+
for item in block:
|
|
1762
|
+
if item.indent > least:
|
|
1763
|
+
new_block.append(item)
|
|
1764
|
+
else:
|
|
1765
|
+
if len(new_block):
|
|
1766
|
+
self.nest_line_block_segment(new_block)
|
|
1767
|
+
new_items.append(new_block)
|
|
1768
|
+
new_block = nodes.line_block()
|
|
1769
|
+
new_items.append(item)
|
|
1770
|
+
if len(new_block):
|
|
1771
|
+
self.nest_line_block_segment(new_block)
|
|
1772
|
+
new_items.append(new_block)
|
|
1773
|
+
block[:] = new_items
|
|
1774
|
+
|
|
1775
|
+
def grid_table_top(self, match, context, next_state):
|
|
1776
|
+
"""Top border of a full table."""
|
|
1777
|
+
return self.table_top(match, context, next_state,
|
|
1778
|
+
self.isolate_grid_table,
|
|
1779
|
+
tableparser.GridTableParser)
|
|
1780
|
+
|
|
1781
|
+
def simple_table_top(self, match, context, next_state):
|
|
1782
|
+
"""Top border of a simple table."""
|
|
1783
|
+
return self.table_top(match, context, next_state,
|
|
1784
|
+
self.isolate_simple_table,
|
|
1785
|
+
tableparser.SimpleTableParser)
|
|
1786
|
+
|
|
1787
|
+
def table_top(self, match, context, next_state,
|
|
1788
|
+
isolate_function, parser_class):
|
|
1789
|
+
"""Top border of a generic table."""
|
|
1790
|
+
nodelist, blank_finish = self.table(isolate_function, parser_class)
|
|
1791
|
+
self.parent += nodelist
|
|
1792
|
+
if not blank_finish:
|
|
1793
|
+
msg = self.reporter.warning(
|
|
1794
|
+
'Blank line required after table.',
|
|
1795
|
+
line=self.state_machine.abs_line_number()+1)
|
|
1796
|
+
self.parent += msg
|
|
1797
|
+
return [], next_state, []
|
|
1798
|
+
|
|
1799
|
+
def table(self, isolate_function, parser_class):
|
|
1800
|
+
"""Parse a table."""
|
|
1801
|
+
block, messages, blank_finish = isolate_function()
|
|
1802
|
+
if block:
|
|
1803
|
+
try:
|
|
1804
|
+
parser = parser_class()
|
|
1805
|
+
tabledata = parser.parse(block)
|
|
1806
|
+
tableline = (self.state_machine.abs_line_number() - len(block)
|
|
1807
|
+
+ 1)
|
|
1808
|
+
table = self.build_table(tabledata, tableline)
|
|
1809
|
+
nodelist = [table] + messages
|
|
1810
|
+
except tableparser.TableMarkupError as err:
|
|
1811
|
+
nodelist = self.malformed_table(block, ' '.join(err.args),
|
|
1812
|
+
offset=err.offset) + messages
|
|
1813
|
+
else:
|
|
1814
|
+
nodelist = messages
|
|
1815
|
+
return nodelist, blank_finish
|
|
1816
|
+
|
|
1817
|
+
def isolate_grid_table(self):
|
|
1818
|
+
messages = []
|
|
1819
|
+
blank_finish = True
|
|
1820
|
+
try:
|
|
1821
|
+
block = self.state_machine.get_text_block(flush_left=True)
|
|
1822
|
+
except statemachine.UnexpectedIndentationError as err:
|
|
1823
|
+
block, src, srcline = err.args
|
|
1824
|
+
messages.append(self.reporter.error('Unexpected indentation.',
|
|
1825
|
+
source=src, line=srcline))
|
|
1826
|
+
blank_finish = False
|
|
1827
|
+
block.disconnect()
|
|
1828
|
+
# for East Asian chars:
|
|
1829
|
+
block.pad_double_width(self.double_width_pad_char)
|
|
1830
|
+
width = len(block[0].strip())
|
|
1831
|
+
for i in range(len(block)):
|
|
1832
|
+
block[i] = block[i].strip()
|
|
1833
|
+
if block[i][0] not in '+|': # check left edge
|
|
1834
|
+
blank_finish = False
|
|
1835
|
+
self.state_machine.previous_line(len(block) - i)
|
|
1836
|
+
del block[i:]
|
|
1837
|
+
break
|
|
1838
|
+
if not self.grid_table_top_pat.match(block[-1]): # find bottom
|
|
1839
|
+
# from second-last to third line of table:
|
|
1840
|
+
for i in range(len(block) - 2, 1, -1):
|
|
1841
|
+
if self.grid_table_top_pat.match(block[i]):
|
|
1842
|
+
self.state_machine.previous_line(len(block) - i + 1)
|
|
1843
|
+
del block[i+1:]
|
|
1844
|
+
blank_finish = False
|
|
1845
|
+
break
|
|
1846
|
+
else:
|
|
1847
|
+
detail = 'Bottom border missing or corrupt.'
|
|
1848
|
+
messages.extend(self.malformed_table(block, detail, i))
|
|
1849
|
+
return [], messages, blank_finish
|
|
1850
|
+
for i in range(len(block)): # check right edge
|
|
1851
|
+
if len(block[i]) != width or block[i][-1] not in '+|':
|
|
1852
|
+
detail = 'Right border not aligned or missing.'
|
|
1853
|
+
messages.extend(self.malformed_table(block, detail, i))
|
|
1854
|
+
return [], messages, blank_finish
|
|
1855
|
+
return block, messages, blank_finish
|
|
1856
|
+
|
|
1857
|
+
def isolate_simple_table(self):
|
|
1858
|
+
start = self.state_machine.line_offset
|
|
1859
|
+
lines = self.state_machine.input_lines
|
|
1860
|
+
limit = len(lines) - 1
|
|
1861
|
+
toplen = len(lines[start].strip())
|
|
1862
|
+
pattern_match = self.simple_table_border_pat.match
|
|
1863
|
+
found = 0
|
|
1864
|
+
found_at = None
|
|
1865
|
+
i = start + 1
|
|
1866
|
+
while i <= limit:
|
|
1867
|
+
line = lines[i]
|
|
1868
|
+
match = pattern_match(line)
|
|
1869
|
+
if match:
|
|
1870
|
+
if len(line.strip()) != toplen:
|
|
1871
|
+
self.state_machine.next_line(i - start)
|
|
1872
|
+
messages = self.malformed_table(
|
|
1873
|
+
lines[start:i+1], 'Bottom border or header rule does '
|
|
1874
|
+
'not match top border.', i-start)
|
|
1875
|
+
return [], messages, i == limit or not lines[i+1].strip()
|
|
1876
|
+
found += 1
|
|
1877
|
+
found_at = i
|
|
1878
|
+
if found == 2 or i == limit or not lines[i+1].strip():
|
|
1879
|
+
end = i
|
|
1880
|
+
break
|
|
1881
|
+
i += 1
|
|
1882
|
+
else: # reached end of input_lines
|
|
1883
|
+
details = 'No bottom table border found'
|
|
1884
|
+
if found:
|
|
1885
|
+
details += ' or no blank line after table bottom'
|
|
1886
|
+
self.state_machine.next_line(found_at - start)
|
|
1887
|
+
block = lines[start:found_at+1]
|
|
1888
|
+
else:
|
|
1889
|
+
self.state_machine.next_line(i - start - 1)
|
|
1890
|
+
block = lines[start:]
|
|
1891
|
+
messages = self.malformed_table(block, details + '.')
|
|
1892
|
+
return [], messages, not found
|
|
1893
|
+
self.state_machine.next_line(end - start)
|
|
1894
|
+
block = lines[start:end+1]
|
|
1895
|
+
# for East Asian chars:
|
|
1896
|
+
block.pad_double_width(self.double_width_pad_char)
|
|
1897
|
+
return block, [], end == limit or not lines[end+1].strip()
|
|
1898
|
+
|
|
1899
|
+
def malformed_table(self, block, detail='', offset=0):
|
|
1900
|
+
block.replace(self.double_width_pad_char, '')
|
|
1901
|
+
data = '\n'.join(block)
|
|
1902
|
+
message = 'Malformed table.'
|
|
1903
|
+
startline = self.state_machine.abs_line_number() - len(block) + 1
|
|
1904
|
+
if detail:
|
|
1905
|
+
message += '\n' + detail
|
|
1906
|
+
error = self.reporter.error(message, nodes.literal_block(data, data),
|
|
1907
|
+
line=startline+offset)
|
|
1908
|
+
return [error]
|
|
1909
|
+
|
|
1910
|
+
def build_table(self, tabledata, tableline, stub_columns=0, widths=None):
|
|
1911
|
+
colwidths, headrows, bodyrows = tabledata
|
|
1912
|
+
table = nodes.table()
|
|
1913
|
+
if widths == 'auto':
|
|
1914
|
+
table['classes'] += ['colwidths-auto']
|
|
1915
|
+
elif widths: # "grid" or list of integers
|
|
1916
|
+
table['classes'] += ['colwidths-given']
|
|
1917
|
+
tgroup = nodes.tgroup(cols=len(colwidths))
|
|
1918
|
+
table += tgroup
|
|
1919
|
+
for colwidth in colwidths:
|
|
1920
|
+
colspec = nodes.colspec(colwidth=colwidth)
|
|
1921
|
+
if stub_columns:
|
|
1922
|
+
colspec.attributes['stub'] = True
|
|
1923
|
+
stub_columns -= 1
|
|
1924
|
+
tgroup += colspec
|
|
1925
|
+
if headrows:
|
|
1926
|
+
thead = nodes.thead()
|
|
1927
|
+
tgroup += thead
|
|
1928
|
+
for row in headrows:
|
|
1929
|
+
thead += self.build_table_row(row, tableline)
|
|
1930
|
+
tbody = nodes.tbody()
|
|
1931
|
+
tgroup += tbody
|
|
1932
|
+
for row in bodyrows:
|
|
1933
|
+
tbody += self.build_table_row(row, tableline)
|
|
1934
|
+
return table
|
|
1935
|
+
|
|
1936
|
+
def build_table_row(self, rowdata, tableline):
|
|
1937
|
+
row = nodes.row()
|
|
1938
|
+
for cell in rowdata:
|
|
1939
|
+
if cell is None:
|
|
1940
|
+
continue
|
|
1941
|
+
morerows, morecols, offset, cellblock = cell
|
|
1942
|
+
attributes = {}
|
|
1943
|
+
if morerows:
|
|
1944
|
+
attributes['morerows'] = morerows
|
|
1945
|
+
if morecols:
|
|
1946
|
+
attributes['morecols'] = morecols
|
|
1947
|
+
entry = nodes.entry(**attributes)
|
|
1948
|
+
row += entry
|
|
1949
|
+
if ''.join(cellblock):
|
|
1950
|
+
self.nested_parse(cellblock, input_offset=tableline+offset,
|
|
1951
|
+
node=entry)
|
|
1952
|
+
return row
|
|
1953
|
+
|
|
1954
|
+
explicit = Struct()
|
|
1955
|
+
"""Patterns and constants used for explicit markup recognition."""
|
|
1956
|
+
|
|
1957
|
+
explicit.patterns = Struct(
|
|
1958
|
+
target=re.compile(r"""
|
|
1959
|
+
(
|
|
1960
|
+
_ # anonymous target
|
|
1961
|
+
| # *OR*
|
|
1962
|
+
(?!_) # no underscore at the beginning
|
|
1963
|
+
(?P<quote>`?) # optional open quote
|
|
1964
|
+
(?![ `]) # first char. not space or
|
|
1965
|
+
# backquote
|
|
1966
|
+
(?P<name> # reference name
|
|
1967
|
+
.+?
|
|
1968
|
+
)
|
|
1969
|
+
%(non_whitespace_escape_before)s
|
|
1970
|
+
(?P=quote) # close quote if open quote used
|
|
1971
|
+
)
|
|
1972
|
+
(?<!(?<!\x00):) # no unescaped colon at end
|
|
1973
|
+
%(non_whitespace_escape_before)s
|
|
1974
|
+
[ ]? # optional space
|
|
1975
|
+
: # end of reference name
|
|
1976
|
+
([ ]+|$) # followed by whitespace
|
|
1977
|
+
""" % vars(Inliner), re.VERBOSE),
|
|
1978
|
+
reference=re.compile(r"""
|
|
1979
|
+
(
|
|
1980
|
+
(?P<simple>%(simplename)s)_
|
|
1981
|
+
| # *OR*
|
|
1982
|
+
` # open backquote
|
|
1983
|
+
(?![ ]) # not space
|
|
1984
|
+
(?P<phrase>.+?) # hyperlink phrase
|
|
1985
|
+
%(non_whitespace_escape_before)s
|
|
1986
|
+
`_ # close backquote,
|
|
1987
|
+
# reference mark
|
|
1988
|
+
)
|
|
1989
|
+
$ # end of string
|
|
1990
|
+
""" % vars(Inliner), re.VERBOSE),
|
|
1991
|
+
substitution=re.compile(r"""
|
|
1992
|
+
(
|
|
1993
|
+
(?![ ]) # first char. not space
|
|
1994
|
+
(?P<name>.+?) # substitution text
|
|
1995
|
+
%(non_whitespace_escape_before)s
|
|
1996
|
+
\| # close delimiter
|
|
1997
|
+
)
|
|
1998
|
+
([ ]+|$) # followed by whitespace
|
|
1999
|
+
""" % vars(Inliner),
|
|
2000
|
+
re.VERBOSE),)
|
|
2001
|
+
|
|
2002
|
+
def footnote(self, match):
|
|
2003
|
+
src, srcline = self.state_machine.get_source_and_line()
|
|
2004
|
+
(indented, indent, offset, blank_finish
|
|
2005
|
+
) = self.state_machine.get_first_known_indented(match.end())
|
|
2006
|
+
label = match.group(1)
|
|
2007
|
+
name = normalize_name(label)
|
|
2008
|
+
footnote = nodes.footnote('\n'.join(indented))
|
|
2009
|
+
footnote.source = src
|
|
2010
|
+
footnote.line = srcline
|
|
2011
|
+
if name[0] == '#': # auto-numbered
|
|
2012
|
+
name = name[1:] # autonumber label
|
|
2013
|
+
footnote['auto'] = 1
|
|
2014
|
+
if name:
|
|
2015
|
+
footnote['names'].append(name)
|
|
2016
|
+
self.document.note_autofootnote(footnote)
|
|
2017
|
+
elif name == '*': # auto-symbol
|
|
2018
|
+
name = ''
|
|
2019
|
+
footnote['auto'] = '*'
|
|
2020
|
+
self.document.note_symbol_footnote(footnote)
|
|
2021
|
+
else: # manually numbered
|
|
2022
|
+
footnote += nodes.label('', label)
|
|
2023
|
+
footnote['names'].append(name)
|
|
2024
|
+
self.document.note_footnote(footnote)
|
|
2025
|
+
if name:
|
|
2026
|
+
self.document.note_explicit_target(footnote, footnote)
|
|
2027
|
+
else:
|
|
2028
|
+
self.document.set_id(footnote, footnote)
|
|
2029
|
+
if indented:
|
|
2030
|
+
self.nested_parse(indented, input_offset=offset, node=footnote)
|
|
2031
|
+
else:
|
|
2032
|
+
footnote += self.reporter.warning('Footnote content expected.')
|
|
2033
|
+
return [footnote], blank_finish
|
|
2034
|
+
|
|
2035
|
+
def citation(self, match):
|
|
2036
|
+
src, srcline = self.state_machine.get_source_and_line()
|
|
2037
|
+
(indented, indent, offset, blank_finish
|
|
2038
|
+
) = self.state_machine.get_first_known_indented(match.end())
|
|
2039
|
+
label = match.group(1)
|
|
2040
|
+
name = normalize_name(label)
|
|
2041
|
+
citation = nodes.citation('\n'.join(indented))
|
|
2042
|
+
citation.source = src
|
|
2043
|
+
citation.line = srcline
|
|
2044
|
+
citation += nodes.label('', label)
|
|
2045
|
+
citation['names'].append(name)
|
|
2046
|
+
self.document.note_citation(citation)
|
|
2047
|
+
self.document.note_explicit_target(citation, citation)
|
|
2048
|
+
if indented:
|
|
2049
|
+
self.nested_parse(indented, input_offset=offset, node=citation)
|
|
2050
|
+
else:
|
|
2051
|
+
citation += self.reporter.warning('Citation content expected.')
|
|
2052
|
+
return [citation], blank_finish
|
|
2053
|
+
|
|
2054
|
+
def hyperlink_target(self, match):
|
|
2055
|
+
pattern = self.explicit.patterns.target
|
|
2056
|
+
lineno = self.state_machine.abs_line_number()
|
|
2057
|
+
(block, indent, offset, blank_finish
|
|
2058
|
+
) = self.state_machine.get_first_known_indented(
|
|
2059
|
+
match.end(), until_blank=True, strip_indent=False)
|
|
2060
|
+
blocktext = match.string[:match.end()] + '\n'.join(block)
|
|
2061
|
+
block = [escape2null(line) for line in block]
|
|
2062
|
+
escaped = block[0]
|
|
2063
|
+
blockindex = 0
|
|
2064
|
+
while True:
|
|
2065
|
+
targetmatch = pattern.match(escaped)
|
|
2066
|
+
if targetmatch:
|
|
2067
|
+
break
|
|
2068
|
+
blockindex += 1
|
|
2069
|
+
try:
|
|
2070
|
+
escaped += block[blockindex]
|
|
2071
|
+
except IndexError:
|
|
2072
|
+
raise MarkupError('malformed hyperlink target.')
|
|
2073
|
+
del block[:blockindex]
|
|
2074
|
+
block[0] = (block[0] + ' ')[targetmatch.end()-len(escaped)-1:].strip()
|
|
2075
|
+
target = self.make_target(block, blocktext, lineno,
|
|
2076
|
+
targetmatch.group('name'))
|
|
2077
|
+
return [target], blank_finish
|
|
2078
|
+
|
|
2079
|
+
def make_target(self, block, block_text, lineno, target_name):
|
|
2080
|
+
target_type, data = self.parse_target(block, block_text, lineno)
|
|
2081
|
+
if target_type == 'refname':
|
|
2082
|
+
target = nodes.target(block_text, '', refname=normalize_name(data))
|
|
2083
|
+
target.indirect_reference_name = data
|
|
2084
|
+
self.add_target(target_name, '', target, lineno)
|
|
2085
|
+
self.document.note_indirect_target(target)
|
|
2086
|
+
return target
|
|
2087
|
+
elif target_type == 'refuri':
|
|
2088
|
+
target = nodes.target(block_text, '')
|
|
2089
|
+
self.add_target(target_name, data, target, lineno)
|
|
2090
|
+
return target
|
|
2091
|
+
else:
|
|
2092
|
+
return data
|
|
2093
|
+
|
|
2094
|
+
def parse_target(self, block, block_text, lineno):
|
|
2095
|
+
"""
|
|
2096
|
+
Determine the type of reference of a target.
|
|
2097
|
+
|
|
2098
|
+
:Return: A 2-tuple, one of:
|
|
2099
|
+
|
|
2100
|
+
- 'refname' and the indirect reference name
|
|
2101
|
+
- 'refuri' and the URI
|
|
2102
|
+
- 'malformed' and a system_message node
|
|
2103
|
+
"""
|
|
2104
|
+
if block and block[-1].strip()[-1:] == '_': # possible indirect target
|
|
2105
|
+
reference = ' '.join(line.strip() for line in block)
|
|
2106
|
+
refname = self.is_reference(reference)
|
|
2107
|
+
if refname:
|
|
2108
|
+
return 'refname', refname
|
|
2109
|
+
ref_parts = split_escaped_whitespace(' '.join(block))
|
|
2110
|
+
reference = ' '.join(''.join(unescape(part).split())
|
|
2111
|
+
for part in ref_parts)
|
|
2112
|
+
return 'refuri', reference
|
|
2113
|
+
|
|
2114
|
+
def is_reference(self, reference):
|
|
2115
|
+
match = self.explicit.patterns.reference.match(
|
|
2116
|
+
whitespace_normalize_name(reference))
|
|
2117
|
+
if not match:
|
|
2118
|
+
return None
|
|
2119
|
+
return unescape(match.group('simple') or match.group('phrase'))
|
|
2120
|
+
|
|
2121
|
+
def add_target(self, targetname, refuri, target, lineno):
|
|
2122
|
+
target.line = lineno
|
|
2123
|
+
if targetname:
|
|
2124
|
+
name = normalize_name(unescape(targetname))
|
|
2125
|
+
target['names'].append(name)
|
|
2126
|
+
if refuri:
|
|
2127
|
+
uri = self.inliner.adjust_uri(refuri)
|
|
2128
|
+
if uri:
|
|
2129
|
+
target['refuri'] = uri
|
|
2130
|
+
else:
|
|
2131
|
+
raise ApplicationError('problem with URI: %r' % refuri)
|
|
2132
|
+
self.document.note_explicit_target(target, self.parent)
|
|
2133
|
+
else: # anonymous target
|
|
2134
|
+
if refuri:
|
|
2135
|
+
target['refuri'] = refuri
|
|
2136
|
+
target['anonymous'] = True
|
|
2137
|
+
self.document.note_anonymous_target(target)
|
|
2138
|
+
|
|
2139
|
+
def substitution_def(self, match):
|
|
2140
|
+
pattern = self.explicit.patterns.substitution
|
|
2141
|
+
src, srcline = self.state_machine.get_source_and_line()
|
|
2142
|
+
(block, indent, offset, blank_finish
|
|
2143
|
+
) = self.state_machine.get_first_known_indented(match.end(),
|
|
2144
|
+
strip_indent=False)
|
|
2145
|
+
blocktext = (match.string[:match.end()] + '\n'.join(block))
|
|
2146
|
+
block.disconnect()
|
|
2147
|
+
escaped = escape2null(block[0].rstrip())
|
|
2148
|
+
blockindex = 0
|
|
2149
|
+
while True:
|
|
2150
|
+
subdefmatch = pattern.match(escaped)
|
|
2151
|
+
if subdefmatch:
|
|
2152
|
+
break
|
|
2153
|
+
blockindex += 1
|
|
2154
|
+
try:
|
|
2155
|
+
escaped = escaped + ' ' + escape2null(
|
|
2156
|
+
block[blockindex].strip())
|
|
2157
|
+
except IndexError:
|
|
2158
|
+
raise MarkupError('malformed substitution definition.')
|
|
2159
|
+
del block[:blockindex] # strip out the substitution marker
|
|
2160
|
+
start = subdefmatch.end()-len(escaped)-1
|
|
2161
|
+
block[0] = (block[0].strip() + ' ')[start:-1]
|
|
2162
|
+
if not block[0]:
|
|
2163
|
+
del block[0]
|
|
2164
|
+
offset += 1
|
|
2165
|
+
while block and not block[-1].strip():
|
|
2166
|
+
block.pop()
|
|
2167
|
+
subname = subdefmatch.group('name')
|
|
2168
|
+
substitution_node = nodes.substitution_definition(blocktext)
|
|
2169
|
+
substitution_node.source = src
|
|
2170
|
+
substitution_node.line = srcline
|
|
2171
|
+
if not block:
|
|
2172
|
+
msg = self.reporter.warning(
|
|
2173
|
+
'Substitution definition "%s" missing contents.' % subname,
|
|
2174
|
+
nodes.literal_block(blocktext, blocktext),
|
|
2175
|
+
source=src, line=srcline)
|
|
2176
|
+
return [msg], blank_finish
|
|
2177
|
+
block[0] = block[0].strip()
|
|
2178
|
+
substitution_node['names'].append(
|
|
2179
|
+
nodes.whitespace_normalize_name(subname))
|
|
2180
|
+
new_abs_offset, blank_finish = self.nested_list_parse(
|
|
2181
|
+
block, input_offset=offset, node=substitution_node,
|
|
2182
|
+
initial_state='SubstitutionDef', blank_finish=blank_finish)
|
|
2183
|
+
i = 0
|
|
2184
|
+
for node in substitution_node[:]:
|
|
2185
|
+
if not (isinstance(node, nodes.Inline)
|
|
2186
|
+
or isinstance(node, nodes.Text)):
|
|
2187
|
+
self.parent += substitution_node[i]
|
|
2188
|
+
del substitution_node[i]
|
|
2189
|
+
else:
|
|
2190
|
+
i += 1
|
|
2191
|
+
for node in substitution_node.findall(nodes.Element):
|
|
2192
|
+
if self.disallowed_inside_substitution_definitions(node):
|
|
2193
|
+
pformat = nodes.literal_block('', node.pformat().rstrip())
|
|
2194
|
+
msg = self.reporter.error(
|
|
2195
|
+
'Substitution definition contains illegal element <%s>:'
|
|
2196
|
+
% node.tagname,
|
|
2197
|
+
pformat, nodes.literal_block(blocktext, blocktext),
|
|
2198
|
+
source=src, line=srcline)
|
|
2199
|
+
return [msg], blank_finish
|
|
2200
|
+
if len(substitution_node) == 0:
|
|
2201
|
+
msg = self.reporter.warning(
|
|
2202
|
+
'Substitution definition "%s" empty or invalid.' % subname,
|
|
2203
|
+
nodes.literal_block(blocktext, blocktext),
|
|
2204
|
+
source=src, line=srcline)
|
|
2205
|
+
return [msg], blank_finish
|
|
2206
|
+
self.document.note_substitution_def(
|
|
2207
|
+
substitution_node, subname, self.parent)
|
|
2208
|
+
return [substitution_node], blank_finish
|
|
2209
|
+
|
|
2210
|
+
def disallowed_inside_substitution_definitions(self, node) -> bool:
|
|
2211
|
+
if (node['ids']
|
|
2212
|
+
or isinstance(node, nodes.reference) and node.get('anonymous')
|
|
2213
|
+
or isinstance(node, nodes.footnote_reference) and node.get('auto')): # noqa: E501
|
|
2214
|
+
return True
|
|
2215
|
+
else:
|
|
2216
|
+
return False
|
|
2217
|
+
|
|
2218
|
+
def directive(self, match, **option_presets):
|
|
2219
|
+
"""Returns a 2-tuple: list of nodes, and a "blank finish" boolean."""
|
|
2220
|
+
type_name = match.group(1)
|
|
2221
|
+
directive_class, messages = directives.directive(
|
|
2222
|
+
type_name, self.memo.language, self.document)
|
|
2223
|
+
self.parent += messages
|
|
2224
|
+
if directive_class:
|
|
2225
|
+
return self.run_directive(
|
|
2226
|
+
directive_class, match, type_name, option_presets)
|
|
2227
|
+
else:
|
|
2228
|
+
return self.unknown_directive(type_name)
|
|
2229
|
+
|
|
2230
|
+
def run_directive(self, directive, match, type_name, option_presets):
|
|
2231
|
+
"""
|
|
2232
|
+
Parse a directive then run its directive function.
|
|
2233
|
+
|
|
2234
|
+
Parameters:
|
|
2235
|
+
|
|
2236
|
+
- `directive`: The class implementing the directive. Must be
|
|
2237
|
+
a subclass of `rst.Directive`.
|
|
2238
|
+
|
|
2239
|
+
- `match`: A regular expression match object which matched the first
|
|
2240
|
+
line of the directive.
|
|
2241
|
+
|
|
2242
|
+
- `type_name`: The directive name, as used in the source text.
|
|
2243
|
+
|
|
2244
|
+
- `option_presets`: A dictionary of preset options, defaults for the
|
|
2245
|
+
directive options. Currently, only an "alt" option is passed by
|
|
2246
|
+
substitution definitions (value: the substitution name), which may
|
|
2247
|
+
be used by an embedded image directive.
|
|
2248
|
+
|
|
2249
|
+
Returns a 2-tuple: list of nodes, and a "blank finish" boolean.
|
|
2250
|
+
"""
|
|
2251
|
+
if isinstance(directive, (FunctionType, MethodType)):
|
|
2252
|
+
from docutils.parsers.rst import convert_directive_function
|
|
2253
|
+
directive = convert_directive_function(directive)
|
|
2254
|
+
lineno = self.state_machine.abs_line_number()
|
|
2255
|
+
initial_line_offset = self.state_machine.line_offset
|
|
2256
|
+
(indented, indent, line_offset, blank_finish
|
|
2257
|
+
) = self.state_machine.get_first_known_indented(match.end(),
|
|
2258
|
+
strip_top=0)
|
|
2259
|
+
block_text = '\n'.join(self.state_machine.input_lines[
|
|
2260
|
+
initial_line_offset : self.state_machine.line_offset + 1]) # noqa: E203,E501
|
|
2261
|
+
try:
|
|
2262
|
+
arguments, options, content, content_offset = (
|
|
2263
|
+
self.parse_directive_block(indented, line_offset,
|
|
2264
|
+
directive, option_presets))
|
|
2265
|
+
except MarkupError as detail:
|
|
2266
|
+
error = self.reporter.error(
|
|
2267
|
+
'Error in "%s" directive:\n%s.' % (type_name,
|
|
2268
|
+
' '.join(detail.args)),
|
|
2269
|
+
nodes.literal_block(block_text, block_text), line=lineno)
|
|
2270
|
+
return [error], blank_finish
|
|
2271
|
+
directive_instance = directive(
|
|
2272
|
+
type_name, arguments, options, content, lineno,
|
|
2273
|
+
content_offset, block_text, self, self.state_machine)
|
|
2274
|
+
try:
|
|
2275
|
+
result = directive_instance.run()
|
|
2276
|
+
except docutils.parsers.rst.DirectiveError as error:
|
|
2277
|
+
msg_node = self.reporter.system_message(error.level, error.msg,
|
|
2278
|
+
line=lineno)
|
|
2279
|
+
msg_node += nodes.literal_block(block_text, block_text)
|
|
2280
|
+
result = [msg_node]
|
|
2281
|
+
assert isinstance(result, list), \
|
|
2282
|
+
'Directive "%s" must return a list of nodes.' % type_name
|
|
2283
|
+
for i in range(len(result)):
|
|
2284
|
+
assert isinstance(result[i], nodes.Node), \
|
|
2285
|
+
('Directive "%s" returned non-Node object (index %s): %r'
|
|
2286
|
+
% (type_name, i, result[i]))
|
|
2287
|
+
return (result,
|
|
2288
|
+
blank_finish or self.state_machine.is_next_line_blank())
|
|
2289
|
+
|
|
2290
|
+
def parse_directive_block(self, indented, line_offset, directive,
|
|
2291
|
+
option_presets):
|
|
2292
|
+
option_spec = directive.option_spec
|
|
2293
|
+
has_content = directive.has_content
|
|
2294
|
+
if indented and not indented[0].strip():
|
|
2295
|
+
indented.trim_start()
|
|
2296
|
+
line_offset += 1
|
|
2297
|
+
while indented and not indented[-1].strip():
|
|
2298
|
+
indented.trim_end()
|
|
2299
|
+
if indented and (directive.required_arguments
|
|
2300
|
+
or directive.optional_arguments
|
|
2301
|
+
or option_spec):
|
|
2302
|
+
for i, line in enumerate(indented):
|
|
2303
|
+
if not line.strip():
|
|
2304
|
+
break
|
|
2305
|
+
else:
|
|
2306
|
+
i += 1
|
|
2307
|
+
arg_block = indented[:i]
|
|
2308
|
+
content = indented[i+1:]
|
|
2309
|
+
content_offset = line_offset + i + 1
|
|
2310
|
+
else:
|
|
2311
|
+
content = indented
|
|
2312
|
+
content_offset = line_offset
|
|
2313
|
+
arg_block = []
|
|
2314
|
+
if option_spec:
|
|
2315
|
+
options, arg_block = self.parse_directive_options(
|
|
2316
|
+
option_presets, option_spec, arg_block)
|
|
2317
|
+
else:
|
|
2318
|
+
options = {}
|
|
2319
|
+
if arg_block and not (directive.required_arguments
|
|
2320
|
+
or directive.optional_arguments):
|
|
2321
|
+
content = arg_block + indented[i:]
|
|
2322
|
+
content_offset = line_offset
|
|
2323
|
+
arg_block = []
|
|
2324
|
+
while content and not content[0].strip():
|
|
2325
|
+
content.trim_start()
|
|
2326
|
+
content_offset += 1
|
|
2327
|
+
if directive.required_arguments or directive.optional_arguments:
|
|
2328
|
+
arguments = self.parse_directive_arguments(
|
|
2329
|
+
directive, arg_block)
|
|
2330
|
+
else:
|
|
2331
|
+
arguments = []
|
|
2332
|
+
if content and not has_content:
|
|
2333
|
+
raise MarkupError('no content permitted')
|
|
2334
|
+
return arguments, options, content, content_offset
|
|
2335
|
+
|
|
2336
|
+
def parse_directive_options(self, option_presets, option_spec, arg_block):
|
|
2337
|
+
options = option_presets.copy()
|
|
2338
|
+
for i, line in enumerate(arg_block):
|
|
2339
|
+
if re.match(Body.patterns['field_marker'], line):
|
|
2340
|
+
opt_block = arg_block[i:]
|
|
2341
|
+
arg_block = arg_block[:i]
|
|
2342
|
+
break
|
|
2343
|
+
else:
|
|
2344
|
+
opt_block = []
|
|
2345
|
+
if opt_block:
|
|
2346
|
+
success, data = self.parse_extension_options(option_spec,
|
|
2347
|
+
opt_block)
|
|
2348
|
+
if success: # data is a dict of options
|
|
2349
|
+
options.update(data)
|
|
2350
|
+
else: # data is an error string
|
|
2351
|
+
raise MarkupError(data)
|
|
2352
|
+
return options, arg_block
|
|
2353
|
+
|
|
2354
|
+
def parse_directive_arguments(self, directive, arg_block):
|
|
2355
|
+
required = directive.required_arguments
|
|
2356
|
+
optional = directive.optional_arguments
|
|
2357
|
+
arg_text = '\n'.join(arg_block)
|
|
2358
|
+
arguments = arg_text.split()
|
|
2359
|
+
if len(arguments) < required:
|
|
2360
|
+
raise MarkupError('%s argument(s) required, %s supplied'
|
|
2361
|
+
% (required, len(arguments)))
|
|
2362
|
+
elif len(arguments) > required + optional:
|
|
2363
|
+
if directive.final_argument_whitespace:
|
|
2364
|
+
arguments = arg_text.split(None, required + optional - 1)
|
|
2365
|
+
else:
|
|
2366
|
+
raise MarkupError(
|
|
2367
|
+
'maximum %s argument(s) allowed, %s supplied'
|
|
2368
|
+
% (required + optional, len(arguments)))
|
|
2369
|
+
return arguments
|
|
2370
|
+
|
|
2371
|
+
def parse_extension_options(self, option_spec, datalines):
|
|
2372
|
+
"""
|
|
2373
|
+
Parse `datalines` for a field list containing extension options
|
|
2374
|
+
matching `option_spec`.
|
|
2375
|
+
|
|
2376
|
+
:Parameters:
|
|
2377
|
+
- `option_spec`: a mapping of option name to conversion
|
|
2378
|
+
function, which should raise an exception on bad input.
|
|
2379
|
+
- `datalines`: a list of input strings.
|
|
2380
|
+
|
|
2381
|
+
:Return:
|
|
2382
|
+
- Success value, 1 or 0.
|
|
2383
|
+
- An option dictionary on success, an error string on failure.
|
|
2384
|
+
"""
|
|
2385
|
+
node = nodes.field_list()
|
|
2386
|
+
newline_offset, blank_finish = self.nested_list_parse(
|
|
2387
|
+
datalines, 0, node, initial_state='ExtensionOptions',
|
|
2388
|
+
blank_finish=True)
|
|
2389
|
+
if newline_offset != len(datalines): # incomplete parse of block
|
|
2390
|
+
return 0, 'invalid option block'
|
|
2391
|
+
try:
|
|
2392
|
+
options = utils.extract_extension_options(node, option_spec)
|
|
2393
|
+
except KeyError as detail:
|
|
2394
|
+
return 0, 'unknown option: "%s"' % detail.args[0]
|
|
2395
|
+
except (ValueError, TypeError) as detail:
|
|
2396
|
+
return 0, 'invalid option value: %s' % ' '.join(detail.args)
|
|
2397
|
+
except utils.ExtensionOptionError as detail:
|
|
2398
|
+
return 0, 'invalid option data: %s' % ' '.join(detail.args)
|
|
2399
|
+
if blank_finish:
|
|
2400
|
+
return 1, options
|
|
2401
|
+
else:
|
|
2402
|
+
return 0, 'option data incompletely parsed'
|
|
2403
|
+
|
|
2404
|
+
def unknown_directive(self, type_name):
|
|
2405
|
+
lineno = self.state_machine.abs_line_number()
|
|
2406
|
+
(indented, indent, offset, blank_finish
|
|
2407
|
+
) = self.state_machine.get_first_known_indented(0, strip_indent=False)
|
|
2408
|
+
text = '\n'.join(indented)
|
|
2409
|
+
error = self.reporter.error('Unknown directive type "%s".' % type_name,
|
|
2410
|
+
nodes.literal_block(text, text),
|
|
2411
|
+
line=lineno)
|
|
2412
|
+
return [error], blank_finish
|
|
2413
|
+
|
|
2414
|
+
def comment(self, match):
|
|
2415
|
+
if self.state_machine.is_next_line_blank():
|
|
2416
|
+
first_comment_line = match.string[match.end():]
|
|
2417
|
+
if not first_comment_line.strip(): # empty comment
|
|
2418
|
+
return [nodes.comment()], True # "A tiny but practical wart."
|
|
2419
|
+
if first_comment_line.startswith('end of inclusion from "'):
|
|
2420
|
+
# cf. parsers.rst.directives.misc.Include
|
|
2421
|
+
self.document.include_log.pop()
|
|
2422
|
+
return [], True
|
|
2423
|
+
(indented, indent, offset, blank_finish
|
|
2424
|
+
) = self.state_machine.get_first_known_indented(match.end())
|
|
2425
|
+
while indented and not indented[-1].strip():
|
|
2426
|
+
indented.trim_end()
|
|
2427
|
+
text = '\n'.join(indented)
|
|
2428
|
+
return [nodes.comment(text, text)], blank_finish
|
|
2429
|
+
|
|
2430
|
+
explicit.constructs = [
|
|
2431
|
+
(footnote,
|
|
2432
|
+
re.compile(r"""
|
|
2433
|
+
\.\.[ ]+ # explicit markup start
|
|
2434
|
+
\[
|
|
2435
|
+
( # footnote label:
|
|
2436
|
+
[0-9]+ # manually numbered footnote
|
|
2437
|
+
| # *OR*
|
|
2438
|
+
\# # anonymous auto-numbered footnote
|
|
2439
|
+
| # *OR*
|
|
2440
|
+
\#%s # auto-number ed?) footnote label
|
|
2441
|
+
| # *OR*
|
|
2442
|
+
\* # auto-symbol footnote
|
|
2443
|
+
)
|
|
2444
|
+
\]
|
|
2445
|
+
([ ]+|$) # whitespace or end of line
|
|
2446
|
+
""" % Inliner.simplename, re.VERBOSE)),
|
|
2447
|
+
(citation,
|
|
2448
|
+
re.compile(r"""
|
|
2449
|
+
\.\.[ ]+ # explicit markup start
|
|
2450
|
+
\[(%s)\] # citation label
|
|
2451
|
+
([ ]+|$) # whitespace or end of line
|
|
2452
|
+
""" % Inliner.simplename, re.VERBOSE)),
|
|
2453
|
+
(hyperlink_target,
|
|
2454
|
+
re.compile(r"""
|
|
2455
|
+
\.\.[ ]+ # explicit markup start
|
|
2456
|
+
_ # target indicator
|
|
2457
|
+
(?![ ]|$) # first char. not space or EOL
|
|
2458
|
+
""", re.VERBOSE)),
|
|
2459
|
+
(substitution_def,
|
|
2460
|
+
re.compile(r"""
|
|
2461
|
+
\.\.[ ]+ # explicit markup start
|
|
2462
|
+
\| # substitution indicator
|
|
2463
|
+
(?![ ]|$) # first char. not space or EOL
|
|
2464
|
+
""", re.VERBOSE)),
|
|
2465
|
+
(directive,
|
|
2466
|
+
re.compile(r"""
|
|
2467
|
+
\.\.[ ]+ # explicit markup start
|
|
2468
|
+
(%s) # directive name
|
|
2469
|
+
[ ]? # optional space
|
|
2470
|
+
:: # directive delimiter
|
|
2471
|
+
([ ]+|$) # whitespace or end of line
|
|
2472
|
+
""" % Inliner.simplename, re.VERBOSE))]
|
|
2473
|
+
|
|
2474
|
+
def explicit_markup(self, match, context, next_state):
|
|
2475
|
+
"""Footnotes, hyperlink targets, directives, comments."""
|
|
2476
|
+
nodelist, blank_finish = self.explicit_construct(match)
|
|
2477
|
+
self.parent += nodelist
|
|
2478
|
+
self.explicit_list(blank_finish)
|
|
2479
|
+
return [], next_state, []
|
|
2480
|
+
|
|
2481
|
+
def explicit_construct(self, match):
|
|
2482
|
+
"""Determine which explicit construct this is, parse & return it."""
|
|
2483
|
+
errors = []
|
|
2484
|
+
for method, pattern in self.explicit.constructs:
|
|
2485
|
+
expmatch = pattern.match(match.string)
|
|
2486
|
+
if expmatch:
|
|
2487
|
+
try:
|
|
2488
|
+
return method(self, expmatch)
|
|
2489
|
+
except MarkupError as error:
|
|
2490
|
+
lineno = self.state_machine.abs_line_number()
|
|
2491
|
+
message = ' '.join(error.args)
|
|
2492
|
+
errors.append(self.reporter.warning(message, line=lineno))
|
|
2493
|
+
break
|
|
2494
|
+
nodelist, blank_finish = self.comment(match)
|
|
2495
|
+
return nodelist + errors, blank_finish
|
|
2496
|
+
|
|
2497
|
+
def explicit_list(self, blank_finish) -> None:
|
|
2498
|
+
"""
|
|
2499
|
+
Create a nested state machine for a series of explicit markup
|
|
2500
|
+
constructs (including anonymous hyperlink targets).
|
|
2501
|
+
"""
|
|
2502
|
+
offset = self.state_machine.line_offset + 1 # next line
|
|
2503
|
+
newline_offset, blank_finish = self.nested_list_parse(
|
|
2504
|
+
self.state_machine.input_lines[offset:],
|
|
2505
|
+
input_offset=self.state_machine.abs_line_offset() + 1,
|
|
2506
|
+
node=self.parent, initial_state='Explicit',
|
|
2507
|
+
blank_finish=blank_finish)
|
|
2508
|
+
self.goto_line(newline_offset)
|
|
2509
|
+
if not blank_finish:
|
|
2510
|
+
self.parent += self.unindent_warning('Explicit markup')
|
|
2511
|
+
|
|
2512
|
+
def anonymous(self, match, context, next_state):
|
|
2513
|
+
"""Anonymous hyperlink targets."""
|
|
2514
|
+
nodelist, blank_finish = self.anonymous_target(match)
|
|
2515
|
+
self.parent += nodelist
|
|
2516
|
+
self.explicit_list(blank_finish)
|
|
2517
|
+
return [], next_state, []
|
|
2518
|
+
|
|
2519
|
+
def anonymous_target(self, match):
|
|
2520
|
+
lineno = self.state_machine.abs_line_number()
|
|
2521
|
+
(block, indent, offset, blank_finish
|
|
2522
|
+
) = self.state_machine.get_first_known_indented(match.end(),
|
|
2523
|
+
until_blank=True)
|
|
2524
|
+
blocktext = match.string[:match.end()] + '\n'.join(block)
|
|
2525
|
+
block = [escape2null(line) for line in block]
|
|
2526
|
+
target = self.make_target(block, blocktext, lineno, '')
|
|
2527
|
+
return [target], blank_finish
|
|
2528
|
+
|
|
2529
|
+
def line(self, match, context, next_state):
|
|
2530
|
+
"""Section title overline or transition marker."""
|
|
2531
|
+
if self.state_machine.match_titles:
|
|
2532
|
+
return [match.string], 'Line', []
|
|
2533
|
+
elif match.string.strip() == '::':
|
|
2534
|
+
raise statemachine.TransitionCorrection('text')
|
|
2535
|
+
elif len(match.string.strip()) < 4:
|
|
2536
|
+
msg = self.reporter.info(
|
|
2537
|
+
'Unexpected possible title overline or transition.\n'
|
|
2538
|
+
"Treating it as ordinary text because it's so short.",
|
|
2539
|
+
line=self.state_machine.abs_line_number())
|
|
2540
|
+
self.parent += msg
|
|
2541
|
+
raise statemachine.TransitionCorrection('text')
|
|
2542
|
+
else:
|
|
2543
|
+
blocktext = self.state_machine.line
|
|
2544
|
+
msg = self.reporter.error(
|
|
2545
|
+
'Unexpected section title or transition.',
|
|
2546
|
+
nodes.literal_block(blocktext, blocktext),
|
|
2547
|
+
line=self.state_machine.abs_line_number())
|
|
2548
|
+
self.parent += msg
|
|
2549
|
+
return [], next_state, []
|
|
2550
|
+
|
|
2551
|
+
def text(self, match, context, next_state):
|
|
2552
|
+
"""Titles, definition lists, paragraphs."""
|
|
2553
|
+
return [match.string], 'Text', []
|
|
2554
|
+
|
|
2555
|
+
|
|
2556
|
+
class RFC2822Body(Body):
|
|
2557
|
+
|
|
2558
|
+
"""
|
|
2559
|
+
RFC2822 headers are only valid as the first constructs in documents. As
|
|
2560
|
+
soon as anything else appears, the `Body` state should take over.
|
|
2561
|
+
"""
|
|
2562
|
+
|
|
2563
|
+
patterns = Body.patterns.copy() # can't modify the original
|
|
2564
|
+
patterns['rfc2822'] = r'[!-9;-~]+:( +|$)'
|
|
2565
|
+
initial_transitions = [(name, 'Body')
|
|
2566
|
+
for name in Body.initial_transitions]
|
|
2567
|
+
initial_transitions.insert(-1, ('rfc2822', 'Body')) # just before 'text'
|
|
2568
|
+
|
|
2569
|
+
def rfc2822(self, match, context, next_state):
|
|
2570
|
+
"""RFC2822-style field list item."""
|
|
2571
|
+
fieldlist = nodes.field_list(classes=['rfc2822'])
|
|
2572
|
+
self.parent += fieldlist
|
|
2573
|
+
field, blank_finish = self.rfc2822_field(match)
|
|
2574
|
+
fieldlist += field
|
|
2575
|
+
offset = self.state_machine.line_offset + 1 # next line
|
|
2576
|
+
newline_offset, blank_finish = self.nested_list_parse(
|
|
2577
|
+
self.state_machine.input_lines[offset:],
|
|
2578
|
+
input_offset=self.state_machine.abs_line_offset() + 1,
|
|
2579
|
+
node=fieldlist, initial_state='RFC2822List',
|
|
2580
|
+
blank_finish=blank_finish)
|
|
2581
|
+
self.goto_line(newline_offset)
|
|
2582
|
+
if not blank_finish:
|
|
2583
|
+
self.parent += self.unindent_warning(
|
|
2584
|
+
'RFC2822-style field list')
|
|
2585
|
+
return [], next_state, []
|
|
2586
|
+
|
|
2587
|
+
def rfc2822_field(self, match):
|
|
2588
|
+
name = match.string[:match.string.find(':')]
|
|
2589
|
+
(indented, indent, line_offset, blank_finish
|
|
2590
|
+
) = self.state_machine.get_first_known_indented(match.end(),
|
|
2591
|
+
until_blank=True)
|
|
2592
|
+
fieldnode = nodes.field()
|
|
2593
|
+
fieldnode += nodes.field_name(name, name)
|
|
2594
|
+
fieldbody = nodes.field_body('\n'.join(indented))
|
|
2595
|
+
fieldnode += fieldbody
|
|
2596
|
+
if indented:
|
|
2597
|
+
self.nested_parse(indented, input_offset=line_offset,
|
|
2598
|
+
node=fieldbody)
|
|
2599
|
+
return fieldnode, blank_finish
|
|
2600
|
+
|
|
2601
|
+
|
|
2602
|
+
class SpecializedBody(Body):
|
|
2603
|
+
|
|
2604
|
+
"""
|
|
2605
|
+
Superclass for second and subsequent compound element members. Compound
|
|
2606
|
+
elements are lists and list-like constructs.
|
|
2607
|
+
|
|
2608
|
+
All transition methods are disabled (redefined as `invalid_input`).
|
|
2609
|
+
Override individual methods in subclasses to re-enable.
|
|
2610
|
+
|
|
2611
|
+
For example, once an initial bullet list item, say, is recognized, the
|
|
2612
|
+
`BulletList` subclass takes over, with a "bullet_list" node as its
|
|
2613
|
+
container. Upon encountering the initial bullet list item, `Body.bullet`
|
|
2614
|
+
calls its ``self.nested_list_parse`` (`RSTState.nested_list_parse`), which
|
|
2615
|
+
starts up a nested parsing session with `BulletList` as the initial state.
|
|
2616
|
+
Only the ``bullet`` transition method is enabled in `BulletList`; as long
|
|
2617
|
+
as only bullet list items are encountered, they are parsed and inserted
|
|
2618
|
+
into the container. The first construct which is *not* a bullet list item
|
|
2619
|
+
triggers the `invalid_input` method, which ends the nested parse and
|
|
2620
|
+
closes the container. `BulletList` needs to recognize input that is
|
|
2621
|
+
invalid in the context of a bullet list, which means everything *other
|
|
2622
|
+
than* bullet list items, so it inherits the transition list created in
|
|
2623
|
+
`Body`.
|
|
2624
|
+
"""
|
|
2625
|
+
|
|
2626
|
+
def invalid_input(self, match=None, context=None, next_state=None):
|
|
2627
|
+
"""Not a compound element member. Abort this state machine."""
|
|
2628
|
+
self.state_machine.previous_line() # back up so parent SM can reassess
|
|
2629
|
+
raise EOFError
|
|
2630
|
+
|
|
2631
|
+
indent = invalid_input
|
|
2632
|
+
bullet = invalid_input
|
|
2633
|
+
enumerator = invalid_input
|
|
2634
|
+
field_marker = invalid_input
|
|
2635
|
+
option_marker = invalid_input
|
|
2636
|
+
doctest = invalid_input
|
|
2637
|
+
line_block = invalid_input
|
|
2638
|
+
grid_table_top = invalid_input
|
|
2639
|
+
simple_table_top = invalid_input
|
|
2640
|
+
explicit_markup = invalid_input
|
|
2641
|
+
anonymous = invalid_input
|
|
2642
|
+
line = invalid_input
|
|
2643
|
+
text = invalid_input
|
|
2644
|
+
|
|
2645
|
+
|
|
2646
|
+
class BulletList(SpecializedBody):
|
|
2647
|
+
|
|
2648
|
+
"""Second and subsequent bullet_list list_items."""
|
|
2649
|
+
|
|
2650
|
+
def bullet(self, match, context, next_state):
|
|
2651
|
+
"""Bullet list item."""
|
|
2652
|
+
if match.string[0] != self.parent['bullet']:
|
|
2653
|
+
# different bullet: new list
|
|
2654
|
+
self.invalid_input()
|
|
2655
|
+
listitem, blank_finish = self.list_item(match.end())
|
|
2656
|
+
self.parent += listitem
|
|
2657
|
+
self.blank_finish = blank_finish
|
|
2658
|
+
return [], next_state, []
|
|
2659
|
+
|
|
2660
|
+
|
|
2661
|
+
class DefinitionList(SpecializedBody):
|
|
2662
|
+
|
|
2663
|
+
"""Second and subsequent definition_list_items."""
|
|
2664
|
+
|
|
2665
|
+
def text(self, match, context, next_state):
|
|
2666
|
+
"""Definition lists."""
|
|
2667
|
+
return [match.string], 'Definition', []
|
|
2668
|
+
|
|
2669
|
+
|
|
2670
|
+
class EnumeratedList(SpecializedBody):
|
|
2671
|
+
|
|
2672
|
+
"""Second and subsequent enumerated_list list_items."""
|
|
2673
|
+
|
|
2674
|
+
def enumerator(self, match, context, next_state):
|
|
2675
|
+
"""Enumerated list item."""
|
|
2676
|
+
format, sequence, text, ordinal = self.parse_enumerator(
|
|
2677
|
+
match, self.parent['enumtype'])
|
|
2678
|
+
if (format != self.format
|
|
2679
|
+
or (sequence != '#' and (sequence != self.parent['enumtype']
|
|
2680
|
+
or self.auto
|
|
2681
|
+
or ordinal != (self.lastordinal + 1)))
|
|
2682
|
+
or not self.is_enumerated_list_item(ordinal, sequence, format)):
|
|
2683
|
+
# different enumeration: new list
|
|
2684
|
+
self.invalid_input()
|
|
2685
|
+
if sequence == '#':
|
|
2686
|
+
self.auto = 1
|
|
2687
|
+
listitem, blank_finish = self.list_item(match.end())
|
|
2688
|
+
self.parent += listitem
|
|
2689
|
+
self.blank_finish = blank_finish
|
|
2690
|
+
self.lastordinal = ordinal
|
|
2691
|
+
return [], next_state, []
|
|
2692
|
+
|
|
2693
|
+
|
|
2694
|
+
class FieldList(SpecializedBody):
|
|
2695
|
+
|
|
2696
|
+
"""Second and subsequent field_list fields."""
|
|
2697
|
+
|
|
2698
|
+
def field_marker(self, match, context, next_state):
|
|
2699
|
+
"""Field list field."""
|
|
2700
|
+
field, blank_finish = self.field(match)
|
|
2701
|
+
self.parent += field
|
|
2702
|
+
self.blank_finish = blank_finish
|
|
2703
|
+
return [], next_state, []
|
|
2704
|
+
|
|
2705
|
+
|
|
2706
|
+
class OptionList(SpecializedBody):
|
|
2707
|
+
|
|
2708
|
+
"""Second and subsequent option_list option_list_items."""
|
|
2709
|
+
|
|
2710
|
+
def option_marker(self, match, context, next_state):
|
|
2711
|
+
"""Option list item."""
|
|
2712
|
+
try:
|
|
2713
|
+
option_list_item, blank_finish = self.option_list_item(match)
|
|
2714
|
+
except MarkupError:
|
|
2715
|
+
self.invalid_input()
|
|
2716
|
+
self.parent += option_list_item
|
|
2717
|
+
self.blank_finish = blank_finish
|
|
2718
|
+
return [], next_state, []
|
|
2719
|
+
|
|
2720
|
+
|
|
2721
|
+
class RFC2822List(SpecializedBody, RFC2822Body):
|
|
2722
|
+
|
|
2723
|
+
"""Second and subsequent RFC2822-style field_list fields."""
|
|
2724
|
+
|
|
2725
|
+
patterns = RFC2822Body.patterns
|
|
2726
|
+
initial_transitions = RFC2822Body.initial_transitions
|
|
2727
|
+
|
|
2728
|
+
def rfc2822(self, match, context, next_state):
|
|
2729
|
+
"""RFC2822-style field list item."""
|
|
2730
|
+
field, blank_finish = self.rfc2822_field(match)
|
|
2731
|
+
self.parent += field
|
|
2732
|
+
self.blank_finish = blank_finish
|
|
2733
|
+
return [], 'RFC2822List', []
|
|
2734
|
+
|
|
2735
|
+
blank = SpecializedBody.invalid_input
|
|
2736
|
+
|
|
2737
|
+
|
|
2738
|
+
class ExtensionOptions(FieldList):
|
|
2739
|
+
|
|
2740
|
+
"""
|
|
2741
|
+
Parse field_list fields for extension options.
|
|
2742
|
+
|
|
2743
|
+
No nested parsing is done (including inline markup parsing).
|
|
2744
|
+
"""
|
|
2745
|
+
|
|
2746
|
+
def parse_field_body(self, indented, offset, node) -> None:
|
|
2747
|
+
"""Override `Body.parse_field_body` for simpler parsing."""
|
|
2748
|
+
lines = []
|
|
2749
|
+
for line in list(indented) + ['']:
|
|
2750
|
+
if line.strip():
|
|
2751
|
+
lines.append(line)
|
|
2752
|
+
elif lines:
|
|
2753
|
+
text = '\n'.join(lines)
|
|
2754
|
+
node += nodes.paragraph(text, text)
|
|
2755
|
+
lines = []
|
|
2756
|
+
|
|
2757
|
+
|
|
2758
|
+
class LineBlock(SpecializedBody):
|
|
2759
|
+
|
|
2760
|
+
"""Second and subsequent lines of a line_block."""
|
|
2761
|
+
|
|
2762
|
+
blank = SpecializedBody.invalid_input
|
|
2763
|
+
|
|
2764
|
+
def line_block(self, match, context, next_state):
|
|
2765
|
+
"""New line of line block."""
|
|
2766
|
+
lineno = self.state_machine.abs_line_number()
|
|
2767
|
+
line, messages, blank_finish = self.line_block_line(match, lineno)
|
|
2768
|
+
self.parent += line
|
|
2769
|
+
self.parent.parent += messages
|
|
2770
|
+
self.blank_finish = blank_finish
|
|
2771
|
+
return [], next_state, []
|
|
2772
|
+
|
|
2773
|
+
|
|
2774
|
+
class Explicit(SpecializedBody):
|
|
2775
|
+
|
|
2776
|
+
"""Second and subsequent explicit markup construct."""
|
|
2777
|
+
|
|
2778
|
+
def explicit_markup(self, match, context, next_state):
|
|
2779
|
+
"""Footnotes, hyperlink targets, directives, comments."""
|
|
2780
|
+
nodelist, blank_finish = self.explicit_construct(match)
|
|
2781
|
+
self.parent += nodelist
|
|
2782
|
+
self.blank_finish = blank_finish
|
|
2783
|
+
return [], next_state, []
|
|
2784
|
+
|
|
2785
|
+
def anonymous(self, match, context, next_state):
|
|
2786
|
+
"""Anonymous hyperlink targets."""
|
|
2787
|
+
nodelist, blank_finish = self.anonymous_target(match)
|
|
2788
|
+
self.parent += nodelist
|
|
2789
|
+
self.blank_finish = blank_finish
|
|
2790
|
+
return [], next_state, []
|
|
2791
|
+
|
|
2792
|
+
blank = SpecializedBody.invalid_input
|
|
2793
|
+
|
|
2794
|
+
|
|
2795
|
+
class SubstitutionDef(Body):
|
|
2796
|
+
|
|
2797
|
+
"""
|
|
2798
|
+
Parser for the contents of a substitution_definition element.
|
|
2799
|
+
"""
|
|
2800
|
+
|
|
2801
|
+
patterns = {
|
|
2802
|
+
'embedded_directive': re.compile(r'(%s)::( +|$)'
|
|
2803
|
+
% Inliner.simplename),
|
|
2804
|
+
'text': r''}
|
|
2805
|
+
initial_transitions = ['embedded_directive', 'text']
|
|
2806
|
+
|
|
2807
|
+
def embedded_directive(self, match, context, next_state):
|
|
2808
|
+
nodelist, blank_finish = self.directive(match,
|
|
2809
|
+
alt=self.parent['names'][0])
|
|
2810
|
+
self.parent += nodelist
|
|
2811
|
+
if not self.state_machine.at_eof():
|
|
2812
|
+
self.blank_finish = blank_finish
|
|
2813
|
+
raise EOFError
|
|
2814
|
+
|
|
2815
|
+
def text(self, match, context, next_state):
|
|
2816
|
+
if not self.state_machine.at_eof():
|
|
2817
|
+
self.blank_finish = self.state_machine.is_next_line_blank()
|
|
2818
|
+
raise EOFError
|
|
2819
|
+
|
|
2820
|
+
|
|
2821
|
+
class Text(RSTState):
|
|
2822
|
+
|
|
2823
|
+
"""
|
|
2824
|
+
Classifier of second line of a text block.
|
|
2825
|
+
|
|
2826
|
+
Could be a paragraph, a definition list item, or a title.
|
|
2827
|
+
"""
|
|
2828
|
+
|
|
2829
|
+
patterns = {'underline': Body.patterns['line'],
|
|
2830
|
+
'text': r''}
|
|
2831
|
+
initial_transitions = [('underline', 'Body'), ('text', 'Body')]
|
|
2832
|
+
|
|
2833
|
+
def blank(self, match, context, next_state):
|
|
2834
|
+
"""End of paragraph."""
|
|
2835
|
+
# NOTE: self.paragraph returns [node, system_message(s)], literalnext
|
|
2836
|
+
paragraph, literalnext = self.paragraph(
|
|
2837
|
+
context, self.state_machine.abs_line_number() - 1)
|
|
2838
|
+
self.parent += paragraph
|
|
2839
|
+
if literalnext:
|
|
2840
|
+
self.parent += self.literal_block()
|
|
2841
|
+
return [], 'Body', []
|
|
2842
|
+
|
|
2843
|
+
def eof(self, context):
|
|
2844
|
+
if context:
|
|
2845
|
+
self.blank(None, context, None)
|
|
2846
|
+
return []
|
|
2847
|
+
|
|
2848
|
+
def indent(self, match, context, next_state):
|
|
2849
|
+
"""Definition list item."""
|
|
2850
|
+
dl = nodes.definition_list()
|
|
2851
|
+
# the definition list starts on the line before the indent:
|
|
2852
|
+
lineno = self.state_machine.abs_line_number() - 1
|
|
2853
|
+
dl.source, dl.line = self.state_machine.get_source_and_line(lineno)
|
|
2854
|
+
dl_item, blank_finish = self.definition_list_item(context)
|
|
2855
|
+
dl += dl_item
|
|
2856
|
+
self.parent += dl
|
|
2857
|
+
offset = self.state_machine.line_offset + 1 # next line
|
|
2858
|
+
newline_offset, blank_finish = self.nested_list_parse(
|
|
2859
|
+
self.state_machine.input_lines[offset:],
|
|
2860
|
+
input_offset=self.state_machine.abs_line_offset() + 1,
|
|
2861
|
+
node=dl, initial_state='DefinitionList',
|
|
2862
|
+
blank_finish=blank_finish, blank_finish_state='Definition')
|
|
2863
|
+
self.goto_line(newline_offset)
|
|
2864
|
+
if not blank_finish:
|
|
2865
|
+
self.parent += self.unindent_warning('Definition list')
|
|
2866
|
+
return [], 'Body', []
|
|
2867
|
+
|
|
2868
|
+
def underline(self, match, context, next_state):
|
|
2869
|
+
"""Section title."""
|
|
2870
|
+
lineno = self.state_machine.abs_line_number()
|
|
2871
|
+
title = context[0].rstrip()
|
|
2872
|
+
underline = match.string.rstrip()
|
|
2873
|
+
source = title + '\n' + underline
|
|
2874
|
+
messages = []
|
|
2875
|
+
if column_width(title) > len(underline):
|
|
2876
|
+
if len(underline) < 4:
|
|
2877
|
+
if self.state_machine.match_titles:
|
|
2878
|
+
msg = self.reporter.info(
|
|
2879
|
+
'Possible title underline, too short for the title.\n'
|
|
2880
|
+
"Treating it as ordinary text because it's so short.",
|
|
2881
|
+
line=lineno)
|
|
2882
|
+
self.parent += msg
|
|
2883
|
+
raise statemachine.TransitionCorrection('text')
|
|
2884
|
+
else:
|
|
2885
|
+
blocktext = context[0] + '\n' + self.state_machine.line
|
|
2886
|
+
msg = self.reporter.warning(
|
|
2887
|
+
'Title underline too short.',
|
|
2888
|
+
nodes.literal_block(blocktext, blocktext),
|
|
2889
|
+
line=lineno)
|
|
2890
|
+
messages.append(msg)
|
|
2891
|
+
if not self.state_machine.match_titles:
|
|
2892
|
+
blocktext = context[0] + '\n' + self.state_machine.line
|
|
2893
|
+
# We need get_source_and_line() here to report correctly
|
|
2894
|
+
src, srcline = self.state_machine.get_source_and_line()
|
|
2895
|
+
# TODO: why is abs_line_number() == srcline+1
|
|
2896
|
+
# if the error is in a table (try with test_tables.py)?
|
|
2897
|
+
# print("get_source_and_line", srcline)
|
|
2898
|
+
# print("abs_line_number", self.state_machine.abs_line_number())
|
|
2899
|
+
msg = self.reporter.error(
|
|
2900
|
+
'Unexpected section title.',
|
|
2901
|
+
nodes.literal_block(blocktext, blocktext),
|
|
2902
|
+
source=src, line=srcline)
|
|
2903
|
+
self.parent += messages
|
|
2904
|
+
self.parent += msg
|
|
2905
|
+
return [], next_state, []
|
|
2906
|
+
style = underline[0]
|
|
2907
|
+
context[:] = []
|
|
2908
|
+
self.section(title, source, style, lineno - 1, messages)
|
|
2909
|
+
return [], next_state, []
|
|
2910
|
+
|
|
2911
|
+
def text(self, match, context, next_state):
|
|
2912
|
+
"""Paragraph."""
|
|
2913
|
+
startline = self.state_machine.abs_line_number() - 1
|
|
2914
|
+
msg = None
|
|
2915
|
+
try:
|
|
2916
|
+
block = self.state_machine.get_text_block(flush_left=True)
|
|
2917
|
+
except statemachine.UnexpectedIndentationError as err:
|
|
2918
|
+
block, src, srcline = err.args
|
|
2919
|
+
msg = self.reporter.error('Unexpected indentation.',
|
|
2920
|
+
source=src, line=srcline)
|
|
2921
|
+
lines = context + list(block)
|
|
2922
|
+
paragraph, literalnext = self.paragraph(lines, startline)
|
|
2923
|
+
self.parent += paragraph
|
|
2924
|
+
self.parent += msg
|
|
2925
|
+
if literalnext:
|
|
2926
|
+
try:
|
|
2927
|
+
self.state_machine.next_line()
|
|
2928
|
+
except EOFError:
|
|
2929
|
+
pass
|
|
2930
|
+
self.parent += self.literal_block()
|
|
2931
|
+
return [], next_state, []
|
|
2932
|
+
|
|
2933
|
+
def literal_block(self):
|
|
2934
|
+
"""Return a list of nodes."""
|
|
2935
|
+
(indented, indent, offset, blank_finish
|
|
2936
|
+
) = self.state_machine.get_indented()
|
|
2937
|
+
while indented and not indented[-1].strip():
|
|
2938
|
+
indented.trim_end()
|
|
2939
|
+
if not indented:
|
|
2940
|
+
return self.quoted_literal_block()
|
|
2941
|
+
data = '\n'.join(indented)
|
|
2942
|
+
literal_block = nodes.literal_block(data, data)
|
|
2943
|
+
(literal_block.source,
|
|
2944
|
+
literal_block.line) = self.state_machine.get_source_and_line(offset+1)
|
|
2945
|
+
nodelist = [literal_block]
|
|
2946
|
+
if not blank_finish:
|
|
2947
|
+
nodelist.append(self.unindent_warning('Literal block'))
|
|
2948
|
+
return nodelist
|
|
2949
|
+
|
|
2950
|
+
def quoted_literal_block(self):
|
|
2951
|
+
abs_line_offset = self.state_machine.abs_line_offset()
|
|
2952
|
+
offset = self.state_machine.line_offset
|
|
2953
|
+
parent_node = nodes.Element()
|
|
2954
|
+
new_abs_offset = self.nested_parse(
|
|
2955
|
+
self.state_machine.input_lines[offset:],
|
|
2956
|
+
input_offset=abs_line_offset, node=parent_node, match_titles=False,
|
|
2957
|
+
state_machine_kwargs={'state_classes': (QuotedLiteralBlock,),
|
|
2958
|
+
'initial_state': 'QuotedLiteralBlock'})
|
|
2959
|
+
self.goto_line(new_abs_offset)
|
|
2960
|
+
return parent_node.children
|
|
2961
|
+
|
|
2962
|
+
def definition_list_item(self, termline):
|
|
2963
|
+
# the parser is already on the second (indented) line:
|
|
2964
|
+
dd_lineno = self.state_machine.abs_line_number()
|
|
2965
|
+
dt_lineno = dd_lineno - 1
|
|
2966
|
+
(indented, indent, line_offset, blank_finish
|
|
2967
|
+
) = self.state_machine.get_indented()
|
|
2968
|
+
dl_item = nodes.definition_list_item(
|
|
2969
|
+
'\n'.join(termline + list(indented)))
|
|
2970
|
+
(dl_item.source,
|
|
2971
|
+
dl_item.line) = self.state_machine.get_source_and_line(dt_lineno)
|
|
2972
|
+
dt_nodes, messages = self.term(termline, dt_lineno)
|
|
2973
|
+
dl_item += dt_nodes
|
|
2974
|
+
dd = nodes.definition('', *messages)
|
|
2975
|
+
dd.source, dd.line = self.state_machine.get_source_and_line(dd_lineno)
|
|
2976
|
+
dl_item += dd
|
|
2977
|
+
if termline[0][-2:] == '::':
|
|
2978
|
+
dd += self.reporter.info(
|
|
2979
|
+
'Blank line missing before literal block (after the "::")? '
|
|
2980
|
+
'Interpreted as a definition list item.',
|
|
2981
|
+
line=dd_lineno)
|
|
2982
|
+
# TODO: drop a definition if it is an empty comment to allow
|
|
2983
|
+
# definition list items with several terms?
|
|
2984
|
+
# https://sourceforge.net/p/docutils/feature-requests/60/
|
|
2985
|
+
self.nested_parse(indented, input_offset=line_offset, node=dd)
|
|
2986
|
+
return dl_item, blank_finish
|
|
2987
|
+
|
|
2988
|
+
classifier_delimiter = re.compile(' +: +')
|
|
2989
|
+
|
|
2990
|
+
def term(self, lines, lineno):
|
|
2991
|
+
"""Return a definition_list's term and optional classifiers."""
|
|
2992
|
+
assert len(lines) == 1
|
|
2993
|
+
text_nodes, messages = self.inline_text(lines[0], lineno)
|
|
2994
|
+
dt = nodes.term(lines[0])
|
|
2995
|
+
dt.source, dt.line = self.state_machine.get_source_and_line(lineno)
|
|
2996
|
+
node_list = [dt]
|
|
2997
|
+
for i in range(len(text_nodes)):
|
|
2998
|
+
node = text_nodes[i]
|
|
2999
|
+
if isinstance(node, nodes.Text):
|
|
3000
|
+
parts = self.classifier_delimiter.split(node)
|
|
3001
|
+
if len(parts) == 1:
|
|
3002
|
+
node_list[-1] += node
|
|
3003
|
+
else:
|
|
3004
|
+
text = parts[0].rstrip()
|
|
3005
|
+
textnode = nodes.Text(text)
|
|
3006
|
+
node_list[-1] += textnode
|
|
3007
|
+
node_list += [nodes.classifier(unescape(part, True), part)
|
|
3008
|
+
for part in parts[1:]]
|
|
3009
|
+
else:
|
|
3010
|
+
node_list[-1] += node
|
|
3011
|
+
return node_list, messages
|
|
3012
|
+
|
|
3013
|
+
|
|
3014
|
+
class SpecializedText(Text):
|
|
3015
|
+
|
|
3016
|
+
"""
|
|
3017
|
+
Superclass for second and subsequent lines of Text-variants.
|
|
3018
|
+
|
|
3019
|
+
All transition methods are disabled. Override individual methods in
|
|
3020
|
+
subclasses to re-enable.
|
|
3021
|
+
"""
|
|
3022
|
+
|
|
3023
|
+
def eof(self, context):
|
|
3024
|
+
"""Incomplete construct."""
|
|
3025
|
+
return []
|
|
3026
|
+
|
|
3027
|
+
def invalid_input(self, match=None, context=None, next_state=None):
|
|
3028
|
+
"""Not a compound element member. Abort this state machine."""
|
|
3029
|
+
raise EOFError
|
|
3030
|
+
|
|
3031
|
+
blank = invalid_input
|
|
3032
|
+
indent = invalid_input
|
|
3033
|
+
underline = invalid_input
|
|
3034
|
+
text = invalid_input
|
|
3035
|
+
|
|
3036
|
+
|
|
3037
|
+
class Definition(SpecializedText):
|
|
3038
|
+
|
|
3039
|
+
"""Second line of potential definition_list_item."""
|
|
3040
|
+
|
|
3041
|
+
def eof(self, context):
|
|
3042
|
+
"""Not a definition."""
|
|
3043
|
+
self.state_machine.previous_line(2) # so parent SM can reassess
|
|
3044
|
+
return []
|
|
3045
|
+
|
|
3046
|
+
def indent(self, match, context, next_state):
|
|
3047
|
+
"""Definition list item."""
|
|
3048
|
+
dl_item, blank_finish = self.definition_list_item(context)
|
|
3049
|
+
self.parent += dl_item
|
|
3050
|
+
self.blank_finish = blank_finish
|
|
3051
|
+
return [], 'DefinitionList', []
|
|
3052
|
+
|
|
3053
|
+
|
|
3054
|
+
class Line(SpecializedText):
|
|
3055
|
+
|
|
3056
|
+
"""
|
|
3057
|
+
Second line of over- & underlined section title or transition marker.
|
|
3058
|
+
"""
|
|
3059
|
+
|
|
3060
|
+
eofcheck = 1 # ignored, will be removed in Docutils 2.0.
|
|
3061
|
+
|
|
3062
|
+
def eof(self, context):
|
|
3063
|
+
"""Transition marker at end of section or document."""
|
|
3064
|
+
marker = context[0].strip()
|
|
3065
|
+
if len(marker) < 4:
|
|
3066
|
+
self.state_correction(context)
|
|
3067
|
+
src, srcline = self.state_machine.get_source_and_line()
|
|
3068
|
+
# lineno = self.state_machine.abs_line_number() - 1
|
|
3069
|
+
transition = nodes.transition(rawsource=context[0])
|
|
3070
|
+
transition.source = src
|
|
3071
|
+
transition.line = srcline - 1
|
|
3072
|
+
# transition.line = lineno
|
|
3073
|
+
self.parent += transition
|
|
3074
|
+
return []
|
|
3075
|
+
|
|
3076
|
+
def blank(self, match, context, next_state):
|
|
3077
|
+
"""Transition marker."""
|
|
3078
|
+
src, srcline = self.state_machine.get_source_and_line()
|
|
3079
|
+
marker = context[0].strip()
|
|
3080
|
+
if len(marker) < 4:
|
|
3081
|
+
self.state_correction(context)
|
|
3082
|
+
transition = nodes.transition(rawsource=marker)
|
|
3083
|
+
transition.source = src
|
|
3084
|
+
transition.line = srcline - 1
|
|
3085
|
+
self.parent += transition
|
|
3086
|
+
return [], 'Body', []
|
|
3087
|
+
|
|
3088
|
+
def text(self, match, context, next_state):
|
|
3089
|
+
"""Potential over- & underlined title."""
|
|
3090
|
+
lineno = self.state_machine.abs_line_number() - 1
|
|
3091
|
+
overline = context[0]
|
|
3092
|
+
title = match.string
|
|
3093
|
+
underline = ''
|
|
3094
|
+
try:
|
|
3095
|
+
underline = self.state_machine.next_line()
|
|
3096
|
+
except EOFError:
|
|
3097
|
+
blocktext = overline + '\n' + title
|
|
3098
|
+
if len(overline.rstrip()) < 4:
|
|
3099
|
+
self.short_overline(context, blocktext, lineno, 2)
|
|
3100
|
+
else:
|
|
3101
|
+
msg = self.reporter.error(
|
|
3102
|
+
'Incomplete section title.',
|
|
3103
|
+
nodes.literal_block(blocktext, blocktext),
|
|
3104
|
+
line=lineno)
|
|
3105
|
+
self.parent += msg
|
|
3106
|
+
return [], 'Body', []
|
|
3107
|
+
source = '%s\n%s\n%s' % (overline, title, underline)
|
|
3108
|
+
overline = overline.rstrip()
|
|
3109
|
+
underline = underline.rstrip()
|
|
3110
|
+
if not self.transitions['underline'][0].match(underline):
|
|
3111
|
+
blocktext = overline + '\n' + title + '\n' + underline
|
|
3112
|
+
if len(overline.rstrip()) < 4:
|
|
3113
|
+
self.short_overline(context, blocktext, lineno, 2)
|
|
3114
|
+
else:
|
|
3115
|
+
msg = self.reporter.error(
|
|
3116
|
+
'Missing matching underline for section title overline.',
|
|
3117
|
+
nodes.literal_block(source, source),
|
|
3118
|
+
line=lineno)
|
|
3119
|
+
self.parent += msg
|
|
3120
|
+
return [], 'Body', []
|
|
3121
|
+
elif overline != underline:
|
|
3122
|
+
blocktext = overline + '\n' + title + '\n' + underline
|
|
3123
|
+
if len(overline.rstrip()) < 4:
|
|
3124
|
+
self.short_overline(context, blocktext, lineno, 2)
|
|
3125
|
+
else:
|
|
3126
|
+
msg = self.reporter.error(
|
|
3127
|
+
'Title overline & underline mismatch.',
|
|
3128
|
+
nodes.literal_block(source, source),
|
|
3129
|
+
line=lineno)
|
|
3130
|
+
self.parent += msg
|
|
3131
|
+
return [], 'Body', []
|
|
3132
|
+
title = title.rstrip()
|
|
3133
|
+
messages = []
|
|
3134
|
+
if column_width(title) > len(overline):
|
|
3135
|
+
blocktext = overline + '\n' + title + '\n' + underline
|
|
3136
|
+
if len(overline.rstrip()) < 4:
|
|
3137
|
+
self.short_overline(context, blocktext, lineno, 2)
|
|
3138
|
+
else:
|
|
3139
|
+
msg = self.reporter.warning(
|
|
3140
|
+
'Title overline too short.',
|
|
3141
|
+
nodes.literal_block(source, source),
|
|
3142
|
+
line=lineno)
|
|
3143
|
+
messages.append(msg)
|
|
3144
|
+
style = (overline[0], underline[0])
|
|
3145
|
+
self.section(title.lstrip(), source, style, lineno + 1, messages)
|
|
3146
|
+
return [], 'Body', []
|
|
3147
|
+
|
|
3148
|
+
indent = text # indented title
|
|
3149
|
+
|
|
3150
|
+
def underline(self, match, context, next_state):
|
|
3151
|
+
overline = context[0]
|
|
3152
|
+
blocktext = overline + '\n' + self.state_machine.line
|
|
3153
|
+
lineno = self.state_machine.abs_line_number() - 1
|
|
3154
|
+
if len(overline.rstrip()) < 4:
|
|
3155
|
+
self.short_overline(context, blocktext, lineno, 1)
|
|
3156
|
+
msg = self.reporter.error(
|
|
3157
|
+
'Invalid section title or transition marker.',
|
|
3158
|
+
nodes.literal_block(blocktext, blocktext),
|
|
3159
|
+
line=lineno)
|
|
3160
|
+
self.parent += msg
|
|
3161
|
+
return [], 'Body', []
|
|
3162
|
+
|
|
3163
|
+
def short_overline(self, context, blocktext, lineno, lines=1) -> None:
|
|
3164
|
+
msg = self.reporter.info(
|
|
3165
|
+
'Possible incomplete section title.\nTreating the overline as '
|
|
3166
|
+
"ordinary text because it's so short.",
|
|
3167
|
+
line=lineno)
|
|
3168
|
+
self.parent += msg
|
|
3169
|
+
self.state_correction(context, lines)
|
|
3170
|
+
|
|
3171
|
+
def state_correction(self, context, lines=1):
|
|
3172
|
+
self.state_machine.previous_line(lines)
|
|
3173
|
+
context[:] = []
|
|
3174
|
+
raise statemachine.StateCorrection('Body', 'text')
|
|
3175
|
+
|
|
3176
|
+
|
|
3177
|
+
class QuotedLiteralBlock(RSTState):
|
|
3178
|
+
|
|
3179
|
+
"""
|
|
3180
|
+
Nested parse handler for quoted (unindented) literal blocks.
|
|
3181
|
+
|
|
3182
|
+
Special-purpose. Not for inclusion in `state_classes`.
|
|
3183
|
+
"""
|
|
3184
|
+
|
|
3185
|
+
patterns = {'initial_quoted': r'(%(nonalphanum7bit)s)' % Body.pats,
|
|
3186
|
+
'text': r''}
|
|
3187
|
+
initial_transitions = ('initial_quoted', 'text')
|
|
3188
|
+
|
|
3189
|
+
def __init__(self, state_machine, debug=False) -> None:
|
|
3190
|
+
RSTState.__init__(self, state_machine, debug)
|
|
3191
|
+
self.messages = []
|
|
3192
|
+
self.initial_lineno = None
|
|
3193
|
+
|
|
3194
|
+
def blank(self, match, context, next_state):
|
|
3195
|
+
if context:
|
|
3196
|
+
raise EOFError
|
|
3197
|
+
else:
|
|
3198
|
+
return context, next_state, []
|
|
3199
|
+
|
|
3200
|
+
def eof(self, context):
|
|
3201
|
+
if context:
|
|
3202
|
+
src, srcline = self.state_machine.get_source_and_line(
|
|
3203
|
+
self.initial_lineno)
|
|
3204
|
+
text = '\n'.join(context)
|
|
3205
|
+
literal_block = nodes.literal_block(text, text)
|
|
3206
|
+
literal_block.source = src
|
|
3207
|
+
literal_block.line = srcline
|
|
3208
|
+
self.parent += literal_block
|
|
3209
|
+
else:
|
|
3210
|
+
self.parent += self.reporter.warning(
|
|
3211
|
+
'Literal block expected; none found.',
|
|
3212
|
+
line=self.state_machine.abs_line_number()
|
|
3213
|
+
) # src not available, statemachine.input_lines is empty
|
|
3214
|
+
self.state_machine.previous_line()
|
|
3215
|
+
self.parent += self.messages
|
|
3216
|
+
return []
|
|
3217
|
+
|
|
3218
|
+
def indent(self, match, context, next_state):
|
|
3219
|
+
assert context, ('QuotedLiteralBlock.indent: context should not '
|
|
3220
|
+
'be empty!')
|
|
3221
|
+
self.messages.append(
|
|
3222
|
+
self.reporter.error('Unexpected indentation.',
|
|
3223
|
+
line=self.state_machine.abs_line_number()))
|
|
3224
|
+
self.state_machine.previous_line()
|
|
3225
|
+
raise EOFError
|
|
3226
|
+
|
|
3227
|
+
def initial_quoted(self, match, context, next_state):
|
|
3228
|
+
"""Match arbitrary quote character on the first line only."""
|
|
3229
|
+
self.remove_transition('initial_quoted')
|
|
3230
|
+
quote = match.string[0]
|
|
3231
|
+
pattern = re.compile(re.escape(quote))
|
|
3232
|
+
# New transition matches consistent quotes only:
|
|
3233
|
+
self.add_transition('quoted',
|
|
3234
|
+
(pattern, self.quoted, self.__class__.__name__))
|
|
3235
|
+
self.initial_lineno = self.state_machine.abs_line_number()
|
|
3236
|
+
return [match.string], next_state, []
|
|
3237
|
+
|
|
3238
|
+
def quoted(self, match, context, next_state):
|
|
3239
|
+
"""Match consistent quotes on subsequent lines."""
|
|
3240
|
+
context.append(match.string)
|
|
3241
|
+
return context, next_state, []
|
|
3242
|
+
|
|
3243
|
+
def text(self, match, context, next_state):
|
|
3244
|
+
if context:
|
|
3245
|
+
self.messages.append(
|
|
3246
|
+
self.reporter.error('Inconsistent literal block quoting.',
|
|
3247
|
+
line=self.state_machine.abs_line_number()))
|
|
3248
|
+
self.state_machine.previous_line()
|
|
3249
|
+
raise EOFError
|
|
3250
|
+
|
|
3251
|
+
|
|
3252
|
+
state_classes = (Body, BulletList, DefinitionList, EnumeratedList, FieldList,
|
|
3253
|
+
OptionList, LineBlock, ExtensionOptions, Explicit, Text,
|
|
3254
|
+
Definition, Line, SubstitutionDef, RFC2822Body, RFC2822List)
|
|
3255
|
+
"""Standard set of State classes used to start `RSTStateMachine`."""
|