Using multiplex to style python in the middle of yaml. “yaml” mode works fine on its own, and multiplex starts “python” just fine. Once the python starts, though, I can’t close it. I’ve tried it locally and in codepen. You can see it on codepen: https://codepen.io/plocket/pen/ZEGYmXv.
What do I need to change?
Here’s the code that’s in codepen:
<section>
<div class="container">
<div class="code-container">
<textarea id="code">
---
foo: |
somestring
---
code: |
if (foo):
bar = "str"
zz: |
- item = "str"
---
</textarea>
</div><br>
</div>
</section>
CodeMirror.defineMode("yamlmixed", function(){
let outer = CodeMirror.getMode( {}, "yaml" );
let inner = CodeMirror.getMode( {}, "python" );
let innerOptions = {
open: /^code: /,
// close: /\n[^\s]/,
// Tried this to see if the regex was broken, but it isn't working either.
close: "zz",
mode: inner,
parseDelimiters: true, // I've also tried without this. Hasn't worked either way.
};
return CodeMirror.multiplexingMode( outer, innerOptions );
});
let mixedMode = {
name: "yamlmixed",
};
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
mode: 'yamlmixed',
});
Embedded: