Including example Travis CI configuration from examples/ directory in docs/setup.md
This commit is contained in:
@@ -9,6 +9,8 @@ TAG_REGEX_PATTERN = re.compile(
|
||||
"(?P<filename>[^"]+)" # "filename"
|
||||
(?:\s+start="(?P<start>[^"]+)")? # optional start expression
|
||||
(?:\s+end="(?P<end>[^"]+)")? # optional end expression
|
||||
(?:\s+before="(?P<before>[^"]+)")? # optional preceding text to add
|
||||
(?:\s+after="(?P<after>[^"]+)")? # optional succeeding text to add
|
||||
\s*
|
||||
%} # closing tag
|
||||
''',
|
||||
@@ -23,6 +25,8 @@ class ImportMarkdownPlugin(mkdocs.plugins.BasePlugin):
|
||||
filename = match.group('filename')
|
||||
start = match.group('start')
|
||||
end = match.group('end')
|
||||
before = match.group('before')
|
||||
after = match.group('after')
|
||||
|
||||
file_path_abs = os.path.join(os.path.dirname(page_src_path), filename)
|
||||
|
||||
@@ -38,12 +42,18 @@ class ImportMarkdownPlugin(mkdocs.plugins.BasePlugin):
|
||||
if end:
|
||||
text_to_include, _, _ = text_to_include.partition(end)
|
||||
|
||||
if before:
|
||||
text_to_include = before.replace('\\n', '\n') + text_to_include
|
||||
|
||||
if after:
|
||||
text_to_include = text_to_include + after.replace('\\n', '\n')
|
||||
|
||||
return (
|
||||
'<!-- BEGIN INCLUDE %s %s %s -->' % (
|
||||
filename, cgi.escape(start), cgi.escape(end)
|
||||
'<!-- BEGIN INCLUDE %s %s %s -->\n' % (
|
||||
filename, cgi.escape(start or ''), cgi.escape(end or '')
|
||||
)
|
||||
+ text_to_include
|
||||
+ '<!-- END INCLUDE -->'
|
||||
+ '\n<!-- END INCLUDE -->'
|
||||
)
|
||||
|
||||
markdown = re.sub(TAG_REGEX_PATTERN, found_import_markdown_tag, markdown)
|
||||
|
||||
Reference in New Issue
Block a user