-
Notifications
You must be signed in to change notification settings - Fork 2
feat: prism highlighting #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 10 commits
3a13772
f10bb3a
5798822
efc87b3
996157c
034819e
1455071
449c820
f885c08
0c368e9
ed74d90
0dbf5ba
8993fe2
7a19843
58ba4d0
bef31b6
ab5edf3
e5fafff
351cec7
e96512f
360404d
058f52c
c3fde76
9145db6
eb8e870
39c7b0b
cff6e07
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
load1n9 marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| .markdown { | ||
| word-wrap: break-word; | ||
|
|
||
| > *:first-child { | ||
| >*:first-child { | ||
| margin-top: 0 !important; | ||
| } | ||
|
|
||
| > *:last-child { | ||
| >*:last-child { | ||
| margin-bottom: 0 !important; | ||
| } | ||
|
||
|
|
||
|
|
@@ -39,14 +39,46 @@ | |
| margin-left: 2rem; | ||
| } | ||
|
|
||
| p > code { | ||
| background-color: var(--neutral-100); | ||
| outline: 0.15em solid var(--neutral-100); | ||
| p>code { | ||
| background-color: light-dark(hsl(230, 1%, 98%), hsl(220, 13%, 18%)); | ||
| outline: 0.15em solid light-dark(hsl(230, 1%, 98%), hsl(220, 13%, 18%)); | ||
| } | ||
|
|
||
| pre:has(code) { | ||
| outline: 1rem solid var(--neutral-100); | ||
| background-color: var(--neutral-100); | ||
| outline: 1rem solid light-dark(hsl(230, 1%, 98%), hsl(220, 13%, 18%)); | ||
| background-color: light-dark(hsl(230, 1%, 98%), hsl(220, 13%, 18%)); | ||
| overflow: auto; | ||
| } | ||
|
||
| } | ||
|
|
||
| ::-webkit-scrollbar { | ||
| width: 6px; | ||
| height: 6px; | ||
| } | ||
|
|
||
| ::-webkit-scrollbar-button:start:decrement, | ||
| ::-webkit-scrollbar-button:end:increment { | ||
| display: block; | ||
| height: 10px; | ||
| } | ||
|
|
||
| ::-webkit-scrollbar-button:vertical:increment { | ||
| background-color: var(--neutral-400); | ||
| } | ||
|
|
||
| ::-webkit-scrollbar-track-piece { | ||
| background-color: var(--neutral-400); | ||
| -webkit-border-radius: 3px; | ||
| } | ||
|
|
||
| ::-webkit-scrollbar-thumb:vertical { | ||
| height: 50px; | ||
| background-color: var(--neutral-400); | ||
| -webkit-border-radius: 3px; | ||
| } | ||
|
|
||
| ::-webkit-scrollbar-thumb:horizontal { | ||
| width: 50px; | ||
| background-color: var(--neutral-400); | ||
| -webkit-border-radius: 3px; | ||
| } | ||
| } | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,32 @@ | ||
| import * as marked from "marked"; | ||
|
|
||
| import { Marked } from "marked"; | ||
| import { markedHighlight } from "marked-highlight"; | ||
| import Prism from "prismjs"; | ||
| import "prismjs/components/prism-bash.min.js"; | ||
| import "prismjs/components/prism-javascript.min.js"; | ||
| import "prismjs/components/prism-typescript.min.js"; | ||
| import "prismjs/components/prism-css.min.js"; | ||
| import "prismjs/components/prism-json.min.js"; | ||
| import "prismjs/components/prism-jsx.min.js"; | ||
| import "prismjs/components/prism-tsx.min.js"; | ||
| import "prismjs/components/prism-rust.min.js"; | ||
| import { css } from "utils/css.ts"; | ||
| import clsx from "clsx"; | ||
|
|
||
|
|
||
| const marked = new Marked(markedHighlight({ | ||
| emptyLangClass: "language-none", | ||
| langPrefix: "language-", | ||
| highlight(code, lang, _info) { | ||
| const languageAliases: Record<string, string> = { | ||
| rs: "rust", | ||
| console: "sh" | ||
| }; | ||
load1n9 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| lang = languageAliases[lang] ?? lang; | ||
| const language = Prism.languages[lang] ?? Prism.languages.autoit; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Isn't
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isnt our default language the autohotkey language?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nah wait wrong language its this one https://www.autoitscript.com/site/autoit/ |
||
| return Prism.highlight(code, language, lang); | ||
| }, | ||
| })); | ||
|
|
||
| const classes = await css(import.meta.resolve("./Markdown.css")); | ||
|
|
||
| export interface MarkdownProps { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,8 +18,10 @@ | |
| "fresh_charts": "https://deno.land/x/[email protected]/mod.ts", | ||
| "lightningcss": "npm:lightningcss@^1.27.0", | ||
| "marked": "npm:marked@^14.1.2", | ||
| "marked-highlight": "npm:[email protected]", | ||
| "octokit": "npm:[email protected]", | ||
| "preact": "npm:preact@^10.24.0", | ||
| "prismjs": "npm:prismjs@^1.29.0", | ||
eliassjogreen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "preact-render-to-string": "npm:preact-render-to-string@^6.5.11", | ||
| "utils/": "./utils/" | ||
| }, | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
load1n9 marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.