koca / vue-prism-editor

A dead simple code editor with syntax highlighting and line numbers. 3kb/gz
https://prism-editor.netlify.com
MIT License
751 stars 84 forks source link

Vue 3 - highligther misses token parsing in Python. #132

Closed surister closed 2 years ago

surister commented 2 years ago

When I put some python code some parts are not highlighted because they are not matched:

prism: image

css inspection: image

My setup:


<script>
import 'vue-prism-editor/dist/prismeditor.min.css'; // import the styles somewhere
import {highlight, languages} from 'prismjs/components/prism-core';
import 'prismjs/components/prism-python'
import '../assets/css/darcula.css'

import {PrismEditor} from 'vue-prism-editor';
import Wednesday from "@/components/wednesday";

export default {
  name: 'Home',
  data: function () {
    return {
      code: 'def accumulate(iterable, func=operator.add, *, initial=None):\n' +
          '    \'Return running totals\'\n' +
          '    # accumulate([1,2,3,4,5]) --> 1 3 6 10 15\n' +
          '    # accumulate([1,2,3,4,5], initial=100) --> 100 101 103 106 110 115\n' +
          '    # accumulate([1,2,3,4,5], operator.mul) --> 1 2 6 24 120\n' +
          '    it = iter(iterable)\n' +
          '    total = initial\n' +
          '    if initial is None:\n' +
          '        try:\n' +
          '            total = next(it)\n' +
          '        except StopIteration:\n' +
          '            return\n' +
          '    yield total\n' +
          '    for element in it:\n' +
          '        total = func(total, element)\n' +
          '        yield total'

    }
  },
  methods: {
    highlighter(code) {
      return highlight(code, languages.python); // languages.<insert language> to return html with markup
    },
  },
  components: {
    Wednesday,
    PrismEditor
  },
}
</script>
koca commented 2 years ago

Since its related to prismjs i cant tell from looking at code snippets. Please upload your code to codesandbox or stackblitz. And reopen the issue. :)