diff --git a/html2text/__init__.py b/html2text/__init__.py index 6b281ca..1921a24 100644 --- a/html2text/__init__.py +++ b/html2text/__init__.py @@ -86,6 +86,7 @@ def __init__( self.tag_callback = None self.open_quote = config.OPEN_QUOTE # covered in cli self.close_quote = config.CLOSE_QUOTE # covered in cli + self.ignore_sup_sub = config.IGNORE_SUP_SUB # covered in cli if out is None: self.out = self.outtextf @@ -716,7 +717,7 @@ def link_url(self: HTML2Text, link: str, title: str = "") -> None: self.out("\n[/code]") self.p() - if tag in ["sup", "sub"]: + if not self.ignore_sup_sub and tag in ["sup", "sub"]: if start: self.o("<{}>".format(tag)) else: diff --git a/html2text/cli.py b/html2text/cli.py index d0c62c9..2708c40 100644 --- a/html2text/cli.py +++ b/html2text/cli.py @@ -264,6 +264,12 @@ class bcolors: ) p.add_argument("filename", nargs="?") p.add_argument("encoding", nargs="?", default="utf-8") + p.add_argument( + "--ignore-sup-sub", + dest="ignore_sup_sub", + default=config.IGNORE_SUP_SUB, + help="Ignore the sup and sub tags", + ) args = p.parse_args() if args.filename and args.filename != "-": diff --git a/html2text/config.py b/html2text/config.py index 88d3f91..e4979a9 100644 --- a/html2text/config.py +++ b/html2text/config.py @@ -163,3 +163,6 @@ # Use double quotation marks when converting the tag. OPEN_QUOTE = '"' CLOSE_QUOTE = '"' + +# Ignore the sup and sub tags +IGNORE_SUP_SUB = True