* Given an element, if it contains only one child element and any text nodes * it contains contain only space characters, return the sole child element. * Otherwise returns undefined. * * This is meant to return the CODE element in when * there is a single
(element)
| 595 | * is textual content. |
| 596 | */ |
| 597 | function childContentWrapper(element) { |
| 598 | var wrapper = undefined; |
| 599 | for (var c = element.firstChild; c; c = c.nextSibling) { |
| 600 | var type = c.nodeType; |
| 601 | wrapper = (type === 1) // Element Node |
| 602 | ? (wrapper ? element : c) |
| 603 | : (type === 3) // Text Node |
| 604 | ? (notWs.test(c.nodeValue) ? element : wrapper) |
| 605 | : wrapper; |
| 606 | } |
| 607 | return wrapper === element ? undefined : wrapper; |
| 608 | } |
| 609 | |
| 610 | /** Given triples of [style, pattern, context] returns a lexing function, |
| 611 | * The lexing function interprets the patterns to find token boundaries and |