def __init__(self): Formatter.__init__(self) # in elements' dicts, following key can be used: # - 'nitf': new NITF compatible element to use (empty string to remove) # - 'attrib': new attribute to use (replace existing one if set) # - 'filter': callback to use for complex changes (root_elment and element as arguments) self.HTML2NITF = { 'p': {}, 'b': { 'nitf': 'em', 'attrib': {'class': 'bold'}}, 'br': {'filter': self.br_filter}, 'strong': { 'nitf': 'em', 'attrib': {'class': 'bold'}}, 'i': { 'nitf': 'em', 'attrib': {'class': 'italic'}}, 'em': { 'nitf': 'em', 'attrib': {'class': 'italic'}}, 'u': { 'nitf': 'em', 'attrib': {'class': 'underscore'}}, 'strike': {'nitf': 'em'}, 'sup': {}, 'sub': {}, 'a': {}, 'img': {'nitf': ''}, # <img> use <media> in nitf, so we remove element 'blockquote': {'nitf': 'bq'}, 'pre': {}, 'ol': {}, 'ul': {}, 'li': {}, # FIXME: hl1 is not used here as it can only appear in <hedline> 'h1': {'nitf': 'hl2'}, 'h2': {'nitf': 'hl2'}, 'h3': {'nitf': 'hl2'}, 'h4': {'nitf': 'hl2'}, 'h5': {'nitf': 'hl2'}, 'h6': {'nitf': 'hl2'}, # tables 'table': {}, 'tbody': {}, 'tr': {}, 'td': {}, 'th': {}, 'style': {'nitf': EraseElement}, # <style> may be there in case of bad paste }
def __init__(self): Formatter.__init__(self) # in elements' dicts, following key can be used: # - 'nitf': new NITF compatible element to use (empty string to remove) # - 'attrib': new attribute to use (replace existing one if set) # - 'filter': callback to use for complex changes (root_elment and element as arguments) self.HTML2NITF = { "p": {}, "b": {"nitf": "em", "attrib": {"class": "bold"}}, "br": {"filter": self.br_filter}, "strong": {"nitf": "em", "attrib": {"class": "bold"}}, "i": {"nitf": "em", "attrib": {"class": "italic"}}, "em": {"nitf": "em", "attrib": {"class": "italic"}}, "u": {"nitf": "em", "attrib": {"class": "underscore"}}, "strike": {"nitf": "em"}, "sup": {}, "sub": {}, "a": {}, "img": {"nitf": ""}, # <img> use <media> in nitf, so we remove element "blockquote": {"nitf": "bq"}, "pre": {}, "ol": {}, "ul": {}, "li": {}, # FIXME: hl1 is not used here as it can only appear in <hedline> "h1": {"nitf": "hl2"}, "h2": {"nitf": "hl2"}, "h3": {"nitf": "hl2"}, "h4": {"nitf": "hl2"}, "h5": {"nitf": "hl2"}, "h6": {"nitf": "hl2"}, # tables "table": {}, "tbody": {}, "tr": {}, "td": {}, "th": {}, "style": {"nitf": EraseElement}, # <style> may be there in case of bad paste }