# Path: coldsweat/markup.py
# class BaseProcessor(BaseParser):
#     '''
#     Parse and partially reconstruct the input document     
#     '''
# 
#     # HTML 5 only    
#     void_elements = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 
#       'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr' ]
#       
#     def __init__(self, xhtml_mode=False):
#         BaseParser.__init__(self)
#         self.xhtml_mode = xhtml_mode
# 
#     #@@NOTE: reset is called implicitly by base class
#         
#     def reset(self):
#         BaseParser.reset(self)
#         self.pieces = []
#         
#     def output(self):
#         '''
#         Return processed HTML as a single string
#         '''
#         return ''.join(self.pieces)    
#         
#     def unknown_starttag(self, tag, attrs):
#         # Called for each unhandled tag, where attrs is a list of (attr, value) tuples
#         #   e.g. for <pre class="screen">, tag="pre", attrs=[("class", "screen")]
#         #   The attr name will be translated to lower case, and quotes in the  
#         #   value have been removed and character and entity references 
#         #   have been replaced. Starting Python 2.6 all entity references from 
#         #   htmlentitydefs are replaced in the attribute values                    
#         s = "".join([' %s="%s"' % (key, escape_html(value)) for key, value in attrs])
#         if self.xhtml_mode and (tag in self.void_elements):
#             self.pieces.append("<%s%s />" % (tag, s))
#         else:
#             self.pieces.append("<%s%s>" % (tag, s))
#         
#     def unknown_endtag(self, tag):
#         # Called for each unhandled end tag, e.g. for </pre>, tag will be "pre"
#         #   Reconstruct the original end tag.
#         if tag not in self.void_elements:
#             self.pieces.append("</%s>" % tag)
#             
#     def handle_charref(self, ref):
#         # Called for each character reference, e.g. for "&#160;", ref will be "160"
#         #   Unescape the original character reference if not reserved
#         if ref in HTML_RESERVED_CHARREFS: 
#             self.pieces.append("&#%s;" % ref) 
#         else:
#             self.pieces.append(self.unescape("&#%s;" % ref))
# 
#     def handle_entityref(self, ref):
#         # Called for each entity reference, e.g. for "&copy;", ref will be "copy"
#         #   Unescape the original entity reference if not reserved
#         if ref in HTML_RESERVED_ENTITIES:
#             self.pieces.append("&%s;" % ref)             
#         else:                        
#             self.pieces.append(self.unescape("&%s;" % ref))
# 
#     def handle_data(self, text):
#         # Called for each block of plain text, i.e. outside of any tag and
#         #   not containing any character or entity references
#         #   Store the original text verbatim
#         self.pieces.append(text)
# 
#     # The following elements will be stripped by 
#     #   the default implementation
# 
#     def handle_comment(self, text):
#         pass # Strip comments
# 
#     def handle_pi(self, text):
#         pass # Strip pi
# 
#     def handle_decl(self, text):
#         pass # Strip doctype declaration


import feedparser    
from os import path
from ..markup import BaseProcessor
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Description: base processor tests

Copyright (c) 2013—2016 Andrea Peltrin
License: MIT (see LICENSE for details)
'''



def run_tests():

    # Figure out current dir
    test_dir = path.dirname(path.abspath(__file__))

    test_files = [
        ('markup/in.xml', 'markup/out.xml'),
    ]

    # Use xhtml_mode to match Feedpaser output

# Path: coldsweat/markup.py
# class BaseProcessor(BaseParser):
#     '''
#     Parse and partially reconstruct the input document     
#     '''
# 
#     # HTML 5 only    
#     void_elements = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 
#       'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr' ]
#       
#     def __init__(self, xhtml_mode=False):
#         BaseParser.__init__(self)
#         self.xhtml_mode = xhtml_mode
# 
#     #@@NOTE: reset is called implicitly by base class
#         
#     def reset(self):
#         BaseParser.reset(self)
#         self.pieces = []
#         
#     def output(self):
#         '''
#         Return processed HTML as a single string
#         '''
#         return ''.join(self.pieces)    
#         
#     def unknown_starttag(self, tag, attrs):
#         # Called for each unhandled tag, where attrs is a list of (attr, value) tuples
#         #   e.g. for <pre class="screen">, tag="pre", attrs=[("class", "screen")]
#         #   The attr name will be translated to lower case, and quotes in the  
#         #   value have been removed and character and entity references 
#         #   have been replaced. Starting Python 2.6 all entity references from 
#         #   htmlentitydefs are replaced in the attribute values                    
#         s = "".join([' %s="%s"' % (key, escape_html(value)) for key, value in attrs])
#         if self.xhtml_mode and (tag in self.void_elements):
#             self.pieces.append("<%s%s />" % (tag, s))
#         else:
#             self.pieces.append("<%s%s>" % (tag, s))
#         
#     def unknown_endtag(self, tag):
#         # Called for each unhandled end tag, e.g. for </pre>, tag will be "pre"
#         #   Reconstruct the original end tag.
#         if tag not in self.void_elements:
#             self.pieces.append("</%s>" % tag)
#             
#     def handle_charref(self, ref):
#         # Called for each character reference, e.g. for "&#160;", ref will be "160"
#         #   Unescape the original character reference if not reserved
#         if ref in HTML_RESERVED_CHARREFS: 
#             self.pieces.append("&#%s;" % ref) 
#         else:
#             self.pieces.append(self.unescape("&#%s;" % ref))
# 
#     def handle_entityref(self, ref):
#         # Called for each entity reference, e.g. for "&copy;", ref will be "copy"
#         #   Unescape the original entity reference if not reserved
#         if ref in HTML_RESERVED_ENTITIES:
#             self.pieces.append("&%s;" % ref)             
#         else:                        
#             self.pieces.append(self.unescape("&%s;" % ref))
# 
#     def handle_data(self, text):
#         # Called for each block of plain text, i.e. outside of any tag and
#         #   not containing any character or entity references
#         #   Store the original text verbatim
#         self.pieces.append(text)
# 
#     # The following elements will be stripped by 
#     #   the default implementation
# 
#     def handle_comment(self, text):
#         pass # Strip comments
# 
#     def handle_pi(self, text):
#         pass # Strip pi
# 
#     def handle_decl(self, text):
#         pass # Strip doctype declaration


# Path: coldsweat/tests/processor.py
import feedparser    
from os import path
from ..markup import BaseProcessor

#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Description: base processor tests

Copyright (c) 2013—2016 Andrea Peltrin
License: MIT (see LICENSE for details)
'''



def run_tests():

    # Figure out current dir
    test_dir = path.dirname(path.abspath(__file__))

    test_files = [
        ('markup/in.xml', 'markup/out.xml'),
    ]

    # Use xhtml_mode to match Feedpaser output

    p = BaseProcessor(xhtml_mode=True)