Index: third_party/WebKit/Source/devtools/front_end/audits2/lighthouse/renderer/dom.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/audits2/lighthouse/renderer/dom.js b/third_party/WebKit/Source/devtools/front_end/audits2/lighthouse/renderer/dom.js |
index 28e02dac9ffc9da49f2bb8776f0055fee1dc6f18..83ab5fdae12c7927a2e2c3639b194a2dd728b29e 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/audits2/lighthouse/renderer/dom.js |
+++ b/third_party/WebKit/Source/devtools/front_end/audits2/lighthouse/renderer/dom.js |
@@ -101,7 +101,7 @@ class DOM { |
* @param {string} text |
* @return {!Element} |
*/ |
- createSpanFromMarkdown(text) { |
+ convertMarkdownLinkSnippets(text) { |
const element = this.createElement('span'); |
// Split on markdown links (e.g. [some link](https://...)). |
@@ -126,6 +126,28 @@ class DOM { |
return element; |
} |
+ /** |
+ * @param {string} text |
+ * @return {!Element} |
+ */ |
+ convertMarkdownCodeSnippets(text) { |
+ const element = this.createElement('span'); |
+ |
+ const parts = text.split(/`(.*?)`/g); // Split on markdown code slashes |
+ while (parts.length) { |
+ // Pop off the same number of elements as there are capture groups. |
+ const [preambleText, codeText] = parts.splice(0, 2); |
+ element.appendChild(this._document.createTextNode(preambleText)); |
+ if (codeText) { |
+ const pre = /** @type {!HTMLPreElement} */ (this.createElement('code')); |
+ pre.textContent = codeText; |
+ element.appendChild(pre); |
+ } |
+ } |
+ |
+ return element; |
+ } |
+ |
/** |
* @return {!Document} |
*/ |