checklists
This commit is contained in:
parent
2a980f9a7e
commit
c4b914bf9e
Binary file not shown.
@ -12,6 +12,7 @@
|
|||||||
import Blockquote from '$lib/marked/renderers/Blockquote.svelte';
|
import Blockquote from '$lib/marked/renderers/Blockquote.svelte';
|
||||||
import MathInline from '$lib/marked/renderers/MathInline.svelte';
|
import MathInline from '$lib/marked/renderers/MathInline.svelte';
|
||||||
import MathBlock from '$lib/marked/renderers/MathBlock.svelte';
|
import MathBlock from '$lib/marked/renderers/MathBlock.svelte';
|
||||||
|
import ListItem from '$lib/marked/renderers/ListItem.svelte';
|
||||||
|
|
||||||
export let plaintext: string;
|
export let plaintext: string;
|
||||||
|
|
||||||
@ -31,6 +32,7 @@ prose-blockquote:first:before:content-['']"
|
|||||||
renderers={{
|
renderers={{
|
||||||
heading: Heading,
|
heading: Heading,
|
||||||
list: List,
|
list: List,
|
||||||
|
listitem: ListItem,
|
||||||
link: Link,
|
link: Link,
|
||||||
'internal-link': InternalLink,
|
'internal-link': InternalLink,
|
||||||
'internal-embed': InternalEmbed,
|
'internal-embed': InternalEmbed,
|
||||||
|
@ -85,7 +85,6 @@ const MathInline = {
|
|||||||
tokenizer(src: string) {
|
tokenizer(src: string) {
|
||||||
const match = src.match(/^(\${1})((?:\\.|[^$])+)\1/);
|
const match = src.match(/^(\${1})((?:\\.|[^$])+)\1/);
|
||||||
if (match) {
|
if (match) {
|
||||||
console.log(src, match);
|
|
||||||
return {
|
return {
|
||||||
type: 'math-inline',
|
type: 'math-inline',
|
||||||
raw: match[0],
|
raw: match[0],
|
||||||
@ -106,7 +105,6 @@ const MathBlock = {
|
|||||||
tokenizer(src: string) {
|
tokenizer(src: string) {
|
||||||
const match = src.match(/^(\${2})((?:\\.|[^$]|\n)+)\1/);
|
const match = src.match(/^(\${2})((?:\\.|[^$]|\n)+)\1/);
|
||||||
if (match) {
|
if (match) {
|
||||||
console.log(src, match);
|
|
||||||
return {
|
return {
|
||||||
type: 'math-block',
|
type: 'math-block',
|
||||||
raw: match[0],
|
raw: match[0],
|
||||||
@ -117,39 +115,6 @@ const MathBlock = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// const MathInline = {
|
|
||||||
// name: 'math-block',
|
|
||||||
// level: 'inline',
|
|
||||||
// start(src: string) {
|
|
||||||
// return src.indexOf('$');
|
|
||||||
// },
|
|
||||||
|
|
||||||
// tokenizer(src: string) {
|
|
||||||
// // console.log(src);
|
|
||||||
// const match = src.match(/^(\${1,2})((?:\\.|[^$]|\n)+)\1/m);
|
|
||||||
// if (match) {
|
|
||||||
// console.log(src, match);
|
|
||||||
// if (match[1] == '$') {
|
|
||||||
// console.log('inline');
|
|
||||||
// return {
|
|
||||||
// type: 'math-inline',
|
|
||||||
// raw: match[0],
|
|
||||||
// text: match[2].trim()
|
|
||||||
// };
|
|
||||||
// } else if (match[1] == '$$') {
|
|
||||||
// console.log('block');
|
|
||||||
|
|
||||||
// return {
|
|
||||||
// type: 'math-block',
|
|
||||||
// raw: match[0],
|
|
||||||
// text: match[2].trim()
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
InternalLinkExtension,
|
InternalLinkExtension,
|
||||||
InternalEmbedExtension,
|
InternalEmbedExtension,
|
||||||
@ -158,5 +123,3 @@ export default [
|
|||||||
MathBlock,
|
MathBlock,
|
||||||
MathInline
|
MathInline
|
||||||
];
|
];
|
||||||
|
|
||||||
// ^\#([\w\/]+)\W*
|
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let ordered: boolean;
|
export let ordered: boolean;
|
||||||
export let start: number;
|
export let start: number;
|
||||||
|
|
||||||
|
export let items: any;
|
||||||
|
console.log(items);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- Styling is taken care of by Tailwind Typography plugin -->
|
<!-- Styling is taken care of by Tailwind Typography plugin -->
|
||||||
{#if ordered}
|
{#if ordered}
|
||||||
<ol><slot /></ol>
|
<ol {start}><slot /></ol>
|
||||||
{:else}
|
{:else}
|
||||||
<ul><slot /></ul>
|
<ul><slot /></ul>
|
||||||
{/if}
|
{/if}
|
||||||
|
23
webapp/src/lib/marked/renderers/ListItem.svelte
Normal file
23
webapp/src/lib/marked/renderers/ListItem.svelte
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
export let task: boolean;
|
||||||
|
export let checked: boolean;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if task || checked}
|
||||||
|
<li class="list-none translate-x-[-1.625em]">
|
||||||
|
<div class="inline-flex items-center gap-2">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
bind:checked
|
||||||
|
value=""
|
||||||
|
class="w-4 h-4 accent-[#7b6cd9] text-blue-600 bg-gray-100 rounded border-gray-300 focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"
|
||||||
|
/>
|
||||||
|
<!-- <label for="default-checkbox" class="ml-2 text-sm text-gray-900 dark:text-gray-300"
|
||||||
|
><slot /></label
|
||||||
|
> -->
|
||||||
|
<slot />
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{:else}
|
||||||
|
<li><slot /></li>
|
||||||
|
{/if}
|
Loading…
Reference in New Issue
Block a user