Strips the outer tag, if text starts with a tag.  Not entity aware;
    designed to quickly strip outer tags from lxml cleaner output.  Only
    checks for <p> and <div> outer tags.
484803
def strip_outer_tag(text):
    """"""
    if not text or not isinstance(text, basestring):
        return text
    stripped = text.strip()
    if (stripped.startswith('<p>') or stripped.startswith('<div>')) and \
        (stripped.endswith('</p>') or stripped.endswith('</div>')):
        return stripped[stripped.index('>')+1:stripped.rindex('<')]
    return text
72708
def handle_endtag(self, tag):
        
        if tag in PARENT_ELEMENTS:
            self.current_parent_element['tag'] = ''
            self.current_parent_element['attrs'] = ''

        if tag == 'li':
            self.parsing_li = True
        if tag != 'br':
            self.cleaned_html += '</{}>'.format(tag)
1246673
private void processTag(boolean start) {
    	if (start) {
    		nested++;
    		doc.startElement(tag,attributes);
    	}
    	else {
            nested--;
            doc.endElement(tag);
    	}
    }
1211876
private void processEndTag() throws XMLStreamException, TTException {
        mLevelInToShredder--;

        if (mInserted) {
            mInsertedEndTag = true;
        }

        if (mRemovedNode) {
            mRemovedNode = false;
        } else {

            // Move cursor to parent.
            if (mWtx.getNode().getDataKey() == mLastNodeKey) {
                /*
                 * An end tag must have been parsed immediately before and it
                 * must have been an empty element at the end of a subtree, thus
                 * move this time to parent node.
                 */
                assert mWtx.getNode().hasParent() && mWtx.getNode().getKind() == IConstants.ELEMENT;
                mWtx.moveTo(mWtx.getNode().getParentKey());
            } else {
                if (mWtx.getNode().getKind() == IConstants.ELEMENT) {
                    final ElementNode element = (ElementNode)mWtx.getNode();
                    if (element.hasFirstChild() && element.hasParent()) {
                        // It's not an empty element, thus move to parent.
                        mWtx.moveTo(mWtx.getNode().getParentKey());
                    }
                    // } else {
                    // checkIfLastNode(true);
                    // }
                } else if (((ITreeStructData)mWtx.getNode()).hasParent()) {
                    if (((ITreeStructData)mWtx.getNode()).hasRightSibling()) {
                        mWtx.moveTo(((ITreeStructData)mWtx.getNode()).getRightSiblingKey());
                        /*
                         * Means next event is an end tag in StAX reader, but
                         * something different where the Treetank transaction
                         * points to, which also means it has to be deleted.
                         */
                        mKeyMatches = -1;
                        mDelete = EDelete.ATBOTTOM;
                        deleteNode();
                    }
                    mWtx.moveTo(mWtx.getNode().getParentKey());
                }

            }

            mLastNodeKey = mWtx.getNode().getDataKey();

            // Move cursor to right sibling if it has one.
            if (((ITreeStructData)mWtx.getNode()).hasRightSibling()) {
                mWtx.moveTo(((ITreeStructData)mWtx.getNode()).getRightSiblingKey());
                mMovedToRightSibling = true;

                skipWhitespaces(mReader);
                if (mReader.peek().getEventType() == XMLStreamConstants.END_ELEMENT) {
                    /*
                     * Means next event is an end tag in StAX reader, but
                     * something different where the Treetank transaction points
                     * to, which also means it has to be deleted.
                     */
                    mKeyMatches = -1;
                    mDelete = EDelete.ATBOTTOM;
                    deleteNode();
                }
            } else {
                mMovedToRightSibling = false;
            }
        }
    }
244300
def clean_text(self, text):
        ''''''
        if text is None:
            return ''
        text = re.sub(ILLEGAL_CHARACTERS_RE, '', text)
        if '<' in text or '&lt' in text:
            text = clean(text, tags=self.tags, strip=self.strip)

        return unescape(text)
864912
def empty_content?(element)
        text = +""
        child_nodes = element.child_nodes
        (0...child_nodes.length).each do |i|
          item = child_nodes.item(i)
          if item.node_type == Node.TEXT_NODE
            text << item.get_data.strip
          end
        end
        text.strip.length == 0
      end
