diff --git a/block/quotes.js b/block/quotes.js index 97c73c4..2f4d6ca 100644 --- a/block/quotes.js +++ b/block/quotes.js @@ -1,7 +1,7 @@ const main = require('../index.js'); let conf = { - open: '\n\n>', + open: '\n\n> ', close: '\n\n', } diff --git a/block/spoiler.js b/block/spoiler.js new file mode 100644 index 0000000..51f520c --- /dev/null +++ b/block/spoiler.js @@ -0,0 +1,22 @@ +const main = require('../index.js'); + +let conf = { + open: '\n\n>! ', + close: '\n\n', +} + +function convert(string, plain) { + if (plain) return string.replaceAll(conf.open, ''); + let start = string.indexOf(conf.open); + let end = string.indexOf(conf.close, start + 5); + let ogText = string.substring(start, end); + let cleanedText = ogText.replace(/^>!\s*/, ''); + let [summary, ...contentLines] = cleanedText.split('\n').filter(line => line.trim() !== ''); // Filter out empty lines + let content = contentLines.join('\n').trim(); + let contentEndIndex = content.indexOf('\n\n'); + if (contentEndIndex !== -1) {content = content.substring(0, contentEndIndex).trim();} + let html = `
${summary.replace(">! ", "")}${content}
`; + string = string.replace(ogText, html.trim()); + return string; +} +main.registerBlock({open: conf.open,close: conf.close,exec: convert}); \ No newline at end of file diff --git a/index.js b/index.js index 6077965..47fee00 100644 --- a/index.js +++ b/index.js @@ -30,7 +30,9 @@ let cssStyles = { contDanger: "convertdanger", contSuccess: "convertsuccess", httprequest: "mdhttpRequest", - contPrimary: "convertprimary" + contPrimary: "convertprimary", + small: "convertsmall", + details: "convertdetails" }; function getStyle(index, incCSS = false) { diff --git a/inline/headings.js b/inline/headings.js index 7bd644a..76a56e6 100644 --- a/inline/headings.js +++ b/inline/headings.js @@ -56,6 +56,15 @@ function convert(string, plain) { string = string.replace(ogHead, head); return string; } + if(string.indexOf('\n-#') !== -1) { + if(plain) return string.replace('\n-#', ''); + let start = string.indexOf('\n-#'); + let end = string.indexOf('\n', start + 2); + let ogHead = string.substring(start, end); + let head = `\n${ogHead.replace('\n-#', '').replace('\n', '')}`; + string = string.replace(ogHead, head); + return string; + } return -1; };