Skip to content

Commit f3f29ac

Browse files
fix(tooling) developer.html does not render highlighted language properly (highlightjs#2672)
* Fix inconsistency in developer.html Co-authored-by: Josh Goebel <me@joshgoebel.com>
1 parent 01f049b commit f3f29ac

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

tools/developer.html

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ <h3>Code</h3>
7070
</div>
7171
<div>
7272
<h3>Rendered in <span class="rendering_time">...</span> ms [<span class="rendering_stats">...</span>]</h3>
73-
<highlightjs auto :code="code" />
73+
<highlightjs :language="language" :code="code" />
7474
</div>
7575
<div>
7676
<h3>Markup</h3>
@@ -99,6 +99,7 @@ <h3>Markup</h3>
9999
var result = hljs.getLanguage(language) ? hljs.highlight(language, source, true) : hljs.highlightAuto(source);
100100
var rendering_time = +new Date() - start_time;
101101
vue.code = source;
102+
vue.language = hljs.getLanguage(language) ? language : '';
102103

103104
var rendering_stats = result.language + ': relevance ' + (result.relevance );
104105
if (result.second_best) {
@@ -144,15 +145,25 @@ <h3>Markup</h3>
144145
Vue.use(hljs.vuePlugin);
145146
let vue = new Vue({
146147
el: '#app',
147-
data: { code: "" },
148-
watch: { code: function(){
149-
// update data-klass post-render for cool class previews
150-
this.$nextTick(() => {
151-
$(".hljs span").each((_,el) => {
152-
$(el).attr("data-klass", el.className.replace("hljs-",""))
148+
data: { code: "", language: "" },
149+
methods: {
150+
refreshKlass: function() {
151+
// update data-klass post-render for cool class previews
152+
this.$nextTick(() => {
153+
$(".hljs span").each((_,el) => {
154+
$(el).attr("data-klass", el.className.replace("hljs-",""))
155+
})
153156
})
154-
})
155-
}}
157+
}
158+
},
159+
watch: {
160+
code: function(){
161+
this.refreshKlass();
162+
},
163+
language: function(){
164+
this.refreshKlass();
165+
}
166+
}
156167
})
157168
</script>
158169
</body>

0 commit comments

Comments
 (0)