remplace les balises des crochets seulement si ça match une liste de mots

This commit is contained in:
Valentin
2023-07-19 02:20:20 +02:00
parent d2acfe6369
commit 0b8dbccb92
7 changed files with 65 additions and 20 deletions
+4 -2
View File
@@ -54,10 +54,12 @@ saut de ligne dans texte libre (à la fin de chaque ligne) : `<br>`
`[lampe]` `[lampe]`
`[bibliographie]`
### IMAGES ### IMAGES
`[smallimg]` `[imgsmall]`
![smallimg](screenshots/smallimg.png) ![imgsmall](screenshots/smallimg.png)
`[fullpage2imgs]` `[fullpage2imgs]`
![fullpage2imgs](screenshots/fullpage2imgs.png) ![fullpage2imgs](screenshots/fullpage2imgs.png)
+2 -1
View File
@@ -1,6 +1,6 @@
core: core:
grav: grav:
version: 1.7.42.1 version: 1.7.42.3
schema: 1.7.0_2020-11-20_1 schema: 1.7.0_2020-11-20_1
history: history:
- { version: 1.7.41.1, date: '2023-05-25 20:58:44' } - { version: 1.7.41.1, date: '2023-05-25 20:58:44' }
@@ -14,3 +14,4 @@ core:
- { version: 1.7.42.1, date: '2023-06-28 22:41:44' } - { version: 1.7.42.1, date: '2023-06-28 22:41:44' }
- { version: 1.7.42.1, date: '2023-07-06 22:48:42' } - { version: 1.7.42.1, date: '2023-07-06 22:48:42' }
- { version: 1.7.42.1, date: '2023-07-06 23:08:22' } - { version: 1.7.42.1, date: '2023-07-06 23:08:22' }
- { version: 1.7.42.3, date: '2023-07-18 20:38:16' }
@@ -1,25 +1,25 @@
last_checked: 1688670548 last_checked: 1689718026
data: data:
- -
title: 'macOS 13.0 Ventura Apache Setup: Upgrading Homebrew' title: 'macOS 13.0 Ventura Apache Setup: Upgrading Homebrew'
url: 'https://getgrav.org/blog/macos-ventura-apache-upgrade-homebrew' url: 'https://getgrav.org/blog/macos-ventura-apache-upgrade-homebrew'
date: 1671969600 date: 1671969600
nicetime: '6 months ago' nicetime: '7 months ago'
- -
title: 'macOS 13.0 Ventura Apache Setup: LetsEncrypt SSL' title: 'macOS 13.0 Ventura Apache Setup: LetsEncrypt SSL'
url: 'https://getgrav.org/blog/macos-ventura-apache-ssl' url: 'https://getgrav.org/blog/macos-ventura-apache-ssl'
date: 1671966180 date: 1671966180
nicetime: '6 months ago' nicetime: '7 months ago'
- -
title: 'macOS 13.0 Ventura Apache Setup: MySQL, Xdebug & More...' title: 'macOS 13.0 Ventura Apache Setup: MySQL, Xdebug & More...'
url: 'https://getgrav.org/blog/macos-ventura-apache-mysql-vhost-apc' url: 'https://getgrav.org/blog/macos-ventura-apache-mysql-vhost-apc'
date: 1671966000 date: 1671966000
nicetime: '6 months ago' nicetime: '7 months ago'
- -
title: 'macOS 13.0 Ventura Apache Setup: Multiple PHP Versions' title: 'macOS 13.0 Ventura Apache Setup: Multiple PHP Versions'
url: 'https://getgrav.org/blog/macos-ventura-apache-multiple-php-versions' url: 'https://getgrav.org/blog/macos-ventura-apache-multiple-php-versions'
date: 1671962400 date: 1671962400
nicetime: '6 months ago' nicetime: '7 months ago'
- -
title: 'Big changes for Email plugin' title: 'Big changes for Email plugin'
url: 'https://getgrav.org/blog/new-email-plugin' url: 'https://getgrav.org/blog/new-email-plugin'
@@ -49,4 +49,4 @@ data:
title: 'Grav Premium Focus: NextGen Editor' title: 'Grav Premium Focus: NextGen Editor'
url: 'https://getgrav.org/blog/premium-focus-nextgen-editor' url: 'https://getgrav.org/blog/premium-focus-nextgen-editor'
date: 1610713140 date: 1610713140
nicetime: '2 years ago' nicetime: '3 years ago'
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
last_checked: 1689214351 last_checked: 1689725650
data: data:
feed: feed:
- -
+4 -3
View File
@@ -19,8 +19,10 @@ class setMarginTexts extends Paged.Handler {
// cleaner pour que les paragraphes tombent sur la marge haute // cleaner pour que les paragraphes tombent sur la marge haute
for(let i = 0; i < labeurs.length; i++) { for(let i = 0; i < labeurs.length; i++) {
if (labeurs[i] == labeurs[i].parentNode.firstElementChild if (labeurs[i] == labeurs[i].parentNode.firstElementChild
&& !labeurs[i].firstElementChild.hasAttribute("data-split-from")) { && !labeurs[i].firstElementChild?.hasAttribute("data-split-from")) {
labeurs[i].firstElementChild.style.marginTop = "0px"; if (labeurs[i].firstElementChild) {
labeurs[i].firstElementChild.style.marginTop = "0px";
}
} }
} }
// pareil pour les titres temps // pareil pour les titres temps
@@ -147,7 +149,6 @@ class setMarginTexts extends Paged.Handler {
coverImg.firstChild.style.height = "100%"; coverImg.firstChild.style.height = "100%";
coverImg.firstChild.style.width = "auto"; coverImg.firstChild.style.width = "auto";
console.log(coverImg);
h3.parentElement.append(coverImg); h3.parentElement.append(coverImg);
let nextImg = document.createElement('img'); let nextImg = document.createElement('img');
+47 -6
View File
@@ -1,10 +1,51 @@
// transformer les balises [...] en <div class="..."> // transformer les balises [...] en <div class="..."> si ça correspond aux classes prédéfinies
let bodyContent = $('#body').html() let baliseWords = [
.replace(/\[([^\/\]]+)\]/g, '<div class="$1">') 'labeur',
.replace(/\[\/([^\]]+)\]/g, '</div>'); '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); $('#body').empty().append(bodyContent);
// isoler les chiffres des titres // isoler les chiffres des titres
let moments = document.getElementsByClassName("moment"); let moments = document.getElementsByClassName("moment");
@@ -32,7 +73,7 @@ for(let i = 0; i < latours.length; i++) {
headerEl.append(iconImg); headerEl.append(iconImg);
headerEl.append(headContent); headerEl.append(headContent);
latours[i].firstChild.remove(); latours[i].firstChild?.remove();
latours[i].prepend(headerEl); latours[i].prepend(headerEl);
} }
@@ -48,7 +89,7 @@ for(let i = 0; i < lampes.length; i++) {
headerEl.append(iconImg); headerEl.append(iconImg);
headerEl.append(headContent); headerEl.append(headContent);
lampes[i].firstChild.remove(); lampes[i].firstChild?.remove();
lampes[i].prepend(headerEl); lampes[i].prepend(headerEl);
} }