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

Function getFrontmatter

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

* @param {string} content * @return {?string}

(content)

Source from the content-addressed store, hash-verified

34 * @return {?string}
35 */
36function getFrontmatter(content) {
37 const end = content.search(/(\n-|\n#)/m);
38 if (end < 0) {
39 return null;
40 }
41 const withWhitespace = content.substr(0, end);
42 if (withWhitespace.trim().length < 1) {
43 return null;
44 }
45 return withWhitespace;
46}
47
48/**
49 * @param {?string} maybeComment

Callers 1

overrideTocFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected