How to use the turndown/lib/turndown.browser.umd function in turndown

To help you get started, we’ve selected a few turndown 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 benweet / stackedit / src / services / editor / cledit / cleditCore.js View on Github external
evt.preventDefault();
      }
    });

    contentElt.addEventListener('cut', (evt) => {
      if (evt.clipboardData) {
        evt.clipboardData.setData('text/plain', selectionMgr.getSelectedText());
        evt.preventDefault();
        replace(selectionMgr.selectionStart, selectionMgr.selectionEnd, '');
      } else {
        undoMgr.setCurrentMode('single');
      }
      adjustCursorPosition();
    });

    turndownService = new TurndownService(store.getters['data/computedSettings'].turndown);
    turndownService.escape = str => str; // Disable escaping
  }

  contentElt.addEventListener('paste', (evt) => {
    undoMgr.setCurrentMode('single');
    evt.preventDefault();
    let data;
    let { clipboardData } = evt;
    if (clipboardData) {
      data = clipboardData.getData('text/plain');
      if (turndownService) {
        try {
          const html = clipboardData.getData('text/html');
          if (html) {
            const sanitizedHtml = htmlSanitizer.sanitizeHtml(html)
              .replace(/ /g, ' '); // Replace non-breaking spaces with classic spaces
github benweet / stackedit / src / libs / cleditCore.js View on Github external
var htmlSanitizer = require('./htmlSanitizer').default
var DiffMatchPatch = require('diff-match-patch')
var TurndownService = require('turndown/lib/turndown.browser.umd')

var turndownService = new TurndownService({
  headingStyle: 'atx',
  hr: '----------',
  bulletListMarker: '-',
  codeBlockStyle: 'fenced',
})

function cledit(contentElt, scrollElt, windowParam) {
  scrollElt = scrollElt || contentElt
  var editor = {
    $contentElt: contentElt,
    $scrollElt: scrollElt,
    $window: windowParam || window,
    $keystrokes: [],
    $markers: {}
  }
  editor.$document = editor.$window.document

turndown

A library that converts HTML to Markdown

MIT
Latest version published 5 days ago

Package Health Score

87 / 100
Full package analysis