1 import {MarkdownSerializer, defaultMarkdownSerializer} from "prosemirror-markdown";
2 import {docToHtml} from "./util";
4 const nodes = defaultMarkdownSerializer.nodes;
5 const marks = defaultMarkdownSerializer.marks;
8 nodes.callout = function(state, node) {
9 writeNodeAsHtml(state, node);
14 open: '<span style="text-decoration: underline;">',
19 open: '<span style="text-decoration: line-through;">',
34 function writeNodeAsHtml(state, node) {
35 const html = docToHtml({ content: [node] });
37 state.ensureNewLine();
42 // Update serializers to just write out as HTML if we have an attribute
43 // or element that cannot be represented in commonmark without losing
44 // formatting or content.
45 for (const [nodeType, serializerFunction] of Object.entries(nodes)) {
46 nodes[nodeType] = function(state, node) {
47 if (node.attrs.align) {
48 writeNodeAsHtml(state, node);
50 serializerFunction(state, node);
56 const serializer = new MarkdownSerializer(nodes, marks);
58 export default serializer;