bugdown: Replace deprecated markdown.util.etree with ElementTree.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2020-06-02 21:37:07 -07:00
committed by Tim Abbott
parent 01ccb75259
commit f65af9cdb7
2 changed files with 38 additions and 38 deletions

View File

@@ -1,7 +1,7 @@
from markdown.extensions import Extension
from typing import Any, Dict, Optional, List, Tuple
import markdown
from xml.etree.ElementTree import Element
from xml.etree.ElementTree import Element, SubElement
from zerver.lib.bugdown import walk_tree_with_family, ResultWithFamily
@@ -50,15 +50,15 @@ class NestedCodeBlocksRendererTreeProcessor(markdown.treeprocessors.Treeprocesso
return nested_code_blocks
def get_codehilite_block(self, code_block_text: Optional[str]) -> Element:
div = markdown.util.etree.Element("div")
div = Element("div")
div.set("class", "codehilite")
pre = markdown.util.etree.SubElement(div, "pre")
pre = SubElement(div, "pre")
pre.text = code_block_text
return div
def replace_element(
self, parent: Optional[Element],
replacement: markdown.util.etree.Element,
replacement: Element,
element_to_replace: Element
) -> None:
if parent is None: