107 Commits

Author SHA1 Message Date
Adrian Vollmer
1df42864cd Center loading indicator 2024-04-21 17:35:29 +02:00
Adrian Vollmer
b496b1cad7 Fix doc title and loading indicator 2024-04-21 17:35:29 +02:00
Adrian Vollmer
8aa570030b Rename some files; also finish some work from prev commit 2024-04-21 17:35:29 +02:00
Adrian Vollmer
54fda10acc Embed pre and post scripts in javascript
This also removes the dependency on beautifulsoup.
2024-04-21 17:35:15 +02:00
Adrian Vollmer
2e8a3ee989 Use camel case in JS 2024-04-21 16:23:03 +02:00
Adrian Vollmer
ac664c27a1 Avoid manually triggering DOMContentLoaded
It confuses scripts when it is triggered twice. Instead of passing the
global context, we simply write it into the HTML of the iframe.
We need to encode it in base64 to avoid context confusion (e.g. `</script>`
inside the JSON of the global context).
2024-04-21 15:37:23 +02:00
Adrian Vollmer
9faf9ca98b Add URL pragma of main.js in python code 2024-04-21 14:56:22 +02:00
Adrian Vollmer
1170afbfd3 Add makefile 2024-04-20 17:57:40 +02:00
Adrian Vollmer
04777f15f8 Show version in HTML source 2024-04-09 18:45:53 +02:00
Adrian Vollmer
58da889112 Rename iframe 2024-04-09 17:56:04 +02:00
Adrian Vollmer
b9e88c0fa9
Fix wrong boolean logic in embed_css 2024-04-09 13:44:06 +02:00
Adrian Vollmer
bd6ad1fc69 Soften URL pattern
Apparently, only one dash is also allowed.
2024-04-08 18:55:10 +02:00
Adrian Vollmer
b37d287cc6 Fix fetch monkey patch
Wait for `global_context` to exist. Fix bug with b64 encoding. Respect
mime type.
2024-04-08 18:54:49 +02:00
Adrian Vollmer
d0a6ba478e Don't embed eternal CSS resources 2024-04-08 18:53:29 +02:00
Adrian Vollmer
648a962ca4 Fix double execution 2024-04-03 20:31:56 +02:00
Adrian Vollmer
f7530f8ff9 Fix source URL pragmas 2024-04-03 20:17:43 +02:00
Adrian Vollmer
b99d1c2977 Improve tests 2024-04-03 20:02:57 +02:00
Adrian Vollmer
77fc23ea00 Check for existence of global_context before access 2024-04-03 19:53:52 +02:00
Adrian Vollmer
6f7ea071ff Black tests 2024-04-03 19:47:04 +02:00
Adrian Vollmer
b79e0f6d07 Include remark about sphinx in README 2024-04-01 14:26:55 +02:00
Adrian Vollmer
0bde114839 Apply black 2024-03-31 10:56:04 +02:00
Adrian Vollmer
c58206b892 Add black check to nox file 2024-03-31 10:54:35 +02:00
Adrian Vollmer
4f41fbf64e Add test cases 2024-03-30 18:22:03 +01:00
Adrian Vollmer
68991a56d6 Add flake8 config 2024-03-30 13:12:22 +01:00
Adrian Vollmer
c1f6b659ea Fix markdown warning in README 2024-03-26 19:50:03 +01:00
Adrian Vollmer
e798b329a9 Copy missing functions to inject_pre.js
This should fix #6.

(Code duplication should be avoided though...)
2024-03-26 18:29:33 +01:00
Adrian Vollmer
ec6c845a11 Fix HTML entities inside style elements
This patch causes the contents of the file to be inserted verbatim into
the style element.
2024-03-26 18:25:19 +01:00
Adrian Vollmer
70d3a54215 Monkeypatch more functions used by Sphinx
This also monkeypatches `URLSearchParams.delete`
and `window.history`.
2024-02-18 21:08:07 +01:00
Adrian Vollmer
2b870da3cb Process DOM of virtual HTML file before rendering
With this commit, the virtual HTML file is processed before it's fed to
the iframe and thus rendered. With the previous approach, script tags
with inline JavaScript were executed first and script tags with a
virtual `src` were executed last. This messed up the execution flow of
the document.
2024-02-18 21:05:51 +01:00
Adrian Vollmer
6aaa3841d2 Create the iframe without display='none'
This is important for JavaScript programs like mermaid, which initialize
an svg based on the actual size of the parent div.

See #5
2024-02-18 21:02:36 +01:00
Adrian Vollmer
3fa8f86019 Add minimal test case 2023-09-30 17:45:20 +02:00
Adrian Vollmer
fb7bae8e42 Fix compatibility with Sphinx >= 7.2; close #4 2023-09-30 17:45:20 +02:00
Adrian Vollmer
caaa346b2b
Fix test requirements 2023-08-15 14:03:16 +02:00
Adrian Vollmer
782d014691
Move to pyproject.toml 2023-08-15 13:59:01 +02:00
Adrian Vollmer
3dd6f551f9 Clarify README about building jupyter-books
Close #3
2023-07-03 19:37:54 +02:00
Adrian Vollmer
88a3383b1d Make use of GitHubs warning blockquote 2022-11-26 09:59:48 +01:00
Adrian Vollmer
ecc3adaacd Fix home page in setup.cfg 2022-10-29 15:59:41 +02:00
Adrian Vollmer
f6e6228bbf Reduce errors related to mime types
We don't need to know about the `ImportError` every time we guess a mime
type. Because an `ImportError` is also raised if `python-magic` is
installed but `libmagic1` is not present, we can handle this at the
beginning of the file.
2022-10-18 17:44:52 +02:00
Adrian Vollmer
31ff902098 Add fall back when guessing mime type
This fixes a bug that appears if the document is built on a system
without libmagic1. The python library python-magic uses it to guess the
mime type. We treat files with unknown mime type as `octet-stream`,
which causes them to be downloaded rather than displayed in the main
iframe. This results in lots of popups when opening the resulting HTML
file in a browser.

In this commit we add a fallback to the built-in library `mimetypes`
which gueses the mime type from the filename alone. This should work in
most cases but could still fail.

Close #2.
2022-10-18 17:30:40 +02:00
Adrian Vollmer
3958492feb Add revert flag 2022-10-18 17:24:47 +02:00
Adrian Vollmer
815b6ac11a Remove redundant source url pragma 2022-10-18 14:03:56 +02:00
Adrian Vollmer
384f76120c Add sphinx-tabs to test 2022-10-17 18:07:25 +02:00
Adrian Vollmer
c24f30f5ec Fix error with about:srcdoc links; add extra check 2022-10-16 19:18:24 +02:00
Adrian Vollmer
0c4bbe69a3 Update README 2022-10-12 18:28:00 +02:00
Adrian Vollmer
7764198e91 Fix README 2022-10-12 18:15:44 +02:00
Adrian Vollmer
068f2db12c Fix links with leading slash 2022-10-12 15:27:51 +02:00
Adrian Vollmer
fadbb72e67 Add support for append-pre/post 2022-10-12 14:48:58 +02:00
Adrian Vollmer
25fb93219c Rename some files; fix sourceURL pragmas 2022-10-12 14:41:57 +02:00
Adrian Vollmer
b563da585e Improve docstring 2022-10-12 13:43:24 +02:00
Adrian Vollmer
e05de76bad Improve CSS embedding 2022-10-12 13:42:05 +02:00