-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61399e3
commit c328dc9
Showing
12 changed files
with
869 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import setup, { iMarkdown } from './setup.ts'; | ||
|
||
export default function (props: Partial<iMarkdown>) { | ||
const { c, fref, markdown_content, renderOptions, ...p } = setup(props); | ||
|
||
return ( | ||
<div | ||
class={c.markdown} | ||
ref={fref} | ||
dangerouslySetInnerHTML={{ __html: markdown_content }} | ||
{...p} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { applyDefaults, cn, opt, partializeClasses } from '../../src/utils.ts'; | ||
import { iComponent } from '../../src/types.ts'; | ||
import { RenderOptions } from '@/src/markdown.ts'; | ||
import { render } from '@/src/markdown.ts'; | ||
|
||
export type iMarkdown = iComponent<HTMLDivElement> & { | ||
markdown_content: string; | ||
renderOptions: RenderOptions; | ||
}; | ||
|
||
const defaults: iMarkdown = { | ||
markdown_content: '', | ||
renderOptions: { | ||
allowIframes: true, | ||
allowMath: true, | ||
customClasses: { | ||
paragraph: ['comp-text', 'txt-paragraph'], | ||
heading: ['comp-text'], | ||
code: ['comp-code_wrapper'], | ||
codespan: ['comp-code', 'comp-code_wrapper', 'clr-bg-panel'], | ||
link: ['comp-link'], | ||
hr: ['comp-separator'], | ||
}, | ||
}, | ||
}; | ||
|
||
export default (props: Partial<iMarkdown>) => { | ||
const p = applyDefaults<iMarkdown>(defaults, props); | ||
|
||
const classes = partializeClasses({ | ||
markdown: opt(cn('comp-markdown'), p.class, p.nostyle), | ||
}); | ||
|
||
p.markdown_content = render(p.markdown_content, p.renderOptions); | ||
|
||
delete p.class; | ||
return { c: classes, ...p }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"imports": { | ||
"@/": "./", | ||
"$fresh/": "https://deno.land/x/[email protected]/", | ||
"preact": "https://esm.sh/[email protected]", | ||
"preact/": "https://esm.sh/[email protected]/", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
import { render } from '../../deno-gfm/mod.ts'; | ||
|
||
const CONTENT_PATH = new URL('../static/content.md', import.meta.url); | ||
const TEST_PATH = new URL('../static/test.txt', import.meta.url); | ||
import { Main, Markdown } from '@/mod.ts'; | ||
import 'https://esm.sh/[email protected]'; | ||
import 'https://esm.sh/[email protected]/components/prism-jsx?no-check&pin=v57'; | ||
import 'https://esm.sh/[email protected]/components/prism-typescript?no-check&pin=v57'; | ||
import 'https://esm.sh/[email protected]/components/prism-tsx?no-check&pin=v57'; | ||
import 'https://esm.sh/[email protected]/components/prism-bash?no-check&pin=v57'; | ||
import 'https://esm.sh/[email protected]/components/prism-powershell?no-check&pin=v57'; | ||
import 'https://esm.sh/[email protected]/components/prism-json?no-check&pin=v57'; | ||
import 'https://esm.sh/[email protected]/components/prism-diff?no-check&pin=v57'; | ||
|
||
export default async function Md() { | ||
const markdown = await (await fetch(CONTENT_PATH)).text(); | ||
const test = await (await fetch(TEST_PATH)).text(); | ||
|
||
const body = render(markdown, { | ||
allowIframes: true, | ||
allowMath: true, | ||
customClasses: { | ||
// list: ['asdf'], | ||
}, | ||
}); | ||
|
||
console.log(test === body ? 'good' : 'bad'); | ||
const markdown = | ||
await (await fetch(new URL('../static/content.md', import.meta.url))) | ||
.text(); | ||
|
||
// return <div dangerouslySetInnerHTML={{ __html: body }}></div>; | ||
return <div>{body}</div>; | ||
return ( | ||
<div> | ||
<Main layout_type='center'> | ||
<Markdown markdown_content={markdown} /> | ||
</Main> | ||
</div> | ||
); | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.