Skip to content

Commit

Permalink
(enh) Auto-update the highlighted output when the language dropdown c…
Browse files Browse the repository at this point in the history
…hanges.
  • Loading branch information
shabbir23ah authored May 3, 2023
1 parent cc93b0e commit bc56b4e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 7 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
## Version 11.9.0
## Version 11.9.0 (next release)

Parser:

- (enh) prevent rehighlighting of an element [joshgoebel][]
- added 3rd party Iptables grammar to SUPPORTED_LANGUAGES [Checconio][]

Dev tool:

- (chore) Update dev tool to use the new `highlight` API. [Shah Shabbir Ahmmed][]
- (enh) Auto-update the highlighted output when the language dropdown changes. [Shah Shabbir Ahmmed][]

[Shah Shabbir Ahmmed]: https://github.com/shabbir23ah
[Josh Goebel]: https://github.com/joshgoebel
[Checconio]: https://github.com/Checconio

Expand Down
10 changes: 7 additions & 3 deletions tools/developer.html
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,12 @@ <h3>Markup</h3>
localStorage.setItem(key_THEME, css);
})

$('.editor button#update-highlighting').click(function(e) {
function update() {
var editor = $(this).parents('.editor');
var language = editor.find('.languages').val();
var source = editor.find('textarea').val();
var start_time = +new Date();
var result = hljs.getLanguage(language) ? hljs.highlight(language, source, true) : hljs.highlightAuto(source);
var result = hljs.getLanguage(language) ? hljs.highlight(source, { language, ignoreIllegals: true}) : hljs.highlightAuto(source);
var rendering_time = +new Date() - start_time;
editor.find('.hljs').html(result.value);
$(".hljs span").each((_,el) => {
Expand All @@ -383,7 +383,11 @@ <h3>Markup</h3>
editor.find('.rendering_time').text(rendering_time);
editor.find('output').text(result.value);
saveSettings();
});

};

$('.editor button#update-highlighting').click(update);
$(".languages").change(update);

$('.editor button#show-structure').click(function(e) {
var editor = $(this).parents('.editor');
Expand Down

0 comments on commit bc56b4e

Please sign in to comment.