File tree 6 files changed +52
-30
lines changed
src/components/ui/markdown
6 files changed +52
-30
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,6 @@ import { Gallery } from '../gallery'
16
16
import { FixedZoomedImage } from '../image'
17
17
import { LinkCard } from '../link-card'
18
18
import styles from './markdown.module.css'
19
- import { CommentAtRule } from './parsers/comment-at'
20
19
import { ContainerRule } from './parsers/container'
21
20
import { InsertRule } from './parsers/ins'
22
21
import { KateXRule } from './parsers/katex'
@@ -210,7 +209,7 @@ export const Markdown: FC<MdProps & MarkdownToJSX.Options & PropsWithChildren> =
210
209
additionalParserRules : {
211
210
spoilder : SpoilderRule ,
212
211
mention : MentionRule ,
213
- commentAt : CommentAtRule ,
212
+
214
213
mark : MarkRule ,
215
214
ins : InsertRule ,
216
215
kateX : KateXRule ,
Original file line number Diff line number Diff line change
1
+ ## Token
2
+
3
+ This is a ||Spoiler||
4
+
5
+ A ` code ` .
6
+
7
+ ==mark== it.
8
+
9
+ ++Something Insert++
10
+
11
+ ## Latex
12
+
13
+ $ c = \pm\sqrt{a^2 + b^2} $
14
+
15
+ ## Container
16
+
17
+ ::: warning
18
+ _ here be dragons_
19
+ :::
20
+
21
+ ::: banner {error}
22
+ _ here be dragons_
23
+ :::
24
+
25
+
26
+ ::: gallery
27
+ https://loremflickr.com/640/480/city?1
28
+ https://loremflickr.com/640/480/city?2
29
+ https://loremflickr.com/640/480/city?3
30
+ ![ ] ( https://loremflickr.com/640/480/city?4 " Image ")
31
+ :::
32
+
1
33
## Rich Link
2
34
3
35
```
Original file line number Diff line number Diff line change 92
92
@apply cursor-not-allowed;
93
93
}
94
94
95
- code {
95
+ : not ( pre ) code {
96
96
@apply bg-zinc-200 font-mono dark:bg-neutral-800;
97
97
}
98
98
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
- import type { MarkdownToJSX } from 'markdown-to-jsx '
1
+ import React from 'react '
2
2
import {
3
- Priority ,
4
3
parseCaptureInline ,
4
+ Priority ,
5
5
simpleInlineRegex ,
6
6
} from 'markdown-to-jsx'
7
- import React from 'react '
7
+ import type { MarkdownToJSX } from 'markdown-to-jsx '
8
8
9
9
// ==Mark==
10
10
export const MarkRule : MarkdownToJSX . Rule = {
@@ -15,7 +15,7 @@ export const MarkRule: MarkdownToJSX.Rule = {
15
15
return (
16
16
< mark
17
17
key = { state ?. key }
18
- className = "! bg-always-yellow-200 !rounded-lg ! bg-opacity-80 !bg-none ! text-black"
18
+ className = "rounded-md bg-always-yellow-400 bg-opacity-80 px-1 text-black"
19
19
>
20
20
{ output ( node . content , state ! ) }
21
21
</ mark >
Original file line number Diff line number Diff line change @@ -12,6 +12,11 @@ export const pickImagesFromMarkdown = (md: string) => {
12
12
const res : MImageType [ ] = [ ]
13
13
14
14
for ( const line of lines ) {
15
+ if ( ! line . startsWith ( '!' ) && isRawImageUrl ( line ) ) {
16
+ res . push ( { url : line , name : line } )
17
+ continue
18
+ }
19
+
15
20
const match = regexp . exec ( line )
16
21
if ( ! match ) {
17
22
continue
@@ -23,3 +28,12 @@ export const pickImagesFromMarkdown = (md: string) => {
23
28
24
29
return res
25
30
}
31
+
32
+ const isRawImageUrl = ( url : string ) => {
33
+ try {
34
+ new URL ( url )
35
+ } catch ( e ) {
36
+ return false
37
+ }
38
+ return true
39
+ }
You can’t perform that action at this time.
0 commit comments