MCPcopy
hub / github.com/marktext/marktext / appendBackref

Function appendBackref

packages/muya/src/state/renderToStaticHTML.ts:153–163  ·  view source on GitHub ↗
(definitionHtml: string, n: number)

Source from the content-addressed store, hash-verified

151}
152
153function appendBackref(definitionHtml: string, n: number): string {
154 const backref = ` <a href="#fnref-${n}" class="footnote-backref">↩</a>`;
155 // Inject the backref inside the trailing `</p>` so the arrow sits next to
156 // the last word of the last paragraph (pandoc style). If the definition
157 // doesn't end with a paragraph (rare — e.g. ends in a list), tack the
158 // backref on after the block.
159 const lastClose = definitionHtml.lastIndexOf('</p>');
160 if (lastClose >= 0)
161 return `${definitionHtml.slice(0, lastClose)}${backref}${definitionHtml.slice(lastClose)}`;
162 return `${definitionHtml}${backref}`;
163}

Callers 1

transformFootnotesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected