Skip to content

XML mode doesn't highlight processing instructions #3479

@doerwalter

Description

@doerwalter

highlight.js does not highlight processing instructions in XML mode (except for the pseudo processing instruction <?xml ...?>)

I am using highlight.js 11.4.0 and the following HTML code:

<pre class="language-xml">
&lt;?ul4 langs(*names)?&gt;
&lt;?whitespace strip?&gt;
&lt;?doc Languages?>
&lt;ul>
	&lt;?for n in names?>
		&lt;li>
			&lt;?printx n?>
		&lt;/li>
	&lt;?end for?>
&lt;/ul> 
</pre>

I include highlight.js like this (in the <head>):

<script src="/static/highlight.js/11.4.0/highlight.min.js"></script>

I activate highlight.js by the following <script> at the end of the <body>:

<script>
	document.addEventListener('DOMContentLoaded', (event) => {
		document.querySelectorAll('pre, code').forEach(el => {
			hljs.highlightElement(el);
		});
	});
</script>

The only highlighted parts in the result however are the start and end tags. None of the processing instructions get hightlighted:

Bildschirmfoto 2022-02-14 um 11 55 36

For information about XML processing instructions see: https://www.w3.org/TR/REC-xml/#sec-pi

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementAn enhancement or new featuregood first issueShould be easier for first time contributorshelp welcomeCould use help from communitylanguage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions