Take a VML string and prepare it for either IE8 or IE6/IE7.
@param {Array} markup A string array of the VML markup to prepare
330203
function (markup) {
		var vmlStyle = 'display:inline-block;behavior:url(#default#VML);',
			isIE8 = this.isIE8;

		markup = markup.join('');

		if (isIE8) { // add xmlns and style inline
			markup = markup.replace('/>', ' xmlns="urn:schemas-microsoft-com:vml" />');
			if (markup.indexOf('style="') === -1) {
				markup = markup.replace('/>', ' style="' + vmlStyle + '" />');
			} else {
				markup = markup.replace('style="', 'style="' + vmlStyle);
			}

		} else { // add namespace
			markup = markup.replace('<', '<hcv:');
		}

		return markup;
	}
224564
function prettifyXml(xmlInput, options = {}) {
  const {
    indent: indentOption = 2,
    newline: newlineOption = EOL,
  } = options
  const indentString = stringTimesN(indentOption, ' ')

  let formatted = ''
  const regex = /(>)(<)(\/*)/g
  const xml = xmlInput.replace(regex, `$1${newlineOption}$2$3`)
  let pad = 0
  xml.split(/\r?\n/).forEach(l => {
    const line = l.trim()

    let indent = 0
    if (line.match(/.+<\/\w[^>]*>$/)) {
      indent = 0
    } else if (line.match(/^<\/\w/)) {
      // Somehow istanbul doesn't see the else case as covered, although it is. Skip it.
      /* istanbul ignore else  */
      if (pad !== 0) {
        pad -= 1
      }
    } else if (line.match(/^<\w([^>]*[^\/])?>.*$/)) {
      indent = 1
    } else {
      indent = 0
    }

    const padding = stringTimesN(pad, indentString)
    formatted += padding + line + newlineOption // eslint-disable-line prefer-template
    pad += indent
  })

  return formatted.trim()
}
1092045
function prepareDom(doc, cfg = {}) {
    if (!(doc instanceof Document)) {
        console.warn('Cannnot prepare, the provided element is not a document.');
        return;
    }
    // apply defaults
    _.defaults(cfg, defaults);
    // append any default styles
    appendStyle(cfg.style, doc);
    // attach event handlers
    Handler.addAll(doc, cfg);

    return doc;
}
739506
function(element) {
      // For SVG or Symbol elements, innerHTML returns `undefined` in IE.
      // Reference: https://stackoverflow.com/q/28129956/633107
      // The XMLSerializer API is supported on IE11 and is the recommended workaround.
      var serializer = new XMLSerializer();

      return Array.prototype.map.call(element.childNodes, function (child) {
        return serializer.serializeToString(child);
      }).join('');
    }
737450
function(markup, targetdoc) {
		var elm, doc = this._document ||
			(this._document = document.implementation.createHTMLDocument(""));
		return gui.Guide.suspend(function() {
			doc.body.innerHTML = this._unsanitize(markup);
			elm = doc.querySelector("." + this._classname) || doc.body;
			return Array.map(elm.childNodes, function(node) {
				return (targetdoc || document).importNode(node, true);
			});
		}, this);
	}
394888
function md2html( file ){
  file = file.substr( file.length - 3 ) === '.md' ? file : file + '.md'; // add extension if need be

  let md;
  try{
    md = fs.readFileSync( path.join(__dirname, './md', file) , 'utf8');
  } catch(e){
    throw 'A markdown file named `' + file + '` was referenced but could not be read';
  }

  // let html = converter.makeHtml( md );
  //let html = mdConvertor( md );
  let html = marked( md, {
    highlight: function(code, lang){
      let ret;

      if( lang ){
        ret = hljs.highlight(lang, code).value;
      } else {
        ret = hljs.highlightAuto(code).value;
      }

      return ret;

    },

    smartypants: true,

    renderer: mdRend,

    gfm: true
  } );


  return html;
}
131084
function processMeta (markdownContent) {
  let meta = {};
  let metaArr;
  let metaString;
  let metas;

  let yamlObject;

  switch (true) {
    case _metaRegex.test(markdownContent):
      metaArr = markdownContent.match(_metaRegex);
      metaString = metaArr ? metaArr[1].trim() : '';

      if (metaString) {
        metas = metaString.match(/(.*): (.*)/ig);
        metas.forEach(item => {
          const parts = item.split(': ');
          if (parts[0] && parts[1]) {
            meta[cleanString(parts[0], true)] = parts[1].trim();
          }
        });
      }
      break;

    case _metaRegexYaml.test(markdownContent):
      metaArr = markdownContent.match(_metaRegexYaml);
      metaString = metaArr ? metaArr[1].trim() : '';
      yamlObject = yaml.safeLoad(metaString);
      meta = cleanObjectStrings(yamlObject);
      break;

    default:
    // No meta information
  }

  return meta;
}
752696
function() {
      var markup = [
        '<?xml version="1.0" standalone="no" ?>',
          '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" ',
            '"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">',
          '<svg ',
            'xmlns="http://www.w3.org/2000/svg" ',
            'xmlns:xlink="http://www.w3.org/1999/xlink" ',
            'version="1.1" ',
            'width="', this.width, '" ',
            'height="', this.height, '" ',
            'xml:space="preserve">',
          '<desc>Created with Fabric.js ', fabric.version, '</desc>',
          fabric.createSVGFontFacesMarkup(this.getObjects())
      ];

      if (this.backgroundImage) {
        markup.push(
          '<image x="0" y="0" ',
            'width="', this.width,
            '" height="', this.height,
            '" preserveAspectRatio="', (this.backgroundImageStretch ? 'none' : 'defer'),
            '" xlink:href="', this.backgroundImage.src,
            '" style="opacity:', this.backgroundImageOpacity,
          '"></image>'
        );
      }

      for (var i = 0, objects = this.getObjects(), len = objects.length; i < len; i++) {
        markup.push(objects[i].toSVG());
      }
      markup.push('</svg>');

      return markup.join('');
    }
