I am building a webpage in Vue3. On this webpage I want to display some Solidity code and I would like it to be pretty and highlightend. I found the Highlight.js (link) library. And I also found "rules" for Solidity (link), since solidity doesn't come with highlight.js.
Now, I did got this to work, when I was using Flask (python), but I switched to Vue, and for the love of all that is holy, I can't get it to work now.
So far, I tried following what highlight.js has described on their website, with regards to Vze. But that didn't work. That way didn't even work when using it on "javascript" code and "python" code. The coloring was wrong...
Currently, I import highlight.js in the :
index.html
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<link
rel="stylesheet"
href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/vs2015.min.css"
/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
<script
type="text/javascript"
src="/node_modules/highlightjs-solidity/dist/solidity.min.js"
></script>
<!-- <script
type="text/javascript"
src="/node_modules/highlightjs-solidity/dist/yul.min.js"
></script> -->
</head>
And then in the Vue Component:
...
mounted() {
self.hljs.highlightAll();
...
Now, this does work for "javascript" code and "python" code. It also works with random "haskell" code, when I import it in the head:
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/languages/haskell.min.js"></script>
But I just can't get it to work with Solidity.
