Skip to content

Commit

Permalink
Fix bug #600 (#601)
Browse files Browse the repository at this point in the history
  • Loading branch information
YoranBrondsema authored and bantic committed Mar 2, 2018
1 parent 7da84f8 commit f57215f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/js/parsers/section.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ const SKIPPABLE_ELEMENT_TAG_NAMES = [

const NEWLINES = /\n/g;
function sanitize(text) {
text = text.replace(NEWLINES, '');
return text;
return text.replace(NEWLINES, ' ');
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/js/utils/selection-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function findOffsetInTextNode(node, coords) {
* @see https://github.com/ProseMirror/prosemirror/blob/4c22e3fe97d87a355a0534e25d65aaf0c0d83e57/src/edit/dompos.js
* @return {Object} {node, offset}
*/
/* eslint-disable complexity */
function findOffsetInNode(node, coords) {
let closest, dyClosest = 1e8, coordsClosest, offset = 0;
for (let child = node.firstChild; child; child = child.nextSibling) {
Expand Down Expand Up @@ -79,6 +80,7 @@ function findOffsetInNode(node, coords) {
}
return {node, offset};
}
/* eslint-enable complexity */

function constrainNodeTo(node, parentNode, existingOffset) {
let compare = parentNode.compareDocumentPosition(node);
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/parsers/dom-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ let expectations = [
['<ul><li>first element</li><li><ul><li>nested element</li></ul></li></ul>', ['* first element', '* nested element']],

// See https://github.com/bustle/mobiledoc-kit/issues/333
['abc\ndef', ['abcdef']]
['abc\ndef', ['abc def']]
];

expectations.forEach(([html, dslText]) => {
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/parsers/html-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ test('style tags are ignored', (assert) => {
});

// See https://github.com/bustle/mobiledoc-kit/issues/333
test('newlines ("\\n") are ignored', (assert) => {
test('newlines ("\\n") are replaced with space characters', (assert) => {
let html = "abc\ndef";
let post = parseHTML(html);
let {post: expected} = Helpers.postAbstract.buildFromText(['abcdef']);
let {post: expected} = Helpers.postAbstract.buildFromText(['abc def']);

assert.postIsSimilar(post, expected);
});

0 comments on commit f57215f

Please sign in to comment.