Skip to content

Commit

Permalink
add highlightjs
Browse files Browse the repository at this point in the history
  • Loading branch information
leomcelroy committed Dec 23, 2023
1 parent 6701603 commit 7729fc3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
30 changes: 22 additions & 8 deletions astro/src/components/Help.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
import styles from './Help.module.css'
import { useState, useEffect } from 'preact/hooks'
import { marked } from 'marked'
import { marked, Marked } from 'marked'
import { loadCodeFromString } from '../lib/loadCodeFromString.ts'
// import Prism from "prismjs";
// import hljs from 'highlight.js';
// import {markedHighlight} from "marked-highlight";
import hljs from 'highlight.js';
import {markedHighlight} from "marked-highlight";

// console.log(Marked);

// const marked = new Marked(
// markedHighlight({
// langPrefix: 'hljs language-',
// highlight(code, lang, info) {
// const language = hljs.getLanguage(lang) ? lang : 'plaintext';
// return hljs.highlight(code, { language }).value;
// }
// })
// );

marked.setOptions({
// highlight: function (code, language) {

// const validLanguage = Prism.languages[language] ? language : 'markup'
// return Prism.highlight(code, Prism.languages[validLanguage], validLanguage)
// }
highlight: function (code, lang) {

const language = hljs.getLanguage(lang) ? lang : 'markup';
return hljs.highlight(code, { language }).value;

// const validLanguage = Prism.languages[language] ? language : 'markup'
// return Prism.highlight(code, Prism.languages[validLanguage], validLanguage)
}
})

export default function Help({
Expand Down
7 changes: 2 additions & 5 deletions astro/src/pages/editor.astro
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ import '../css/global.css'
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />

<!-- Prism CSS -->
<link
href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/themes/prism.min.css"
rel="stylesheet"
/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">


<meta name="generator" content={Astro.generator} />
<title>Blot</title>
Expand Down

1 comment on commit 7729fc3

@vercel
Copy link

@vercel vercel bot commented on 7729fc3 Dec 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

blot – ./astro

blot.hackclub.dev
blot-git-main.hackclub.dev

Please sign in to comment.