Skip to content

Commit

Permalink
Enable client-side Prism in dev playground
Browse files Browse the repository at this point in the history
  • Loading branch information
MattIPv4 committed Oct 16, 2023
1 parent f229e6c commit ab5fe3b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion dev/client.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2022 DigitalOcean
Copyright 2023 DigitalOcean
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -19,6 +19,11 @@ limitations under the License.
require('./client.scss');
const render = require('./render');

const Prism = require('../vendor/prismjs/prism');
require('../vendor/prismjs/plugins/keep-markup/prism-keep-markup')(Prism);
require('../vendor/prismjs/plugins/toolbar/prism-toolbar')(Prism);
require('../vendor/prismjs/plugins/copy-to-clipboard/prism-copy-to-clipboard')(Prism);

document.addEventListener('DOMContentLoaded', event => {
const textbox = document.getElementById('textbox');
const output = document.getElementById('output');
Expand All @@ -42,6 +47,9 @@ document.addEventListener('DOMContentLoaded', event => {
newScript.appendChild(document.createTextNode(oldScript.innerHTML));
oldScript.parentNode.replaceChild(newScript, oldScript);
});

// Run Prism on the output
Prism.highlightAllUnder(output);
};

// Monkey-patch addEventListener to short-circuit future DOMContentLoaded handlers
Expand Down

0 comments on commit ab5fe3b

Please sign in to comment.