Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: Source/devtools/front_end/documentation/DocumentationView.js

Issue 530003002: DevTools: [Documentation] Add syntax highlight for code examples (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@iliia-patch
Patch Set: Comments addressed Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/documentation/DocumentationView.js
diff --git a/Source/devtools/front_end/documentation/DocumentationView.js b/Source/devtools/front_end/documentation/DocumentationView.js
index 5e782965a5ae9b94703114a957809ef2cd9a23cc..9e496bcf296a5e6825687453af01bc8e656d27d3 100644
--- a/Source/devtools/front_end/documentation/DocumentationView.js
+++ b/Source/devtools/front_end/documentation/DocumentationView.js
@@ -26,6 +26,11 @@ WebInspector.DocumentationView.showDocumentationURL = function(url, searchItem)
view.showDocumentation(url, searchItem);
}
+WebInspector.DocumentationView._languageToMimeType = {
+ "javascript": "text/javascript",
+ "html": "text/html"
+};
+
WebInspector.DocumentationView.prototype = {
/**
* @param {string} url
@@ -213,6 +218,10 @@ WebInspector.DocumentationView.Renderer.prototype = {
var code = example.createChild("div", "documentation-example-code");
code.classList.add("source-code");
code.textContent = examples[i].code;
+ if (!examples[i].language)
+ continue;
+ var syntaxHighlighter = new WebInspector.DOMSyntaxHighlighter(WebInspector.DocumentationView._languageToMimeType[examples[i].language.toLowerCase()], true);
+ syntaxHighlighter.syntaxHighlightNode(code);
}
},

Powered by Google App Engine
This is Rietveld 408576698