remplace les balises des crochets seulement si ça match une liste de mots
This commit is contained in:
@@ -19,8 +19,10 @@ class setMarginTexts extends Paged.Handler {
|
||||
// cleaner pour que les paragraphes tombent sur la marge haute
|
||||
for(let i = 0; i < labeurs.length; i++) {
|
||||
if (labeurs[i] == labeurs[i].parentNode.firstElementChild
|
||||
&& !labeurs[i].firstElementChild.hasAttribute("data-split-from")) {
|
||||
labeurs[i].firstElementChild.style.marginTop = "0px";
|
||||
&& !labeurs[i].firstElementChild?.hasAttribute("data-split-from")) {
|
||||
if (labeurs[i].firstElementChild) {
|
||||
labeurs[i].firstElementChild.style.marginTop = "0px";
|
||||
}
|
||||
}
|
||||
}
|
||||
// pareil pour les titres temps
|
||||
@@ -147,7 +149,6 @@ class setMarginTexts extends Paged.Handler {
|
||||
coverImg.firstChild.style.height = "100%";
|
||||
coverImg.firstChild.style.width = "auto";
|
||||
|
||||
console.log(coverImg);
|
||||
h3.parentElement.append(coverImg);
|
||||
|
||||
let nextImg = document.createElement('img');
|
||||
|
||||
@@ -1,10 +1,51 @@
|
||||
|
||||
// transformer les balises [...] en <div class="...">
|
||||
let bodyContent = $('#body').html()
|
||||
.replace(/\[([^\/\]]+)\]/g, '<div class="$1">')
|
||||
.replace(/\[\/([^\]]+)\]/g, '</div>');
|
||||
// transformer les balises [...] en <div class="..."> si ça correspond aux classes prédéfinies
|
||||
let baliseWords = [
|
||||
'labeur',
|
||||
'free',
|
||||
'temps',
|
||||
'moment',
|
||||
'latour',
|
||||
'lampe',
|
||||
'bibliographie',
|
||||
'imgsmall',
|
||||
'fullpage2imgs',
|
||||
'fullpageimage',
|
||||
'tripleimgs',
|
||||
'tripleimgs_bottom',
|
||||
'tripleimgs2',
|
||||
'tripleimgs2_bottom',
|
||||
'bottomimg',
|
||||
'imgfullspreadleft',
|
||||
'imgfullspreadright',
|
||||
'imgfullspreadright_bleedtop',
|
||||
'imgfullspreadright_bleed',
|
||||
'breakbefore',
|
||||
'breakafter'
|
||||
];
|
||||
|
||||
// Get the HTML content of the "body" element
|
||||
var bodyContent = $('#body').html();
|
||||
|
||||
// Replace text between brackets only if it matches one of the words in the list
|
||||
bodyContent = bodyContent.replace(/\[([^\/\]]+)\]/g, function(match, word) {
|
||||
if (baliseWords.includes(word)) {
|
||||
return '<div class="' + word + '">';
|
||||
} else {
|
||||
return match; // No replacement if the word is not in the list
|
||||
}
|
||||
}).replace(/\[\/([^\]]+)\]/g, function(match, word) {
|
||||
if (baliseWords.includes(word)) {
|
||||
return '</div>';
|
||||
} else {
|
||||
return match; // No replacement if the word is not in the list
|
||||
}
|
||||
});
|
||||
|
||||
// Update the content of the "body" element
|
||||
$('#body').empty().append(bodyContent);
|
||||
|
||||
|
||||
// isoler les chiffres des titres
|
||||
let moments = document.getElementsByClassName("moment");
|
||||
|
||||
@@ -32,7 +73,7 @@ for(let i = 0; i < latours.length; i++) {
|
||||
headerEl.append(iconImg);
|
||||
headerEl.append(headContent);
|
||||
|
||||
latours[i].firstChild.remove();
|
||||
latours[i].firstChild?.remove();
|
||||
latours[i].prepend(headerEl);
|
||||
}
|
||||
|
||||
@@ -48,7 +89,7 @@ for(let i = 0; i < lampes.length; i++) {
|
||||
headerEl.append(iconImg);
|
||||
headerEl.append(headContent);
|
||||
|
||||
lampes[i].firstChild.remove();
|
||||
lampes[i].firstChild?.remove();
|
||||
lampes[i].prepend(headerEl);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user