608653
def strip_html(html)
      return @stripped_html if @stripped_html
      allowed = @settings[:allowed_tags]
      reg = if allowed.any?
        Regexp.new(
          %(<(?!(\\s|\\/)*(#{
            allowed.map {|tag| Regexp.escape( tag )}.join( "|" )
          })( |>|\\/|'|"|<|\\s*\\z))[^>]*(>+|\\s*\\z)),
          Regexp::IGNORECASE | Regexp::MULTILINE, 'u'
        )
      else
        /<[^>]*(>+|\s*\z)/m
      end
       @stripped_html = html.gsub(reg,'')
    end
630334
def _get_stripped_text_from_node(self, node):
        """"""
        return (
            node.text_content()
            .replace(u"\u00A0", " ")
            .replace("\t", "")
            .replace("\n", "")
            .strip()
        )
340423
def removeTags(dom):
    
    # python 2 / 3 shill
    try:
        string_type = basestring
    except NameError:
        string_type = str

    # initialize stack with proper value (based on dom parameter)
    element_stack = None
    if type(dom) in [list, tuple]:
        element_stack = dom
    elif isinstance(dom, HTMLElement):
        element_stack = dom.childs if dom.isTag() else [dom]
    elif isinstance(dom, string_type):
        element_stack = parseString(dom).childs
    else:
        element_stack = dom

    # remove all tags
    output = ""
    while element_stack:
        el = element_stack.pop(0)

        if not (el.isTag() or el.isComment() or not el.getTagName()):
            output += el.__str__()

        if el.childs:
            element_stack = el.childs + element_stack

    return output
92497
def strip_text(text, entities):
    
    if not entities:
        return text.strip()

    while text and text[-1].isspace():
        e = entities[-1]
        if e.offset + e.length == len(text):
            if e.length == 1:
                del entities[-1]
                if not entities:
                    return text.strip()
            else:
                e.length -= 1
        text = text[:-1]

    while text and text[0].isspace():
        for i in reversed(range(len(entities))):
            e = entities[i]
            if e.offset != 0:
                e.offset -= 1
                continue

            if e.length == 1:
                del entities[0]
                if not entities:
                    return text.lstrip()
            else:
                e.length -= 1

        text = text[1:]

    return text
220368
def strip_tags(cls, html):
        
        s = cls()
        s.feed(html)

        return s.get_data()
678206
def __strip_tags(self, node: yaml.Node) -> None:
        
        if isinstance(node, yaml.SequenceNode):
            for subnode in node.value:
                self.__strip_tags(subnode)
        elif isinstance(node, yaml.MappingNode):
            node.tag = 'tag:yaml.org,2002:map'
            for key_node, value_node in node.value:
                self.__strip_tags(key_node)
                self.__strip_tags(value_node)
1239586
def tag_with_inline_text(tag_node)
      # Normalize each of the lines to ignore the multiline bar (|) and
      # excess whitespace
      @document.source_lines[(tag_node.line - 1)...(following_node_line(tag_node) - 1)]
               .map do |line|
        line.strip.gsub(/\|\z/, '').rstrip
      end.join(' ')
    end
1212607
function(node) {
			//skip nodes with no name
			if (!node.name) {
				return true;
			}
	
			//skip formatting elements
			if (node.name === "b" || node.name === "i" || node.name === "em") { //$NON-NLS-0$ //$NON-NLS-1$ //$NON-NLS-2$
				return true;
			}
	
			//skip paragraphs and other blocks of formatted text
			if (node.name === "tt" || node.name === "code" || node.name === "blockquote") { //$NON-NLS-0$ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
				return true;
			}
			//include the element if we have no reason to skip it
			return false;
		}
688162
def is_break_tag(self, el):
        """"""

        name = sv.util.lower(el.name) if self.type != 'xhtml' else el.name
        return name in self.break_tags or name in self.user_break_tags
702473
def strip_namespaces(file_or_xml):
    

    xml_content = _xml_content_to_string(file_or_xml)
    if not isinstance(xml_content, string_types):
        return xml_content

    # This pattern can have overlapping matches, necessitating the loop
    while _NAMESPACES_FROM_DEC_REGEX.search(xml_content) is not None:
        xml_content = _NAMESPACES_FROM_DEC_REGEX.sub(r'\1', xml_content)

    # Remove namespaces at the tag level
    xml_content = _NAMESPACES_FROM_TAG_REGEX.sub(r'\1', xml_content)

    # Remove namespaces at the attribute level
    xml_content = _NAMESPACES_FROM_ATTR_REGEX.sub(r'\1\3', xml_content)

    return xml_content
393498
private static String stripFileExtensionIfAny(final String name) {
        final int suffix = name.lastIndexOf(".html");
        return suffix == -1 ? name : name.substring(0, suffix);
    }