Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix em/strong #685

Merged
merged 2 commits into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/idyll-ast/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ function childrenToMarkup(node, depth, separator = '\n') {
}

function nodeToMarkup(node, depth) {
const markupNodes = ['em', 'i', 'b'];
const markupNodes = ['strong', 'em', 'i', 'b'];
switch (node.type) {
case 'textnode':
return `${' '.repeat(depth)}${node.value.trim()}`;
Expand All @@ -969,9 +969,10 @@ function nodeToMarkup(node, depth) {
return `\n${childrenToMarkup(node, depth)}\n`;
} else if (markupNodes.includes(node.name.toLowerCase())) {
switch (node.name.toLowerCase()) {
case 'em':
case 'strong':
case 'b':
return `**${childrenToMarkup(node, 0, ' ').trim()}**`;
case 'em':
case 'i':
return `*${childrenToMarkup(node, 0, ' ').trim()}*`;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/idyll-ast/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ This is the first paragraph

expect(markup).to.eql(
`
One two **three**
One two *three*
`.trim()
);
});
Expand Down