Expand [caption] shortcodes instead of emitting them as text

WordPress expands shortcodes at render time via do_shortcode(), so the
raw post_content the export reads still contains them literally. All ten
[caption] instances were being written straight into the Markdown and
rendered as visible markup -- the Hosting page led with
[caption id="attachment_205" align="aligncenter" width="300"].

They now become the same div.wp-caption / p.wp-caption-text structure
WordPress produces, which the ported theme CSS already styles. The
shortcode is swapped for a placeholder before the HTML->Markdown pass and
rebuilt after, so the image inside stays Markdown and still goes through
Astro's image pipeline rather than being frozen as raw HTML pointing into
src/assets, which would not resolve at runtime.

[caption] is the only shortcode in use -- no gallery/embed/video/audio.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-15 19:39:12 -04:00
co-authored by Claude Opus 5
parent 73399911cc
commit 873dcc1892
11 changed files with 100 additions and 12 deletions
+40 -2
View File
@@ -100,6 +100,35 @@ function rewriteInternalLinks(html, linkMap, unresolved) {
);
}
// WordPress expands [caption] at render time via do_shortcode(); the raw post_content keeps it
// literal, so it has to be expanded here or it shows up as visible markup on the page.
// The shortcode is swapped for a placeholder before the HTML->Markdown conversion and rebuilt
// afterwards, so the <img> inside still goes through Turndown (and therefore still gets picked
// up by Astro's image pipeline) rather than being frozen as raw HTML pointing into src/assets.
const CAPTION_PLACEHOLDER = (i) => `CAPTIONPLACEHOLDER${i}END`;
function extractCaptions(html, captions) {
return html.replace(/\[caption([^\]]*)\]([\s\S]*?)\[\/caption\]/gi, (_match, attrs, inner) => {
const lastTag = inner.lastIndexOf('>');
captions.push({
align: (attrs.match(/align=["']?(align\w+)["']?/i) || [, 'aligncenter'])[1],
width: (attrs.match(/width=["']?(\d+)["']?/i) || [, ''])[1],
mediaHtml: inner.slice(0, lastTag + 1),
text: inner.slice(lastTag + 1).trim(),
});
return CAPTION_PLACEHOLDER(captions.length - 1);
});
}
// Blank lines around the image are load-bearing: they close the surrounding raw HTML block so
// the image is parsed as Markdown rather than swallowed as literal HTML.
function buildCaption({ align, width, mediaHtml, text }) {
const media = turndown.turndown(mediaHtml).trim();
const style = width ? ` style="width: ${Number(width) + 10}px"` : '';
const caption = text ? `\n<p class="wp-caption-text">${text}</p>` : '';
return `<div class="wp-caption ${align}"${style}>\n\n${media}\n${caption}\n</div>`;
}
async function buildLinkMap(conn) {
const [rows] = await conn.execute(
`SELECT ID, post_type, post_name FROM ${TABLE_PREFIX}posts
@@ -134,11 +163,20 @@ async function exportPostType(conn, postType, destDir, { attachmentPaths, thumbn
}
html = rewriteImageUrls(html, destDir);
html = rewriteInternalLinks(html, linkMap, unresolved);
const markdown = turndown.turndown(html);
const captions = [];
html = extractCaptions(html, captions);
const markdown = turndown
.turndown(html)
.replace(/CAPTIONPLACEHOLDER(\d+)END/g, (_m, i) => buildCaption(captions[Number(i)]));
let excerpt = fixLiteralNewlines(row.post_excerpt || '');
if (!excerpt) {
const plain = html.replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim();
const plain = html
.replace(/CAPTIONPLACEHOLDER\d+END/g, ' ')
.replace(/<[^>]+>/g, ' ')
.replace(/\s+/g, ' ')
.trim();
// 60 words: what the theme's front-page loop sets ($sbExcerptLength = 60).
// The slideshow truncates this further to 30 at render, as the theme does.
excerpt = plain.split(' ').slice(0, 60).join(' ');
+6 -1
View File
@@ -3,7 +3,12 @@ title: "Cepstral Text-to-Speech"
slug: "cepstral-text-to-speech"
---
\[caption id="attachment\_346" align="aligncenter" width="344"\][![Cepstral Text-to-Speech](../../assets/uploads/2016/03/cepstral_top_logo.png)](../../assets/uploads/2016/03/cepstral_top_logo.png) Cepstral Text-to-Speech\[/caption\]VICIdial integrates with Cepstral Text-to-Speech to provide dynamic audio messages per-lead for outbound and inbound calling.
<div class="wp-caption aligncenter" style="width: 354px">
[![Cepstral Text-to-Speech](../../assets/uploads/2016/03/cepstral_top_logo.png)](../../assets/uploads/2016/03/cepstral_top_logo.png)
<p class="wp-caption-text">Cepstral Text-to-Speech</p>
</div>VICIdial integrates with Cepstral Text-to-Speech to provide dynamic audio messages per-lead for outbound and inbound calling.
The VICIdial Outbound survey auto-dialing features have built-in administrative utilities to allow for Cepstral to generate dynamic per-lead messages almost instantly once a customer picks up the line.
+6 -1
View File
@@ -3,7 +3,12 @@ title: "DNC.com Integration"
slug: "dnc-com-integration"
---
\[caption id="attachment\_340" align="aligncenter" width="219"\][![DNC.com logo](../../assets/uploads/2016/03/DNCcomlogo.png)](../../assets/uploads/2016/03/DNCcomlogo.png) DNC.com logo\[/caption\]VICIdial has built-in utilities to integrate with several DNC.com features.
<div class="wp-caption aligncenter" style="width: 229px">
[![DNC.com logo](../../assets/uploads/2016/03/DNCcomlogo.png)](../../assets/uploads/2016/03/DNCcomlogo.png)
<p class="wp-caption-text">DNC.com logo</p>
</div>VICIdial has built-in utilities to integrate with several DNC.com features.
Included in the integration are filtering by your DNC.com lists and settings, as well as filtering your lists by the U.S.A cellphone lists for better TCPA compliance when calling within the United States.
+6 -1
View File
@@ -3,7 +3,12 @@ title: "Hosting"
slug: "hosting"
---
\[caption id="attachment\_205" align="aligncenter" width="300"\][![VICIhost Hosted Contact Center Solution](../../assets/uploads/2015/11/vicihost-logo_300x100.jpg)](http://www.vicihost.com) VICIhost Hosted Contact Center Solution\[/caption\]<br />
<div class="wp-caption aligncenter" style="width: 310px">
[![VICIhost Hosted Contact Center Solution](../../assets/uploads/2015/11/vicihost-logo_300x100.jpg)](http://www.vicihost.com)
<p class="wp-caption-text">VICIhost Hosted Contact Center Solution</p>
</div><br />
If you don't want to have to manage your own VICIdial equipment, then let the experts do it for you! The Vicidial Group's VICIhost service can get you up and running today on your own dedicated server in our custom built server cloud.
@@ -3,7 +3,12 @@ title: "OrecX Audio and Screen Recording"
slug: "orecx-audio-and-screen-recording"
---
\[caption id="attachment\_352" align="aligncenter" width="600"\][![OrecX recording](../../assets/uploads/2016/03/OrecX_logo-600.png)](../../assets/uploads/2016/03/OrecX_logo-600.png) OrecX recording\[/caption\]Even though VICIdial can natively record phone calls, integration with the OrecX suite of recording utilities allows for recording of any VOIP phone calls on your network, as well as the option to record the agents' screens and have them tied to the lead that the agent is talking to.
<div class="wp-caption aligncenter" style="width: 610px">
[![OrecX recording](../../assets/uploads/2016/03/OrecX_logo-600.png)](../../assets/uploads/2016/03/OrecX_logo-600.png)
<p class="wp-caption-text">OrecX recording</p>
</div>Even though VICIdial can natively record phone calls, integration with the OrecX suite of recording utilities allows for recording of any VOIP phone calls on your network, as well as the option to record the agents' screens and have them tied to the lead that the agent is talking to.
For more information about OrecX, [please contact us](/contact-us).
+6 -1
View File
@@ -3,7 +3,12 @@ title: "QueueMetrics Reporting"
slug: "queuemetrics-reporting"
---
\[caption id="attachment\_334" align="aligncenter" width="253"\][![QueueMetrics logo](../../assets/uploads/2016/03/QueueMetrics_logo.png)](../../assets/uploads/2016/03/QueueMetrics_logo.png) QueueMetrics logo\[/caption\]QueueMetrics is a third-party reporting package that allows you to visualize call center activities in several different ways.
<div class="wp-caption aligncenter" style="width: 263px">
[![QueueMetrics logo](../../assets/uploads/2016/03/QueueMetrics_logo.png)](../../assets/uploads/2016/03/QueueMetrics_logo.png)
<p class="wp-caption-text">QueueMetrics logo</p>
</div>QueueMetrics is a third-party reporting package that allows you to visualize call center activities in several different ways.
VICIdial fully integrates with the QueueMetrics statistical analysis package through it's ability to log calls and agent activity to a queue\_log table in a MySQL database.
@@ -5,4 +5,9 @@ slug: "rankminer-call-analytics"
### Helping Call Centers Improve Agent Performance and Close More Sales
\[caption id="attachment\_361" align="aligncenter" width="650"\][![Rankminer Dashboard Screen](../../assets/uploads/2016/03/Rankminer-dashboard-example_20160319-1024x601.png)](../../assets/uploads/2016/03/Rankminer-dashboard-example_20160319.png) Rankminer Dashboard Screen\[/caption\] RankMiner is a leading pioneer in the field of predictive voice analytics. RankMiners products use patented technology to analyze the emotional behavior and tone of speakers in a conversation. They create predictive models of future behavior enabling RankMiners customers to improve conversion rates, operational effectiveness and agent performance. In more simple terms, RankMiner can help you make more sales by helping you to target the right leads. It can also operate as an automated layer of quality control for your agents. [**To learn how one of our VICIhost clients increased their sales by over 40% by using RankMiner, click here.**](/vicidial-partners-with-rankminer-and-its-customer-insight-agent-insight-products-to-increase-call-center-effectiveness) [View RankMiner's Agent Performance white paper to discover how voice analytics can improve your call agent performance.](http://offers.rankminer.com/using-artificial-intelligence-monitor-measure-call-center-agent-performance) For more information on RankMiner Analytics, [please contact us](/contact-us). **Note: As of September 2020, Rankminer is no longer an operating company.**<br />To go back to the third-party add-ons page, [click here](/third-party-add-ons).
<div class="wp-caption aligncenter" style="width: 660px">
[![Rankminer Dashboard Screen](../../assets/uploads/2016/03/Rankminer-dashboard-example_20160319-1024x601.png)](../../assets/uploads/2016/03/Rankminer-dashboard-example_20160319.png)
<p class="wp-caption-text">Rankminer Dashboard Screen</p>
</div> RankMiner is a leading pioneer in the field of predictive voice analytics. RankMiners products use patented technology to analyze the emotional behavior and tone of speakers in a conversation. They create predictive models of future behavior enabling RankMiners customers to improve conversion rates, operational effectiveness and agent performance. In more simple terms, RankMiner can help you make more sales by helping you to target the right leads. It can also operate as an automated layer of quality control for your agents. [**To learn how one of our VICIhost clients increased their sales by over 40% by using RankMiner, click here.**](/vicidial-partners-with-rankminer-and-its-customer-insight-agent-insight-products-to-increase-call-center-effectiveness) [View RankMiner's Agent Performance white paper to discover how voice analytics can improve your call agent performance.](http://offers.rankminer.com/using-artificial-intelligence-monitor-measure-call-center-agent-performance) For more information on RankMiner Analytics, [please contact us](/contact-us). **Note: As of September 2020, Rankminer is no longer an operating company.**<br />To go back to the third-party add-ons page, [click here](/third-party-add-ons).
@@ -3,7 +3,12 @@ title: "Sangoma Call Progress Analysis"
slug: "sangoma-call-progress-analysis"
---
\[caption id="attachment\_357" align="aligncenter" width="408"\][![Sangoma Lyra Answering Machine Detection](../../assets/uploads/2016/03/sangoma_lyra_amd_logo.png)](../../assets/uploads/2016/03/sangoma_lyra_amd_logo.png) Sangoma Lyra Answering Machine Detection\[/caption\]<br />**NOTE: Sangoma stopped selling their Lyra product in 2017. If you have a valid Lyra license for your server, it will still work with VICIdial, but you can no longer purchase new licenses at this point.**
<div class="wp-caption aligncenter" style="width: 418px">
[![Sangoma Lyra Answering Machine Detection](../../assets/uploads/2016/03/sangoma_lyra_amd_logo.png)](../../assets/uploads/2016/03/sangoma_lyra_amd_logo.png)
<p class="wp-caption-text">Sangoma Lyra Answering Machine Detection</p>
</div><br />**NOTE: Sangoma stopped selling their Lyra product in 2017. If you have a valid Lyra license for your server, it will still work with VICIdial, but you can no longer purchase new licenses at this point.**
VICIdial is integrated with the Sangoma/ParaXip CPD SIP gateway. This product is a proprietary Answering machine/Fax machine/Pre-Answer call progress detection engine that claims up to 95% accuracy in very fast detection of humans and machines on calls.
@@ -5,7 +5,12 @@ slug: "vicidial-declared-one-of-the-most-promising-contact-center-technologies-i
VICIdial was chosen as one of the Top 20 Most Promising Contact Center Technology Providers for 2016 by CIO Review magazine.
\[caption id="attachment\_421" align="aligncenter" width="252"\][![CIO Review most promising call center technology providers for 2016](../../assets/uploads/2016/06/CIOreview_most-promosing_2016.png)](../../assets/uploads/2016/06/CIOreview_most-promosing_2016.png) CIO Review most promising call center technology providers for 2016\[/caption\]
<div class="wp-caption aligncenter" style="width: 262px">
[![CIO Review most promising call center technology providers for 2016](../../assets/uploads/2016/06/CIOreview_most-promosing_2016.png)](../../assets/uploads/2016/06/CIOreview_most-promosing_2016.png)
<p class="wp-caption-text">CIO Review most promising call center technology providers for 2016</p>
</div>
Click the link below to read the article:<br />[**CIO Review 2016 Profile of VICIdial**](../../assets/uploads/2016/07/CIOreview_july2016_profile_VICIdial.pdf)
+6 -1
View File
@@ -41,7 +41,12 @@ slug: "vicidial-screenshots"
### Website Customer Chat Screen
\[caption id="attachment\_514" align="alignleft" width="572"\][![VICIchat Customer Website Chat](../../assets/uploads/2018/05/chat_customer_screenshot_20160818.png)](../../assets/uploads/2018/05/chat_customer_screenshot_20160818.png) This is an example of what the customer will see during a VICIdial website customer chat. There is also an option once the chat session is complete, to send the customer to a survey website.\[/caption\]
<div class="wp-caption alignleft" style="width: 582px">
[![VICIchat Customer Website Chat](../../assets/uploads/2018/05/chat_customer_screenshot_20160818.png)](../../assets/uploads/2018/05/chat_customer_screenshot_20160818.png)
<p class="wp-caption-text">This is an example of what the customer will see during a VICIdial website customer chat. There is also an option once the chat session is complete, to send the customer to a survey website.</p>
</div>
### Agent Screen(with multi-form feature)
@@ -3,7 +3,12 @@ title: "VICIhost High-Level Data Encryption"
slug: "vicihost-high-level-data-encryption"
---
\[caption id="attachment\_324" align="aligncenter" width="930"\][![VICIhost high-level data encryption](../../assets/uploads/2016/03/main_page_big_image_encryption.png)](../../assets/uploads/2016/03/main_page_big_image_encryption.png) VICIhost high-level data encryption\[/caption\]With the VICIhost Hosted VICIdial service, you can use NIST-approved high-Level data encryption to protect your customer's sensitive data. These features can also allow you to be PCI-compliant in how you store and access customer data.
<div class="wp-caption aligncenter" style="width: 940px">
[![VICIhost high-level data encryption](../../assets/uploads/2016/03/main_page_big_image_encryption.png)](../../assets/uploads/2016/03/main_page_big_image_encryption.png)
<p class="wp-caption-text">VICIhost high-level data encryption</p>
</div>With the VICIhost Hosted VICIdial service, you can use NIST-approved high-Level data encryption to protect your customer's sensitive data. These features can also allow you to be PCI-compliant in how you store and access customer data.
[**Click here for more information on VICIhost High-Level Data Encryption**](http://www.vicihost.com/?p=131).