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';
1414 */
1515export function parser ( source , renderer , markdownIt ) {
1616 let tokens = stringToTokens ( source , markdownIt ) ;
17+ console . log ( tokens ) ;
18+ console . log ( '----' ) ;
1719 tokens = cleanupTokens ( tokens ) ;
1820 tokens = groupTextTokens ( tokens ) ;
1921
Original file line number Diff line number Diff line change 11import getTokenTypeByToken from './getTokenTypeByToken' ;
2- import flattenTokens from './flattenTokens ' ;
2+ import flattenInlineTokens from './flattenInlineTokens ' ;
33
44export function cleanupTokens ( tokens ) {
5- tokens = flattenTokens ( tokens ) ;
5+ tokens = flattenInlineTokens ( tokens ) ;
66 tokens . forEach ( token => {
77 token . type = getTokenTypeByToken ( token ) ;
88
@@ -11,6 +11,8 @@ export function cleanupTokens(tokens) {
1111 }
1212 } ) ;
1313
14+ console . log ( tokens ) ;
15+
1416 /**
1517 * changing a link token to a blocklink to fix issue where link tokens with
1618 * nested non text tokens breaks component
Original file line number Diff line number Diff line change 11export default function flattenTokens ( tokens ) {
22 return tokens . reduce ( ( acc , curr ) => {
3- if ( curr . children && curr . children . length > 0 ) {
3+ if ( curr . type === 'inline' && curr . children && curr . children . length > 0 ) {
44 const children = flattenTokens ( curr . children ) ;
55 while ( children . length ) {
66 acc . push ( children . shift ( ) ) ;
Original file line number Diff line number Diff line change 11
22const copy = `
3-
3+ 
44[](https://google.com)
55[](https://google.com)
66
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ import groupTextTokens from './util/groupTextTokens';
1414 */
1515export function parser ( source , renderer , markdownIt ) {
1616 let tokens = stringToTokens ( source , markdownIt ) ;
17+ console . log ( tokens ) ;
18+ console . log ( '----' ) ;
1719 tokens = cleanupTokens ( tokens ) ;
1820 tokens = groupTextTokens ( tokens ) ;
1921
Original file line number Diff line number Diff line change 11import getTokenTypeByToken from './getTokenTypeByToken' ;
2- import flattenTokens from './flattenTokens ' ;
2+ import flattenInlineTokens from './flattenInlineTokens ' ;
33
44export function cleanupTokens ( tokens ) {
5- tokens = flattenTokens ( tokens ) ;
5+ tokens = flattenInlineTokens ( tokens ) ;
66 tokens . forEach ( token => {
77 token . type = getTokenTypeByToken ( token ) ;
88
@@ -11,6 +11,8 @@ export function cleanupTokens(tokens) {
1111 }
1212 } ) ;
1313
14+ console . log ( tokens ) ;
15+
1416 /**
1517 * changing a link token to a blocklink to fix issue where link tokens with
1618 * nested non text tokens breaks component
Original file line number Diff line number Diff line change 11export default function flattenTokens ( tokens ) {
22 return tokens . reduce ( ( acc , curr ) => {
3- if ( curr . children && curr . children . length > 0 ) {
3+ if ( curr . type === 'inline' && curr . children && curr . children . length > 0 ) {
44 const children = flattenTokens ( curr . children ) ;
55 while ( children . length ) {
66 acc . push ( children . shift ( ) ) ;
You can’t perform that action at this time.
0 commit comments