()
| 1438 | var preCodeXmpRe = /^(?:pre|code|xmp)$/i; |
| 1439 | |
| 1440 | function doWork() { |
| 1441 | var endTime = (win['PR_SHOULD_USE_CONTINUATION'] ? |
| 1442 | clock['now']() + 250 /* ms */ : |
| 1443 | Infinity); |
| 1444 | for (; k < elements.length && clock['now']() < endTime; k++) { |
| 1445 | var cs = elements[k]; |
| 1446 | var className = cs.className; |
| 1447 | if (prettyPrintRe.test(className) |
| 1448 | // Don't redo this if we've already done it. |
| 1449 | // This allows recalling pretty print to just prettyprint elements |
| 1450 | // that have been added to the page since last call. |
| 1451 | && !prettyPrintedRe.test(className)) { |
| 1452 | |
| 1453 | // make sure this is not nested in an already prettified element |
| 1454 | var nested = false; |
| 1455 | for (var p = cs.parentNode; p; p = p.parentNode) { |
| 1456 | var tn = p.tagName; |
| 1457 | if (preCodeXmpRe.test(tn) |
| 1458 | && p.className && prettyPrintRe.test(p.className)) { |
| 1459 | nested = true; |
| 1460 | break; |
| 1461 | } |
| 1462 | } |
| 1463 | if (!nested) { |
| 1464 | // Mark done. If we fail to prettyprint for whatever reason, |
| 1465 | // we shouldn't try again. |
| 1466 | cs.className += ' prettyprinted'; |
| 1467 | |
| 1468 | // If the classes includes a language extensions, use it. |
| 1469 | // Language extensions can be specified like |
| 1470 | // <pre class="prettyprint lang-cpp"> |
| 1471 | // the language extension "cpp" is used to find a language handler |
| 1472 | // as passed to PR.registerLangHandler. |
| 1473 | // HTML5 recommends that a language be specified using "language-" |
| 1474 | // as the prefix instead. Google Code Prettify supports both. |
| 1475 | // http://dev.w3.org/html5/spec-author-view/the-code-element.html |
| 1476 | var langExtension = className.match(langExtensionRe); |
| 1477 | // Support <pre class="prettyprint"><code class="language-c"> |
| 1478 | var wrapper; |
| 1479 | if (!langExtension && (wrapper = childContentWrapper(cs)) |
| 1480 | && codeRe.test(wrapper.tagName)) { |
| 1481 | langExtension = wrapper.className.match(langExtensionRe); |
| 1482 | } |
| 1483 | |
| 1484 | if (langExtension) { langExtension = langExtension[1]; } |
| 1485 | |
| 1486 | var preformatted; |
| 1487 | if (preformattedTagNameRe.test(cs.tagName)) { |
| 1488 | preformatted = 1; |
| 1489 | } else { |
| 1490 | var currentStyle = cs['currentStyle']; |
| 1491 | var whitespace = ( |
| 1492 | currentStyle |
| 1493 | ? currentStyle['whiteSpace'] |
| 1494 | : (document.defaultView |
| 1495 | && document.defaultView.getComputedStyle) |
| 1496 | ? document.defaultView.getComputedStyle(cs, null) |
| 1497 | .getPropertyValue('white-space') |
no test coverage detected