Applies text-to-HTML conversion.
    
    Takes an optional argument to specify the name of a filter to use.
198307
def apply_markup(value, arg=None):
    
    if arg is not None:
        return formatter(value, filter_name=arg)
    return formatter(value)
367489
def html_format(value):
    
    if not value:
        return ''
    elif MARKUP_LANGUAGE == 'markdown':
        return markdown(value)
    elif MARKUP_LANGUAGE == 'textile':
        return textile(value)
    elif MARKUP_LANGUAGE == 'restructuredtext':
        return restructuredtext(value)
    elif '</p>' not in value:
        return linebreaks(value)
    return value
1169256
def _filter(self, text, context, encoding):
        """"""

        content = []
        blocks, attributes, comments = self.to_text(bs4.BeautifulSoup(text, self.parser))
        if self.comments:
            for c, desc in comments:
                content.append(filters.SourceText(c, context + ': ' + desc, encoding, self.type + 'comment'))
        if self.attributes:
            for a, desc in attributes:
                content.append(filters.SourceText(a, context + ': ' + desc, encoding, self.type + 'attribute'))
        for b, desc in blocks:
            content.append(filters.SourceText(b, context + ': ' + desc, encoding, self.type + 'content'))
        return content
1307589
def raw_html_filter(key: str, value: list, format: str, meta: Any) -> Optional[list]:
    
    if key == "RawInline" and format == "latex" and value[0] == "html":
        if value[1] == "<sup>":
            filtered = [RawInline("latex", r"\textsuperscript{")]
        elif value[1] == "</sup>":
            filtered = [RawInline("latex", "}")]
        elif value[1] == "<sub>":
            filtered = [RawInline("latex", r"\textsubscript{")]
        elif value[1] == "</sub>":
            filtered = [RawInline("latex", "}")]
        else:
            return None
        return filtered

    return None
221006
def convert_text(filename):
    """"""
    text_content = open(filename, "r")
    if ".md" in filename:
        text_cont1 = "\n" + markdown.markdown(text_content.read()) + "\n"
    elif ".docx" in filename:
        with open(os.path.join(cwd, "content", filename), "rb") as docx_file:
            result = mammoth.convert_to_html(docx_file)
            final_docx_html = result.value
        text_cont1 = "\n" + final_docx_html + "\n"
    elif ".tile" in filename:
        text_cont1 = "\n" + textile.textile(text_content.read()) + "\n"
    elif ".jade" in filename:
        text_cont1 = "\n" + pyjade.simple_convert(text_content.read()) + "\n"
    elif ".rst" in filename:
        text_cont1 = "\n" + \
            publish_parts(text_content.read(), writer_name='html')[
                'html_body'] + "\n"
    elif ".html" in filename:
        text_cont1 = text_content.read()
    elif ".txt" in filename:
        text_cont1 = text_content.read()
    else:
        print(filename + " is not a valid file type!")
        text_cont1 = "NULL"

    return text_cont1 + "\n\n"
1261637
function renderHtml(fragment, opts) {
    var html = (!fragment || !u.trim(fragment._txt)) ?
      '&nbsp;' : // show space for empty/missing to allow selection/editing
      renderMarkdown(fragment._txt, opts);
    // use opts.noWrap to avoid breaking CSS nested selectors like li > ul in menus
    if (opts && opts.noWrap) return html;
    var href = (fragment && esc(fragment._href)) || '';
    return '<div data-render-html="' + href + '">' + html + '</div>';
  }
1201483
def to_html(input, context = {}, result = nil)
      result = call(input, context, result = nil)
      output = result[:output]
      if output.respond_to?(:to_html)
        output.to_html
      else
        output.to_s
      end
    end
266747
def detect_html(text):
    
    pattern = re.compile('\\s*<(!doctype|html)', re.IGNORECASE)
    return bool(pattern.match(text))
570895
def _htmlify_text(self, s):
    """"""
    colored = self._handle_ansi_color_codes(html.escape(s))
    return linkify(self._buildroot, colored, self._linkify_memo).replace('\n', '</br>')
1003949
static String convertFromHtml(final String textToConvert) {

        //LinkedHashmap since the order matters
        final Map<String, String> regexps = new LinkedHashMap<>();

        regexps.put("< *a *href=[\'\"](.*?)[\'\"] *>(.*?)</ *a *>","$2 ($1)");
        regexps.put("< *a *href=[\'\"](.*?)[\'\"] *>(.*?)< *a */>","$2 ($1)");
        regexps.put("</ *(br|p|table|h[1-4]|pre|hr|li|ul) *>","\n");
        regexps.put("< *(br|p|table|h[1-4]|pre|hr|li|ul) */>","\n");
        regexps.put("< *(p|table|h[1-4]|ul|pre) *>","\n");
        regexps.put("<li>", " - ");
        regexps.put("</th>", "\t");
        regexps.put("<\\w*?>", "");

        return regexps.entrySet().stream().sequential()
                .reduce(textToConvert, (string, entrySet) -> string.replaceAll(entrySet.getKey(), entrySet.getValue()), (a, b) -> b);
    }
