File tree Expand file tree Collapse file tree 7 files changed +15
-7
lines changed
react-native-markdown-renderer/lib Expand file tree Collapse file tree 7 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ import groupTextTokens from './util/groupTextTokens';
14
14
*/
15
15
export function parser ( source , renderer , markdownIt ) {
16
16
let tokens = stringToTokens ( source , markdownIt ) ;
17
+ console . log ( tokens ) ;
18
+ console . log ( '----' ) ;
17
19
tokens = cleanupTokens ( tokens ) ;
18
20
tokens = groupTextTokens ( tokens ) ;
19
21
Original file line number Diff line number Diff line change 1
1
import getTokenTypeByToken from './getTokenTypeByToken' ;
2
- import flattenTokens from './flattenTokens ' ;
2
+ import flattenInlineTokens from './flattenInlineTokens ' ;
3
3
4
4
export function cleanupTokens ( tokens ) {
5
- tokens = flattenTokens ( tokens ) ;
5
+ tokens = flattenInlineTokens ( tokens ) ;
6
6
tokens . forEach ( token => {
7
7
token . type = getTokenTypeByToken ( token ) ;
8
8
@@ -11,6 +11,8 @@ export function cleanupTokens(tokens) {
11
11
}
12
12
} ) ;
13
13
14
+ console . log ( tokens ) ;
15
+
14
16
/**
15
17
* changing a link token to a blocklink to fix issue where link tokens with
16
18
* nested non text tokens breaks component
Original file line number Diff line number Diff line change 1
1
export default function flattenTokens ( tokens ) {
2
2
return tokens . reduce ( ( acc , curr ) => {
3
- if ( curr . children && curr . children . length > 0 ) {
3
+ if ( curr . type === 'inline' && curr . children && curr . children . length > 0 ) {
4
4
const children = flattenTokens ( curr . children ) ;
5
5
while ( children . length ) {
6
6
acc . push ( children . shift ( ) ) ;
Original file line number Diff line number Diff line change 1
1
2
2
const copy = `
3
-
3
+ 
4
4
[](https://google.com)
5
5
[](https://google.com)
6
6
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ import groupTextTokens from './util/groupTextTokens';
14
14
*/
15
15
export function parser ( source , renderer , markdownIt ) {
16
16
let tokens = stringToTokens ( source , markdownIt ) ;
17
+ console . log ( tokens ) ;
18
+ console . log ( '----' ) ;
17
19
tokens = cleanupTokens ( tokens ) ;
18
20
tokens = groupTextTokens ( tokens ) ;
19
21
Original file line number Diff line number Diff line change 1
1
import getTokenTypeByToken from './getTokenTypeByToken' ;
2
- import flattenTokens from './flattenTokens ' ;
2
+ import flattenInlineTokens from './flattenInlineTokens ' ;
3
3
4
4
export function cleanupTokens ( tokens ) {
5
- tokens = flattenTokens ( tokens ) ;
5
+ tokens = flattenInlineTokens ( tokens ) ;
6
6
tokens . forEach ( token => {
7
7
token . type = getTokenTypeByToken ( token ) ;
8
8
@@ -11,6 +11,8 @@ export function cleanupTokens(tokens) {
11
11
}
12
12
} ) ;
13
13
14
+ console . log ( tokens ) ;
15
+
14
16
/**
15
17
* changing a link token to a blocklink to fix issue where link tokens with
16
18
* nested non text tokens breaks component
Original file line number Diff line number Diff line change 1
1
export default function flattenTokens ( tokens ) {
2
2
return tokens . reduce ( ( acc , curr ) => {
3
- if ( curr . children && curr . children . length > 0 ) {
3
+ if ( curr . type === 'inline' && curr . children && curr . children . length > 0 ) {
4
4
const children = flattenTokens ( curr . children ) ;
5
5
while ( children . length ) {
6
6
acc . push ( children . shift ( ) ) ;
You can’t perform that action at this time.
0 commit comments