switch remark options to use gfm, fences

This commit is contained in:
Shawn Erquhart 2017-06-13 15:30:11 -04:00
parent b293b235bb
commit e7ac3a7671
4 changed files with 6 additions and 4 deletions

View File

@ -31,7 +31,7 @@ function cleanupPaste(paste) {
.use(rehypeSanitize) .use(rehypeSanitize)
.use(rehypeReparse) .use(rehypeReparse)
.use(rehypeToRemark) .use(rehypeToRemark)
.use(remarkToMarkdown, { commonmark: true, footnotes: true, pedantic: true }) .use(remarkToMarkdown, { fences: true, footnotes: true, pedantic: true })
.process(paste); .process(paste);
} }

View File

@ -150,10 +150,12 @@ export default class Editor extends Component {
const { serializer } = this.state; const { serializer } = this.state;
const newState = this.view.state.applyAction(action); const newState = this.view.state.applyAction(action);
const md = serializer.serialize(newState.doc); const md = serializer.serialize(newState.doc);
console.log(md);
const processedMarkdown = unified() const processedMarkdown = unified()
.use(markdownToRemark) .use(markdownToRemark)
.use(remarkToMarkdown, { commonmark: true, footnotes: true, pedantic: true }) .use(remarkToMarkdown, { fences: true, commonmark: true, footnotes: true, pedantic: true })
.processSync(md); .processSync(md);
console.log(processedMarkdown.contents);
this.props.onChange(processedMarkdown.contents); this.props.onChange(processedMarkdown.contents);
this.view.updateState(newState); this.view.updateState(newState);
if (newState.selection !== this.state.selection) { if (newState.selection !== this.state.selection) {

View File

@ -12,7 +12,7 @@ const state = { activeMarks: Mark.none, textsArray: [] };
*/ */
function parser(src) { function parser(src) {
const result = unified() const result = unified()
.use(remarkToMarkdown, { commonmark: true, footnotes: true, pedantic: true }) .use(remarkToMarkdown, { fences: true, footnotes: true, pedantic: true })
.parse(src); .parse(src);
return unified() return unified()

View File

@ -9,7 +9,7 @@ import previewStyle from '../defaultPreviewStyle';
const MarkdownPreview = ({ value, getAsset }) => { const MarkdownPreview = ({ value, getAsset }) => {
const Markdown = unified() const Markdown = unified()
.use(markdownToRemark, { commonmark: true, footnotes: true, pedantic: true }) .use(markdownToRemark, { footnotes: true, pedantic: true })
.use(remarkToRehype, { allowDangerousHTML: true }) .use(remarkToRehype, { allowDangerousHTML: true })
.use(cmsPluginToRehype, { getAsset }) .use(cmsPluginToRehype, { getAsset })
.use(rehypeToReact, { createElement: React.createElement }) .use(rehypeToReact, { createElement: React.createElement })