mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-21 20:25:51 +00:00
36 lines
980 B
Python
Executable File
36 lines
980 B
Python
Executable File
#!/bin/env python3
|
|
|
|
import sys
|
|
|
|
def convert_page(text, reverse):
|
|
replacements = {
|
|
"<div class='multicode'>": "<!-- <div class='multicode'> -->",
|
|
"</div>": "<!-- </div> -->",
|
|
"(rest-api-tool.html": "(https://ripple.com/build/rest-tool",
|
|
"(transactions.html": "(https://ripple.com/build/transactions",
|
|
"(rippled-apis.html": "(https://ripple.com/build/rippled-apis",
|
|
}
|
|
|
|
for (k,v) in replacements.items():
|
|
if reverse:
|
|
text = text.replace(v,k)
|
|
else:
|
|
text = text.replace(k,v)
|
|
|
|
return text
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) < 2 or len(sys.argv) > 3:
|
|
exit("usage: %s infile [reverse]" % sys.argv[0])
|
|
|
|
if len(sys.argv) == 3 and sys.argv[2].lower() == "true":
|
|
reverse = True
|
|
else:
|
|
reverse = False
|
|
|
|
with open(sys.argv[1]) as f:
|
|
text = f.read()
|
|
text = convert_page(text, reverse)
|
|
print(text)
|
|
|