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 issue #600 #601

Merged
merged 2 commits into from
Mar 2, 2018
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
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);
});