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

Function generateContentForSection

genReadme.mjs:99–133  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

97}
98
99function generateContentForSection(options) {
100 const {
101 content,
102 relativeHeadingLevel,
103 name,
104 prefix,
105 showHeading,
106 suffix,
107 tabLevel,
108 withKey,
109 withToc,
110 } = {
111 ...defaultOptions,
112 ...options,
113 };
114 let fence = getFence(name, withToc);
115 let fenceContent = fence.start + "\n";
116 if (withToc) {
117 let lines = content.toc.split("\n");
118 for (let i = 0, len = lines.length; i < len; i += 1)
119 fenceContent +=
120 " ".repeat(tabLevel) + lines[i] + (i !== len - 1 ? "\n" : "");
121 } else {
122 fenceContent += showHeading
123 ? `${"#".repeat(baseHeadingLevel + relativeHeadingLevel)} ` +
124 prefix +
125 content.frontmatter[withKey] +
126 suffix +
127 "\n\n"
128 : "";
129 fenceContent += withHeadingContext(baseHeadingLevel, content.body) + "\n";
130 }
131 fenceContent += fence.end;
132 return fenceContent;
133}
134function getFenceForSection(readme, sectionName, isToc = false) {
135 try {
136 let fence = getFence(sectionName, isToc);

Callers 1

updateSectionWithFunction · 0.85

Calls 2

getFenceFunction · 0.85
withHeadingContextFunction · 0.85

Tested by

no test coverage detected