mirror of
https://github.com/wallabag/wallabag.git
synced 2026-10-29 13:15:09 +01:00
Limit highlight.js work to code blocks that do not already carry the `data-highlighted` marker set by `highlightElement()`. This lets cached DOM reconnect cleanly without reprocessing the same block or logging redundant work on repeat visits.
12 lines
333 B
JavaScript
12 lines
333 B
JavaScript
import { Controller } from '@hotwired/stimulus';
|
|
import 'highlight.js/styles/atom-one-light.css';
|
|
import hljs from 'highlight.js';
|
|
|
|
export default class extends Controller {
|
|
connect() {
|
|
this.element.querySelectorAll('pre code:not([data-highlighted])').forEach((element) => {
|
|
hljs.highlightElement(element);
|
|
});
|
|
}
|
|
}
|