MCPcopy Create free account
hub / github.com/ampproject/amphtml / isolateCommentJson

Function isolateCommentJson

build-system/tasks/markdown-toc/index.js:52–68  ·  view source on GitHub ↗

* @param {?string} maybeComment * @return {?Object}

(maybeComment)

Source from the content-addressed store, hash-verified

50 * @return {?Object}
51 */
52function isolateCommentJson(maybeComment) {
53 if (!maybeComment) {
54 return null;
55 }
56
57 const json = maybeComment.replace('<!--', '').replace('-->', '').trim();
58 if (!json) {
59 return null;
60 }
61
62 try {
63 const options = JSON.parse(json);
64 return options;
65 } catch (_) {
66 return null;
67 }
68}
69
70/**
71 * @param {string} content

Callers 1

overrideTocFunction · 0.85

Calls 2

replaceMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected