Skip to content

Support <script type="module"> and other attributes#3237

Merged
oprypin merged 13 commits into
masterfrom
mjs
Jun 19, 2023
Merged

Support <script type="module"> and other attributes#3237
oprypin merged 13 commits into
masterfrom
mjs

Conversation

@oprypin

@oprypin oprypin commented Jun 3, 2023

Copy link
Copy Markdown

See docs in the diff.

Try it out:

pip install git+https://github.com/mkdocs/mkdocs.git@refs/pull/3237/head

Particularly I'm hoping the frontend change of fiddling with defer in standard themes doesn't cause problems.


Frontend changes:

  • Stop using defer for all scripts
  • Update highlight.js to version 11.8.0

Small config features:

  • Fix propagating warnings from sub-items of ListOfItems
  • Strip trailing _ from config members, to bypass Python reserved words
  • Make it possible to create a subclass of SubConfig[T]

Refactors:

  • Consistently use tojson for pasting strings to JavaScript
  • More concise error message in SubConfig
  • Make TemplateContext typed, move utils.filters to utils.templates

The actual change:

  • Expand config.extra_javascript to support type, async, defer
  • Include *.mjs files into javascript_files()

Oleh Prypin added 10 commits June 3, 2023 15:52
Example of adding an `async` boolean option that can be read through `config['async']` or `config.async_`:

    class ExampleConfig(Config):
        async_ = Type(bool, default=False)
`SubConfig[SomeType]()` is now the preferred way to express `SubConfig(SomeType)`
but more importantly, it is now possible to subclass `SubConfig[SomeType]` for post-processing of the value.
The top-level template object `extra_javascript` gets soft-deprecated because it still reports only a list of plain strings.

Themes need to take action and pick up the new config keys from `config.extra_javascript` instead.
Comment thread docs/dev-guide/themes.md

@squidfunk squidfunk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM from eyeballing, but I didn't run the code. Only some minor questions/adjustment (see comments).

Comment thread docs/user-guide/configuration.md Outdated
Comment thread mkdocs/contrib/search/__init__.py
Comment thread mkdocs/utils/filters.py
Comment thread mkdocs/utils/filters.py
Comment thread mkdocs/utils/filters.py
Comment thread docs/user-guide/configuration.md Outdated
Comment thread mkdocs/contrib/search/__init__.py
acodeninja added a commit to CPS-Innovation/digital-sop that referenced this pull request Jul 27, 2023
acodeninja added a commit to CPS-Innovation/digital-sop that referenced this pull request Jul 27, 2023
* Update dependency mkdocs to v1.5.0

* Correction to playbooks link

* Adapt base template to work with new extended script object

mkdocs/mkdocs#3237

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Lawrence Goldstien <lawrence.goldstien@madetech.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants