mirror of
https://github.com/jimeh/commonflow.org.git
synced 2026-02-19 05:46:40 +00:00
wip: add linters and formatters
This commit is contained in:
@@ -73,13 +73,13 @@ function extractText(node: MdastNode): string {
|
||||
function findHeadingIndex(
|
||||
nodes: RootContent[],
|
||||
text: string,
|
||||
depth: number = 2
|
||||
depth: number = 2,
|
||||
): number {
|
||||
return nodes.findIndex(
|
||||
(node) =>
|
||||
node.type === "heading" &&
|
||||
(node as Heading).depth === depth &&
|
||||
extractText(node).toLowerCase().includes(text.toLowerCase())
|
||||
extractText(node).toLowerCase().includes(text.toLowerCase()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ function findHeadingIndex(
|
||||
function extractSectionNodes(
|
||||
nodes: RootContent[],
|
||||
startText: string,
|
||||
depth: number = 2
|
||||
depth: number = 2,
|
||||
): RootContent[] {
|
||||
const startIdx = findHeadingIndex(nodes, startText, depth);
|
||||
if (startIdx === -1) return [];
|
||||
@@ -114,7 +114,7 @@ function extractSectionNodes(
|
||||
function getHeadingText(
|
||||
nodes: RootContent[],
|
||||
text: string,
|
||||
depth: number = 2
|
||||
depth: number = 2,
|
||||
): string {
|
||||
const idx = findHeadingIndex(nodes, text, depth);
|
||||
if (idx === -1) return text;
|
||||
@@ -135,7 +135,7 @@ async function nodesToHtml(nodes: RootContent[]): Promise<string> {
|
||||
.use(rehypeStringify, { allowDangerousHtml: true })
|
||||
.run(root);
|
||||
|
||||
const html = await unified()
|
||||
const html = unified()
|
||||
.use(rehypeStringify, { allowDangerousHtml: true })
|
||||
.stringify(result as HastRoot);
|
||||
|
||||
@@ -299,7 +299,7 @@ function buildTocItems(parsed: Partial<ParsedSpec>): TocItem[] {
|
||||
*/
|
||||
export async function parseSpecContent(
|
||||
markdown: string,
|
||||
version: string
|
||||
version: string,
|
||||
): Promise<ParsedSpec> {
|
||||
const svgPath = `/spec/${version}.svg`;
|
||||
|
||||
@@ -320,7 +320,7 @@ export async function parseSpecContent(
|
||||
const terminologyTitle = getHeadingText(nodes, "Terminology");
|
||||
const specificationTitle = getHeadingText(
|
||||
nodes,
|
||||
"Git Common-Flow Specification"
|
||||
"Git Common-Flow Specification",
|
||||
);
|
||||
|
||||
// Extract section nodes
|
||||
@@ -376,7 +376,7 @@ export async function parseSpecContent(
|
||||
|
||||
// Convert FAQ answers to HTML
|
||||
const faqAnswers = await Promise.all(
|
||||
faqAnswerNodes.map((nodes) => nodesToHtml(nodes))
|
||||
faqAnswerNodes.map((nodes) => nodesToHtml(nodes)),
|
||||
);
|
||||
|
||||
// Assign FAQ answers
|
||||
|
||||
Reference in New Issue
Block a user