Skip to content

Commit

Permalink
Allow to pass string arguments with single or double quotes (#105)
Browse files Browse the repository at this point in the history
* Allow to pass strings with singles or double quotes

* Fix error in message

* Show error instead of raising an exception if a parsed boolean value is not valid

* Skip test in windows

* Fix error in message

* Update documentation

* Improve warning messages
  • Loading branch information
mondeja authored May 24, 2022
1 parent 5f3b92f commit 68b30c4
Show file tree
Hide file tree
Showing 14 changed files with 668 additions and 256 deletions.
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ Paths of included files can be absolute or relative to the path of the file
that includes them. This argument also accept globs, in which case certain
paths can be ignored using the `exclude` argument.

File paths to include and string arguments can be wrapped by double `"` or
single `'` quotes, which can be escaped prepending them a `\` character as
`\"` and `\'`.

The arguments **start** and **end** may contain usual (Python-style) escape
sequences like `\n` to match against newlines.

<!-- mdpo-disable-next-line -->
#### **`include-markdown`**

Expand Down Expand Up @@ -97,9 +104,9 @@ content to include.

```jinja
{%
include-markdown "docs/includes/header.md"
start="<!--\n\ttable-start\n-->"
end="<!--\n\ttable-end\n-->"
include-markdown 'docs/includes/header.md'
start='<!--\n\ttable-start\n-->'
end='<!--\n\ttable-end\n-->'
rewrite-relative-urls=false
comments=false
%}
Expand All @@ -116,13 +123,13 @@ content to include.
{%
include-markdown "../LICENSE*"
start="<!--license \"start\" -->"
end="<!--license \"end\" -->"
end='<!--license "end" -->'
exclude="../LICENSE*.rst"
%}
```

```jinja
{% include-markdown "/escap\"ed/double-quotes/in/file\"/name.md" %}
{% include-markdown '/escap\'ed/single-quotes/in/file\'/name.md' %}
```

<!-- mdpo-disable-next-line -->
Expand Down Expand Up @@ -166,8 +173,8 @@ Includes the content of a file or a group of files.

```jinja
{%
include "../LICENSE*"
exclude="../LICENSE*.rst"
include '../LICENSE*'
exclude='../LICENSE*.rst'
%}
```

Expand Down
2 changes: 1 addition & 1 deletion examples/start-end-not-found-warnings/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
%}

{%
include "./included.md"
include './included.md'
start="<--start-->"
end="<--end-->"
%}
22 changes: 15 additions & 7 deletions locale/es/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ Las rutas de los archivos incluidos pueden ser absolutas o relativas a la ruta
del archivo que las incluye. Este argumento también acepta globs, en cuyo caso
ciertas rutas pueden ser ignoradas usando el argumento `exclude`.

Las rutas de archivo para incluir y los argumentos de cadena se pueden envolver
con comillas dobles `"` o simples `'`, que se pueden escapar anteponiendo un
carácter `\` como `\"` y `\'`.

Las cadenas **start** y **end** pueden contener caracteres usuales de secuencias
de escape (al estilo Python) como `\n` para hacer coincidir contra caracteres de
salto de línea

#### **`include-markdown`**

Incluye contenido de archivos Markdown, opcionalmente usando dos delimitadores
Expand Down Expand Up @@ -94,9 +102,9 @@ encuentran en el contenido a incluir se eliminan. Los valores posibles son

```jinja
{%
include-markdown "docs/includes/header.md"
start="<!--\n\ttable-start\n-->"
end="<!--\n\ttable-end\n-->"
include-markdown 'docs/includes/header.md'
start='<!--\n\ttable-start\n-->'
end='<!--\n\ttable-end\n-->'
rewrite-relative-urls=false
comments=false
%}
Expand All @@ -113,13 +121,13 @@ encuentran en el contenido a incluir se eliminan. Los valores posibles son
{%
include-markdown "../LICENSE*"
start="<!--license \"start\" -->"
end="<!--license \"end\" -->"
end='<!--license "end" -->'
exclude="../LICENSE*.rst"
%}
```

```jinja
{% include-markdown "/escap\"ed/double-quotes/in/file\"/name.md" %}
{% include-markdown '/escap\'ed/single-quotes/in/file\'/name.md' %}
```

#### **`include`**
Expand Down Expand Up @@ -163,8 +171,8 @@ se encuentran en el contenido a incluir se eliminan. Los valores posibles son

```jinja
{%
include "../LICENSE*"
exclude="../LICENSE*.rst"
include '../LICENSE*'
exclude='../LICENSE*.rst'
%}
```

