microlight icon indicating copy to clipboard operation
microlight copied to clipboard

Support `<pre><code>` tags.

Open 2brownc opened this issue 3 years ago • 3 comments

Currently microlight class needs to be included in the class list. But most syntax highlight scripts automatically work on code wrapped in <pre><code> tags.

I request same behavior with microlight.js.

2brownc avatar Jul 06 '21 10:07 2brownc

What would be better is:

https://github.com/asvd/microlight/blob/master/microlight.js#L39-L41

Changing this to:

-     var reset = function(cls) {
+     var reset = function(nodes) {
         // nodes to highlight
-        microlighted = _document.getElementsByClassName(cls||'microlight');
+        microlighted = nodes || _document.getElementsByClassName('microlight');

And then release as a major version bump.

This would solve all problems in a way that is trivially backwards compatible.

Qix- avatar Jul 06 '21 17:07 Qix-

Following @Qix- Idea I modified it to highlight all automatically

	var reset = function(nodes) {
        microlighted = document.getElementsByTagName("code");

you can find the fork here https://github.com/gurugeek/microlight/blob/master/microlight.js

gurugeek avatar Dec 17 '21 10:12 gurugeek

@gurugeek your change does not do what I suggested.

Qix- avatar Dec 17 '21 13:12 Qix-