MCPcopy
hub / github.com/typescript-cheatsheets/react / getFenceForSection

Function getFenceForSection

genReadme.mjs:134–148  ·  view source on GitHub ↗
(readme, sectionName, isToc = false)

Source from the content-addressed store, hash-verified

132 return fenceContent;
133}
134function getFenceForSection(readme, sectionName, isToc = false) {
135 try {
136 let fence = getFence(sectionName, isToc);
137 let regex = new RegExp(`(${fence.start}[\\s\\S]+${fence.end})`, "gm");
138 return { regex: regex, content: regex.exec(readme.content) };
139 } catch (err) {
140 console.error(
141 `🚨 You've encountered a ${err.name} ➜ ${err.message} \n` +
142 `💡 ProTip ➜ Please ensure the comments exist and are separated by a newline.`
143 );
144
145 console.error({ readme, sectionName });
146 console.error(err);
147 }
148}
149function getFence(sectionName, isToc = false) {
150 let name = isToc ? sectionName + "-toc" : sectionName;
151 let START_COMMENT = "<!--START-SECTION:" + name + "-->";

Callers 1

updateSectionWithFunction · 0.85

Calls 1

getFenceFunction · 0.85

Tested by

no test coverage detected