File tree Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,18 @@ export const italic: Callback<any> = () => {
25
25
return { open, close }
26
26
}
27
27
28
+ export const link : Callback < any > = ( ) => {
29
+ const open = ( tag : string ) => {
30
+ return `<a href="${ tag } " target="_blank" class="underline text-xs">`
31
+ }
32
+
33
+ const close = ( ) => {
34
+ return ' </a>'
35
+ }
36
+
37
+ return { open, close }
38
+ }
39
+
28
40
export const useRaw : Callback < any > = ( ) => {
29
41
const convert = ( page : ContextStatePageContent ) => {
30
42
let final = ''
@@ -35,8 +47,21 @@ export const useRaw: Callback<any> = () => {
35
47
36
48
if ( page . type !== 'paragraph' ) return page . raw
37
49
38
- for ( let i = 0 ; i < page . raw . length ; i ++ ) {
39
- const letter = page . raw . charAt ( i )
50
+ const over : Array < string > = [ ]
51
+
52
+ let _raw = page . raw
53
+
54
+ page . raw . split ( / [ , ] + / ) . forEach ( ( word : string ) => {
55
+ console . log ( word )
56
+ if ( word . includes ( 'http' ) ) over . push ( word )
57
+ } )
58
+
59
+ over . forEach ( ( word : string ) => {
60
+ _raw = _raw . replace ( word , `${ link ( ) . open ( word ) } ${ word } ${ link ( ) . close ( ) } ` )
61
+ } )
62
+
63
+ for ( let i = 0 ; i < _raw . length ; i ++ ) {
64
+ const letter = _raw . charAt ( i )
40
65
41
66
if ( letter === '*' && ! _italic ) {
42
67
_italic = true
You can’t perform that action at this time.
0 commit comments