Expand Down
17 changes: 17 additions & 0 deletions locale/es/README.md.po
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,20 @@ msgstr ""
"Las rutas de los archivos incluidos pueden ser absolutas o relativas a la "
"ruta del archivo que las incluye. Este argumento también acepta globs, en "
"cuyo caso ciertas rutas pueden ser ignoradas usando el argumento `exclude`."

msgid ""
"The arguments **start** and **end** may contain usual (Python-style) escape "
"sequences like `\\n` to match against newlines."
msgstr ""
"Las cadenas **start** y **end** pueden contener caracteres usuales de "
"secuencias de escape (al estilo Python) como `\\n` para hacer coincidir "
"contra caracteres de salto de línea"

msgid ""
"File paths to include and string arguments can be wrapped by double `\"` or "
"single `'` quotes, which can be escaped prepending them a `\\` character as "
"`\\\"` and `\\'`."
msgstr ""
"Las rutas de archivo para incluir y los argumentos de cadena se pueden "
"envolver con comillas dobles `\"` o simples `'`, que se pueden escapar "
"anteponiendo un carácter `\\` como `\\\"` y `\\'`."
22 changes: 15 additions & 7 deletions locale/fr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ Les paths des fichiers inclus peuvent être absolus ou relatifs au le path du
fichier qui les inclut. Cet argument accepte également des globs, auquel cas
certains paths peuvent être ignorés à l'aide de l'argument `exclude`.

Les chemins d'accès aux fichiers à inclure et les arguments de chaîne peuvent
être entourés de guillemets doubles `"` ou simples `'`, qui peuvent être
échappés en leur ajoutant un caractère `\` comme `\"` et `\'`.

Les chaînes **start** et **end** peuvent contenir des séquences d'échappement
habituelles (de style Python) telles que `\n` pour correspondre aux nouvelles
lignes.

#### **`include-markdown`**

Inclut contenu des Markdown fichiers, en utilisant éventuellement deux
Expand Down Expand Up @@ -93,9 +101,9 @@ le contenu à inclure sont supprimées. Les valeurs possibles sont `true` et

```jinja
{%
include-markdown "docs/includes/header.md"
start="<!--\n\ttable-start\n-->"
end="<!--\n\ttable-end\n-->"
include-markdown 'docs/includes/header.md'
start='<!--\n\ttable-start\n-->'
end='<!--\n\ttable-end\n-->'
rewrite-relative-urls=false
comments=false
%}
Expand All @@ -112,13 +120,13 @@ le contenu à inclure sont supprimées. Les valeurs possibles sont `true` et
{%
include-markdown "../LICENSE*"
start="<!--license \"start\" -->"
end="<!--license \"end\" -->"
end='<!--license "end" -->'
exclude="../LICENSE*.rst"
%}
```

```jinja
{% include-markdown "/escap\"ed/double-quotes/in/file\"/name.md" %}
{% include-markdown '/escap\'ed/single-quotes/in/file\'/name.md' %}
```

#### **`include`**
Expand Down Expand Up @@ -162,8 +170,8 @@ trouvées dans le contenu à inclure sont supprimées. Les valeurs possibles son

```jinja
{%
include "../LICENSE*"
exclude="../LICENSE*.rst"
include '../LICENSE*'
exclude='../LICENSE*.rst'
%}
```

Expand Down
17 changes: 17 additions & 0 deletions locale/fr/README.md.po
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,20 @@ msgstr ""
"Les paths des fichiers inclus peuvent être absolus ou relatifs au le path du"
" fichier qui les inclut. Cet argument accepte également des globs, auquel "
"cas certains paths peuvent être ignorés à l'aide de l'argument `exclude`."

msgid ""
"The arguments **start** and **end** may contain usual (Python-style) escape "
"sequences like `\\n` to match against newlines."
msgstr ""
"Les chaînes **start** et **end** peuvent contenir des séquences "
"d'échappement habituelles (de style Python) telles que `\\n` pour "
"correspondre aux nouvelles lignes."

msgid ""
"File paths to include and string arguments can be wrapped by double `\"` or "
"single `'` quotes, which can be escaped prepending them a `\\` character as "
"`\\\"` and `\\'`."
msgstr ""
"Les chemins d'accès aux fichiers à inclure et les arguments de chaîne "
"peuvent être entourés de guillemets doubles `\"` ou simples `'`, qui peuvent"
" être échappés en leur ajoutant un caractère `\\` comme `\\\"` et `\\'`."
Loading

0 comments on commit 68b30c4

Please sign in to comment.