I’m using code mirror to display and highlight code extracts.
The following php extract is well highlighted because it has the php open tag at the beginning:
<?php
if (true) {
The following php extract is not well highlighted because it hasn’t the tag.
if (true) {
Which config would allow me this?
For now, I tried to play with the config without success:
import {basicSetup, EditorView} from "codemirror"
import {php} from "@codemirror/lang-php"
import {languages} from "@codemirror/language-data"
// The Markdown parser will dynamically load parsers
// for code blocks, using @codemirror/language-data to
// look up the appropriate dynamic import.
let view = new EditorView({
doc: "if (true) {",
plain: true,
mode: {
name: "php",
startOpen: true
},
extensions: [
basicSetup,
php()
],
parent: document.body
})
You can try it in this sandbox along with if (true) {.
Bonus: I’m using react-codemirror