fix: Allow bare `{! file.md !}' inclusion
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing

Also moves the site tests into a bash script.

  Resolves #6.
This commit is contained in:
Glen Whitney 2021-01-10 09:12:49 -08:00
parent 03f3cc811b
commit 82602a4bbe
12 changed files with 591 additions and 12 deletions

View file

@ -59,7 +59,8 @@ with the first line of a file; in this case, `pause` and `terminate` retain
their usual meanings, although there is not currently any way to resume from a
`pause` when `start` is not specified. This adjustment to `semiliterate`
parameters makes it easier to extract "front-matter" style documentation from
files.
files. It also means that a plain `{! file.md !}` directive will simply
incorporate the full contents of `file.md`.
"""
self.start_hot = False
if 'start' not in kwargs:
@ -75,8 +76,8 @@ files.
include_open = re.compile(r'''(?<![`\\])(\{\!\s*)([\s'"])''')
include_quoted_file = re.compile(
r'''(['"])(?P<fn>.*?)\1\s+(?P<yml>[\s\S]*?)\s\!\}''')
include_bare_file = re.compile(r'\s(?P<fn>.*?)\s+(?P<yml>[\s\S]*?)\s\!\}')
r'''(['"])(?P<fn>.*?)\1\s+(?P<yml>[\s\S]*?)\s?\!\}''')
include_bare_file = re.compile(r'\s(?P<fn>.*?)\s+(?P<yml>[\s\S]*?)\s?\!\}')
def extract_line(self, line):
"""Copy line to the output stream, applying all specified replacements
@ -101,10 +102,14 @@ files.
if body_match:
break
if not body_match:
raise EOFError("semiliterate: End of file while scanning for `!}`")
errmsg = "semiliterate: End of file while scanning for `!}`"
utils.log.error(errmsg)
raise EOFError(errmsg)
include_path = self.include_root + '/' + body_match['fn']
new_root = re.match(r'(.*)/', include_path)[1]
include_parameters = yaml.safe_load(body_match['yml'])
if not include_parameters:
include_parameters = {}
with open(include_path) as include_file:
self.transcribe(preamble)
inclusion = StreamInclusion(