From 0e4cfbb361a0c0f084a63099219a94bc33c6cc48 Mon Sep 17 00:00:00 2001 From: Leandre17 Date: Thu, 13 Feb 2025 12:17:59 +0100 Subject: fix _extention.qmd to explain the new version of the leandre filter extension --- _extensions/leandre-filter/leandre.lua | 4 +--- _extention.qmd | 17 ++++++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/_extensions/leandre-filter/leandre.lua b/_extensions/leandre-filter/leandre.lua index 25ea053..650e195 100644 --- a/_extensions/leandre-filter/leandre.lua +++ b/_extensions/leandre-filter/leandre.lua @@ -1,6 +1,4 @@ function Str(el) - el.text = el.text:gsub("Leandre", "Léandre") - el.text = el.text:gsub("leandre", "Léandre") - el.text = el.text:gsub("LEANDRE", "Léandre") + el.text = el.text:gsub("[Ll][Ee][Aa][Nn][Dd][Rr][Ee]", "Léandre") return el end diff --git a/_extention.qmd b/_extention.qmd index 4fbb66f..2a8f92d 100644 --- a/_extention.qmd +++ b/_extention.qmd @@ -6,8 +6,10 @@ A filter extention is a flexible and powerful tool for introducing new global be # Creation -To create a extention we need to have an "_extensions" folder and in this folder we need to create a folder for each extention. -For each extention we need to have a file name "_extension.yml" to tell quarto the structure of this extention. Here is an exemple: +To create a extention we need to have an "_extensions" folder +and in this folder we need to create a folder for each extention. +For each extention we need to have a file name "_extension.yml" to tell quarto the structure of this extention. +Here is an exemple: ```yaml title: Leandre Name Filter author: Léandre @@ -32,13 +34,14 @@ _extensions/ For this exemple we will talk about the file leandre.lua ```lua function Str(el) - if el.text:find("Leandre") then - el.text = el.text:gsub("Leandre", "Léandre") - end + el.text = el.text:gsub("[Ll][Ee][Aa][Nn][Dd][Rr][Ee]", "Léandre") return el end ``` -What do this small code do is searching for the string "Leandre" and when it find it. It will replace it with the string "Léandre" +What do this small code do is using the function gsub for each part of the document. +The gsub function search for a patern and replace it with the given string. +The patern given here "[Ll][Ee][Aa][Nn][Dd][Rr][Ee]" to permit to have evry possibility covered of the word léandre. + # More resources @@ -53,4 +56,4 @@ More about filter [https://quarto.org/docs/extensions/filters.html](https://quarto.org/docs/extensions/filters.html) And other type of extension -[https://quarto.org/docs/extensions/creating.html#development](https://quarto.org/docs/extensions/creating.html#development) \ No newline at end of file +[https://quarto.org/docs/extensions/creating.html#development](https://quarto.org/docs/extensions/creating.html#development) -- cgit v1.2.3