Function: extractTextWithWhitespace

Returns the text content of the specified node.

Parameters:

elems - DOM nodes to return the text for.
173787
function(elems)
	{
	    // Known block elements for handling linefeeds (list is not complete)
		var blocks = ['BLOCKQUOTE', 'DIV', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'OL', 'P', 'PRE', 'TABLE', 'UL'];
		var ret = [];
		
		function doExtract(elts)
		{
			// Single break should be ignored
			if (elts.length == 1 && (elts[0].nodeName == 'BR' ||
				elts[0].innerHTML == '\n'))
			{
				return;
			}
			
		    for (var i = 0; i < elts.length; i++)
		    {
		        var elem = elts[i];

				// DIV with a br or linefeed forces a linefeed
				if (elem.nodeName == 'BR' || elem.innerHTML == '\n' ||
					((elts.length == 1 || i == 0) && (elem.nodeName == 'DIV' &&
					elem.innerHTML.toLowerCase() == '<br>')))
		    	{
	    			ret.push('\n');
		    	}
				else
				{
			        if (elem.nodeType === 3 || elem.nodeType === 4)
			        {
			        	if (elem.nodeValue.length > 0)
			        	{
			        		ret.push(elem.nodeValue);
			        	}
			        }
			        else if (elem.nodeType !== 8 && elem.childNodes.length > 0)
					{
						doExtract(elem.childNodes);
					}
			        
	        		if (i < elts.length - 1 && mxUtils.indexOf(blocks, elts[i + 1].nodeName) >= 0)
	        		{
	        			ret.push('\n');		
	        		}
				}
		    }
		};
		
		doExtract(elems);
	    
	    return ret.join('');
	}
1318709
def get_match(self, elem):
        """"""
        for m in self.matches:
            if (m.expression is not None and eval(m.expression)==True) \
            or (m.xpath is not None and len(elem.xpath(m.xpath, namespaces=m.namespaces)) > 0):
                LOG.debug("=> match: %r" % m.expression)
                return m
858768
def extract_paragraphs(xml_string):
    """"""
    assert isinstance(xml_string, str)
    xml_tree = ET.XML(xml_string.encode('utf-8'), parser=UTB())
    full_text = xml_tree.find('article:originalText', elsevier_ns)
    if full_text is None:
        logger.info('Could not find full text element article:originalText')
        return None
    article_body = _get_article_body(full_text)
    if article_body:
        return article_body
    raw_text = _get_raw_text(full_text)
    if raw_text:
        return [raw_text]
    return None
27514
def content(self):
        
        # The code that follows is obviously pretty disgusting.
        # It seems like it might be impossible to completely replicate
        # the text of the original message if it has trailing whitespace
        message = self._content_xpb.one_(self._message_element)
        first_line = message.text
        if message.text[:2] == '  ':
            first_line = message.text[2:]
        else:
            log.debug("message did not have expected leading whitespace")
        subsequent_lines = ''.join([
            html.tostring(child, encoding='unicode').replace('<br>', '\n')
            for child in message.iterchildren()
        ])
        message_text = first_line + subsequent_lines
        if len(message_text) > 0 and message_text[-1] == ' ':
            message_text = message_text[:-1]
        else:
            log.debug("message did not have expected leading whitespace")

        return message_text
1249905
def text_length(elem):
    

    if not elem:
        return 0

    value = elem.value()

    try:
        value = len(value)
    except:
        value = 0

    try:
        for a in elem.elements:
            value += len(a.value())
    except:
        pass

    return value
43539
private void parseElementDecl() throws Exception {
        String name;

        requireWhitespace();
        // Read the element type name.
        name = readNmtoken(true);

        requireWhitespace();
        // Read the content model.
        parseContentspec(name);

        skipWhitespace();
        require('>');
    }
415708
def prettyXml(elem):
    
    roughString = ET.tostring(elem, "utf-8")
    reparsed = minidom.parseString(roughString)
    return reparsed.toprettyxml(indent="  ")
187572
function checkForIrregularWhitespace(node) {
            const sourceLines = sourceCode.lines;

            sourceLines.forEach((sourceLine, lineIndex) => {
                const lineNumber = lineIndex + 1;
                let match;

                while ((match = IRREGULAR_WHITESPACE.exec(sourceLine)) !== null) {
                    const location = {
                        line: lineNumber,
                        column: match.index
                    };

                    errors.push({ node, message: "Irregular whitespace not allowed.", loc: location });
                }
            });
        }
