MCPcopy Create free account
hub / github.com/socketstream/socketstream / prettyPrintOne

Function prettyPrintOne

docs/js/google-code-prettify.js:1391–1409  ·  view source on GitHub ↗

* @param sourceCodeHtml {string} The HTML to pretty print. * @param opt_langExtension {string} The language name to use. * Typically, a filename extension like 'cpp' or 'java'. * @param opt_numberLines {number|boolean} True to number lines, * or the 1-indexed number of the first

(sourceCodeHtml, opt_langExtension, opt_numberLines)

Source from the content-addressed store, hash-verified

1389 * or the 1-indexed number of the first line in sourceCodeHtml.
1390 */
1391 function prettyPrintOne(sourceCodeHtml, opt_langExtension, opt_numberLines) {
1392 var container = document.createElement('pre');
1393 // This could cause images to load and onload listeners to fire.
1394 // E.g. <img onerror="alert(1337)" src="nosuchimage.png">.
1395 // We assume that the inner HTML is from a trusted source.
1396 container.innerHTML = sourceCodeHtml;
1397 if (opt_numberLines) {
1398 numberLines(container, opt_numberLines, true);
1399 }
1400
1401 var job = {
1402 langExtension: opt_langExtension,
1403 numberLines: opt_numberLines,
1404 sourceNode: container,
1405 pre: 1
1406 };
1407 applyDecorator(job);
1408 return container.innerHTML;
1409 }
1410
1411 function prettyPrint(opt_whenDone) {
1412 function byTagName(tn) { return document.getElementsByTagName(tn); }

Callers

nothing calls this directly

Calls 2

numberLinesFunction · 0.85
applyDecoratorFunction · 0.85

Tested by

no test coverage detected