Skip to content

Commit

Permalink
Migration script: update with some partial fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mDuo13 committed Nov 29, 2023
1 parent 387914b commit 3105526
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tool/md_dactyl_to_redocly.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ class IncludeSvgReplacer(RegexReplacer):
regex = re.compile(r'\{\{ *include_svg\( *"(?P<fname>[^"]+)"[, ]*("(?P<caption>[^"]+)")?\) *}}')
@staticmethod
def replace(m):
return '<figure><a href="'+m.group("fname")+'" title="'+m.group("caption")+'">{% inline-svg file="/' + m.group("fname") + '" /%}</a></figure>'
# TODO: maybe wrap in something like this, except make it work?
# <figure><a href="'+m.group("fname")+'" title="'+m.group("caption")+'"> ... </a></figure>
return '{% inline-svg file="/' + m.group("fname") + '" /%}'
regex_todos.append(IncludeSvgReplacer())

class PrefixedCodeSnippetReplacer(RegexReplacer):
Expand Down Expand Up @@ -221,7 +223,7 @@ def replace(m: re.Match):
def convert_category_page(ftext):
if not category_regex.search(ftext):
return ftext
ftext2 = re.sub(category_regex, "", ftext)
ftext2 = re.sub(category_regex, "metadata:\n indexPage: true\n", ftext)
ftext2 = ftext2 + "\n{% child-pages /%}\n"
return ftext2

Expand All @@ -235,11 +237,13 @@ def main():
for replacer in regex_todos:
ftext2 = replacer.replace_all(ftext2)

ftext2 = convert_category_page(ftext2)

# Temporarily commented out because of a Redocly bug that causes it to hang
# ftext2 = convert_category_page(ftext2)

if ftext2 != ftext:
#print("performing syntax conversion in", fname)
with open(fname, "w") as f:
f.write(ftext2)

main()
main()

0 comments on commit 3105526

Please sign in to comment.