How to use the html2text.config.UNIFIABLE function in html2text

To help you get started, we’ve selected a few html2text examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JimmXinu / FanFicFare / included_dependencies / html2text / __init__.py View on Github external
self.drop_white_space = 0
        self.inheader = False
        self.abbr_title = None  # current abbreviation definition
        self.abbr_data = None  # last inner HTML (for abbr being defined)
        self.abbr_list = {}  # stack of abbreviations to write later
        self.baseurl = baseurl
        self.stressed = False
        self.preceding_stressed = False
        self.preceding_data = None
        self.current_tag = None

        try:
            del unifiable_n[name2cp('nbsp')]
        except KeyError:
            pass
        config.UNIFIABLE['nbsp'] = '&nbsp_place_holder;'
github JimmXinu / FanFicFare / included_dependencies / html2text / __init__.py View on Github external
def entityref(self, c):
        if not self.unicode_snob and c in config.UNIFIABLE.keys():
            return config.UNIFIABLE[c]
        else:
            try:
                name2cp(c)
            except KeyError:
                return "&" + c + ';'
            else:
                if c == 'nbsp':
                    return config.UNIFIABLE[c]
                else:
                    return chr(name2cp(c))
github JimmXinu / FanFicFare / included_dependencies / html2text / utils.py View on Github external
import sys

from html2text import config
from html2text.compat import htmlentitydefs


def name2cp(k):
    """Return sname to codepoint"""
    if k == 'apos':
        return ord("'")
    return htmlentitydefs.name2codepoint[k]


unifiable_n = {}
for k in config.UNIFIABLE.keys():
    unifiable_n[name2cp(k)] = config.UNIFIABLE[k]


def hn(tag):
    if tag[0] == 'h' and len(tag) == 2:
        try:
            n = int(tag[1])
            if n in range(1, 10):  # pragma: no branch
                return n
        except ValueError:
            return 0


def dumb_property_dict(style):
    """
    :returns: A hash of css attributes
    """