Skip to content

Commit cbe0d9b

Browse files
committed
fixed issue with bold copy
#39
1 parent a9abf1c commit cbe0d9b

File tree

13 files changed

+20
-50
lines changed

13 files changed

+20
-50
lines changed

example/App.js

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -128,43 +128,9 @@ const initialLayout = {
128128
export default class App extends Component {
129129
state = {
130130
index: 0,
131-
routes: [{ key: 'all', title: 'All Markdown' }, { key: 'linkedimg', title: 'Linked Images' }],
131+
routes: [{ key: 'linkedimg', title: 'Linked Images' }],
132132
};
133133

134-
getView(value) {
135-
switch (value) {
136-
case 0: {
137-
return <Markdown children={copyAll} />;
138-
}
139-
case 1: {
140-
return <Markdown renderer={renderer.render} children={copyAll} />;
141-
}
142-
case 2: {
143-
return <Markdown style={customMarkdownStyle} children={copyAll} />;
144-
}
145-
case 3: {
146-
return <Markdown rules={rules} children={copyAll} />;
147-
}
148-
case 4: {
149-
return <Markdown rules={rules} style={customMarkdownStyle} children={copyAll} />;
150-
}
151-
case 5: {
152-
return (
153-
<Markdown
154-
rules={pluginRules}
155-
plugins={[new PluginContainer(markdownItCheckbox, { divWrap: true })]}
156-
style={customMarkdownStyle}
157-
children={copyAllCheckboxPlugin}
158-
/>
159-
);
160-
}
161-
162-
default: {
163-
return <Markdown># Text</Markdown>;
164-
}
165-
}
166-
}
167-
168134
handleChangeValue = (itemValue, itemIndex) => {
169135
this.setState({ view: itemIndex });
170136
};

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ export function parser(source, renderer, markdownIt) {
1616

1717
let tokens = stringToTokens(source, markdownIt);
1818
tokens = cleanupTokens(tokens);
19-
20-
// console.log(JSON.stringify(tokens));
2119
tokens = groupTextTokens(tokens);
2220

2321
const astTree = tokensToAST(tokens);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@ const renderRules = {
2929
},
3030

3131
text: (node, children, parent, styles) => {
32+
console.log('text', node.content);
33+
console.log('parent', parent);
3234
return <Text key={node.key}>{node.content}</Text>;
3335
},
3436
span: (node, children, parent, styles) => {
3537
return <Text key={node.key}>{children}</Text>;
3638
},
3739

3840
strong: (node, children, parent, styles) => {
41+
console.log('strong', children);
3942
return (
4043
<Text key={node.key} style={styles.strong}>
4144
{children}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export default class Token {
2-
constructor(type, nesting = 0, children = null) {
2+
constructor(type, nesting = 0, children = null, block = false) {
33
this.type = type;
44
this.nesting = nesting;
55
this.children = children;
6-
this.block = false;
6+
this.block = block;
77
}
88
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ export default function groupTextTokens(tokens) {
1212
result.push(new Token('textgroup', 1));
1313
result.push(token);
1414
} else if (!token.block && hasGroup) {
15-
hasGroup = false;
1615
result.push(token);
17-
result.push(new Token('textgroup', -1));
1816
} else if (token.block && hasGroup) {
1917
hasGroup = false;
2018
result.push(new Token('textgroup', -1));

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import getTokenTypeByToken from './getTokenTypeByToken';
33

44
/**
55
*
6-
* @param {{type: string, tag:string, content: string, children: *, attrs: Array, meta, info}} token
6+
* @param {{type: string, tag:string, content: string, children: *, attrs: Array, meta, info, block: boolean}} token
77
* @param {number} tokenIndex
88
* @return {{type: string, content, tokenIndex: *, index: number, attributes: {}, children: *}}
99
*/
@@ -25,6 +25,7 @@ function createNode(token, tokenIndex) {
2525
sourceType: token.type,
2626
sourceInfo: token.info,
2727
sourceMeta: token.meta,
28+
block: token.block,
2829
key: getUniqueID(),
2930
content,
3031
tokenIndex,

example/src/copy/all.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ foo
44
55
# code inline
66
7+
**Foo Bar**
8+
79
Hello \`code inline\` code_inline
810
911
__Advertisement :)__

example/src/copy/linkedimg.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
12
const copy = `
3+
**test**
4+
25
## Linked Images
36
[![Minion](https://octodex.github.com/images/minion.png)](https://google.com)
47
[![Stormtroopocat](https://octodex.github.com/images/stormtroopocat.png)](https://google.com)

src/lib/parser.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ export function parser(source, renderer, markdownIt) {
1616

1717
let tokens = stringToTokens(source, markdownIt);
1818
tokens = cleanupTokens(tokens);
19-
20-
// console.log(JSON.stringify(tokens));
2119
tokens = groupTextTokens(tokens);
2220

2321
const astTree = tokensToAST(tokens);

src/lib/renderRules.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@ const renderRules = {
2929
},
3030

3131
text: (node, children, parent, styles) => {
32+
console.log('text', node.content);
33+
console.log('parent', parent);
3234
return <Text key={node.key}>{node.content}</Text>;
3335
},
3436
span: (node, children, parent, styles) => {
3537
return <Text key={node.key}>{children}</Text>;
3638
},
3739

3840
strong: (node, children, parent, styles) => {
41+
console.log('strong', children);
3942
return (
4043
<Text key={node.key} style={styles.strong}>
4144
{children}

src/lib/util/Token.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
export default class Token {
2-
constructor(type, nesting = 0, children = null) {
2+
constructor(type, nesting = 0, children = null, block = false) {
33
this.type = type;
44
this.nesting = nesting;
55
this.children = children;
6-
this.block = false;
7-
6+
this.block = block;
87
}
98
}

src/lib/util/groupTextTokens.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ export default function groupTextTokens(tokens) {
1212
result.push(new Token('textgroup', 1));
1313
result.push(token);
1414
} else if (!token.block && hasGroup) {
15-
hasGroup = false;
1615
result.push(token);
17-
result.push(new Token('textgroup', -1));
1816
} else if (token.block && hasGroup) {
1917
hasGroup = false;
2018
result.push(new Token('textgroup', -1));

src/lib/util/tokensToAST.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import getTokenTypeByToken from './getTokenTypeByToken';
33

44
/**
55
*
6-
* @param {{type: string, tag:string, content: string, children: *, attrs: Array, meta, info}} token
6+
* @param {{type: string, tag:string, content: string, children: *, attrs: Array, meta, info, block: boolean}} token
77
* @param {number} tokenIndex
88
* @return {{type: string, content, tokenIndex: *, index: number, attributes: {}, children: *}}
99
*/
@@ -25,6 +25,7 @@ function createNode(token, tokenIndex) {
2525
sourceType: token.type,
2626
sourceInfo: token.info,
2727
sourceMeta: token.meta,
28+
block: token.block,
2829
key: getUniqueID(),
2930
content,
3031
tokenIndex,

0 commit comments

Comments
 (0)