Skip to content

Commit 8e90c19

Browse files
authored
Merge pull request #3162 from tannewt/update_mistune
Move release note converter to latest markdown helper lib
2 parents cb7df2e + 384a7f7 commit 8e90c19

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

tools/convert_release_notes.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44

55
import sys
66
import mistune
7+
import mistune.renderers
78

89
print(sys.argv[1])
910

1011
with open(sys.argv[1], "r") as source_file:
1112
source = source_file.read()
1213

13-
html = mistune.Markdown()
14+
html = mistune.create_markdown()
1415

1516
print()
1617
print("HTML")
@@ -19,47 +20,50 @@
1920
print(html(source))
2021
print("</blockquote>")
2122

22-
class AdafruitBBCodeRenderer:
23-
def __init__(self, **kwargs):
24-
self.options = kwargs
25-
23+
class AdafruitBBCodeRenderer(mistune.renderers.BaseRenderer):
2624
def placeholder(self):
2725
return ''
2826

2927
def paragraph(self, text):
3028
return text + "\n\n"
3129

30+
def block_text(self, text):
31+
return text
32+
3233
def text(self, text):
3334
return text
3435

3536
def link(self, link, title, text):
36-
return "[url={}]{}[/url]".format(link, text)
37+
return "[url={}]{}[/url]".format(link, title)
3738

3839
def autolink(self, link, is_email):
3940
if not is_email:
4041
return "[url={}]{}[/url]".format(link, link)
4142
return link
4243

43-
def header(self, text, level, raw):
44+
def heading(self, text, level):
4445
return "[b][size=150]{}[/size][/b]\n".format(text)
4546

4647
def codespan(self, text):
4748
return "[color=#E74C3C][size=95]{}[/size][/color]".format(text)
4849

49-
def list_item(self, text):
50+
def list_item(self, text, level):
5051
return "[*]{}[/*]\n".format(text.strip())
5152

52-
def list(self, body, ordered=True):
53+
def list(self, text, ordered, level, start=None):
5354
ordered_indicator = "=" if ordered else ""
54-
return "[list{}]\n{}[/list]".format(ordered_indicator, body)
55+
return "[list{}]\n{}[/list]".format(ordered_indicator, text)
5556

5657
def double_emphasis(self, text):
5758
return "[b]{}[/b]".format(text)
5859

5960
def emphasis(self, text):
6061
return "[b]{}[/b]".format(text)
6162

62-
bbcode = mistune.Markdown(renderer=AdafruitBBCodeRenderer())
63+
def strong(self, text):
64+
return "[i]{}[/i]".format(text)
65+
66+
bbcode = mistune.create_markdown(renderer=AdafruitBBCodeRenderer())
6367

6468
print()
6569
print("BBCode")

0 commit comments

Comments
 (0)