diff --git a/docs-utils/fix-callouts.js b/docs-utils/fix-callouts.js new file mode 100644 index 000000000..93468c5c3 --- /dev/null +++ b/docs-utils/fix-callouts.js @@ -0,0 +1,122 @@ +const fs = require('fs'); +const path = require('path'); + +// The root folder to process +const rootFolder = 'docs'; + +// Maximum number of files to process simultaneously +const MAX_CONCURRENT_FILES = 100; // Adjust this based on your system's limit + +// Array to keep track of currently processing files +let activeFiles = 0; +let fileQueue = []; + +// Function to process the HTML content +function convertCallout(htmlCallout) { + let markdownCallout = htmlCallout.trim(); + + // Remove inline styles (e.g., style="color:red;") + markdownCallout = markdownCallout.replace(/\s*style="[^"]*"/g, ''); + + // Convert
and
to new lines with `>` prefix + markdownCallout = markdownCallout.replace(//g, '\n>\n> '); + + // Convert

...

only if it's NOT the first

element + let firstParagraph = true; + markdownCallout = markdownCallout.replace(/

(.*?)<\/p>/gs, (_, pContent) => { + pContent = pContent.trim(); // Remove any extra whitespace around the paragraph content + + if (firstParagraph) { + firstParagraph = false; + return pContent; + } + + // Ensure that any existing blank lines or spaces are cleaned up + return `\n> ${pContent}`; + }); + + // Convert