Skip to content

Commit ecc07b7

Browse files
committed
beta 3.2.4 fixed issue where images where only shown as copy.
1 parent 77b75c3 commit ecc07b7

File tree

7 files changed

+15
-7
lines changed

7 files changed

+15
-7
lines changed

example/react-native-markdown-renderer/lib/parser.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import groupTextTokens from './util/groupTextTokens';
1414
*/
1515
export 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

example/react-native-markdown-renderer/lib/util/cleanupTokens.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import getTokenTypeByToken from './getTokenTypeByToken';
2-
import flattenTokens from './flattenTokens';
2+
import flattenInlineTokens from './flattenInlineTokens';
33

44
export 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

example/react-native-markdown-renderer/lib/util/flattenTokens.js renamed to example/react-native-markdown-renderer/lib/util/flattenInlineTokens.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export 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());

example/src/copy/linkedimg.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
const copy = `
3-
3+
![Minion](https://octodex.github.com/images/minion.png)
44
[![Minion](https://octodex.github.com/images/minion.png)](https://google.com)
55
[![Stormtroopocat](https://octodex.github.com/images/stormtroopocat.png)](https://google.com)
66

src/lib/parser.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import groupTextTokens from './util/groupTextTokens';
1414
*/
1515
export 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

src/lib/util/cleanupTokens.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import getTokenTypeByToken from './getTokenTypeByToken';
2-
import flattenTokens from './flattenTokens';
2+
import flattenInlineTokens from './flattenInlineTokens';
33

44
export 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

src/lib/util/flattenTokens.js renamed to src/lib/util/flattenInlineTokens.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export 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());

0 commit comments

Comments
 (0)