-
Notifications
You must be signed in to change notification settings - Fork 37
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
fix: yaml is correctly highlighted #96
Changes from all commits
b9fc9f3
7e9991e
9bd88fd
f885fe9
4e7b9b7
f02caed
b25fa7a
8023a9d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import katex from "katex"; | |
|
||
import { CSS, KATEX_CLASSES, KATEX_CSS } from "./style.ts"; | ||
export { CSS, KATEX_CSS, Marked }; | ||
import "https://esm.sh/[email protected]/components/prism-yaml"; | ||
|
||
Marked.marked.use(markedAlert()); | ||
Marked.marked.use(gfmHeadingId()); | ||
|
@@ -254,6 +255,8 @@ export function render(markdown: string, opts: RenderOptions = {}): string { | |
"line", | ||
"deleted", | ||
"inserted", | ||
"key", | ||
"atrule", | ||
...(opts.allowMath ? KATEX_CLASSES : []), | ||
], | ||
a: ["anchor"], | ||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,14 @@ | |
color: var(--color-prettylights-syntax-constant); | ||
} | ||
|
||
&.atrule { | ||
color: var(--color-prettylights-syntax-keyword); | ||
} | ||
|
||
&.punctuation { | ||
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. You added 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. I think the css produced purely by prism is also lacking css for this, although I could be wrong. Is it the styling looking incorrect? |
||
color: var(--color-prettylights-syntax-entity); | ||
} | ||
|
||
&.function { | ||
color: var(--color-prettylights-syntax-entity); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<div class="highlight highlight-source-yaml notranslate"><pre><span class="token key atrule">doe</span><span class="token punctuation">:</span> <span class="token string">"a deer, a female deer"</span> | ||
<span class="token key atrule">ray</span><span class="token punctuation">:</span> <span class="token string">"a drop of golden sun"</span> | ||
<span class="token key atrule">pi</span><span class="token punctuation">:</span> <span class="token number">3.14159</span> | ||
<span class="token key atrule">xmas</span><span class="token punctuation">:</span> <span class="token boolean">true</span> | ||
<span class="token key atrule">french-hens</span><span class="token punctuation">:</span> <span class="token number">3</span> | ||
<span class="token key atrule">calling-birds</span><span class="token punctuation">:</span> | ||
<span class="token punctuation">-</span> huey | ||
<span class="token punctuation">-</span> dewey | ||
<span class="token punctuation">-</span> louie | ||
<span class="token punctuation">-</span> fred | ||
<span class="token key atrule">xmas-fifth-day</span><span class="token punctuation">:</span> | ||
<span class="token key atrule">calling-birds</span><span class="token punctuation">:</span> four | ||
<span class="token key atrule">french-hens</span><span class="token punctuation">:</span> <span class="token number">3</span> | ||
<span class="token key atrule">golden-rings</span><span class="token punctuation">:</span> <span class="token number">5</span> | ||
<span class="token key atrule">partridges</span><span class="token punctuation">:</span> | ||
<span class="token key atrule">count</span><span class="token punctuation">:</span> <span class="token number">1</span> | ||
<span class="token key atrule">location</span><span class="token punctuation">:</span> <span class="token string">"a pear tree"</span> | ||
<span class="token key atrule">turtle-doves</span><span class="token punctuation">:</span> two</pre></div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
```yaml | ||
doe: "a deer, a female deer" | ||
ray: "a drop of golden sun" | ||
pi: 3.14159 | ||
xmas: true | ||
french-hens: 3 | ||
calling-birds: | ||
- huey | ||
- dewey | ||
- louie | ||
- fred | ||
xmas-fifth-day: | ||
calling-birds: four | ||
french-hens: 3 | ||
golden-rings: 5 | ||
partridges: | ||
count: 1 | ||
location: "a pear tree" | ||
turtle-doves: two | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is pulling in yaml for everyone necessary? It seems like the actual fix is the additional types below. Won't that still work if the user app pulls in YAML (like it has to pull in most languages)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly I think it is. The necessary thing is making sure this returns something:
deno-gfm/mod.ts
Line 53 in b9f7352
The only way I could do that is by importing the package. For whatever reason I couldn't find any way to invoke the loadlanguages function that prism has.