wcoder / highlightjs-line-numbers.js

Line numbering plugin for Highlight.js
https://wcoder.github.io/highlightjs-line-numbers.js/
MIT License
544 stars 126 forks source link

`TypeError: Cannot read properties of undefined (reading 'trim')` #102

Open Billy-Sheppard opened 4 months ago

Billy-Sheppard commented 4 months ago

Describe the bug JS console error from highlightjs-line-numbers.min.js.

To Reproduce Steps to reproduce the behavior:

...
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/vs2015.min.css" integrity="sha512-mtXspRdOWHCYp+f4c7CkWGYPPRAhq9X+xCvJMUBVAb6pqA4U8pxhT3RWT3LP3bKbiolYL2CkL1bSKZZO4eeTew==" crossorigin="anonymous" referrerpolicy="no-referrer">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js" integrity="sha512-D9gUyxqja7hBtkWpPWGt9wfbfaMGVt9gnyCvYa+jojwwPHLCzUm5i8rpk7vD7wNee9bA35eYIjobYPaQuKS1MQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlightjs-line-numbers.js/2.8.0/highlightjs-line-numbers.min.js" integrity="sha512-axd5V66bnXpNVQzm1c7u1M614TVRXXtouyWCE+eMYl8ALK8ePJEs96Xtx7VVrPBc0UraCn63U1+ARFI3ofW+aA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
...

Have this in your HTML, use highlightjs (and line-numbers). Prints this to console.

highlightjs-line-numbers.min.js:1  
Uncaught TypeError: Cannot read properties of undefined (reading 'trim')
    at highlightjs-line-numbers.min.js:1:1620
    at f (highlightjs-line-numbers.min.js:1:1932)
    at highlightjs-line-numbers.min.js:1:1004

Expected behavior No errors.

Desktop (please complete the following information):