How to use the prosemirror-markdown.MarkdownParser function in prosemirror-markdown

To help you get started, we’ve selected a few prosemirror-markdown examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ifiokjr / remirror / @remirror / editor-markdown / src / from-markdown.ts View on Github external
export const fromMarkdown = (markdown: string, schema: EditorSchema) =>
  new MarkdownParser(schema, md('commonmark'), {
    blockquote: { block: 'blockquote' },
    paragraph: { block: 'paragraph' },
    list_item: { block: 'listItem' },
    bullet_list: { block: 'bulletList' },
    ordered_list: {
      block: 'orderedList',
      getAttrs: tok => ({ order: parseInt(tok.attrGet('order') ?? '1', 10) }),
    },
    heading: { block: 'heading', getAttrs: tok => ({ level: +tok.tag.slice(1) }) },
    code_block: { block: 'codeBlock' },
    fence: { block: 'codeBlock', getAttrs: tok => ({ language: tok.info }) },
    hr: { node: 'horizontalRule' },
    image: {
      node: 'image',
      getAttrs: tok => ({
        src: tok.attrGet('src'),
github pubpub / pubpub-editor / packages / pubpub-editor / src / markdown / markdownParser.js View on Github external
import { CitationEngine } from '../references';
import { MarkdownParser } from 'prosemirror-markdown';
import { Schema } from 'prosemirror-model';
import markdownit from './markdownitInstance';
import { schema as pubSchema } from '../prosemirror-setup/schema';

const markdownSchema = pubSchema;

export const markdownParser = new MarkdownParser(markdownSchema,
	markdownit,
	{
		article: {block: 'article'},

		blockquote: {block: 'blockquote'},
		paragraph: {block: 'paragraph'},
		list_item: {block: 'list_item'},
		bullet_list: {block: 'bullet_list'},
		ordered_list: {block: 'ordered_list', attrs: tok => ({order: +tok.attrGet('order') || 1})},
		heading: {block: 'heading', attrs: tok => ({level: +tok.tag.slice(1)})},
		code_block: {block: 'code_block'},
		fence: {block: 'code_block'},
		html_inline: {node: 'code_block'},
		html_block: {node: 'html_block', attrs: tok => {
			return {content: tok.content};
		}},
github pubpub / pubpub-editor / packages / pubpub-editor / dist / markdown / markdownParser.js View on Github external
var _prosemirrorMarkdown = require('prosemirror-markdown');

var _prosemirrorModel = require('prosemirror-model');

var _markdownitInstance = require('./markdownitInstance');

var _markdownitInstance2 = _interopRequireDefault(_markdownitInstance);

var _schema = require('../prosemirror-setup/schema');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var markdownSchema = _schema.schema;

var markdownParser = exports.markdownParser = new _prosemirrorMarkdown.MarkdownParser(markdownSchema, _markdownitInstance2.default, {
	article: { block: 'article' },

	blockquote: { block: 'blockquote' },
	paragraph: { block: 'paragraph' },
	list_item: { block: 'list_item' },
	bullet_list: { block: 'bullet_list' },
	ordered_list: { block: 'ordered_list', attrs: function attrs(tok) {
			return { order: +tok.attrGet('order') || 1 };
		} },
	heading: { block: 'heading', attrs: function attrs(tok) {
			return { level: +tok.tag.slice(1) };
		} },
	code_block: { block: 'code_block' },
	fence: { block: 'code_block' },
	html_inline: { node: 'code_block' },
	html_block: { node: 'html_block', attrs: function attrs(tok) {
github quartzy / prosemirror-suggestions / src / mentions.js View on Github external
export function addMentionsToMarkdownParser(parser) {
  return new MarkdownParser(parser.schema, parser.tokenizer, {
    ...parser.tokens,
    mention: markdownParser(),
  });
}