Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to markdown-it #581

Merged
merged 1 commit into from
Nov 21, 2017
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"dependencies": {
"codemirror": "^5.26.0",
"codemirror-graphql": "^0.6.11",
"marked": "0.3.6"
"markdown-it": "^8.4.0"
},
"peerDependencies": {
"graphql": "^0.6.0 || ^0.7.0 || ^0.8.0-b || ^0.9.0 || ^0.10.0 || ^0.11.0",
Expand Down
7 changes: 4 additions & 3 deletions src/components/DocExplorer/MarkdownContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

import React from 'react';
import PropTypes from 'prop-types';
import Marked from 'marked';
import MD from 'markdown-it';

const md = new MD();

export default class MarkdownContent extends React.Component {
static propTypes = {
Expand All @@ -26,11 +28,10 @@ export default class MarkdownContent extends React.Component {
return <div />;
}

const html = Marked(markdown, { sanitize: true });
return (
<div
className={this.props.className}
dangerouslySetInnerHTML={{ __html: html }}
dangerouslySetInnerHTML={{ __html: md.render(markdown) }}
/>
);
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/QueryEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
import React from 'react';
import PropTypes from 'prop-types';
import { GraphQLSchema } from 'graphql';
import marked from 'marked';
import MD from 'markdown-it';
import { normalizeWhitespace } from '../utility/normalizeWhitespace';
import onHasCompletion from '../utility/onHasCompletion';

const md = new MD();
const AUTO_COMPLETE_AFTER_KEY = /^[a-zA-Z0-9_@(]$/;

/**
Expand Down Expand Up @@ -96,7 +97,7 @@ export class QueryEditor extends React.Component {
},
info: {
schema: this.props.schema,
renderDescription: text => marked(text, { sanitize: true }),
renderDescription: text => md.render(text),
onClick: reference => this.props.onClickReference(reference),
},
jump: {
Expand Down
8 changes: 5 additions & 3 deletions src/utility/onHasCompletion.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
*/

import { GraphQLNonNull, GraphQLList } from 'graphql';
import marked from 'marked';
import MD from 'markdown-it';

const md = new MD();

/**
* Render a custom UI for CodeMirror's hint which includes additional info
Expand Down Expand Up @@ -55,7 +57,7 @@ export default function onHasCompletion(cm, data, onHintInformationRender) {

// Now that the UI has been set up, add info to information.
const description = ctx.description
? marked(ctx.description, { sanitize: true })
? md.render(ctx.description)
: 'Self descriptive.';
const type = ctx.type
? '<span class="infoType">' + renderType(ctx.type) + '</span>'
Expand All @@ -70,7 +72,7 @@ export default function onHasCompletion(cm, data, onHintInformationRender) {

if (ctx.isDeprecated) {
const reason = ctx.deprecationReason
? marked(ctx.deprecationReason, { sanitize: true })
? md.render(ctx.deprecationReason)
: '';
deprecation.innerHTML =
'<span class="deprecation-label">Deprecated</span>' + reason;
Expand Down