Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFerdinand Thiessen <rpm@fthiessen.de>2022-10-28 14:02:03 +0300
committerFerdinand Thiessen <rpm@fthiessen.de>2022-10-28 14:18:01 +0300
commit39037a7f6ae99d3ce321da5869786e52803dff9a (patch)
tree7157463959ea519e75700c11b2e21bce6290c231
parent4cb7bf37ed4ebf24f1d57945abffdbeeae9d452d (diff)
Test also markdown serializationfeat/test-commonmark
As two different markdown strings can be semantically the same, we can test if the resulting rendered HTML are syntactically equal. Currently about hundred test cases fail because of a known limitation of `prosemirror-markdown` not able to serialize nested marks correctly, see https://github.com/ProseMirror/prosemirror-markdown/issues/82 Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
-rw-r--r--src/tests/markdown.spec.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/tests/markdown.spec.js b/src/tests/markdown.spec.js
index ec8a30e55..0ce0dfbd0 100644
--- a/src/tests/markdown.spec.js
+++ b/src/tests/markdown.spec.js
@@ -25,9 +25,11 @@ const markdownThroughEditorHtml = (html) => {
describe('Commonmark', () => {
const skippedMarkdownTests = [
// contain HTML
- 21, 31, 201, 344, 474, 475, 476, 490, 493, 523, 535, 642, 643,
+ 21, 31, 344, 474, 475, 476, 642, 643,
// contain comments
309, 308,
+ // < > are escaped, because HTML is disabled for markdown-it
+ 201, 490, 493, 523, 535
];
const normalize = (str) => {
@@ -52,6 +54,18 @@ describe('Commonmark', () => {
// Ignore special markup for untouched markdown
expect(normalize(rendered)).toBe(expected)
})
+
+ test('commonmark serialization ' + entry.example, () => {
+ const expected = markdownit.render(entry.markdown)
+ const serialized = markdownThroughEditorHtml(expected)
+
+ try {
+ expect(markdownit.render(serialized)).toBe(expected)
+ } catch(e) {
+ // This is just for debugging, so jest shows also the difference within the two markdown source codes
+ expect(markdownit.render(serialized) + '\n\n' + serialized).toBe(expected + '\n\n' + entry.markdown)
+ }
+ })
})
})