1235413
def markup(str, remove_para=false)
      return '' unless str
      unless defined? @markup
        @markup = SM::SimpleMarkup.new

        # class names, variable names, or instance variables
        @markup.add_special(/(
                               \w+(::\w+)*[.\#]\w+(\([\.\w+\*\/\+\-\=\<\>]+\))?  # A::B.meth(**) (for operator in Fortran95)
                             | \#\w+(\([.\w\*\/\+\-\=\<\>]+\))?  #  meth(**) (for operator in Fortran95)
                             | \b([A-Z]\w*(::\w+)*[.\#]\w+)  #    A::B.meth
                             | \b([A-Z]\w+(::\w+)*)       #    A::B..
                             | \#\w+[!?=]?                #    #meth_name 
                             | \b\w+([_\/\.]+\w+)*[!?=]?  #    meth_name
                             )/x, 
                            :CROSSREF)

        # external hyperlinks
        @markup.add_special(/((link:|https?:|mailto:|ftp:|www\.)\S+\w)/, :HYPERLINK)

        # and links of the form  <text>[<url>]
        @markup.add_special(/(((\{.*?\})|\b\S+?)\[\S+?\.\S+?\])/, :TIDYLINK)
#        @markup.add_special(/\b(\S+?\[\S+?\.\S+?\])/, :TIDYLINK)

      end
      unless defined? @html_formatter
        @html_formatter = HyperlinkHtml.new(self.path, self)
      end

      # Convert leading comment markers to spaces, but only
      # if all non-blank lines have them

      if str =~ /^(?>\s*)[^\#]/
        content = str
      else
        content = str.gsub(/^\s*(#+)/)  { $1.tr('#',' ') }
      end

      res = @markup.convert(content, @html_formatter)
      if remove_para
        res.sub!(/^<p>/, '')
        res.sub!(/<\/p>$/, '')
      end
      res
    end
436343
function IconvHtmlStream(options) {
    this.buff = new Buffer([]);
    this.isBuffering = true;
    this.conv = null;
    options = options || {};
    this.rewrite = (options.rewrite !== false);
    this.inputEncoding = 'utf8';
    this.encoding = options.encoding = 'utf8'; // this is the *output* encoding
    this.conv = iconv.getEncoder(this.inputEncoding);
    Transform.call(this, options);
}
637072
function htmlParserImpl(html, handler) {
    if (html === null || html === undefined) {
      html = '';
    } else if (typeof html !== 'string') {
      html = '' + html;
    }
    inertBodyElement.innerHTML = html;

    //mXSS protection
    var mXSSAttempts = 5;
    do {
      if (mXSSAttempts === 0) {
        throw $sanitizeMinErr('uinput', 'Failed to sanitize html because the input is unstable');
      }
      mXSSAttempts--;

      // strip custom-namespaced attributes on IE<=11
      if (window.document.documentMode) {
        stripCustomNsAttrs(inertBodyElement);
      }
      html = inertBodyElement.innerHTML; //trigger mXSS
      inertBodyElement.innerHTML = html;
    } while (html !== inertBodyElement.innerHTML);

    var node = inertBodyElement.firstChild;
    while (node) {
      switch (node.nodeType) {
        case 1: // ELEMENT_NODE
          handler.start(node.nodeName.toLowerCase(), attrToMap(node.attributes));
          break;
        case 3: // TEXT NODE
          handler.chars(node.textContent);
          break;
      }

      var nextNode;
      if (!(nextNode = node.firstChild)) {
        if (node.nodeType === 1) {
          handler.end(node.nodeName.toLowerCase());
        }
        nextNode = node.nextSibling;
        if (!nextNode) {
          while (nextNode == null) {
            node = node.parentNode;
            if (node === inertBodyElement) break;
            nextNode = node.nextSibling;
            if (node.nodeType === 1) {
              handler.end(node.nodeName.toLowerCase());
            }
          }
        }
      }
      node = nextNode;
    }

    while ((node = inertBodyElement.firstChild)) {
      inertBodyElement.removeChild(node);
    }
  }
409464
function processVars (markdownContent, config) {
  if (config.variables && Array.isArray(config.variables)) {
    config.variables.forEach((v) => {
      markdownContent = markdownContent.replace(new RegExp('%' + v.name + '%', 'g'), v.content);
    });
  }
  if (config.base_url) {
    markdownContent = markdownContent.replace(/%base_url%/g, config.base_url);
  }
  if (config.image_url) {
    markdownContent = markdownContent.replace(/%image_url%/g, config.image_url);
  }
  return markdownContent;
}
1042684
function enqueueMarkup(parentID, markup, toIndex) {
  // NOTE: Null values reduce hidden classes.
  updateQueue.push({
    parentID: parentID,
    parentNode: null,
    type: ReactMultiChildUpdateTypes.INSERT_MARKUP,
    markupIndex: markupQueue.push(markup) - 1,
    textContent: null,
    fromIndex: null,
    toIndex: toIndex
  });
}
238730
function (o) {
            var self = this;
            o = self.addFoundAt(o);
            Y.each(o, function (i, k1) {
                if (i && i.forEach) {
                    Y.each(i, function (a, k) {
                        if (!(a instanceof Object)) {
                            return;
                        }
                        if (!a.type) {
                            a.type = 'Object'; //Default type is Object
                        }
                        if (a.final === '') {
                            a.final = true;
                        }
                        if (!a.description) {
                            a.description = ' ';
                        } else {
                            //a.description = markdown(a.description, true, self.defaultTags);
                            a.description = self.markdown(a.description);
                        }
                        if (a.example) {
                            a.example = self.markdown(a.example);
                        }
                        a = self.addFoundAt(a);

                        Y.each(a, function (c, d) {
                            if (c.forEach || (c instanceof Object)) {
                                c = self.augmentData(c);
                                a[d] = c;
                            }
                        });

                        o[k1][k] = a;
                    });
                } else if (i instanceof Object) {
                    i = self.addFoundAt(i);
                    Y.each(i, function (v, k) {
                        if (k === 'final') {
                            o[k1][k] = true;
                        }
                        if (k === 'description' || k === 'example') {
                            if (k1 === 'return') {
                                o[k1][k] = self.markdown(v);
                            } else if (v.forEach || (v instanceof Object)) {
                                o[k1][k] = self.augmentData(v);
                            } else {
                                //o[k1][k] = markdown(v, true, self.defaultTags);
                                o[k1][k] = self.markdown(v);
                            }
                        }
                    });
                } else if (k1 === 'description' || k1 === 'example') {
                    //o[k1] = markdown(i, true, self.defaultTags);
                    o[k1] = self.markdown(i);
                }
            });
            return o;
        }
1090248
function(markup) {
		markup = markup || "";
		return gui.Guide.suspend(function() {
			var doc = document.implementation.createHTMLDocument("");
			if (markup.toLowerCase().contains("<!doctype")) {
				try {
					doc.documentElement.innerHTML = markup;
				} catch (ie9exception) {
					doc = new ActiveXObject("htmlfile");
					doc.open();
					doc.write(markup);
					doc.close();
				}
			} else {
				doc.body.innerHTML = markup;
			}
			return doc;
		});
	}
1120764
function _sanitizeHtml(defaultDoc, unsafeHtmlInput) {
    var inertBodyElement = null;
    try {
        inertBodyHelper = inertBodyHelper || new InertBodyHelper(defaultDoc);
        // Make sure unsafeHtml is actually a string (TypeScript types are not enforced at runtime).
        var unsafeHtml = unsafeHtmlInput ? String(unsafeHtmlInput) : '';
        inertBodyElement = inertBodyHelper.getInertBodyElement(unsafeHtml);
        // mXSS protection. Repeatedly parse the document to make sure it stabilizes, so that a browser
        // trying to auto-correct incorrect HTML cannot cause formerly inert HTML to become dangerous.
        var mXSSAttempts = 5;
        var parsedHtml = unsafeHtml;
        do {
            if (mXSSAttempts === 0) {
                throw new Error('Failed to sanitize html because the input is unstable');
            }
            mXSSAttempts--;
            unsafeHtml = parsedHtml;
            parsedHtml = inertBodyElement.innerHTML;
            inertBodyElement = inertBodyHelper.getInertBodyElement(unsafeHtml);
        } while (unsafeHtml !== parsedHtml);
        var sanitizer = new SanitizingHtmlSerializer();
        var safeHtml = sanitizer.sanitizeChildren(getTemplateContent(inertBodyElement) || inertBodyElement);
        if (isDevMode() && sanitizer.sanitizedSomething) {
            console.warn('WARNING: sanitizing HTML stripped some content (see http://g.co/ng/security#xss).');
        }
        return safeHtml;
    }
    finally {
        // In case anything goes wrong, clear out inertElement to reset the entire DOM structure.
        if (inertBodyElement) {
            var parent_1 = getTemplateContent(inertBodyElement) || inertBodyElement;
            while (parent_1.firstChild) {
                parent_1.removeChild(parent_1.firstChild);
            }
        }
    }
}
533125
function markExtension(editor) {
  const ml = new MarkerList();
  const mm = new MarkerManager(ml);
  let wmh, mmh, vmh;

  editor.eventManager.addEventType('markerUpdated');

  if (editor.isViewer()) {
    vmh = new ViewerMarkerHelper(editor.preview);
  } else {
    wmh = new WysiwygMarkerHelper(editor.getSquire());
    mmh = new MarkdownMarkerHelper(editor.getCodeMirror());
  }

  /**
   * getHelper
   * Get helper for current situation
   * @returns {object} helper
   */
  function getHelper() {
    let helper;

    if (editor.isViewer()) {
      helper = vmh;
    } else if (editor.isWysiwygMode()) {
      helper = wmh;
    } else {
      helper = mmh;
    }

    return helper;
  }

  /**
   * Update mark when resizing
   */
  function updateMarkWhenResizing() {
    const helper = getHelper();

    ml.getAll().forEach(marker => {
      helper.updateMarkerWithExtraInfo(marker);
    });

    editor.eventManager.emit('markerUpdated', ml.getAll());
  }

  // We need to update marker after window have been resized
  $(window).on('resize', updateMarkWhenResizing);

  editor.on('removeEditor', () => {
    $(window).off('resize', updateMarkWhenResizing);
  });

  // Reset marker content after set value
  editor.on('setMarkdownAfter', () => {
    const helper = getHelper();
    mm.resetContent(helper.getTextContent());
  });

  /**
   * setValueWithMarkers
   * Set value with markers
   * @param {string} value markdown content
   * @param {object} markerDataCollection marker data that obtain with exportMarkers method
   * @returns {Array.<object>} markers
   */
  editor.setValueWithMarkers = (value, markerDataCollection) => {
    let helper;

    ml.resetMarkers();

    markerDataCollection.forEach(markerData => {
      ml.addMarker(markerData.start, markerData.end, markerData.id);
    });

    editor.setValue(value);

    mm.resetContent(value.replace(FIND_CRLF_RX, ''));

    if (editor.isViewer() || editor.isWysiwygMode()) {
      helper = getHelper();
      mm.updateMarkersByContent(helper.getTextContent());
    } else {
      helper = mmh;
    }

    ml.getAll().forEach(marker => {
      helper.updateMarkerWithExtraInfo(marker);
    });

    editor.eventManager.emit('markerUpdated', ml.getAll());

    return ml.getAll();
  };

  /**
   * getMarker
   * Get markers that have given id
   * @param {string} id id of marker
   * @returns {object}
   */
  editor.getMarker = id => ml.getMarker(id);

  /**
   * getMarkersAll
   * Get all markers
   * @returns {Array.<object>}
   */
  editor.getMarkersAll = () => ml.getAll();

  /**
   * removeMarker
   * Remove marker with given id
   * @param {string} id of marker that should be removed
   * @returns {marker} removed marker
   */
  editor.removeMarker = id => ml.removeMarker(id);

  /**
   * getMarkersData
   * Get marker data to export so you can restore markers next time
   * @returns {object} markers data
   */
  editor.exportMarkers = () => {
    let markersData;

    if (editor.isMarkdownMode()) {
      markersData = ml.getMarkersData();
    } else if (editor.isViewer() || editor.isWysiwygMode()) {
      mm.updateMarkersByContent(editor.getValue().replace(FIND_CRLF_RX, ''));
      markersData = ml.getMarkersData();
      mm.updateMarkersByContent(getHelper().getTextContent());
    }

    return markersData;
  };

  /**
   * selectMarker
   * Make selection with marker that have given id
   * @param {string} id id of marker
   */
  editor.selectMarker = id => {
    const helper = getHelper();
    const marker = editor.getMarker(id);

    if (marker) {
      helper.selectOffsetRange(marker.start, marker.end);
    }
  };

  /**
   * addMarker
   * Add Marker with given id
   * if you pass just id then it uses current selection for marker
   * or you can pass start and end offset for marker
   * @param {number|string} start start offset or id
   * @param {number} end end offset
   * @param {string} id id of marker
   * @returns {object} marker that have made
   */
  editor.addMarker = (start, end, id) => {
    let marker;
    const helper = getHelper();

    if (!id) {
      id = start;
      marker = helper.getMarkerInfoOfCurrentSelection();
    } else {
      marker = {
        start,
        end
      };

      marker = helper.updateMarkerWithExtraInfo(marker);
    }

    if (marker) {
      marker.id = id;
      marker = ml.addMarker(marker);
      ml.sortBy('end');
      editor.eventManager.emit('markerUpdated', [marker]);
    }

    return marker;
  };

  /**
   * clearSelect
   * Clear selection
   */
  editor.clearSelect = () => {
    getHelper().clearSelect();
  };

  if (!editor.isViewer()) {
    editor.on('changeMode', () => {
      editor._updateMarkers();
    });

    editor.on('change', util.debounce(() => {
      editor._updateMarkers();
    }, MARKER_UPDATE_DELAY));

    /**
     * _updateMarkers
     * Update markers with current text content
     */
    editor._updateMarkers = () => {
      const helper = getHelper();

      if (!ml.getAll().length) {
        return;
      }

      mm.updateMarkersByContent(helper.getTextContent());

      ml.getAll().forEach(marker => {
        helper.updateMarkerWithExtraInfo(marker);
      });

      editor.eventManager.emit('markerUpdated', ml.getAll());
    };
  }
}