diff --git a/CHANGES.md b/CHANGES.md index aed414f091..e46b22fe81 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ New Grammars: Grammars: +- enh(xml) support processing instructions (#3492) [Josh Goebel][] - enh(ruby ) better support multi-line IRB prompts - enh(bash) improved keyword `$pattern` (numbers allowed in command names) [Martin Mattel][] - add `meta.prompt` scope for REPL prompts, etc [Josh Goebel][] diff --git a/src/languages/php.js b/src/languages/php.js index 9dfa2fb3b3..f0e5f8ef68 100644 --- a/src/languages/php.js +++ b/src/languages/php.js @@ -29,11 +29,10 @@ export default function(hljs) { const PREPROCESSOR = { scope: 'meta', variants: [ - { - begin: /<\?php/, - relevance: 10 - }, // boost for obvious PHP - { begin: /<\?[=]?/ }, + { begin: /<\?php/, relevance: 10 }, // boost for obvious PHP + { begin: /<\?=/ }, + // less relevant per PSR-1 which says not to use short-tags + { begin: /<\?/, relevance: 0.1 }, { begin: /\?>/ } // end php tag ] }; diff --git a/src/languages/xml.js b/src/languages/xml.js index 971bc9cba7..cb640d8a1e 100644 --- a/src/languages/xml.js +++ b/src/languages/xml.js @@ -122,11 +122,23 @@ export default function(hljs) { relevance: 10 }, XML_ENTITIES, + // xml processing instructions { className: 'meta', - begin: /<\?xml/, end: /\?>/, - relevance: 10 + variants: [ + { + begin: /<\?xml/, + relevance: 10, + contains: [ + QUOTE_META_STRING_MODE + ] + }, + { + begin: /<\?[a-z][a-z0-9]+/, + } + ] + }, { className: 'tag', diff --git a/test/markup/xml/namespace.expect.txt b/test/markup/xml/namespace.expect.txt index 4317227c5f..05aaa944e8 100644 --- a/test/markup/xml/namespace.expect.txt +++ b/test/markup/xml/namespace.expect.txt @@ -1,3 +1,3 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> +<?xml version="1.0" encoding="ISO-8859-1" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"></xs:schema> <s:schema xmlns:s="http://www.w3.org/2001/XMLSchema"></s:schema> diff --git a/test/markup/xml/processing.expect.txt b/test/markup/xml/processing.expect.txt new file mode 100644 index 0000000000..19018d0d0b --- /dev/null +++ b/test/markup/xml/processing.expect.txt @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<?PITarget PIContent?> +<?xml-stylesheet type="text/xsl" href="style.xsl"?> +<?xml-stylesheet type="text/css" href="style.css"?> +Some <?Pub _font FontColor="green"?>green<?Pub /_font?> text. +<?mso-application progid="Excel.Sheet"?> diff --git a/test/markup/xml/processing.txt b/test/markup/xml/processing.txt new file mode 100644 index 0000000000..e9565dd387 --- /dev/null +++ b/test/markup/xml/processing.txt @@ -0,0 +1,6 @@ + + + + +Some green text. +