Skip to content

Commit

Permalink
1.3.3a build
Browse files Browse the repository at this point in the history
  • Loading branch information
FAXES authored Sep 21, 2024
1 parent a124287 commit 818111c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion block/quotes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const main = require('../index.js');

let conf = {
open: '\n\n>',
open: '\n\n> ',
close: '\n\n',
}

Expand Down
22 changes: 22 additions & 0 deletions block/spoiler.js
Original file line number Diff line number Diff line change
@@ -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 = `<details class="convertdetails"><summary>${summary.replace(">! ", "")}</summary>${content}</details>`;
string = string.replace(ogText, html.trim());
return string;
}
main.registerBlock({open: conf.open,close: conf.close,exec: convert});
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions inline/headings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<small${main.getStyle('small', true)}>${ogHead.replace('\n-#', '').replace('\n', '')}</small>`;
string = string.replace(ogHead, head);
return string;
}
return -1;
};

Expand Down

0 comments on commit 818111c

Please sign in to comment.