Skip to content

Commit cf76712

Browse files
authored
Merge pull request #194 from agriyakhetarpal/fix/js-escape-patterns
Fix incorrect regex usage instructions for `TryExamples` JSON configuration file
2 parents 84537b0 + ef2dd31 commit cf76712

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

docs/directives/try_examples.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,28 +240,31 @@ The format is a list of
240240

241241
```json
242242
{
243-
"ignore_patterns": ["^/latest/.*", "^/stable/reference/generated/example.html"]
243+
"ignore_patterns": ["^\/latest/.*", "^\/stable\/reference\/generated\/example.html"]
244244
}
245245
```
246246

247247
`TryExamples` buttons will be hidden in url pathnames matching at least one of these
248248
patterns, effectively disabling the interactive documentation. In the provided example:
249249

250-
* The pattern `"^/latest/.*"` disables interactive examples for urls for the documentation
250+
* The pattern `"^\/latest\/.*"` disables interactive examples for urls for the documentation
251251
for the latest version of the package, which may be useful if this documentation is
252252
for a development version for which a corresponding package build is not available
253-
in a Jupyterlite kernel.
253+
in a JupyterLite kernel.
254254

255-
* The pattern `"^/stable/reference/generated/example.html"` targets a particular url
255+
* The pattern `"^\/stable\/reference\/generated\/example.html"` targets a particular url
256256
in the documentation for the latest stable release.
257257

258258
Note that these patterns should match the [pathname](https://developer.mozilla.org/en-US/docs/Web/API/Location/pathname) of the url, not the full url. This is the path portion of
259-
the url. For instance, the pathname of https://jupyterlite-sphinx.readthedocs.io/en/latest/directives/try_examples.html is `/en/latest/directives/try_examples.html`.
259+
the url. For instance, the pathname of https://jupyterlite-sphinx.readthedocs.io/en/latest/directives/try_examples.html is `/en/latest/directives/try_examples.html`. Also, note that since these are JavaScript-based regular
260+
expressions, to use special characters in the regular expression (such as `/`), they
261+
must be escaped with a backslash (`\`).
260262

261263
Again, the configuration file can be added or edited within the deployed documentation,
262264
allowing for disabling or enabling examples without rebuilding the documentation.
263265

264266
#### "global_min_height"
267+
265268
To avoid having unusably small notebooks for very small examples due to the default of
266269
having the embedded notebooks' iframe containers take the same amount of space as the
267270
rendered content they replace, users can set a global minimum height in

0 commit comments

Comments
 (0)