Skip to content
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
4 changes: 2 additions & 2 deletions js/editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/editor.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-files.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-files.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-public.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-text.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-text.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-viewer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-viewer.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/markdownit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ const markdownit = MarkdownIt('commonmark', { html: false, breaks: false })
.use(keepSyntax)
.use(markdownitMentions)

// Issue #3370: To preserve softbreaks within md files we preserve all whitespaces, so we must not introduce additional new lines after a <br> element
markdownit.renderer.rules.hardbreak = (tokens, idx, options) => (options.xhtmlOut ? '<br />' : '<br>')

export default markdownit
1 change: 1 addition & 0 deletions src/tests/markdown.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('Commonmark', () => {
// https://github.com/markdown-it/markdown-it/blob/df4607f1d4d4be7fdc32e71c04109aea8cc373fa/test/commonmark.js#L10
return str.replace(/<blockquote><\/blockquote>/g, '<blockquote>\n</blockquote>')
.replace(/<span class="keep-md">([^<]+)<\/span>/g, '$1')
.replace(/<br \/>/, '<br />\n')
}

spec.forEach((entry) => {
Expand Down
16 changes: 8 additions & 8 deletions src/tests/tables.spec.js → src/tests/nodes/Table.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { createEditor } from './../EditorFactory'
import { createMarkdownSerializer } from './../extensions/Markdown'
import markdownit from './../markdownit'
import input from './fixtures/table.md'
import output from './fixtures/tables/basic.out.html'
import otherStructure from './fixtures/tableWithOtherStructure.html'
import handbook from './fixtures/tables/handbook.html'
import handbookOut from './fixtures/tables/handbook.out.html'
import { createEditor } from '../../EditorFactory'
import { createMarkdownSerializer } from '../../extensions/Markdown'
import markdownit from '../../markdownit'
import input from '../fixtures/table.md'
import output from '../fixtures/tables/basic.out.html'
import otherStructure from '../fixtures/tableWithOtherStructure.html'
import handbook from '../fixtures/tables/handbook.html'
import handbookOut from '../fixtures/tables/handbook.out.html'

describe('Table', () => {

Expand Down
23 changes: 23 additions & 0 deletions src/tests/tiptap.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import createEditor from '../EditorFactory'
import markdownit from '../markdownit'

const renderedHTML = ( markdown ) => {
const editor = createEditor({
content: markdownit.render(markdown),
enableRichEditing: true
})
// Remove TrailingNode
return editor.getHTML().replace(/<p><\/p>$/, '')
}

describe('TipTap', () => {
it('render softbreaks', () => {
const markdown = 'This\nis\none\nparagraph'
expect(renderedHTML(markdown)).toEqual(`<p>${markdown}</p>`)
})

it('render hardbreak', () => {
const markdown = 'Hard line break \nNext Paragraph'
expect(renderedHTML(markdown)).toEqual('<p>Hard line break<br>Next Paragraph</p>')
})
})