404
+Page not found
+diff --git a/mkdocs_semiliterate/plugin.py b/mkdocs_semiliterate/plugin.py index 42c07a9..579a9c9 100644 --- a/mkdocs_semiliterate/plugin.py +++ b/mkdocs_semiliterate/plugin.py @@ -16,6 +16,8 @@ from mkdocs_simple_plugin.plugin import SimplePlugin, StreamExtract import os import re +import subprocess +import tempfile import yaml @@ -109,11 +111,21 @@ is checked for `{! ... !}`. utils.log.error(errmsg) raise EOFError(errmsg) filename = body_match['fn'] + gitextract = False if doublequoted: + if filename[:5] == r'\git ': + gitextract = True + filename = filename[5:] filename = (filename.encode('latin-1', 'backslashreplace') .decode('unicode-escape')) include_path = self.include_root + '/' + filename - print(f"Including |{include_path}|") + if gitextract: + (write_handle, include_path) = tempfile.mkstemp() + utils.log.info( + f"semiliterate: extracting {filename} to {include_path}") + contents = subprocess.check_output(['git', 'show', filename]) + os.write(write_handle, contents) + os.close(write_handle) new_root = re.match(r'(.*)/', include_path)[1] try: include_parameters = yaml.safe_load(body_match['yml']) diff --git a/tests/fixtures/git-inclusion/README.md b/tests/fixtures/git-inclusion/README.md new file mode 100644 index 0000000..754dd01 --- /dev/null +++ b/tests/fixtures/git-inclusion/README.md @@ -0,0 +1,7 @@ +# Test of git extraction + +Hopefully we see + +{! "\git 0.1.0:mkdocs.yml" extract: {start: '### install'} !} + +here. diff --git a/tests/fixtures/git-inclusion/mkdocs.yml b/tests/fixtures/git-inclusion/mkdocs.yml new file mode 100644 index 0000000..bd3e416 --- /dev/null +++ b/tests/fixtures/git-inclusion/mkdocs.yml @@ -0,0 +1,6 @@ +site_name: Full inclusion +docs_dir: refsite # dummy +plugins: +- semiliterate: + ignore_folders: [refsite, snippet] + merge_docs_dir: false diff --git a/tests/fixtures/git-inclusion/refsite/404.html b/tests/fixtures/git-inclusion/refsite/404.html new file mode 100644 index 0000000..a5b03b3 --- /dev/null +++ b/tests/fixtures/git-inclusion/refsite/404.html @@ -0,0 +1,103 @@ + + +
+ + + + + + + +Page not found
+Hopefully we see
+ stop: '^\s*###'
+ replace: ['^# (.*\s*)$', '^\s*-(.*\s*)$']
+
+markdown_extensions: +- abbr +- def_list +theme: + name: readthedocs +docs_dir: mkdocs_semiliterate # dummy
+here.