How to use the marked.setOptions function in marked

To help you get started, we’ve selected a few marked 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 Weibozzz / next-blog / components / Edit / index.js View on Github external
import {connect} from 'react-redux';

import {Row, Col,Input} from 'antd';

import marked from 'marked'
import hljs from 'highlight.js';

import {getHtml, OldTime} from '../../until';
import {markdownConfig} from "../../config/markdown";
// import './index.less';

const { TextArea } = Input;

const {options,config} = markdownConfig
hljs.configure(config)
marked.setOptions({
  highlight: (code) => hljs.highlightAuto(code).value,
  ...options
});

class Edit extends Component {
  constructor(props) {
    super(props)
    this.state = {
      previewContent: '',
      aceBoxH: null,
      originContent: '',
      inputValue:'',
    }

    this.cacheValue()
    this.containerScroll = this.containerScroll.bind(this)
github coralproject / talk / client / coral-framework / components / Markdown.js View on Github external
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import marked from 'marked';

const renderer = new marked.Renderer();

// Set link target to `_parent` to work properly in an embed.
renderer.link = (href, title, text) =>
  `<a title="" href="${href}">${text}</a>`;

marked.setOptions({ renderer });

export default class Markdown extends PureComponent {
  render() {
    const { content, ...rest } = this.props;
    const __html = marked(content);
    return <div>;
  }
}

Markdown.propTypes = {
  content: PropTypes.string,
};
</div>
github dwqdaiwenqi / react-3d-viewer / site / src / show_models.js View on Github external
import React,{Component} from 'react';
import {Tick,JSONModel,OBJModel,MTLModel,GLTFModel,DAEModel,AmbientLight,DirectionLight} from '../../dist/scripts/react-3d-viewer.js'
import marked from 'marked'
import './show_model.less'

marked.setOptions({
  renderer: new marked.Renderer(),
  gfm: true,
  tables: true,
  breaks: false,
  pedantic: false,
  sanitize: false,
  smartLists: true,
  smartypants: false
});

// GLTFModel;
// AmbientLight,DirectionLight
// debugger

export class JSON_ extends Component{
  constructor(props){
github argos-ci / argos / src / modules / components / MarkdownElement.js View on Github external
const rendererDefault = new marked.Renderer()

rendererAnchor.heading = (text, level) =&gt; {
  const escapedText = text.toLowerCase().replace(/[^\w]+/g, '-')

  return (
    `
    
      <a id="${escapedText}" class="anchor-link"></a>${text}` +
    `<a href="#${escapedText}" class="anchor-link-style">${'#'}</a>
    
  `
  )
}

marked.setOptions({
  gfm: true,
  tables: true,
  breaks: false,
  pedantic: false,
  sanitize: false,
  smartLists: true,
  smartypants: false,
  highlight(code) {
    return prism.highlight(code, prism.languages.jsx)
  },
})

const anchorLinkStyle = theme =&gt; ({
  '&amp; .anchor-link-style': {
    display: 'none',
  },
github Yoshino-UI / Yoshino / docs / components / Markdown / index.tsx View on Github external
render() {
    marked.setOptions({
      gfm: true,
      tables: true,
      breaks: false,
      pedantic: false,
      sanitize: false,
      smartLists: true,
      smartypants: false,
      highlight(code, lang) {
        if (lang === 'jsx') {
          return Prism.highlight(code, Prism.languages.jsx);
        } else {
          return require('highlight.js').highlight(lang || 'js', code).value;
        }
      }
    });
    return (
github gschier / balloon / lib / render.js View on Github external
function setupDefaults () {
    marked.setOptions({
        renderer: new marked.Renderer(),
        highlight: function (code, lang, callback) {
            require('pygmentize-bundled')({
                lang: lang,
                format: 'html'
            }, code, function (err, result) {
                callback(err, result.toString());
            });
        },
        gfm: true,
        tables: true,
        breaks: false,
        pedantic: false,
        sanitize: false,
        smartLists: true,
        smartypants: false
github Coding / WebIDE-Frontend / app / components / Editor / components / MarkdownEditor / index.jsx View on Github external
line = tokens[idx].lines[0]
    return '<p data-line="' + line + '" class="line">'
  }
  return '</p><p>'
}

md.renderer.rules.heading_open = (tokens, idx) =&gt; {
  let line
  if (tokens[idx].lines &amp;&amp; tokens[idx].level === 0) {
    line = tokens[idx].lines[0]
    return ''
  }
  return ''
}

marked.setOptions({
  highlight: (code) =&gt; {
    require('highlight.js/styles/github-gist.css')
    return require('highlight.js').highlightAuto(code).value
  },
})

@observer
class PreviewEditor extends Component {
  constructor (props) {
    super(props)
  }

  makeHTMLComponent (html) {
    return React.DOM.div({ dangerouslySetInnerHTML: { __html: html } })
  }
</p>
github Hzy0913 / my-blog / admin / src / component / ArticlePreview.vue View on Github external
mounted: function(){
		marked.setOptions({
            renderer: new marked.Renderer(),
            gfm: true,
            tables: true,
            breaks: false,
            pedantic: false,
            sanitize: false,
            smartLists: true,
            smartypants: false,
            highlight: function (code) {
                return highlight.highlightAuto(code).value;
            }
        });
    },
    methods: {
github support-project / knowledge / frontend / src / lib / decorateMarkdown / processMarkdown.js View on Github external
import Promise from 'bluebird'
import logger from 'logger'
import marked from 'marked'
import hljs from 'highlight.js'

const LABEL = 'processMarkdown.js'

marked.setOptions({
  renderer: new marked.Renderer(),
  gfm: true,
  tables: true,
  breaks: true,
  pedantic: false,
  sanitize: false,
  smartLists: true,
  smartypants: false
})

var sequentialId = 0

var renderer = new marked.Renderer()
renderer.heading = function (text, level) {
  var escapedText = text.toLowerCase().replace(/[^\w]+/g, '-')
  return '
github lbovet / docson / src / index.js View on Github external
if( !description && !examples ) {
            return "";
        }

        if ( description ) {
            text = description
        }

        if ( examples && examples.length > 0 ) {
            examples = [ " Examples: \n" ].concat(examples).join("\n\t");
            text = text + examples;
        }

        if(marked) {
            marked.setOptions({gfm: true, breaks: true})
            return new Handlebars.SafeString(marked(text));
        } else {
            return text;
        }
    });