@@ -15,7 +15,7 @@ def __init__(self, *, page_url: str, **options):
1515 super ().__init__ (** options )
1616 self .page_url = page_url
1717
18- def convert_li (self , el : PageElement , text : str , convert_as_inline : bool ) -> str :
18+ def convert_li (self , el : PageElement , text : str , parent_tags : set [ str ] ) -> str :
1919 """Fix markdownify's erroneous indexing in ol tags."""
2020 parent = el .parent
2121 if parent is not None and parent .name == "ol" :
@@ -31,38 +31,38 @@ def convert_li(self, el: PageElement, text: str, convert_as_inline: bool) -> str
3131 bullet = bullets [depth % len (bullets )]
3232 return f"{ bullet } { text } \n "
3333
34- def _convert_hn (self , _n : int , el : PageElement , text : str , convert_as_inline : bool ) -> str :
34+ def _convert_hn (self , _n : int , el : PageElement , text : str , parent_tags : set [ str ] ) -> str :
3535 """Convert h tags to bold text with ** instead of adding #."""
36- if convert_as_inline :
36+ if "_inline" in parent_tags :
3737 return text
3838 return f"**{ text } **\n \n "
3939
40- def convert_code (self , el : PageElement , text : str , convert_as_inline : bool ) -> str :
40+ def convert_code (self , el : PageElement , text : str , parent_tags : set [ str ] ) -> str :
4141 """Undo `markdownify`s underscore escaping."""
4242 return f"`{ text } `" .replace ("\\ " , "" )
4343
44- def convert_pre (self , el : PageElement , text : str , convert_as_inline : bool ) -> str :
44+ def convert_pre (self , el : PageElement , text : str , parent_tags : set [ str ] ) -> str :
4545 """Wrap any codeblocks in `py` for syntax highlighting."""
4646 code = "" .join (el .strings )
4747 return f"```py\n { code } ```"
4848
49- def convert_a (self , el : PageElement , text : str , convert_as_inline : bool ) -> str :
49+ def convert_a (self , el : PageElement , text : str , parent_tags : set [ str ] ) -> str :
5050 """Resolve relative URLs to `self.page_url`."""
5151 el ["href" ] = urljoin (self .page_url , el ["href" ])
5252 # Discord doesn't handle titles properly, showing links with them as raw text.
5353 el ["title" ] = None
54- return super ().convert_a (el , text , convert_as_inline )
54+ return super ().convert_a (el , text , parent_tags )
5555
56- def convert_p (self , el : PageElement , text : str , convert_as_inline : bool ) -> str :
56+ def convert_p (self , el : PageElement , text : str , parent_tags : set [ str ] ) -> str :
5757 """Include only one newline instead of two when the parent is a li tag."""
58- if convert_as_inline :
58+ if "_inline" in parent_tags :
5959 return text
6060
6161 parent = el .parent
6262 if parent is not None and parent .name == "li" :
6363 return f"{ text } \n "
64- return super ().convert_p (el , text , convert_as_inline )
64+ return super ().convert_p (el , text , parent_tags )
6565
66- def convert_hr (self , el : PageElement , text : str , convert_as_inline : bool ) -> str :
66+ def convert_hr (self , el : PageElement , text : str , parent_tags : set [ str ] ) -> str :
6767 """Ignore `hr` tag."""
6868 return ""
0 commit comments