aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--_extensions/leandre-filter/leandre.lua4
-rw-r--r--_extention.qmd17
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)