mirror of
https://gitlab.com/octtspacc/sitoctt
synced 2025-06-05 22:09:20 +02:00
Fix pie di pagina Listed, embed link, bottone footer, script traduzione, pagine
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
const Exp = {};
|
||||
|
||||
const TurndownService = require('turndown');
|
||||
const turndownService = (new TurndownService({
|
||||
const markdownOptions = {
|
||||
headingStyle: "atx",
|
||||
hr: "---",
|
||||
bulletListMarker: "*",
|
||||
@ -10,9 +9,29 @@ const turndownService = (new TurndownService({
|
||||
emDelimiter: "_",
|
||||
strongDelimiter: "**",
|
||||
linkStyle: "inlined",
|
||||
}));
|
||||
turndownService.keep(['span', 'small', 'sup', 'sub', 'table', 'dl', 'iframe', 'video', 'audio', 'scripts']);
|
||||
};
|
||||
|
||||
Exp.Transform = (html) => turndownService.turndown(html);
|
||||
const TurndownService = require('turndown');
|
||||
const turndownService = (new TurndownService(markdownOptions));
|
||||
turndownService.keep(['span', 'small', 'sup', 'sub', 'dl', 'details', 'table', 'iframe', 'video', 'audio', 'scripts']);
|
||||
|
||||
Exp.Transform = (html) => fixFootnoteRefs(turndownService.turndown(html));
|
||||
|
||||
function fixFootnoteRefs (markdown) {
|
||||
const parts = markdown.split('\n' + markdownOptions.hr + '\n');
|
||||
if (parts.length > 1) {
|
||||
let footnotesText = '';
|
||||
const footnotes = ('\n' + parts.slice(-1)[0]).split('[↩](#fnref');
|
||||
for (let index=1; index<footnotes.length; index++) {
|
||||
const footnote = ((footnotes[index - 1].split('.')[0].split(')')[1] || ('\n' + index))
|
||||
+ '. <span id="fn' + index + '"></span>'
|
||||
+ footnotes[index - 1].split('\n').slice(1).join('\n').split('.').slice(1).join('.')
|
||||
+ '[↩](#fnref' + footnotes[index].split('\n')[0]);
|
||||
footnotesText += footnote;
|
||||
}
|
||||
parts[parts.length - 1] = footnotesText;
|
||||
}
|
||||
return parts.join('\n' + markdownOptions.hr + '\n');
|
||||
}
|
||||
|
||||
module.exports = Exp;
|
||||
|
Reference in New Issue
Block a user