WebCoder49 / code-input

Fully customisable, editable, syntax-highlighted textareas + plugins
https://css-tricks.com/creating-an-editable-textarea-that-supports-syntax-highlighted-code/
MIT License
171 stars 23 forks source link

language attr and classes set to "none" in all cases #96

Closed Devastatia closed 5 months ago

Devastatia commented 5 months ago

The language attribute is ignored regardless of what I set it to ("HTML", "html", "CSS", etc.)

code-input.language is set to "none"

pre and code classes both set to "language-none"

The attached screenshot tells all.

code-input-screenshot

Devastatia commented 5 months ago

Curiously, it works as expected when Prism is replaced with highlight.js.

WebCoder49 commented 5 months ago

Quick Workaround (code-input demo)

@Devastatia, The bug should disappear if you add language="none" as an HTML attribute in the markup of the code-input element (or via JavaScript to the code-input element as soon as it is created).


Properly Fixing

There seems to be a problem with these lines of code:

https://github.com/WebCoder49/code-input/blob/c068194690575c04e9c15f9c5b4a23fd8dc3d741/code-input.js#L760-L764

I'm afraid I'm quite busy right now but the bug's scope being restricted to Prism suggests it might be due to Prism's functionality of adding the language-none class, which is not part of highlight.js. I will be available shortly after 25 May and will look at this bug more then.

Clearly, if you know how to fix it, comments / a pull request are very welcome, but not required.