Fixed problems with empty comment nodes generated by Terraform lexer

This commit is contained in:
squidfunk 2022-03-22 17:59:01 +01:00
parent 366a5ea3a4
commit 104c8c85e0
4 changed files with 12 additions and 11 deletions

View File

@ -214,7 +214,7 @@
</script>
{% endblock %}
{% block scripts %}
<script src="{{ 'assets/javascripts/bundle.897f3768.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/bundle.703c595d.min.js' | url }}"></script>
{% for path in config["extra_javascript"] %}
<script src="{{ path | url }}"></script>
{% endfor %}

View File

@ -71,14 +71,15 @@ function findAnnotationMarkers(container: HTMLElement): Text[] {
const markers: Text[] = []
for (const comment of getElements(".c, .c1, .cm", container)) {
let match: RegExpExecArray | null
let text = comment.firstChild as Text
/* Split text at marker and add to list */
while ((match = /\((\d+)\)/.exec(text.textContent!))) {
const marker = text.splitText(match.index)
text = marker.splitText(match[0].length)
markers.push(marker)
}
let text = comment.firstChild as Text
if (text instanceof Text)
while ((match = /\((\d+)\)/.exec(text.textContent!))) {
const marker = text.splitText(match.index)
text = marker.splitText(match[0].length)
markers.push(marker)
}
}
return markers
}