Skip to content

Commit 43be743

Browse files
committed
fixed issue with link not rendering completly inline #19
1 parent 445795c commit 43be743

File tree

6 files changed

+16
-23
lines changed

6 files changed

+16
-23
lines changed

src/lib/parser.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { View } from "react-native";
33
import tokensToAST from "./util/tokensToAST";
44
import { stringToTokens } from "./util/stringToTokens";
55
import { cleanupTokens } from "./util/cleanupTokens";
6+
import groupTextTokens from "./util/groupTextTokens";
67

78
/**
89
*
@@ -13,6 +14,6 @@ import { cleanupTokens } from "./util/cleanupTokens";
1314
*/
1415
export function parser(source, renderer, markdownIt) {
1516
return renderer(
16-
tokensToAST(cleanupTokens(stringToTokens(source, markdownIt)))
17+
tokensToAST(groupTextTokens(cleanupTokens(stringToTokens(source, markdownIt))))
1718
);
1819
}

src/lib/renderRules.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ import React, { Component, PropTypes } from "react";
22
import { Text, View } from "react-native";
33

44
import FitImage from "react-native-fit-image";
5-
import getUniqueID from "./util/getUniqueID";
65
import openUrl from "./util/openUrl";
76
import hasParents from "./util/hasParents";
87
import applyStyle from "./util/applyStyle";
9-
import ImageComponent from "./ImageComponent";
108

119
const renderRules = {
1210
// when unknown elements are introduced, so it wont break
@@ -53,10 +51,11 @@ const renderRules = {
5351
},
5452
// a
5553
link: (node, children, parent, styles) => {
54+
console.log(node);
5655
return (
5756
<Text
5857
key={node.key}
59-
style={styles.a}
58+
style={styles.link}
6059
onPress={() => openUrl(node.attributes.href)}
6160
>
6261
{children}
@@ -80,12 +79,7 @@ const renderRules = {
8079
},
8180

8281
heading2: (node, children, parent, styles) => {
83-
8482
children = applyStyle(children, [styles.heading, styles.heading2], "Text");
85-
86-
console.log(children);
87-
88-
8983
return (
9084
<View key={node.key} style={styles.headingContainer}>
9185
{children}
@@ -235,10 +229,11 @@ const renderRules = {
235229
),
236230
image: (node, children, parent, styles) => {
237231
return (
238-
<ImageComponent
232+
<FitImage
233+
indicator={true}
239234
key={node.key}
240235
style={styles.image}
241-
uri={node.attributes.src}
236+
source={{ uri: node.attributes.src }}
242237
/>
243238
);
244239
}

src/lib/styles.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,16 @@ export const styles = StyleSheet.create({
133133
strikethrough: {
134134
textDecorationLine: "line-through"
135135
},
136-
a: {
137-
textDecorationLine: "underline"
136+
link: {
137+
textDecorationLine: "underline",
138+
color: 'red'
138139
},
139140
u: {
140141
borderColor: "#000000",
141142
borderBottomWidth: 1
143+
},
144+
image: {
145+
flex: 1,
146+
142147
}
143148
});

src/lib/util/cleanupTokens.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ import removeInlineTokens from "./removeInlineTokens";
55
export function cleanupTokens(tokens) {
66
tokens = removeInlineTokens(tokens);
77
tokens.forEach(token => (token.type = getTokenTypeByToken(token)));
8-
tokens = groupTextTokens(tokens);
98
return tokens;
109
}

src/lib/util/getIsInlineTextType.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const textTypes = [
66
'text',
77
'span',
88
'strong',
9-
'a',
9+
'link',
1010
's',
1111
'em',
1212
'br',

src/lib/util/getIsTextType.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,12 @@ const textTypes = [
66
'text',
77
'span',
88
'strong',
9-
'a',
9+
'link',
1010
's',
1111
'em',
1212
'softbreak',
1313
];
1414

15-
// 'heading1',
16-
// 'heading2',
17-
// 'heading3',
18-
// 'heading4',
19-
// 'heading5',
20-
// 'heading6',
21-
2215
/**
2316
*
2417
* @param node

0 commit comments

Comments
 (0)