* @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)
| 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); } |
nothing calls this directly
no test coverage detected