Skip to content

Commit

Permalink
feat(index.js): adds support for html tables and table cells to new line
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeaus committed Jul 24, 2018
1 parent 3fc77ca commit 252254d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ const TAGS_TO_BREAK_ON = [
"h6",
"ol",
"ul",
"li"
"li",
"table",
"td"
];

module.exports = (text = "") =>
Expand Down
12 changes: 12 additions & 0 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,16 @@ describe("lib", () => {
const result = lib("some  text");
expect(result).to.equal("some text");
});

it("should replace tables with new lines", () => {
const result = lib("some<table>text</table>");
expect(result).to.equal("some\ntext");
});

it("should replace table cells with new lines", () => {
const result = lib(
"some<table><tbody><tr><td>text1</td><td>text2</td></tr></tbody></table>"
);
expect(result).to.equal("some\ntext1\ntext2");
});
});

0 comments on commit 252254d

Please sign in to comment.