Process an HTML entry's HTML
435262
def process(text, config, search_path):
    
    processor = HTMLEntry(config, search_path)
    processor.feed(text)
    text = processor.get_data()

    if not config.get('no_smartquotes'):
        text = misaka.smartypants(text)

    return flask.Markup(text)
730296
def getPrevUrl(self, url, data):
        """"""
        mo = compile(r"index(\d+)\.html").search(url)
        num = int(mo.group(1)) - 1
        prefix = url.rsplit('/', 1)[0]
        return "%s/index%d.html" % (prefix, num)
761590
function htmlParser(html, handler) {
  if (typeof html !== 'string') {
    if (html === null || typeof html === 'undefined') {
      html = '';
    } else {
      html = '' + html;
    }
  }
  var index, chars, match, stack = [],
    last = html,
    text;
  stack.last = function () {
    return stack[stack.length - 1];
  };

  while (html) {
    text = '';
    chars = true;

    // Make sure we're not in a script or style element
    if (!stack.last() || !specialElements[stack.last()]) {

      // Comment
      if (html.indexOf("<!--") === 0) {
        // comments containing -- are not allowed unless they terminate the comment
        index = html.indexOf("--", 4);

        if (index >= 0 && html.lastIndexOf("-->", index) === index) {
          if (handler.comment) handler.comment(html.substring(4, index));
          html = html.substring(index + 3);
          chars = false;
        }
        // DOCTYPE
      } else if (DOCTYPE_REGEXP.test(html)) {
        match = html.match(DOCTYPE_REGEXP);

        if (match) {
          html = html.replace(match[0], '');
          chars = false;
        }
        // end tag
      } else if (BEGING_END_TAGE_REGEXP.test(html)) {
        match = html.match(END_TAG_REGEXP);

        if (match) {
          html = html.substring(match[0].length);
          match[0].replace(END_TAG_REGEXP, parseEndTag);
          chars = false;
        }

        // start tag
      } else if (BEGIN_TAG_REGEXP.test(html)) {
        match = html.match(START_TAG_REGEXP);

        if (match) {
          // We only have a valid start-tag if there is a '>'.
          if (match[4]) {
            html = html.substring(match[0].length);
            match[0].replace(START_TAG_REGEXP, parseStartTag);
          }
          chars = false;
        } else {
          // no ending tag found --- this piece should be encoded as an entity.
          text += '<';
          html = html.substring(1);
        }
      }

      if (chars) {
        index = html.indexOf("<");

        text += index < 0 ? html : html.substring(0, index);
        html = index < 0 ? "" : html.substring(index);

        if (handler.chars) handler.chars(decodeEntities(text));
      }

    } else {
      // IE versions 9 and 10 do not understand the regex '[^]', so using a workaround with [\W\w].
      html = html.replace(new RegExp("([\\W\\w]*)<\\s*\\/\\s*" + stack.last() + "[^>]*>", 'i'),
        function (all, text) {
          text = text.replace(COMMENT_REGEXP, "$1").replace(CDATA_REGEXP, "$1");

          if (handler.chars) handler.chars(decodeEntities(text));

          return "";
        });

      parseEndTag("", stack.last());
    }

    if (html == last) {
      // benweet
      // throw $sanitizeMinErr('badparse', "The sanitizer was unable to parse the following block " +
      // 	"of html: {0}", html);
      stack.reverse();
      return stack.cl_each(function (tag) {
        buf.push('</');
        buf.push(tag);
        buf.push('>');
      });
    }
    last = html;
  }

  // Clean up any remaining tags
  parseEndTag();

  function parseStartTag(tag, tagName, rest, unary) {
    tagName = tagName && tagName.toLowerCase();
    if (blockElements[tagName]) {
      while (stack.last() && inlineElements[stack.last()]) {
        parseEndTag("", stack.last());
      }
    }

    if (optionalEndTagElements[tagName] && stack.last() == tagName) {
      parseEndTag("", tagName);
    }

    unary = voidElements[tagName] || !!unary;

    if (!unary) {
      stack.push(tagName);
    }

    var attrs = {};

    rest.replace(ATTR_REGEXP,
      function (match, name, doubleQuotedValue, singleQuotedValue, unquotedValue) {
        var value = doubleQuotedValue || singleQuotedValue || unquotedValue || '';

        attrs[name] = decodeEntities(value);
      });
    if (handler.start) handler.start(tagName, attrs, unary);
  }

  function parseEndTag(tag, tagName) {
    var pos = 0,
      i;
    tagName = tagName && tagName.toLowerCase();
    if (tagName) {
      // Find the closest opened tag of the same type
      for (pos = stack.length - 1; pos >= 0; pos--) {
        if (stack[pos] == tagName) break;
      }
    }

    if (pos >= 0) {
      // Close all the open elements, up the stack
      for (i = stack.length - 1; i >= pos; i--)
        if (handler.end) handler.end(stack[i]);

      // Remove the open elements from the stack
      stack.length = pos;
    }
  }
}
1362666
def handle_data(self, data):
        """"""
        if not self.silent:
            if self.url:
                if self.url == data:
                    data = ''
                else:
                    data = '(' + data + ')'
            self.url = ''
            self.result += cgi.escape(data, True)
        lines = data.splitlines()
        if len(lines) > 1:
            match_obj = RE_HTML_FIRST_NON_QUOTATION_CHAR_ON_LINE.search(
                lines[-1])
            if match_obj:
                self.line_quotation = '&gt;' * match_obj.start()
            else:
                self.line_quotation = ''