241012
def filter(parent, indent)
      return unless (filter_name = accept :filter)

      # Get element attributes
      atts = attributes(shorthand_attributes) || {}

      # Accept inline text or multiline text feed as first child
      error :fiter unless accept(:line_feed).strip.empty?

      # Get everything under the filter and set it as the node value
      # and create a new node and set its extension
      parent[@children] << [
        :filter,
        filter_name[1..-1].to_sym,
        atts,
        get_indented_lines(indent),
        indent
      ]
    end
745154
def do_striptags(value):
    
    if hasattr(value, '__html__'):
        value = value.__html__()
    return Markup(text_type(value)).striptags()
520823
function htmlToComponent(str, tags, opts) {
  var keys = objectKeys(tags);
  var props = opts.props || {};
  var preserveAttributes = opts.preserveAttributes || [];
  var tagAttributes = [];
  var reactTags={};
  var reactKeys=[];
  var key;
  for(var i = 0; i<keys.length; i++) {
    key = "AB"+Math.random().toString(36).substring(2);
    if(typeof tags[keys[i]] !== "function") {
      if(typeof tags[keys[i]].slice !== "function") continue;
      tagAttributes = tags[keys[i]].slice(0,-1);
      reactTags[key] = tags[keys[i]].slice(-1)[0];
    }
    else
      reactTags[key] = tags[keys[i]];

    reactKeys.push(key);

    str = str
      .replace(new RegExp("(<\/?)"+keys[i]+"(?:[^>\"']|\".*\"|'.*')*>", "ig"), function(match, start){
        // find/replace spell-save attributes within tag to restore capitals
        if(start !== "</")
          for(var a=0; a<tagAttributes.length; a++)
            match = replaceAttribute(match, tagAttributes[a], tagAttributes[a]);

        // replace key
        return match
          .replace(new RegExp(start+keys[i]+"(\\s|>)", "i"), start+key+"$1");
      });
  }

  // remove/disable html comments
  str = str.replace(/<!--|-->/g,"")

  // find/replace global spell-save attributes to restore capitals
  var attributes = preserveReactAttributes.concat(preserveAttributes);
  for(var i=0; i<attributes.length; i++) 
    str = replaceAttribute(str, attributes[i], attributes[i]);
 
  var jsx = htmlToJsx(str);

  // replace props variables {key} with corrected variables {props['key']}
  for(var key in props) {
    jsx = jsx
      .replace(new RegExp("(\{"+key+"\})","g"),"{props['"+key+"']}");
  }
  
  var component = ReactTransform(jsx).code;
  
  // replace component variables (ComponentName) with corrected variables (tags['ComponentName'])
  for(var i=0; i<reactKeys.length; i++) {
    component = component
      .replace(new RegExp(reactKeys[i],"g"), "reactTags['"+reactKeys[i]+"']"); 
  }

  return eval(component);
}
710320
def _render(self, text):
        ''''''
        parser = commonmark.Parser()
        ast = parser.parse(text)
        renderer = HtmlRenderer(self)
        html = renderer.render(ast)
        return html
1147785
def _filtered(self, text):
        '''
        
        '''
        filtered = None
        # Text is converted to lower case first, partially for historical
        # purposes, but also because it simplifies writing filter rules
        # (e.g., don't have to worry about case sensitivity).
        text = text.lower()

        for include in self.includes:
            if include.search(text):
                filtered = False
                break

        # If exclusive include filters have been specified and did
        # not match the text, then the text should be filtered out.
        if self.includes and filtered == None:
            return True

        for exclude in self.excludes:
            if exclude.search(text):
                filtered = True
                break

        # If no explicit exclude filters were matched, then the
        # text should *not* be filtered.
        if filtered == None:
            filtered = False

        return filtered
715385
def markdownify(input)
      @context.registers[:site].find_converter_instance(
        Jekyll::Converters::Markdown
      ).convert(input.to_s)
    end
1096306
def textilize(input)
      site = @context.registers[:site]
      converter = if site.respond_to?(:find_converter_instance)
        site.find_converter_instance(Jekyll::Converters::Textile)
      else
        site.getConverterImpl(Jekyll::Converters::Textile)
      end
      converter.convert(input)
    end