Skip to content

Commit

Permalink
fix parsing bug (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
koilebeit authored Oct 17, 2024
1 parent aac43be commit f5f8428
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/lib/downloadPostsPagesAssets.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ const getAssetUrl = (elem, $) => {
return url;
};

/**
* Cleans up escaped asterisks between word characters.
* @param {string} text
* @returns {string}
*/
function cleanEscapedAsterisks(text) {
return text.replace(/\\\*/gm, '*');
}

/**
* Process and sanitize HTML content.
* @param {string} html - HTML content to process.
Expand Down Expand Up @@ -237,15 +246,11 @@ async function fetchAndProcessType(type) {
if (type === 'posts' && categoryIds.some((id) => excludedCategories.includes(id))) {
continue;
}
const title = turndownService.turndown(item.title.rendered);
const title = cleanEscapedAsterisks(turndownService.turndown(item.title.rendered));
const content = await processContent(item.content.rendered, outputDir, item.link, item.slug);
const tagsToRemove = ['span', 'a'];
const excerpt = await processContent(
item.excerpt.rendered,
outputDir,
item.link,
item.slug,
tagsToRemove
const excerpt = cleanEscapedAsterisks(
await processContent(item.excerpt.rendered, outputDir, item.link, item.slug, tagsToRemove)
);
const featuredImageUrl = item.featured_media
? await fetchFeaturedImage(item.featured_media)
Expand Down

0 comments on commit f5f8428

Please sign in to comment.