diff --git a/script/lib/changelog.py b/script/lib/changelog.py index b8ca552b408..0348badf0b6 100644 --- a/script/lib/changelog.py +++ b/script/lib/changelog.py @@ -57,11 +57,26 @@ def reconstruct_brave_changelog_list(li): changes = [] for item in li['children']: - for item2 in item['children']: - changes.append("{} {}[{}]({}){}".format(' -', item2['children'][0]['content'], - item2['children'][1]['children'][0]['content'], - item2['children'][1]['target'], - item2['children'][2]['content'])) + # For special markdown characters such as *EMPHASIS* or `inline code + # blocks`, mistletoe's AST provides us with a nested list. We need + # to traverse the list elements and append them to a single string. + # During this process we also remove the special characters. + appended_entry = str() + for item2 in item['children'][0]['children']: + if 'RawText' in item2['type']: + appended_entry = appended_entry + '{}'.format(item2['content']) + elif 'Link' in item2['type']: + appended_entry = appended_entry + '[{}]({})'.format(item2['children'][0]['content'], item2['target']) + elif 'InlineCode' in item2['type']: + appended_entry = appended_entry + '{}'.format(item2['children'][0]['content']) + else: + # Try to catch all other markdown types in this general case + # + # Mistletoe types defined here: + # https://github.com/miyuchina/mistletoe/blob/master/mistletoe/base_renderer.py#L47-L71 + appended_entry = appended_entry + '{}'.format(item2['children'][0]['content']) + + changes.append(" {} {}".format(' -', appended_entry)) return changes