Skip to content

Commit 1884aef

Browse files
committed
Teste une extension différente
1 parent 7006f60 commit 1884aef

File tree

5 files changed

+65
-80
lines changed

5 files changed

+65
-80
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
local filename = quarto.doc and quarto.doc.input_file or ""
2+
local dirname = quarto.project and quarto.project.directory or ""
3+
4+
-- Escape special characters
5+
local function escape_pattern(str)
6+
return str and str:gsub("([^%w])", "%%%1") or ""
7+
end
8+
9+
dirname = escape_pattern(dirname)
10+
11+
local filename_relative = filename:gsub("^" .. dirname, "")
12+
filename_relative = "https://pythonds.linogaliana.fr" .. filename_relative
13+
filename_relative = filename_relative:gsub("%.qmd$", ".html")
14+
15+
-- Vérifie la langue
16+
local function ends_with(str, suffix)
17+
return str:sub(-#suffix) == suffix
18+
end
19+
20+
-- Création du bloc .callout-note avec contenu HTML
21+
local function get_callout_div()
22+
local html_text
23+
24+
if ends_with(filename_relative, "_en.html") then
25+
html_text = "This is the English 🇬🇧 🇺🇸 version of that chapter, to see the French version go " ..
26+
"<a href=\"" .. filename_relative:gsub("_en.html", ".html") .. "\">there</a>."
27+
else
28+
html_text = "Ceci est la version française 🇫🇷 de ce chapitre, pour voir la version anglaise allez " ..
29+
"<a href=\"" .. filename_relative:gsub(".html", "_en.html") .. "\">ici</a>."
30+
end
31+
32+
return pandoc.Div(
33+
{ pandoc.Para{ pandoc.RawInline("html", html_text) } },
34+
pandoc.Attr("", { "callout-note" })
35+
)
36+
end
37+
38+
-- Hook principal : remplace {{warninglang}} par un .callout-note
39+
return {
40+
{
41+
Para = function (elem)
42+
for i, v in ipairs(elem.content) do
43+
if v.t == "Str" and v.text == "{{warninglang}}" then
44+
return get_callout_div()
45+
end
46+
end
47+
return elem
48+
end
49+
}
50+
}

_quarto-prod.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,15 @@ format:
106106
# PAGE OPTIONS ---------------------
107107

108108
filters:
109+
- at: pre-ast
110+
path: _extensions/linogaliana/lang-switch/lang-notebook.lua
111+
- at: pre-ast
112+
path: _extensions/linogaliana/callout/callout-notebook.lua
109113
- build/replace-title.lua
110114
- build/lang-notebook.lua
111115
- build/callout/callout-jupyter.lua
112116
- include-code-files
113117
- _extensions/linogaliana/lang-switch/button.lua
114-
- at: pre-ast
115-
path: _extensions/linogaliana/callout/callout-notebook.lua
116118

117119
crossref:
118120
chapters: true

_quarto.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,14 @@ format:
6969
# PAGE OPTIONS ---------------------
7070

7171
filters:
72+
- at: pre-ast
73+
path: _extensions/linogaliana/lang-switch/lang-notebook.lua
74+
- at: pre-ast
75+
path: _extensions/linogaliana/callout/callout-notebook.lua
7276
- include-code-files
7377
- build/replace-title.lua
74-
- build/lang-notebook.lua
7578
- _extensions/linogaliana/details-iframe/details.lua
7679
- _extensions/linogaliana/lang-switch/button.lua
77-
- at: pre-ast
78-
path: _extensions/linogaliana/callout/callout-notebook.lua
7980

8081
crossref:
8182
chapters: true

build/lang-notebook.lua

Lines changed: 0 additions & 72 deletions
This file was deleted.

content/manipulation/01_numpy.qmd

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,17 +448,19 @@ x[:,1]
448448
Le principe se généralise, mais se complexifie, pour des _array_ imbriqués. Heureusement, ce sont des objets qu'on manipule assez rarement directement, la plupart de nos données numériques étant des tableaux plats (une valeur - l'observation - est le croisement d'une ligne - l'individu - et d'une colonne - la variable).
449449

450450
:::
451+
451452
::: {.content-visible when-profile="en"}
452453
The same logic applies to multidimensional _arrays_. Indexing then takes place at several levels. Take, for example, a 2-dimensional array (a matrix of sorts):
453454

454-
``{python}
455+
```{python}
455456
x = np.array([[1, 2, 3], [4, 5, 6]], np.int32)
456-
````
457+
```
457458

458459
If we want to select the 2nd row, 3rd column (the element with value 6), we do
459460

461+
```{python}
460462
x[1, 2]
461-
````{python}
463+
```
462464

463465
Now, to select a complete column (e.g. the 2nd), we can use the 2nd index to specify it (index 1 in Python since indexing starts from 0) and then `:` on the first dimension (shortened version of `0:N`) to avoid discriminating according to this dimension:
464466

@@ -467,6 +469,8 @@ x[:,1]
467469
```
468470
469471
The principle is generalized, but becomes more complex, for nested _arrays_. Fortunately, these are objects we rarely manipulate directly, as most of our numerical data are flat arrays (a value - the observation - is the intersection of a row - the individual - and a column - the variable).
472+
473+
470474
:::
471475
472476

0 commit comments

Comments
 (0)