Multiple languages in one editor


On my site,

  • codemirrors are read-only, not used for editing
  • Line numbers where languages start and finish are known
  • For example, PHP & Typescript in one editor
  • Using a separate codemirror for each language is possible, but I just wanted to explore putting all code in one codemirror.

following the examples CodeMirror Mixed-Language Parsing Example seems like it would take me many hours to get it working, so if no one has any ideas I think I would just use multiple codemirror instances instead.

If I had like 10 codemirros on one page, would that be a performance issue?

Best regards


But if these are just for presentation, not editing, it might also be possible to use highlightCode from @lezer/highlight directly to render the highlighted code as static HTML, without involving CodeMirror.