729955
def main(api_key, markup):
    ''''''
    match = GIPHY.search(markup)

    attrs = None

    if match:
        attrs = dict(
            [(key, value.strip())
             for (key, value) in match.groupdict().items() if value])

    else:
        raise ValueError('Error processing input. '
                         'Expected syntax: {}'.format(SYNTAX))

    return create_html(api_key, attrs)
1014398
def _ExtractDataFromShowHtml(self, html):
    
    htmlLines = html.splitlines()
    for count, line in enumerate(htmlLines):
      if line.strip() == r'<pre>':
        startLine = count+1
      if line.strip() == r'</pre>':
        endLine = count

    try:
      dataList = htmlLines[startLine:endLine]
      dataString = '\n'.join(dataList)
      return dataString.strip()
    except:
      raise Exception("Show content not found - check EPGuides html formatting")
685215
def html(self) -> str:
        """"""
        if self.parentNode and self.parentNode._should_escape_text:
            return html.escape(self.data)
        return self.data
924639
function parseCustomHtmlToReact(html, context) {
  if (!defined(html) || html.length === 0) {
    return html;
  }
  return htmlToReactParser.parseWithInstructions(
    html,
    isValidNode,
    getProcessingInstructions(context || {})
  );
}
1354335
def generic_html(self, result, errors):
        
        h1 = htmlize(type(result))
        out = []
        result = pre_process_json(result)

        if not hasattr(result, 'items'):
            # result is a non-container
            header = "<tr><th>Value</th></tr>"
            if type(result) is list:
                result = htmlize_list(result)
            else:
                result = htmlize(result)
            out = ["<tr><td>" + result + "</td></tr>"]
        elif hasattr(result, 'lower'):
            out = ["<tr><td>" + result + "</td></tr>"]
        else:
            # object is a dict
            header = "<tr><th>Key</th><th>Value</th></tr>"
            for key, value in result.items():
                v = htmlize(value)
                row = "<tr><td>{0}</td><td>{1}</td></tr>".format(key, v)
                out.append(row)

        env = Environment(loader=PackageLoader('giotto'))
        template = env.get_template('generic.html')
        rendered = template.render({'header': h1, 'table_header': header, 'table_body': out})
        return {'body': rendered, 'mimetype': 'text/html'}