134466
function( elem, context, xml ) {
			while ( (elem = elem[ dir ]) ) {
				if ( checkNonElements || elem.nodeType === 1  ) {
					return matcher( elem, context, xml );
				}
			}
		}
46275
function elem(tagName) {
    if (!utils.isString(tagName)) {
        return null;
    }

    // element at the very least has name and fn to render itself
    var e = {
        tag: tagName
    };

    // add other values to the element based on the input argument
    if (arguments.length > 1) {
        for (var i = 1, len = arguments.length; i < len; ++i) {
            var arg = arguments[i];

            if (utils.isArray(arg)) {
                if (e.children && e.children.length) {
                    e.children = e.children.concat(arg);
                }
                else {
                    e.children = arg;
                }
            }
            else if (utils.isObject(arg) && arg.hasOwnProperty('tag')) {
                e.children = e.children || [];
                e.children.push(arg);
            }
            else if (utils.isObject(arg) && arg.tag && arg.toString) {
                e.children = [arg];
            }
            else if (utils.isObject(arg)) {
                e.attributes = arg;
            }
            else if (utils.isString(arg)) {
                e.text = arg;
            }
        }
    }

    return e;
}
533269
function(text, length) {
  var div = document.createElement('div')
  var node = document.createTextNode(text)
  div.appendChild(node)
  var abbreviated = div.textContent
  if (abbreviated.length <= length) {
    return text
  }

  var lastWhitespaceIndex = abbreviated.substring(0, length - 1).lastIndexOf(' ')
  abbreviated = abbreviated.substring(0, lastWhitespaceIndex) + '\u2026'

  return abbreviated
}
128082
private static String getTextContent(final Element element) {
		if (element != null) {
			String content = element.getTextContent();
			if (content != null) {
				content = content.trim();
			}
			return content;
		}
		return null;
	}
64209
function getText(element) {
    var text = "";

    var isRecentFirefox = (browserVersion.isFirefox && browserVersion.firefoxVersion >= "1.5");
    if (isRecentFirefox || browserVersion.isKonqueror || browserVersion.isSafari || browserVersion.isOpera) {
        text = getTextContent(element);
    } else if (element.textContent) {
        text = element.textContent;
    } else if (element.innerText) {
        text = element.innerText;
    }

    text = normalizeNewlines(text);
    text = normalizeSpaces(text);

    return text.trim();
}
261820
function( node ) {
			var out = '',
				j = 0;

			// if node is a text node get its text
			if(node.nodeType && node.nodeType === 3){
				//out += modules.domUtils.getElementText( node );
				var containerNode = modules.domUtils.createNode('div');
				modules.domUtils.appendChild(containerNode, modules.domUtils.clone(node));
				out += modules.domUtils.innerHTML(containerNode);
			}


			// exclude text which has been added with include pattern  -
			if(node.nodeType && node.nodeType === 1 && modules.domUtils.hasAttribute(node, 'data-include') === false){

				// begin tag
				out += '<' + node.tagName.toLowerCase();

				// add attributes
				var attrs = modules.domUtils.getOrderedAttributes(node);
				for (j = 0; j < attrs.length; j++) {
					out += ' ' + attrs[j].name +  '=' + '"' + attrs[j].value + '"';
				}

				if(this.selfClosingElt.indexOf(node.tagName.toLowerCase()) === -1){
					out += '>';
				}

				// get the text of the child nodes
				if(node.childNodes && node.childNodes.length > 0){

					for (j = 0; j < node.childNodes.length; j++) {
						var text = this.walkTreeForHtml( node.childNodes[j] );
						if(text !== undefined){
							out += text;
						}
					}
				}

				// end tag
				if(this.selfClosingElt.indexOf(node.tagName.toLowerCase()) > -1){
					out += ' />';
				}else{
					out += '</' + node.tagName.toLowerCase() + '>';
				}
			}

			return (out === '')? undefined : out;
		}
525154
def _parse_text(self, element_name, namespace=''):
        
        try:
            text = self._channel.find('.//' + namespace + element_name).text
        except AttributeError:
            raise Exception(
                'Element, {0} not found in RSS feed'.format(element_name)
            )

        return text
1370206
function getTextRect (node) {
  if (!isBrowser) return
  if (!range) range = document.createRange()

  range.selectNode(node)

  return range.getBoundingClientRect()
}
816740
function getText(node) {
    if (!node || !node.childNodes) {
        return undefined;
    }
    return node.protectedValue ? node.protectedValue.text : node.textContent;
}