Return text formatted as a HTML

  Args:
    text: the text to render
    preformatted: whether the text should be rendered as preformatted
426418
def render_text(text, preformatted=False):
  
  return IPython.core.display.HTML(_html.HtmlBuilder.render_text(text, preformatted))
228884
def pretty_render(data, format='text', indent=0):
    
    if format == 'json':
        return render_json(data)
    elif format == 'html':
        return render_html(data)
    elif format == 'xml':
        return render_xml(data)
    else:
        return dict_to_plaintext(data, indent=indent)
570540
def prettify(unicode_text):
    
    import xml.dom.minidom
    reparsed = xml.dom.minidom.parseString(unicode_text.encode('utf-8'))
    return reparsed.toprettyxml(indent="  ", newl="\n")
569594
function (text) {
        if (text.charAt(0) === '[') {
            switch (text.charAt(text.length - 1)) {
                case ']':
                    return text;
                case '"':
                    return text + ']';
                case ',':
                    return text.substring(0, text.length - 1) + '"]';
                default:
                    return _formatmode7(text.substring(0, text.length - 1));
            }
        } else {
            return text;
        }
    }
1065304
def tokenize(text, format=None):
    
    text = Text(text)
    text = text.replace("\t", " ")
    tokens = re.findall(patterns, text)
    tokens = [token[0] for token in tokens]
    if format == "text":
        return " ".join(tokens)
    else:
        return tokens
597088
def render_text(self, request, instance, context):
        
        render_template = self.get_render_template(request, instance, email_format='text')
        if not render_template:
            # If there is no TEXT variation, create it by removing the HTML tags.
            base_url = request.build_absolute_uri('/')
            html = self.render_html(request, instance, context)
            return html_to_text(html, base_url)

        instance_context = self.get_context(request, instance, email_format='text', parent_context=context)
        instance_context['email_format'] = 'text'

        text = self.render_to_string(request, render_template, instance_context)
        text = text + ""  # Avoid being a safestring
        if self.render_replace_context_fields:
            text = replace_fields(text, instance_context, autoescape=False)
        return text
88531
def _render(self, content, **settings):
        
        lines = self._render_content(content, **settings)

        result = []
        s = self._es_margin(settings)
        for l in lines:
            result.append(self.fmt_margin(l, **s))

        return result
676363
def highlightBlock(self, text):
        
        self.highlight_block(text)

        # Process blocks for fold detection
        current_block = self.currentBlock()
        previous_block = self._find_prev_non_blank_block(current_block)
        if self.editor:
            if self.fold_detector is not None:
                self.fold_detector._editor = weakref.ref(self.editor)
                self.fold_detector.process_block(
                    current_block, previous_block, text)
377630
def html_to_text(html_string):
    
    # create a valid html document from string
    # beware that it inserts <hmtl> <body> and <p> tags
    # where needed
    html_tree = html.document_fromstring(html_string)

    # handle header tags
    for h in html_tree.cssselect("h1, h2, h3, h4, h5, h6"):
        # add two newlines after a header tag
        h.text = h.text + '\n\n'

    # handle links
    # find all a tags starting from the root of the document //
    # and replace the link with (link)
    for a in html_tree.xpath("//a"):
        href = a.attrib['href']
        a.text = a.text + " (" + href + ")"

    # handle paragraphs
    for p in html_tree.xpath("//p"):
        # keep the tail if there is one
        # or add two newlines after the text if there is no tail
        p.tail = p.tail if p.tail else "\n\n"

    # handle breaks
    for br in html_tree.xpath("//br"):
        # add a newline and then the tail (remaining text after the <br/> tag)
        # or add a newline only if there is no tail
        # http://stackoverflow.com/questions/18660382/how-can-i-preserve-br-as-newlines-with-lxml-html-text-content-or-equivalent?rq=1
        br.tail = "\n" + br.tail if br.tail else "\n"

    return html_tree.text_content()
1136923
def html_text(parent, indent)
      return unless (text_feed = accept :html_text)

      text_node = [
        :plain,
        :text,
        {
          value: text_feed.strip,
          escaped: false
        },
        nil,
        indent
      ]

      parent[@children] << text_node
    end
951842
async def render(
        text: TransText,
        request: Optional['Request'],
        multi_line=False) -> Union[Text, List[Text]]:
    

    if isinstance(text, str):
        out = [text]
    elif isinstance(text, StringToTranslate):
        out = await text.render_list(request)
    else:
        raise TypeError('Provided text cannot be rendered')

    if multi_line:
        return out
    else:
        return ' '.join(out)
918189
def parse(self, text):
        
        if self.format == 'markdown':
            try:
                import markdown
            except ImportError:
                raise RuntimeError(u"Looks like markdown is not installed")

            if text.startswith(u'\ufeff'):  # check for unicode BOM
                text = text[1:]

            return markdown.markdown(text, extensions=self.md_extensions)
        elif self.format == 'restructuredtext':
            try:
                from landslide.rst import html_body
            except ImportError:
                raise RuntimeError(u"Looks like docutils are not installed")

            html = html_body(text, input_encoding=self.encoding)

            # RST generates pretty much markup to be removed in our case
            for (pattern, replacement, mode) in self.RST_REPLACEMENTS:
                html = re.sub(re.compile(pattern, mode), replacement, html, 0)

            return html.strip()
        elif self.format == 'textile':
            try:
                import textile
            except ImportError:
                raise RuntimeError(u"Looks like textile is not installed")

            text = text.replace('\n---\n', '\n<hr />\n')

            return textile.textile(text, encoding=self.encoding)
        else:
            raise NotImplementedError(u"Unsupported format %s, cannot parse"
                                      % self.format)
179755
def to_text(value):
    

    text = _by_value.get(value)
    if text is None:
        text = str(value)
    return text
152775
def convert_raw_html(text: str, format: Optional[str] = None) -> "applyJSONFilters":
    """"""
    return applyJSONFilters([raw_html_filter], text, format=format)
1305620
def render(format = :html, position = :prefix, colors = Screen.default_css_colors)
			case format
			when :html
				case position
				when :prefix
					style_code = css_style(colors)
					if style_code
						return %Q|<span style="#{style_code}">|
					else
						return ''
					end
				when :postfix
					style_code = css_style(colors)
					if style_code
						return '</span>'
					else
						return ''
					end
				end
			when :text
				return ''
			end
		end
1151834
def format_content(content):
    

    paragraphs = parse_html(content)

    first = True

    for paragraph in paragraphs:
        if not first:
            yield ""

        for line in paragraph:
            yield line

        first = False
1176994
def FromTextFormat(cls, text):
    """"""
    tmp = cls.protobuf()  # pylint: disable=not-callable
    text_format.Merge(text, tmp)

    return cls.FromSerializedString(tmp.SerializeToString())