Merge pull request #3162 from tannewt/update_mistune
Move release note converter to latest markdown helper lib
This commit is contained in:
commit
8e90c1996c
@ -4,13 +4,14 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import mistune
|
import mistune
|
||||||
|
import mistune.renderers
|
||||||
|
|
||||||
print(sys.argv[1])
|
print(sys.argv[1])
|
||||||
|
|
||||||
with open(sys.argv[1], "r") as source_file:
|
with open(sys.argv[1], "r") as source_file:
|
||||||
source = source_file.read()
|
source = source_file.read()
|
||||||
|
|
||||||
html = mistune.Markdown()
|
html = mistune.create_markdown()
|
||||||
|
|
||||||
print()
|
print()
|
||||||
print("HTML")
|
print("HTML")
|
||||||
@ -19,39 +20,39 @@ print("From the <a href=\"\">GitHub release page</a>:\n<blockquote>")
|
|||||||
print(html(source))
|
print(html(source))
|
||||||
print("</blockquote>")
|
print("</blockquote>")
|
||||||
|
|
||||||
class AdafruitBBCodeRenderer:
|
class AdafruitBBCodeRenderer(mistune.renderers.BaseRenderer):
|
||||||
def __init__(self, **kwargs):
|
|
||||||
self.options = kwargs
|
|
||||||
|
|
||||||
def placeholder(self):
|
def placeholder(self):
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def paragraph(self, text):
|
def paragraph(self, text):
|
||||||
return text + "\n\n"
|
return text + "\n\n"
|
||||||
|
|
||||||
|
def block_text(self, text):
|
||||||
|
return text
|
||||||
|
|
||||||
def text(self, text):
|
def text(self, text):
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def link(self, link, title, text):
|
def link(self, link, title, text):
|
||||||
return "[url={}]{}[/url]".format(link, text)
|
return "[url={}]{}[/url]".format(link, title)
|
||||||
|
|
||||||
def autolink(self, link, is_email):
|
def autolink(self, link, is_email):
|
||||||
if not is_email:
|
if not is_email:
|
||||||
return "[url={}]{}[/url]".format(link, link)
|
return "[url={}]{}[/url]".format(link, link)
|
||||||
return link
|
return link
|
||||||
|
|
||||||
def header(self, text, level, raw):
|
def heading(self, text, level):
|
||||||
return "[b][size=150]{}[/size][/b]\n".format(text)
|
return "[b][size=150]{}[/size][/b]\n".format(text)
|
||||||
|
|
||||||
def codespan(self, text):
|
def codespan(self, text):
|
||||||
return "[color=#E74C3C][size=95]{}[/size][/color]".format(text)
|
return "[color=#E74C3C][size=95]{}[/size][/color]".format(text)
|
||||||
|
|
||||||
def list_item(self, text):
|
def list_item(self, text, level):
|
||||||
return "[*]{}[/*]\n".format(text.strip())
|
return "[*]{}[/*]\n".format(text.strip())
|
||||||
|
|
||||||
def list(self, body, ordered=True):
|
def list(self, text, ordered, level, start=None):
|
||||||
ordered_indicator = "=" if ordered else ""
|
ordered_indicator = "=" if ordered else ""
|
||||||
return "[list{}]\n{}[/list]".format(ordered_indicator, body)
|
return "[list{}]\n{}[/list]".format(ordered_indicator, text)
|
||||||
|
|
||||||
def double_emphasis(self, text):
|
def double_emphasis(self, text):
|
||||||
return "[b]{}[/b]".format(text)
|
return "[b]{}[/b]".format(text)
|
||||||
@ -59,7 +60,10 @@ class AdafruitBBCodeRenderer:
|
|||||||
def emphasis(self, text):
|
def emphasis(self, text):
|
||||||
return "[b]{}[/b]".format(text)
|
return "[b]{}[/b]".format(text)
|
||||||
|
|
||||||
bbcode = mistune.Markdown(renderer=AdafruitBBCodeRenderer())
|
def strong(self, text):
|
||||||
|
return "[i]{}[/i]".format(text)
|
||||||
|
|
||||||
|
bbcode = mistune.create_markdown(renderer=AdafruitBBCodeRenderer())
|
||||||
|
|
||||||
print()
|
print()
|
||||||
print("BBCode")
|
print("BBCode")
|
||||||
|
Loading…
Reference in New Issue
Block a user