842920
def parse_html(self, attr_string):
        """"""
        splitter = re.compile(self.split_regex(separator=self.spnl))
        attrs = splitter.split(attr_string)[1::2]

        idre = re.compile(r'''id=["']?([\w ]*)['"]?''')
        clsre = re.compile(r'''class=["']?([\w ]*)['"]?''')

        id_matches = [idre.search(a) for a in attrs]
        cls_matches = [clsre.search(a) for a in attrs]

        try:
            id = [m.groups()[0] for m in id_matches if m][0]
        except IndexError:
            id = ''

        classes = [m.groups()[0] for m in cls_matches if m][0].split()

        special = ['unnumbered' for a in attrs if '-' in a]
        classes.extend(special)

        kvs = [a.split('=', 1) for a in attrs if '=' in a]
        kvs = OrderedDict((k, v) for k, v in kvs if k not in ('id', 'class'))

        return id, classes, kvs
1201035
function HTMLReactParser(html, options) {
  if (typeof html !== 'string') {
    throw new TypeError('First argument must be a string');
  }
  return domToReact(htmlToDOM(html, domParserOptions), options);
}
491151
def html_to_dom(html, default_encoding=DEFAULT_ENCODING, encoding=None, errors=DEFAULT_ENC_ERRORS):
    """"""
    if isinstance(html, unicode):
        decoded_html = html
        # encode HTML for case it's XML with encoding declaration
        forced_encoding = encoding if encoding else default_encoding
        html = html.encode(forced_encoding, errors)
    else:
        decoded_html = decode_html(html, default_encoding, encoding, errors)

    try:
        dom = lxml.html.fromstring(decoded_html, parser=lxml.html.HTMLParser())
    except ValueError:
        # Unicode strings with encoding declaration are not supported.
        # for XHTML files with encoding declaration, use the declared encoding
        dom = lxml.html.fromstring(html, parser=lxml.html.HTMLParser())

    return dom
817216
function processIssueHtml(element) {
			let outerHTML = null;
			let innerHTML = null;
			if (!element.outerHTML) {
				return outerHTML;
			}
			outerHTML = element.outerHTML;
			if (element.innerHTML.length > 31) {
				innerHTML = `${element.innerHTML.substr(0, 31)}...`;
				outerHTML = outerHTML.replace(element.innerHTML, innerHTML);
			}
			if (outerHTML.length > 251) {
				outerHTML = `${outerHTML.substr(0, 250)}...`;
			}
			return outerHTML;
		}
913203
function parse(html) {
  // compatibility with the old signature
  html = arguments[arguments.length - 1];

  var items      = [];
  var parsedHTML = $.load(html);

  parsedHTML('[itemtype]').map(function (i, item) {
    processItemtype(item, items);
  });

  parsedHTML('[itemprop]').map(function (i, item) {
    processItemprop(item, items);
  });

  return exports.returnJson ? JSON.stringify(items) : items;
}
1102719
def process_input(self, paragraph):
        """"""
        try:
            lang, body = paragraph.split(None, 1)
        except ValueError:
            lang, body = paragraph, None

        if not lang.strip().startswith('%'):
            lang = 'scala'
            body = paragraph.strip()

        else:
            lang = lang.strip()[1:]

        if lang == 'md':
            self.build_markdown(lang, body)
        else:
            self.build_code(lang, body)
341724
public String process(String input) {
        Document doc = Jsoup.parse(input);

        // check if the user wants to inline the data
        Elements elements = doc.getElementsByAttributeValue(DATA_INLINE_ATTR, "true");
        if (elements.isEmpty()) {
            return input;
        }

        extractStyles(doc);
        applyStyles(doc);
        inlineImages(doc);

        doc.outputSettings(doc.outputSettings().syntax(Document.OutputSettings.Syntax.xml).prettyPrint(false).escapeMode(Entities.EscapeMode.extended));
        return StringEscapeUtils.unescapeHtml(doc.outerHtml());
    }
1198651
def _pre_tidy(html):
    
    tree = etree.fromstring(html, etree.HTMLParser())
    for el in tree.xpath('//u'):
        el.tag = 'em'
        c = el.attrib.get('class', '').split()
        if 'underline' not in c:
            c.append('underline')
            el.attrib['class'] = ' '.join(c)

    return tohtml(tree)