fix: Headers parsing fix (#5)
* fix: html tag symbol parsing * fix: missing contributors in parsing
This commit is contained in:
parent
276328e60b
commit
c51271253a
|
@ -14,7 +14,7 @@ function enhanceMarkdownWithBulletPointsCorrected(input) {
|
|||
inFrontMatter = !inFrontMatter
|
||||
if (!inFrontMatter && contributorsLines.length) {
|
||||
// We're exiting frontmatter; time to add contributors
|
||||
extractedFields.push(`contributors:\n${contributorsLines.join('\n')}`)
|
||||
extractedFields.push(`contributors\n${contributorsLines.join('\n')}`)
|
||||
contributorsLines = [] // Reset for safety
|
||||
}
|
||||
return line // Keep the frontmatter delimiters
|
||||
|
@ -24,13 +24,11 @@ function enhanceMarkdownWithBulletPointsCorrected(input) {
|
|||
if (line.startsWith('contributors:')) {
|
||||
inContributors = true // Entering contributors section
|
||||
} else if (inContributors) {
|
||||
if (line.startsWith(' -')) {
|
||||
if (line.trim().startsWith('-')) {
|
||||
contributorsLines.push(line.trim()) // Add contributors line
|
||||
} else {
|
||||
// Exiting contributors section
|
||||
inContributors = false
|
||||
extractedFields.push(`contributors:\n${contributorsLines.join('\n')}`)
|
||||
contributorsLines = [] // Reset
|
||||
}
|
||||
} else {
|
||||
const match = line.match(/(status|category|editor):(.*)/)
|
||||
|
@ -82,8 +80,17 @@ function parseSlugFromFrontmatter(content) {
|
|||
return 1 // Return null if not found
|
||||
}
|
||||
|
||||
function escapeHtmlTagSymbols(content) {
|
||||
// Escape < and > with < and >, respectively
|
||||
// Be cautious with this replacement; adjust as needed based on your context
|
||||
content = content.replace(/(?<!`)<(?!.*?`)/g, '<')
|
||||
content = content.replace(/(?<!`)>(?!.*?`)/g, '>')
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
function unescapeHtmlComments(htmlString) {
|
||||
return htmlString.replace(/\\<\!--/g, '\n<!--').replace(/--\\>/g, '-->\n')
|
||||
return htmlString.replace(/<\!--/g, '\n<!--').replace(/-->/g, '-->\n')
|
||||
}
|
||||
|
||||
function updateMarkdownLinksToExcludeMD(content) {
|
||||
|
@ -107,9 +114,7 @@ export function vacMarkdownToDocusaurusMarkdown(fileContent) {
|
|||
// Replace <br> with <br/>
|
||||
convertedContent = convertedContent.replace(/<br>/g, '<br/>')
|
||||
|
||||
// Escape < and > with \< and \>, respectively
|
||||
// Be cautious with this replacement; adjust as needed based on your context
|
||||
convertedContent = convertedContent.replace(/</g, '\\<').replace(/>/g, '\\>')
|
||||
convertedContent = escapeHtmlTagSymbols(convertedContent)
|
||||
|
||||
// NEW: Remove 'slug' line from frontmatter
|
||||
convertedContent = convertedContent.replace(/^slug:.*\n?/m, '')
|
||||
|
|
Loading…
Reference in New Issue