mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Improved graceful handling of missing code annotations
This commit is contained in:
parent
cb818af6e5
commit
db3ba10979
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -213,7 +213,7 @@
|
|||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script src="{{ 'assets/javascripts/bundle.289a2a4b.min.js' | url }}"></script>
|
<script src="{{ 'assets/javascripts/bundle.2feb5f25.min.js' | url }}"></script>
|
||||||
{% for path in config["extra_javascript"] %}
|
{% for path in config["extra_javascript"] %}
|
||||||
<script src="{{ path | url }}"></script>
|
<script src="{{ path | url }}"></script>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -34,7 +34,8 @@ import {
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
getElement,
|
getElement,
|
||||||
getElements
|
getElements,
|
||||||
|
getOptionalElement
|
||||||
} from "~/browser"
|
} from "~/browser"
|
||||||
import { renderAnnotation } from "~/templates"
|
import { renderAnnotation } from "~/templates"
|
||||||
|
|
||||||
@ -118,8 +119,10 @@ export function mountAnnotationList(
|
|||||||
const annotations = new Map<number, HTMLElement>()
|
const annotations = new Map<number, HTMLElement>()
|
||||||
for (const marker of findAnnotationMarkers(container)) {
|
for (const marker of findAnnotationMarkers(container)) {
|
||||||
const [, id] = marker.textContent!.match(/\((\d+)\)/)!
|
const [, id] = marker.textContent!.match(/\((\d+)\)/)!
|
||||||
annotations.set(+id, renderAnnotation(+id))
|
if (getOptionalElement(`li:nth-child(${id})`, el)) {
|
||||||
marker.replaceWith(annotations.get(+id)!)
|
annotations.set(+id, renderAnnotation(+id))
|
||||||
|
marker.replaceWith(annotations.get(+id)!)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Keep list if there are no annotations to render */
|
/* Keep list if there are no annotations to render */
|
||||||
|
Loading…
Reference in New Issue
Block a user