How to use the simple-markdown.outputFor function in simple-markdown

To help you get started, we’ve selected a few simple-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 deltachat / deltachat-desktop / src / renderer / components / message / MessageBody.js View on Github external
import React from 'react'
import classNames from 'classnames'
import { getSizeClass, getRegex, replaceColons } from '../conversations/emoji'
import { rules } from './MessageMarkdown'
import SimpleMarkdown from 'simple-markdown'

const emojiRegex = getRegex()
const parser = SimpleMarkdown.parserFor(rules)
const ast2react = SimpleMarkdown.outputFor(rules, 'react')

export default function MessageBody (props) {
  const { text, disableJumbomoji, preview } = props
  // if text is only emojis and Jumbomoji is enabled
  const emojifiedText = trim(text.replace(/:[\w\d_\-+]*:/g, replaceColons))
  if (
    emojifiedText.length < 50 &&
    !disableJumbomoji &&
    emojifiedText.replace(emojiRegex, '') === ''
  ) {
    const sizeClass = disableJumbomoji ? '' : getSizeClass(emojifiedText)
    return (
      <span>
        {emojifiedText}
      </span>
    )
github nurdism / neko / client / src / components / markdown.ts View on Github external
spoiler: {
    order: 0,
    match: (source) =&gt; /^\|\|([\s\S]+?)\|\|/.exec(source),
    parse(capture, parse, state) {
      return {
        content: parse(capture[1], state),
      }
    },
    html(node, output, state) {
      return htmlTag('span', htmlTag('span', output(node.content, state), {}, state), { class: 'spoiler' }, state)
    },
  },
}

const parser = md.parserFor(rules)
const htmlOutput = md.outputFor(rules, 'html')

@Component({
  name: 'neko-markdown',
})
export default class extends Vue {
  @Prop({ required: true })
  source!: string

  render(h: any) {
    const state: MarkdownState = {
      inline: true,
      inQuote: false,
      escapeHTML: true,
      cssModuleNames: null,
    }
    return h({ template: `<div>${htmlOutput(parser(this.source, state), state)}</div>` })
github WRidder / react-spa / client / src / components / markdown / custom-md.jsx View on Github external
output: function(node, outputter) {
          return React.createElement(
            "p",
            null,
            outputter(node.content)
          );
        }
    })
});

var rawBuiltParser = SimpleMarkdown.parserFor(rules);
var parse = function(source) {
  var blockSource = source + "\n\n";
  return rawBuiltParser(blockSource, {inline: false});
};
var output = SimpleMarkdown.outputFor(SimpleMarkdown.ruleOutput(rules));

module.exports = {
    parse: parse,
    output: output
};
github jaylineko / discohook / src / markup / parseMarkup.tsx View on Github external
react: null,
  },
  channelMention: {
    order: defaultRules.text.order,
    match: inlineRegex(/^&lt;#\d+&gt;/),
    parse: () =&gt; ({
      type: "mention",
      content: "#unknown-channel",
    }),
    react: null,
  },
}

const parseInline = parserFor(inlineRules, { inline: true })
const parseBlock = parserFor(blockRules, { inline: true })
const reactOutput = outputFor({ ...inlineRules, ...blockRules }, "react")

const ellipsize = (text: string, length: number) =&gt; {
  const shortenedText = text.replace(/\s+/g, " ")
  return shortenedText.length &lt;= length
    ? shortenedText
    : `${shortenedText.slice(0, length)}…`
}

const now = () =&gt; (typeof performance === "undefined" ? 0 : performance.now())

export const parseMarkup = (
  content: string,
  options?: { inline?: boolean; jumboable?: boolean },
) =&gt; {
  const { inline = false, jumboable = false } = options ?? {}