|
|
|
|
@ -37,28 +37,18 @@ function githubAlertsPlugin(md, options = {}) {
|
|
|
|
|
|
|
|
|
|
if (firstChild && firstChild.type === 'text') {
|
|
|
|
|
const content = firstChild.content
|
|
|
|
|
const alertMatch = content.match(/^\[!(NOTE|INFO|TIP|WARNING|IMPORTANT|CAUTION)\](?:\s+(.+?))?$/i)
|
|
|
|
|
const alertMatch = content.match(/^\[!(NOTE|INFO|TIP|WARNING|IMPORTANT|CAUTION)\]/i)
|
|
|
|
|
|
|
|
|
|
if (alertMatch) {
|
|
|
|
|
const alertType = alertMatch[1].toLowerCase()
|
|
|
|
|
const customTitle = alertMatch[2] ? alertMatch[2].trim() : null
|
|
|
|
|
|
|
|
|
|
const alertConfig = alertTypes[alertType]
|
|
|
|
|
if (alertConfig) {
|
|
|
|
|
// Add CSS class to blockquote
|
|
|
|
|
tokens[idx].attrJoin('class', alertConfig.class)
|
|
|
|
|
|
|
|
|
|
// Handle custom title or remove alert tag
|
|
|
|
|
if (customTitle && options.customTitle !== false) {
|
|
|
|
|
// Replace with bold custom title
|
|
|
|
|
firstChild.content = `**${customTitle}**`
|
|
|
|
|
} else if (customTitle && options.customTitle === false) {
|
|
|
|
|
// Custom titles disabled but title provided - remove the entire alert line
|
|
|
|
|
firstChild.content = ''
|
|
|
|
|
} else {
|
|
|
|
|
// No custom title - remove the alert tag
|
|
|
|
|
firstChild.content = ''
|
|
|
|
|
}
|
|
|
|
|
// Remove the alert tag
|
|
|
|
|
firstChild.content = firstChild.content.replace(/^\[!(NOTE|INFO|TIP|WARNING|IMPORTANT|CAUTION)\]\s*/i, '')
|
|
|
|
|
|
|
|
|
|
// If we emptied the first text node, remove it
|
|
|
|
|
if (firstChild.content === '') {
|
|
|
|
|
|