basho / basho_docs

Basho Products Documentation
http://docs.basho.com
Other
168 stars 191 forks source link

Use Hugo shortcodes rather than `<div class="note">` elements #2463

Closed pyrrho closed 7 years ago

pyrrho commented 7 years ago

Like it says on the tin.

This change was motivated by removing incorrectly formatted <div class="info"> elements, and the script I built for it worked to convert <div class="note"> elements as well.

Any <div class="info"> whose contents are indented were left, because markdown would have incorrectly interpreted the contents as a codeblock.

For the curious, here's the script I used to make the edits (minus some manual fixups for lists). ```python #!/usr/bin/env python # find riak/kv -type f | xargs perl -pi -e 's/Nginx version notes<\/div/Nginx version notes<\/div>/' # find riak/cs -type f | xargs perl -pi -e 's/clas="title"/class="title"/' import sys import re import textwrap file_name = sys.argv[1] r = re.compile( r"""(?<=\n) (?:\n)? (?:(.*?)<\/div>)? (?:\n)? (.+?) (?:\n)? <\/div>""", re.X | re.S) wrapper = textwrap.TextWrapper() wrapper.width = 78 wrapper.break_on_hyphens = False wrapper.break_long_words = False with open(file_name) as f: old = f.read() m = r.search(old) while (m != None): new_str = "{{% note " if m.group(2): title_text = ' '.join(m.group(2).strip().split()) title_text = re.sub(r"<\/title>", "", title_text) title_text = re.sub(r"<\/?strong>", "**", title_text) title_text = re.sub(r"<\/?code>", "`", title_text) title_text = re.sub(r"<\/?em>", "_", title_text) new_str += "title=\"" + title_text + "\" " new_str += "%}}\n" body_text = m.group(3).strip() body_text = re.sub(r"<\/?strong>", "**", body_text) body_text = re.sub(r"<\/?code>", "`", body_text) body_text = re.sub(r"<\/?tt>", "`", body_text) body_text = re.sub(r"<\/?em>", "_", body_text) body_text = re.sub(r"<\/?br\/?>", "\n", body_text) body_text = re.sub(r"<\/?p\/?>", "", body_text) body_text = re.sub(r"<\/?ul\/?>\n", "", body_text) body_text = re.sub(r"
  • ", "* ", body_text) body_text = re.sub(r"<\/li>", "\n", body_text) body_text = re.sub(r"
  • lrnrthr commented 7 years ago

    👍 :taco: 🎉 🎣