Advertisement
capyg0zt

Using highlight.js to hightlight javascript on a webpage

May 28th, 2023
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.24 KB | None | 0 0
  1. <!-- Using highlight.js to highlight js [SIMPLE VERSION] You can make it better-->
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5.     <meta charset="UTF-8">
  6.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8.     <title>Syntax Highlighting Example</title>
  9.     <link rel="stylesheet"href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/default.min.css">
  10. </head>
  11. <body>
  12.     <pre>        <!-- replace the code in the <code> tag to highlight this is the code im highlighting -->
  13.         <code>
  14.             const data = [2, 27];
  15. // replace your-endpoint with any your-endpoint
  16. fetch('/your-endpoint', {
  17.   method: 'POST',
  18.   headers: {
  19.     'Content-Type': 'application/json'
  20.   },
  21.   body: JSON.stringify(data)
  22. })
  23.   .then(response => {
  24.     if (response.ok) {
  25.       console.log('Array sent to the database successfully.');
  26.     } else {
  27.       console.error('Error:', response.status);
  28.     }
  29.   })
  30.   .catch(error => {
  31.     console.error('Error:', error);
  32.   });
  33.  
  34.         </code>
  35.     </pre>
  36.     <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
  37.     <script>
  38.         hljs.highlightAll();
  39.     </script>
  40. </body>
  41. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement