diff --git a/editions/markdowndemo/tiddlers/HelloThere.tid b/editions/markdowndemo/tiddlers/HelloThere.tid index b3b4aea0b..e818ddb59 100644 --- a/editions/markdowndemo/tiddlers/HelloThere.tid +++ b/editions/markdowndemo/tiddlers/HelloThere.tid @@ -1,6 +1,6 @@ title: HelloThere -This is a demo of TiddlyWiki5 incorporating a plugin for the [[markdown-js|https://github.com/evilstreak/markdown-js]] Markdown parser from Dominic Baggott. The MarkdownExample tiddler below is written in Markdown. +This is a demo of TiddlyWiki5 incorporating a plugin for parsing tiddlers written in the Markdown language. The plugin uses the [[Remarkable|https://github.com/jonschlinkert/remarkable]] Markdown parser internally. The MarkdownExample tiddler below is written in Markdown. ! Installation @@ -8,31 +8,4 @@ To add the plugin to your own TiddlyWiki5, just drag this link to the browser wi [[$:/plugins/tiddlywiki/markdown]] -! Markdown Dialects - -By default the markdown parser recognises the original dialect of Markdown [[as described by John Gruber|http://daringfireball.net/projects/markdown/]]. An extended dialect called "Maruku" is also included that provides table support and other advanced features. The syntax extensions are modelled on those of [[PHP Markdown Extra|https://michelf.ca/projects/php-markdown/extra/]]. - -The configuration tiddler [[$:/config/markdown/dialect]] determines which dialect is used: - -|!Dialect |!Description | -|Gruber |Standard Markdown | -|Maruku |Extended Maruku Markdown | - - -! Creating ~WikiLinks - -Create wiki links with the usual Markdown link syntax targeting `#` and the target tiddler title: - -``` -[link text](#TiddlerTitle) -``` - -! Images - -Markdown image syntax can be used to reference images by tiddler title or an external URI. For example: - -``` -![alt text](/path/to/img.jpg "Title") - -![alt text](Motovun Jack.jpg "Title") -``` +{{$:/plugins/tiddlywiki/markdown/usage}} \ No newline at end of file diff --git a/editions/markdowndemo/tiddlers/MarkdownExample.tid b/editions/markdowndemo/tiddlers/MarkdownExample.tid index ce6553d53..9d8144c5f 100644 --- a/editions/markdowndemo/tiddlers/MarkdownExample.tid +++ b/editions/markdowndemo/tiddlers/MarkdownExample.tid @@ -19,11 +19,10 @@ web application that allows you type your own Markdown-formatted text and translate it to XHTML. **Note:** This document is itself written using Markdown; you -can [see the source for it by adding '.text' to the URL] [src]. +can see the source for it by editing this tiddler. - [s]: /projects/markdown/syntax "Markdown Syntax" - [d]: /projects/markdown/dingus "Markdown Dingus" - [src]: /projects/markdown/basics.text + [s]: https://daringfireball.net/projects/markdown/syntax "Markdown Syntax" + [d]: https://daringfireball.net/projects/markdown/dingus "Markdown Dingus" ## Paragraphs, Headers, Blockquotes ## @@ -47,7 +46,7 @@ Markdown: A First Level Header ==================== - + A Second Level Header --------------------- @@ -57,11 +56,11 @@ Markdown: The quick brown fox jumped over the lazy dog's back. - + ### Header 3 > This is a blockquote. - > + > > This is the second paragraph in the blockquote. > > ## This is an H2 in a blockquote @@ -70,23 +69,23 @@ Markdown: Output:

A First Level Header

- +

A Second Level Header

- +

Now is the time for all good men to come to the aid of their country. This is just a regular paragraph.

- +

The quick brown fox jumped over the lazy dog's back.

- +

Header 3

- +

This is a blockquote.

- +

This is the second paragraph in the blockquote.

- +

This is an H2 in a blockquote

@@ -100,7 +99,7 @@ Markdown: Some of these words *are emphasized*. Some of these words _are emphasized also_. - + Use two asterisks for **strong emphasis**. Or, if you prefer, __use two underscores instead__. @@ -108,10 +107,10 @@ Output:

Some of these words are emphasized. Some of these words are emphasized also.

- +

Use two asterisks for strong emphasis. Or, if you prefer, use two underscores instead.

- + ## Lists ## @@ -164,7 +163,7 @@ list item text. You can create multi-paragraph list items by indenting the paragraphs by 4 spaces or 1 tab: * A list item. - + With multiple paragraphs. * Another item in the list. @@ -176,7 +175,7 @@ Output:

With multiple paragraphs.

  • Another item in the list.

  • - + ### Links ### @@ -271,7 +270,7 @@ Output:

    I strongly recommend against using any <blink> tags.

    - +

    I wish SmartyPants used named entities like &mdash; instead of decimal-encoded entites like &#8212;.

    @@ -294,7 +293,7 @@ Output:

    If you want your page to validate under XHTML 1.0 Strict, you've got to put paragraph tags in your blockquotes:

    - +
    <blockquote>
             <p>For example.</p>
         </blockquote>
    diff --git a/plugins/tiddlywiki/markdown/config_breaks.tid b/plugins/tiddlywiki/markdown/config_breaks.tid
    new file mode 100644
    index 000000000..18fc90690
    --- /dev/null
    +++ b/plugins/tiddlywiki/markdown/config_breaks.tid
    @@ -0,0 +1,3 @@
    +title: $:/config/markdown/breaks
    +
    +false
    \ No newline at end of file
    diff --git a/plugins/tiddlywiki/markdown/config_linkNewWindow.tid b/plugins/tiddlywiki/markdown/config_linkNewWindow.tid
    new file mode 100644
    index 000000000..274776a7a
    --- /dev/null
    +++ b/plugins/tiddlywiki/markdown/config_linkNewWindow.tid
    @@ -0,0 +1,3 @@
    +title: $:/config/markdown/linkNewWindow
    +
    +true
    \ No newline at end of file
    diff --git a/plugins/tiddlywiki/markdown/config_linkify.tid b/plugins/tiddlywiki/markdown/config_linkify.tid
    new file mode 100644
    index 000000000..eddaff730
    --- /dev/null
    +++ b/plugins/tiddlywiki/markdown/config_linkify.tid
    @@ -0,0 +1,3 @@
    +title: $:/config/markdown/linkify
    +
    +false
    \ No newline at end of file
    diff --git a/plugins/tiddlywiki/markdown/config_quotes.tid b/plugins/tiddlywiki/markdown/config_quotes.tid
    new file mode 100644
    index 000000000..68baf5602
    --- /dev/null
    +++ b/plugins/tiddlywiki/markdown/config_quotes.tid
    @@ -0,0 +1,3 @@
    +title: $:/config/markdown/quotes
    +
    +“”‘’
    \ No newline at end of file
    diff --git a/plugins/tiddlywiki/markdown/config_renderWikiText.tid b/plugins/tiddlywiki/markdown/config_renderWikiText.tid
    new file mode 100644
    index 000000000..2e0001d51
    --- /dev/null
    +++ b/plugins/tiddlywiki/markdown/config_renderWikiText.tid
    @@ -0,0 +1,3 @@
    +title: $:/config/markdown/renderWikiText
    +
    +true
    \ No newline at end of file
    diff --git a/plugins/tiddlywiki/markdown/config_renderWikiTextPragma.tid b/plugins/tiddlywiki/markdown/config_renderWikiTextPragma.tid
    new file mode 100644
    index 000000000..c3cd6d482
    --- /dev/null
    +++ b/plugins/tiddlywiki/markdown/config_renderWikiTextPragma.tid
    @@ -0,0 +1,3 @@
    +title: $:/config/markdown/renderWikiTextPragma
    +
    +\rules only html image macrocallinline syslink transcludeinline wikilink filteredtranscludeblock macrocallblock transcludeblock
    \ No newline at end of file
    diff --git a/plugins/tiddlywiki/markdown/config_typographer.tid b/plugins/tiddlywiki/markdown/config_typographer.tid
    new file mode 100644
    index 000000000..b7a8bbca9
    --- /dev/null
    +++ b/plugins/tiddlywiki/markdown/config_typographer.tid
    @@ -0,0 +1,3 @@
    +title: $:/config/markdown/typographer
    +
    +false
    \ No newline at end of file
    diff --git a/plugins/tiddlywiki/markdown/dialect.tid b/plugins/tiddlywiki/markdown/dialect.tid
    deleted file mode 100755
    index 342ace8ff..000000000
    --- a/plugins/tiddlywiki/markdown/dialect.tid
    +++ /dev/null
    @@ -1,3 +0,0 @@
    -title: $:/config/markdown/dialect
    -
    -Gruber
    \ No newline at end of file
    diff --git a/plugins/tiddlywiki/markdown/files/markdown.js b/plugins/tiddlywiki/markdown/files/markdown.js
    deleted file mode 100755
    index d365cfa07..000000000
    --- a/plugins/tiddlywiki/markdown/files/markdown.js
    +++ /dev/null
    @@ -1,1725 +0,0 @@
    -// Released under MIT license
    -// Copyright (c) 2009-2010 Dominic Baggott
    -// Copyright (c) 2009-2010 Ash Berlin
    -// Copyright (c) 2011 Christoph Dorn  (http://www.christophdorn.com)
    -
    -/*jshint browser:true, devel:true */
    -
    -(function( expose ) {
    -
    -/**
    - *  class Markdown
    - *
    - *  Markdown processing in Javascript done right. We have very particular views
    - *  on what constitutes 'right' which include:
    - *
    - *  - produces well-formed HTML (this means that em and strong nesting is
    - *    important)
    - *
    - *  - has an intermediate representation to allow processing of parsed data (We
    - *    in fact have two, both as [JsonML]: a markdown tree and an HTML tree).
    - *
    - *  - is easily extensible to add new dialects without having to rewrite the
    - *    entire parsing mechanics
    - *
    - *  - has a good test suite
    - *
    - *  This implementation fulfills all of these (except that the test suite could
    - *  do with expanding to automatically run all the fixtures from other Markdown
    - *  implementations.)
    - *
    - *  ##### Intermediate Representation
    - *
    - *  *TODO* Talk about this :) Its JsonML, but document the node names we use.
    - *
    - *  [JsonML]: http://jsonml.org/ "JSON Markup Language"
    - **/
    -var Markdown = expose.Markdown = function(dialect) {
    -  switch (typeof dialect) {
    -    case "undefined":
    -      this.dialect = Markdown.dialects.Gruber;
    -      break;
    -    case "object":
    -      this.dialect = dialect;
    -      break;
    -    default:
    -      if ( dialect in Markdown.dialects ) {
    -        this.dialect = Markdown.dialects[dialect];
    -      }
    -      else {
    -        throw new Error("Unknown Markdown dialect '" + String(dialect) + "'");
    -      }
    -      break;
    -  }
    -  this.em_state = [];
    -  this.strong_state = [];
    -  this.debug_indent = "";
    -};
    -
    -/**
    - *  parse( markdown, [dialect] ) -> JsonML
    - *  - markdown (String): markdown string to parse
    - *  - dialect (String | Dialect): the dialect to use, defaults to gruber
    - *
    - *  Parse `markdown` and return a markdown document as a Markdown.JsonML tree.
    - **/
    -expose.parse = function( source, dialect ) {
    -  // dialect will default if undefined
    -  var md = new Markdown( dialect );
    -  return md.toTree( source );
    -};
    -
    -/**
    - *  toHTML( markdown, [dialect]  ) -> String
    - *  toHTML( md_tree ) -> String
    - *  - markdown (String): markdown string to parse
    - *  - md_tree (Markdown.JsonML): parsed markdown tree
    - *
    - *  Take markdown (either as a string or as a JsonML tree) and run it through
    - *  [[toHTMLTree]] then turn it into a well-formated HTML fragment.
    - **/
    -expose.toHTML = function toHTML( source , dialect , options ) {
    -  var input = expose.toHTMLTree( source , dialect , options );
    -
    -  return expose.renderJsonML( input );
    -};
    -
    -/**
    - *  toHTMLTree( markdown, [dialect] ) -> JsonML
    - *  toHTMLTree( md_tree ) -> JsonML
    - *  - markdown (String): markdown string to parse
    - *  - dialect (String | Dialect): the dialect to use, defaults to gruber
    - *  - md_tree (Markdown.JsonML): parsed markdown tree
    - *
    - *  Turn markdown into HTML, represented as a JsonML tree. If a string is given
    - *  to this function, it is first parsed into a markdown tree by calling
    - *  [[parse]].
    - **/
    -expose.toHTMLTree = function toHTMLTree( input, dialect , options ) {
    -  // convert string input to an MD tree
    -  if ( typeof input ==="string" ) input = this.parse( input, dialect );
    -
    -  // Now convert the MD tree to an HTML tree
    -
    -  // remove references from the tree
    -  var attrs = extract_attr( input ),
    -      refs = {};
    -
    -  if ( attrs && attrs.references ) {
    -    refs = attrs.references;
    -  }
    -
    -  var html = convert_tree_to_html( input, refs , options );
    -  merge_text_nodes( html );
    -  return html;
    -};
    -
    -// For Spidermonkey based engines
    -function mk_block_toSource() {
    -  return "Markdown.mk_block( " +
    -          uneval(this.toString()) +
    -          ", " +
    -          uneval(this.trailing) +
    -          ", " +
    -          uneval(this.lineNumber) +
    -          " )";
    -}
    -
    -// node
    -function mk_block_inspect() {
    -  var util = require("util");
    -  return "Markdown.mk_block( " +
    -          util.inspect(this.toString()) +
    -          ", " +
    -          util.inspect(this.trailing) +
    -          ", " +
    -          util.inspect(this.lineNumber) +
    -          " )";
    -
    -}
    -
    -var mk_block = Markdown.mk_block = function(block, trail, line) {
    -  // Be helpful for default case in tests.
    -  if ( arguments.length == 1 ) trail = "\n\n";
    -
    -  var s = new String(block);
    -  s.trailing = trail;
    -  // To make it clear its not just a string
    -  s.inspect = mk_block_inspect;
    -  s.toSource = mk_block_toSource;
    -
    -  if ( line != undefined )
    -    s.lineNumber = line;
    -
    -  return s;
    -};
    -
    -function count_lines( str ) {
    -  var n = 0, i = -1;
    -  while ( ( i = str.indexOf("\n", i + 1) ) !== -1 ) n++;
    -  return n;
    -}
    -
    -// Internal - split source into rough blocks
    -Markdown.prototype.split_blocks = function splitBlocks( input, startLine ) {
    -  input = input.replace(/(\r\n|\n|\r)/g, "\n");
    -  // [\s\S] matches _anything_ (newline or space)
    -  // [^] is equivalent but doesn't work in IEs.
    -  var re = /([\s\S]+?)($|\n#|\n(?:\s*\n|$)+)/g,
    -      blocks = [],
    -      m;
    -
    -  var line_no = 1;
    -
    -  if ( ( m = /^(\s*\n)/.exec(input) ) != null ) {
    -    // skip (but count) leading blank lines
    -    line_no += count_lines( m[0] );
    -    re.lastIndex = m[0].length;
    -  }
    -
    -  while ( ( m = re.exec(input) ) !== null ) {
    -    if (m[2] == "\n#") {
    -      m[2] = "\n";
    -      re.lastIndex--;
    -    }
    -    blocks.push( mk_block( m[1], m[2], line_no ) );
    -    line_no += count_lines( m[0] );
    -  }
    -
    -  return blocks;
    -};
    -
    -/**
    - *  Markdown#processBlock( block, next ) -> undefined | [ JsonML, ... ]
    - *  - block (String): the block to process
    - *  - next (Array): the following blocks
    - *
    - * Process `block` and return an array of JsonML nodes representing `block`.
    - *
    - * It does this by asking each block level function in the dialect to process
    - * the block until one can. Succesful handling is indicated by returning an
    - * array (with zero or more JsonML nodes), failure by a false value.
    - *
    - * Blocks handlers are responsible for calling [[Markdown#processInline]]
    - * themselves as appropriate.
    - *
    - * If the blocks were split incorrectly or adjacent blocks need collapsing you
    - * can adjust `next` in place using shift/splice etc.
    - *
    - * If any of this default behaviour is not right for the dialect, you can
    - * define a `__call__` method on the dialect that will get invoked to handle
    - * the block processing.
    - */
    -Markdown.prototype.processBlock = function processBlock( block, next ) {
    -  var cbs = this.dialect.block,
    -      ord = cbs.__order__;
    -
    -  if ( "__call__" in cbs ) {
    -    return cbs.__call__.call(this, block, next);
    -  }
    -
    -  for ( var i = 0; i < ord.length; i++ ) {
    -    //D:this.debug( "Testing", ord[i] );
    -    var res = cbs[ ord[i] ].call( this, block, next );
    -    if ( res ) {
    -      //D:this.debug("  matched");
    -      if ( !isArray(res) || ( res.length > 0 && !( isArray(res[0]) ) ) )
    -        this.debug(ord[i], "didn't return a proper array");
    -      //D:this.debug( "" );
    -      return res;
    -    }
    -  }
    -
    -  // Uhoh! no match! Should we throw an error?
    -  return [];
    -};
    -
    -Markdown.prototype.processInline = function processInline( block ) {
    -  return this.dialect.inline.__call__.call( this, String( block ) );
    -};
    -
    -/**
    - *  Markdown#toTree( source ) -> JsonML
    - *  - source (String): markdown source to parse
    - *
    - *  Parse `source` into a JsonML tree representing the markdown document.
    - **/
    -// custom_tree means set this.tree to `custom_tree` and restore old value on return
    -Markdown.prototype.toTree = function toTree( source, custom_root ) {
    -  var blocks = source instanceof Array ? source : this.split_blocks( source );
    -
    -  // Make tree a member variable so its easier to mess with in extensions
    -  var old_tree = this.tree;
    -  try {
    -    this.tree = custom_root || this.tree || [ "markdown" ];
    -
    -    blocks:
    -    while ( blocks.length ) {
    -      var b = this.processBlock( blocks.shift(), blocks );
    -
    -      // Reference blocks and the like won't return any content
    -      if ( !b.length ) continue blocks;
    -
    -      this.tree.push.apply( this.tree, b );
    -    }
    -    return this.tree;
    -  }
    -  finally {
    -    if ( custom_root ) {
    -      this.tree = old_tree;
    -    }
    -  }
    -};
    -
    -// Noop by default
    -Markdown.prototype.debug = function () {
    -  var args = Array.prototype.slice.call( arguments);
    -  args.unshift(this.debug_indent);
    -  if ( typeof print !== "undefined" )
    -      print.apply( print, args );
    -  if ( typeof console !== "undefined" && typeof console.log !== "undefined" )
    -      console.log.apply( null, args );
    -}
    -
    -Markdown.prototype.loop_re_over_block = function( re, block, cb ) {
    -  // Dont use /g regexps with this
    -  var m,
    -      b = block.valueOf();
    -
    -  while ( b.length && (m = re.exec(b) ) != null ) {
    -    b = b.substr( m[0].length );
    -    cb.call(this, m);
    -  }
    -  return b;
    -};
    -
    -/**
    - * Markdown.dialects
    - *
    - * Namespace of built-in dialects.
    - **/
    -Markdown.dialects = {};
    -
    -/**
    - * Markdown.dialects.Gruber
    - *
    - * The default dialect that follows the rules set out by John Gruber's
    - * markdown.pl as closely as possible. Well actually we follow the behaviour of
    - * that script which in some places is not exactly what the syntax web page
    - * says.
    - **/
    -Markdown.dialects.Gruber = {
    -  block: {
    -    atxHeader: function atxHeader( block, next ) {
    -      var m = block.match( /^(#{1,6})\s*(.*?)\s*#*\s*(?:\n|$)/ );
    -
    -      if ( !m ) return undefined;
    -
    -      var header = [ "header", { level: m[ 1 ].length } ];
    -      Array.prototype.push.apply(header, this.processInline(m[ 2 ]));
    -
    -      if ( m[0].length < block.length )
    -        next.unshift( mk_block( block.substr( m[0].length ), block.trailing, block.lineNumber + 2 ) );
    -
    -      return [ header ];
    -    },
    -
    -    setextHeader: function setextHeader( block, next ) {
    -      var m = block.match( /^(.*)\n([-=])\2\2+(?:\n|$)/ );
    -
    -      if ( !m ) return undefined;
    -
    -      var level = ( m[ 2 ] === "=" ) ? 1 : 2;
    -      var header = [ "header", { level : level }, m[ 1 ] ];
    -
    -      if ( m[0].length < block.length )
    -        next.unshift( mk_block( block.substr( m[0].length ), block.trailing, block.lineNumber + 2 ) );
    -
    -      return [ header ];
    -    },
    -
    -    code: function code( block, next ) {
    -      // |    Foo
    -      // |bar
    -      // should be a code block followed by a paragraph. Fun
    -      //
    -      // There might also be adjacent code block to merge.
    -
    -      var ret = [],
    -          re = /^(?: {0,3}\t| {4})(.*)\n?/,
    -          lines;
    -
    -      // 4 spaces + content
    -      if ( !block.match( re ) ) return undefined;
    -
    -      block_search:
    -      do {
    -        // Now pull out the rest of the lines
    -        var b = this.loop_re_over_block(
    -                  re, block.valueOf(), function( m ) { ret.push( m[1] ); } );
    -
    -        if ( b.length ) {
    -          // Case alluded to in first comment. push it back on as a new block
    -          next.unshift( mk_block(b, block.trailing) );
    -          break block_search;
    -        }
    -        else if ( next.length ) {
    -          // Check the next block - it might be code too
    -          if ( !next[0].match( re ) ) break block_search;
    -
    -          // Pull how how many blanks lines follow - minus two to account for .join
    -          ret.push ( block.trailing.replace(/[^\n]/g, "").substring(2) );
    -
    -          block = next.shift();
    -        }
    -        else {
    -          break block_search;
    -        }
    -      } while ( true );
    -
    -      return [ [ "code_block", ret.join("\n") ] ];
    -    },
    -
    -    horizRule: function horizRule( block, next ) {
    -      // this needs to find any hr in the block to handle abutting blocks
    -      var m = block.match( /^(?:([\s\S]*?)\n)?[ \t]*([-_*])(?:[ \t]*\2){2,}[ \t]*(?:\n([\s\S]*))?$/ );
    -
    -      if ( !m ) {
    -        return undefined;
    -      }
    -
    -      var jsonml = [ [ "hr" ] ];
    -
    -      // if there's a leading abutting block, process it
    -      if ( m[ 1 ] ) {
    -        jsonml.unshift.apply( jsonml, this.processBlock( m[ 1 ], [] ) );
    -      }
    -
    -      // if there's a trailing abutting block, stick it into next
    -      if ( m[ 3 ] ) {
    -        next.unshift( mk_block( m[ 3 ] ) );
    -      }
    -
    -      return jsonml;
    -    },
    -
    -    // There are two types of lists. Tight and loose. Tight lists have no whitespace
    -    // between the items (and result in text just in the 
  • ) and loose lists, - // which have an empty line between list items, resulting in (one or more) - // paragraphs inside the
  • . - // - // There are all sorts weird edge cases about the original markdown.pl's - // handling of lists: - // - // * Nested lists are supposed to be indented by four chars per level. But - // if they aren't, you can get a nested list by indenting by less than - // four so long as the indent doesn't match an indent of an existing list - // item in the 'nest stack'. - // - // * The type of the list (bullet or number) is controlled just by the - // first item at the indent. Subsequent changes are ignored unless they - // are for nested lists - // - lists: (function( ) { - // Use a closure to hide a few variables. - var any_list = "[*+-]|\\d+\\.", - bullet_list = /[*+-]/, - number_list = /\d+\./, - // Capture leading indent as it matters for determining nested lists. - is_list_re = new RegExp( "^( {0,3})(" + any_list + ")[ \t]+" ), - indent_re = "(?: {0,3}\\t| {4})"; - - // TODO: Cache this regexp for certain depths. - // Create a regexp suitable for matching an li for a given stack depth - function regex_for_depth( depth ) { - - return new RegExp( - // m[1] = indent, m[2] = list_type - "(?:^(" + indent_re + "{0," + depth + "} {0,3})(" + any_list + ")\\s+)|" + - // m[3] = cont - "(^" + indent_re + "{0," + (depth-1) + "}[ ]{0,4})" - ); - } - function expand_tab( input ) { - return input.replace( / {0,3}\t/g, " " ); - } - - // Add inline content `inline` to `li`. inline comes from processInline - // so is an array of content - function add(li, loose, inline, nl) { - if ( loose ) { - li.push( [ "para" ].concat(inline) ); - return; - } - // Hmmm, should this be any block level element or just paras? - var add_to = li[li.length -1] instanceof Array && li[li.length - 1][0] == "para" - ? li[li.length -1] - : li; - - // If there is already some content in this list, add the new line in - if ( nl && li.length > 1 ) inline.unshift(nl); - - for ( var i = 0; i < inline.length; i++ ) { - var what = inline[i], - is_str = typeof what == "string"; - if ( is_str && add_to.length > 1 && typeof add_to[add_to.length-1] == "string" ) { - add_to[ add_to.length-1 ] += what; - } - else { - add_to.push( what ); - } - } - } - - // contained means have an indent greater than the current one. On - // *every* line in the block - function get_contained_blocks( depth, blocks ) { - - var re = new RegExp( "^(" + indent_re + "{" + depth + "}.*?\\n?)*$" ), - replace = new RegExp("^" + indent_re + "{" + depth + "}", "gm"), - ret = []; - - while ( blocks.length > 0 ) { - if ( re.exec( blocks[0] ) ) { - var b = blocks.shift(), - // Now remove that indent - x = b.replace( replace, ""); - - ret.push( mk_block( x, b.trailing, b.lineNumber ) ); - } - else { - break; - } - } - return ret; - } - - // passed to stack.forEach to turn list items up the stack into paras - function paragraphify(s, i, stack) { - var list = s.list; - var last_li = list[list.length-1]; - - if ( last_li[1] instanceof Array && last_li[1][0] == "para" ) { - return; - } - if ( i + 1 == stack.length ) { - // Last stack frame - // Keep the same array, but replace the contents - last_li.push( ["para"].concat( last_li.splice(1, last_li.length - 1) ) ); - } - else { - var sublist = last_li.pop(); - last_li.push( ["para"].concat( last_li.splice(1, last_li.length - 1) ), sublist ); - } - } - - // The matcher function - return function( block, next ) { - var m = block.match( is_list_re ); - if ( !m ) return undefined; - - function make_list( m ) { - var list = bullet_list.exec( m[2] ) - ? ["bulletlist"] - : ["numberlist"]; - - stack.push( { list: list, indent: m[1] } ); - return list; - } - - - var stack = [], // Stack of lists for nesting. - list = make_list( m ), - last_li, - loose = false, - ret = [ stack[0].list ], - i; - - // Loop to search over block looking for inner block elements and loose lists - loose_search: - while ( true ) { - // Split into lines preserving new lines at end of line - var lines = block.split( /(?=\n)/ ); - - // We have to grab all lines for a li and call processInline on them - // once as there are some inline things that can span lines. - var li_accumulate = ""; - - // Loop over the lines in this block looking for tight lists. - tight_search: - for ( var line_no = 0; line_no < lines.length; line_no++ ) { - var nl = "", - l = lines[line_no].replace(/^\n/, function(n) { nl = n; return ""; }); - - // TODO: really should cache this - var line_re = regex_for_depth( stack.length ); - - m = l.match( line_re ); - //print( "line:", uneval(l), "\nline match:", uneval(m) ); - - // We have a list item - if ( m[1] !== undefined ) { - // Process the previous list item, if any - if ( li_accumulate.length ) { - add( last_li, loose, this.processInline( li_accumulate ), nl ); - // Loose mode will have been dealt with. Reset it - loose = false; - li_accumulate = ""; - } - - m[1] = expand_tab( m[1] ); - var wanted_depth = Math.floor(m[1].length/4)+1; - //print( "want:", wanted_depth, "stack:", stack.length); - if ( wanted_depth > stack.length ) { - // Deep enough for a nested list outright - //print ( "new nested list" ); - list = make_list( m ); - last_li.push( list ); - last_li = list[1] = [ "listitem" ]; - } - else { - // We aren't deep enough to be strictly a new level. This is - // where Md.pl goes nuts. If the indent matches a level in the - // stack, put it there, else put it one deeper then the - // wanted_depth deserves. - var found = false; - for ( i = 0; i < stack.length; i++ ) { - if ( stack[ i ].indent != m[1] ) continue; - list = stack[ i ].list; - stack.splice( i+1, stack.length - (i+1) ); - found = true; - break; - } - - if (!found) { - //print("not found. l:", uneval(l)); - wanted_depth++; - if ( wanted_depth <= stack.length ) { - stack.splice(wanted_depth, stack.length - wanted_depth); - //print("Desired depth now", wanted_depth, "stack:", stack.length); - list = stack[wanted_depth-1].list; - //print("list:", uneval(list) ); - } - else { - //print ("made new stack for messy indent"); - list = make_list(m); - last_li.push(list); - } - } - - //print( uneval(list), "last", list === stack[stack.length-1].list ); - last_li = [ "listitem" ]; - list.push(last_li); - } // end depth of shenegains - nl = ""; - } - - // Add content - if ( l.length > m[0].length ) { - li_accumulate += nl + l.substr( m[0].length ); - } - } // tight_search - - if ( li_accumulate.length ) { - add( last_li, loose, this.processInline( li_accumulate ), nl ); - // Loose mode will have been dealt with. Reset it - loose = false; - li_accumulate = ""; - } - - // Look at the next block - we might have a loose list. Or an extra - // paragraph for the current li - var contained = get_contained_blocks( stack.length, next ); - - // Deal with code blocks or properly nested lists - if ( contained.length > 0 ) { - // Make sure all listitems up the stack are paragraphs - forEach( stack, paragraphify, this); - - last_li.push.apply( last_li, this.toTree( contained, [] ) ); - } - - var next_block = next[0] && next[0].valueOf() || ""; - - if ( next_block.match(is_list_re) || next_block.match( /^ / ) ) { - block = next.shift(); - - // Check for an HR following a list: features/lists/hr_abutting - var hr = this.dialect.block.horizRule( block, next ); - - if ( hr ) { - ret.push.apply(ret, hr); - break; - } - - // Make sure all listitems up the stack are paragraphs - forEach( stack, paragraphify, this); - - loose = true; - continue loose_search; - } - break; - } // loose_search - - return ret; - }; - })(), - - blockquote: function blockquote( block, next ) { - if ( !block.match( /^>/m ) ) - return undefined; - - var jsonml = []; - - // separate out the leading abutting block, if any. I.e. in this case: - // - // a - // > b - // - if ( block[ 0 ] != ">" ) { - var lines = block.split( /\n/ ), - prev = [], - line_no = block.lineNumber; - - // keep shifting lines until you find a crotchet - while ( lines.length && lines[ 0 ][ 0 ] != ">" ) { - prev.push( lines.shift() ); - line_no++; - } - - var abutting = mk_block( prev.join( "\n" ), "\n", block.lineNumber ); - jsonml.push.apply( jsonml, this.processBlock( abutting, [] ) ); - // reassemble new block of just block quotes! - block = mk_block( lines.join( "\n" ), block.trailing, line_no ); - } - - - // if the next block is also a blockquote merge it in - while ( next.length && next[ 0 ][ 0 ] == ">" ) { - var b = next.shift(); - block = mk_block( block + block.trailing + b, b.trailing, block.lineNumber ); - } - - // Strip off the leading "> " and re-process as a block. - var input = block.replace( /^> ?/gm, "" ), - old_tree = this.tree, - processedBlock = this.toTree( input, [ "blockquote" ] ), - attr = extract_attr( processedBlock ); - - // If any link references were found get rid of them - if ( attr && attr.references ) { - delete attr.references; - // And then remove the attribute object if it's empty - if ( isEmpty( attr ) ) { - processedBlock.splice( 1, 1 ); - } - } - - jsonml.push( processedBlock ); - return jsonml; - }, - - referenceDefn: function referenceDefn( block, next) { - var re = /^\s*\[(.*?)\]:\s*(\S+)(?:\s+(?:(['"])(.*?)\3|\((.*?)\)))?\n?/; - // interesting matches are [ , ref_id, url, , title, title ] - - if ( !block.match(re) ) - return undefined; - - // make an attribute node if it doesn't exist - if ( !extract_attr( this.tree ) ) { - this.tree.splice( 1, 0, {} ); - } - - var attrs = extract_attr( this.tree ); - - // make a references hash if it doesn't exist - if ( attrs.references === undefined ) { - attrs.references = {}; - } - - var b = this.loop_re_over_block(re, block, function( m ) { - - if ( m[2] && m[2][0] == "<" && m[2][m[2].length-1] == ">" ) - m[2] = m[2].substring( 1, m[2].length - 1 ); - - var ref = attrs.references[ m[1].toLowerCase() ] = { - href: m[2] - }; - - if ( m[4] !== undefined ) - ref.title = m[4]; - else if ( m[5] !== undefined ) - ref.title = m[5]; - - } ); - - if ( b.length ) - next.unshift( mk_block( b, block.trailing ) ); - - return []; - }, - - para: function para( block, next ) { - // everything's a para! - return [ ["para"].concat( this.processInline( block ) ) ]; - } - } -}; - -Markdown.dialects.Gruber.inline = { - - __oneElement__: function oneElement( text, patterns_or_re, previous_nodes ) { - var m, - res, - lastIndex = 0; - - patterns_or_re = patterns_or_re || this.dialect.inline.__patterns__; - var re = new RegExp( "([\\s\\S]*?)(" + (patterns_or_re.source || patterns_or_re) + ")" ); - - m = re.exec( text ); - if (!m) { - // Just boring text - return [ text.length, text ]; - } - else if ( m[1] ) { - // Some un-interesting text matched. Return that first - return [ m[1].length, m[1] ]; - } - - var res; - if ( m[2] in this.dialect.inline ) { - res = this.dialect.inline[ m[2] ].call( - this, - text.substr( m.index ), m, previous_nodes || [] ); - } - // Default for now to make dev easier. just slurp special and output it. - res = res || [ m[2].length, m[2] ]; - return res; - }, - - __call__: function inline( text, patterns ) { - - var out = [], - res; - - function add(x) { - //D:self.debug(" adding output", uneval(x)); - if ( typeof x == "string" && typeof out[out.length-1] == "string" ) - out[ out.length-1 ] += x; - else - out.push(x); - } - - while ( text.length > 0 ) { - res = this.dialect.inline.__oneElement__.call(this, text, patterns, out ); - text = text.substr( res.shift() ); - forEach(res, add ) - } - - return out; - }, - - // These characters are intersting elsewhere, so have rules for them so that - // chunks of plain text blocks don't include them - "]": function () {}, - "}": function () {}, - - __escape__ : /^\\[\\`\*_{}\[\]()#\+.!\-]/, - - "\\": function escaped( text ) { - // [ length of input processed, node/children to add... ] - // Only esacape: \ ` * _ { } [ ] ( ) # * + - . ! - if ( this.dialect.inline.__escape__.exec( text ) ) - return [ 2, text.charAt( 1 ) ]; - else - // Not an esacpe - return [ 1, "\\" ]; - }, - - "![": function image( text ) { - - // Unlike images, alt text is plain text only. no other elements are - // allowed in there - - // ![Alt text](/path/to/img.jpg "Optional title") - // 1 2 3 4 <--- captures - var m = text.match( /^!\[(.*?)\][ \t]*\([ \t]*([^")]*?)(?:[ \t]+(["'])(.*?)\3)?[ \t]*\)/ ); - - if ( m ) { - if ( m[2] && m[2][0] == "<" && m[2][m[2].length-1] == ">" ) - m[2] = m[2].substring( 1, m[2].length - 1 ); - - m[2] = this.dialect.inline.__call__.call( this, m[2], /\\/ )[0]; - - var attrs = { alt: m[1], href: m[2] || "" }; - if ( m[4] !== undefined) - attrs.title = m[4]; - - return [ m[0].length, [ "img", attrs ] ]; - } - - // ![Alt text][id] - m = text.match( /^!\[(.*?)\][ \t]*\[(.*?)\]/ ); - - if ( m ) { - // We can't check if the reference is known here as it likely wont be - // found till after. Check it in md tree->hmtl tree conversion - return [ m[0].length, [ "img_ref", { alt: m[1], ref: m[2].toLowerCase(), original: m[0] } ] ]; - } - - // Just consume the '![' - return [ 2, "![" ]; - }, - - "[": function link( text ) { - - var orig = String(text); - // Inline content is possible inside `link text` - var res = Markdown.DialectHelpers.inline_until_char.call( this, text.substr(1), "]" ); - - // No closing ']' found. Just consume the [ - if ( !res ) return [ 1, "[" ]; - - var consumed = 1 + res[ 0 ], - children = res[ 1 ], - link, - attrs; - - // At this point the first [...] has been parsed. See what follows to find - // out which kind of link we are (reference or direct url) - text = text.substr( consumed ); - - // [link text](/path/to/img.jpg "Optional title") - // 1 2 3 <--- captures - // This will capture up to the last paren in the block. We then pull - // back based on if there a matching ones in the url - // ([here](/url/(test)) - // The parens have to be balanced - var m = text.match( /^\s*\([ \t]*([^"']*)(?:[ \t]+(["'])(.*?)\2)?[ \t]*\)/ ); - if ( m ) { - var url = m[1]; - consumed += m[0].length; - - if ( url && url[0] == "<" && url[url.length-1] == ">" ) - url = url.substring( 1, url.length - 1 ); - - // If there is a title we don't have to worry about parens in the url - if ( !m[3] ) { - var open_parens = 1; // One open that isn't in the capture - for ( var len = 0; len < url.length; len++ ) { - switch ( url[len] ) { - case "(": - open_parens++; - break; - case ")": - if ( --open_parens == 0) { - consumed -= url.length - len; - url = url.substring(0, len); - } - break; - } - } - } - - // Process escapes only - url = this.dialect.inline.__call__.call( this, url, /\\/ )[0]; - - attrs = { href: url || "" }; - if ( m[3] !== undefined) - attrs.title = m[3]; - - link = [ "link", attrs ].concat( children ); - return [ consumed, link ]; - } - - // [Alt text][id] - // [Alt text] [id] - m = text.match( /^\s*\[(.*?)\]/ ); - - if ( m ) { - - consumed += m[ 0 ].length; - - // [links][] uses links as its reference - attrs = { ref: ( m[ 1 ] || String(children) ).toLowerCase(), original: orig.substr( 0, consumed ) }; - - link = [ "link_ref", attrs ].concat( children ); - - // We can't check if the reference is known here as it likely wont be - // found till after. Check it in md tree->hmtl tree conversion. - // Store the original so that conversion can revert if the ref isn't found. - return [ consumed, link ]; - } - - // [id] - // Only if id is plain (no formatting.) - if ( children.length == 1 && typeof children[0] == "string" ) { - - attrs = { ref: children[0].toLowerCase(), original: orig.substr( 0, consumed ) }; - link = [ "link_ref", attrs, children[0] ]; - return [ consumed, link ]; - } - - // Just consume the "[" - return [ 1, "[" ]; - }, - - - "<": function autoLink( text ) { - var m; - - if ( ( m = text.match( /^<(?:((https?|ftp|mailto):[^>]+)|(.*?@.*?\.[a-zA-Z]+))>/ ) ) != null ) { - if ( m[3] ) { - return [ m[0].length, [ "link", { href: "mailto:" + m[3] }, m[3] ] ]; - - } - else if ( m[2] == "mailto" ) { - return [ m[0].length, [ "link", { href: m[1] }, m[1].substr("mailto:".length ) ] ]; - } - else - return [ m[0].length, [ "link", { href: m[1] }, m[1] ] ]; - } - - return [ 1, "<" ]; - }, - - "`": function inlineCode( text ) { - // Inline code block. as many backticks as you like to start it - // Always skip over the opening ticks. - var m = text.match( /(`+)(([\s\S]*?)\1)/ ); - - if ( m && m[2] ) - return [ m[1].length + m[2].length, [ "inlinecode", m[3] ] ]; - else { - // TODO: No matching end code found - warn! - return [ 1, "`" ]; - } - }, - - " \n": function lineBreak( text ) { - return [ 3, [ "linebreak" ] ]; - } - -}; - -// Meta Helper/generator method for em and strong handling -function strong_em( tag, md ) { - - var state_slot = tag + "_state", - other_slot = tag == "strong" ? "em_state" : "strong_state"; - - function CloseTag(len) { - this.len_after = len; - this.name = "close_" + md; - } - - return function ( text, orig_match ) { - - if ( this[state_slot][0] == md ) { - // Most recent em is of this type - //D:this.debug("closing", md); - this[state_slot].shift(); - - // "Consume" everything to go back to the recrusion in the else-block below - return[ text.length, new CloseTag(text.length-md.length) ]; - } - else { - // Store a clone of the em/strong states - var other = this[other_slot].slice(), - state = this[state_slot].slice(); - - this[state_slot].unshift(md); - - //D:this.debug_indent += " "; - - // Recurse - var res = this.processInline( text.substr( md.length ) ); - //D:this.debug_indent = this.debug_indent.substr(2); - - var last = res[res.length - 1]; - - //D:this.debug("processInline from", tag + ": ", uneval( res ) ); - - var check = this[state_slot].shift(); - if ( last instanceof CloseTag ) { - res.pop(); - // We matched! Huzzah. - var consumed = text.length - last.len_after; - return [ consumed, [ tag ].concat(res) ]; - } - else { - // Restore the state of the other kind. We might have mistakenly closed it. - this[other_slot] = other; - this[state_slot] = state; - - // We can't reuse the processed result as it could have wrong parsing contexts in it. - return [ md.length, md ]; - } - } - }; // End returned function -} - -Markdown.dialects.Gruber.inline["**"] = strong_em("strong", "**"); -Markdown.dialects.Gruber.inline["__"] = strong_em("strong", "__"); -Markdown.dialects.Gruber.inline["*"] = strong_em("em", "*"); -Markdown.dialects.Gruber.inline["_"] = strong_em("em", "_"); - - -// Build default order from insertion order. -Markdown.buildBlockOrder = function(d) { - var ord = []; - for ( var i in d ) { - if ( i == "__order__" || i == "__call__" ) continue; - ord.push( i ); - } - d.__order__ = ord; -}; - -// Build patterns for inline matcher -Markdown.buildInlinePatterns = function(d) { - var patterns = []; - - for ( var i in d ) { - // __foo__ is reserved and not a pattern - if ( i.match( /^__.*__$/) ) continue; - var l = i.replace( /([\\.*+?|()\[\]{}])/g, "\\$1" ) - .replace( /\n/, "\\n" ); - patterns.push( i.length == 1 ? l : "(?:" + l + ")" ); - } - - patterns = patterns.join("|"); - d.__patterns__ = patterns; - //print("patterns:", uneval( patterns ) ); - - var fn = d.__call__; - d.__call__ = function(text, pattern) { - if ( pattern != undefined ) { - return fn.call(this, text, pattern); - } - else - { - return fn.call(this, text, patterns); - } - }; -}; - -Markdown.DialectHelpers = {}; -Markdown.DialectHelpers.inline_until_char = function( text, want ) { - var consumed = 0, - nodes = []; - - while ( true ) { - if ( text.charAt( consumed ) == want ) { - // Found the character we were looking for - consumed++; - return [ consumed, nodes ]; - } - - if ( consumed >= text.length ) { - // No closing char found. Abort. - return null; - } - - var res = this.dialect.inline.__oneElement__.call(this, text.substr( consumed ) ); - consumed += res[ 0 ]; - // Add any returned nodes. - nodes.push.apply( nodes, res.slice( 1 ) ); - } -} - -// Helper function to make sub-classing a dialect easier -Markdown.subclassDialect = function( d ) { - function Block() {} - Block.prototype = d.block; - function Inline() {} - Inline.prototype = d.inline; - - return { block: new Block(), inline: new Inline() }; -}; - -Markdown.buildBlockOrder ( Markdown.dialects.Gruber.block ); -Markdown.buildInlinePatterns( Markdown.dialects.Gruber.inline ); - -Markdown.dialects.Maruku = Markdown.subclassDialect( Markdown.dialects.Gruber ); - -Markdown.dialects.Maruku.processMetaHash = function processMetaHash( meta_string ) { - var meta = split_meta_hash( meta_string ), - attr = {}; - - for ( var i = 0; i < meta.length; ++i ) { - // id: #foo - if ( /^#/.test( meta[ i ] ) ) { - attr.id = meta[ i ].substring( 1 ); - } - // class: .foo - else if ( /^\./.test( meta[ i ] ) ) { - // if class already exists, append the new one - if ( attr["class"] ) { - attr["class"] = attr["class"] + meta[ i ].replace( /./, " " ); - } - else { - attr["class"] = meta[ i ].substring( 1 ); - } - } - // attribute: foo=bar - else if ( /\=/.test( meta[ i ] ) ) { - var s = meta[ i ].split( /\=/ ); - attr[ s[ 0 ] ] = s[ 1 ]; - } - } - - return attr; -} - -function split_meta_hash( meta_string ) { - var meta = meta_string.split( "" ), - parts = [ "" ], - in_quotes = false; - - while ( meta.length ) { - var letter = meta.shift(); - switch ( letter ) { - case " " : - // if we're in a quoted section, keep it - if ( in_quotes ) { - parts[ parts.length - 1 ] += letter; - } - // otherwise make a new part - else { - parts.push( "" ); - } - break; - case "'" : - case '"' : - // reverse the quotes and move straight on - in_quotes = !in_quotes; - break; - case "\\" : - // shift off the next letter to be used straight away. - // it was escaped so we'll keep it whatever it is - letter = meta.shift(); - default : - parts[ parts.length - 1 ] += letter; - break; - } - } - - return parts; -} - -Markdown.dialects.Maruku.block.document_meta = function document_meta( block, next ) { - // we're only interested in the first block - if ( block.lineNumber > 1 ) return undefined; - - // document_meta blocks consist of one or more lines of `Key: Value\n` - if ( ! block.match( /^(?:\w+:.*\n)*\w+:.*$/ ) ) return undefined; - - // make an attribute node if it doesn't exist - if ( !extract_attr( this.tree ) ) { - this.tree.splice( 1, 0, {} ); - } - - var pairs = block.split( /\n/ ); - for ( p in pairs ) { - var m = pairs[ p ].match( /(\w+):\s*(.*)$/ ), - key = m[ 1 ].toLowerCase(), - value = m[ 2 ]; - - this.tree[ 1 ][ key ] = value; - } - - // document_meta produces no content! - return []; -}; - -Markdown.dialects.Maruku.block.block_meta = function block_meta( block, next ) { - // check if the last line of the block is an meta hash - var m = block.match( /(^|\n) {0,3}\{:\s*((?:\\\}|[^\}])*)\s*\}$/ ); - if ( !m ) return undefined; - - // process the meta hash - var attr = this.dialect.processMetaHash( m[ 2 ] ); - - var hash; - - // if we matched ^ then we need to apply meta to the previous block - if ( m[ 1 ] === "" ) { - var node = this.tree[ this.tree.length - 1 ]; - hash = extract_attr( node ); - - // if the node is a string (rather than JsonML), bail - if ( typeof node === "string" ) return undefined; - - // create the attribute hash if it doesn't exist - if ( !hash ) { - hash = {}; - node.splice( 1, 0, hash ); - } - - // add the attributes in - for ( a in attr ) { - hash[ a ] = attr[ a ]; - } - - // return nothing so the meta hash is removed - return []; - } - - // pull the meta hash off the block and process what's left - var b = block.replace( /\n.*$/, "" ), - result = this.processBlock( b, [] ); - - // get or make the attributes hash - hash = extract_attr( result[ 0 ] ); - if ( !hash ) { - hash = {}; - result[ 0 ].splice( 1, 0, hash ); - } - - // attach the attributes to the block - for ( a in attr ) { - hash[ a ] = attr[ a ]; - } - - return result; -}; - -Markdown.dialects.Maruku.block.definition_list = function definition_list( block, next ) { - // one or more terms followed by one or more definitions, in a single block - var tight = /^((?:[^\s:].*\n)+):\s+([\s\S]+)$/, - list = [ "dl" ], - i, m; - - // see if we're dealing with a tight or loose block - if ( ( m = block.match( tight ) ) ) { - // pull subsequent tight DL blocks out of `next` - var blocks = [ block ]; - while ( next.length && tight.exec( next[ 0 ] ) ) { - blocks.push( next.shift() ); - } - - for ( var b = 0; b < blocks.length; ++b ) { - var m = blocks[ b ].match( tight ), - terms = m[ 1 ].replace( /\n$/, "" ).split( /\n/ ), - defns = m[ 2 ].split( /\n:\s+/ ); - - // print( uneval( m ) ); - - for ( i = 0; i < terms.length; ++i ) { - list.push( [ "dt", terms[ i ] ] ); - } - - for ( i = 0; i < defns.length; ++i ) { - // run inline processing over the definition - list.push( [ "dd" ].concat( this.processInline( defns[ i ].replace( /(\n)\s+/, "$1" ) ) ) ); - } - } - } - else { - return undefined; - } - - return [ list ]; -}; - -// splits on unescaped instances of @ch. If @ch is not a character the result -// can be unpredictable - -Markdown.dialects.Maruku.block.table = function table (block, next) { - - var _split_on_unescaped = function(s, ch) { - ch = ch || '\\s'; - if (ch.match(/^[\\|\[\]{}?*.+^$]$/)) { ch = '\\' + ch; } - var res = [ ], - r = new RegExp('^((?:\\\\.|[^\\\\' + ch + '])*)' + ch + '(.*)'), - m; - while(m = s.match(r)) { - res.push(m[1]); - s = m[2]; - } - res.push(s); - return res; - } - - var leading_pipe = /^ {0,3}\|(.+)\n {0,3}\|\s*([\-:]+[\-| :]*)\n((?:\s*\|.*(?:\n|$))*)(?=\n|$)/, - // find at least an unescaped pipe in each line - no_leading_pipe = /^ {0,3}(\S(?:\\.|[^\\|])*\|.*)\n {0,3}([\-:]+\s*\|[\-| :]*)\n((?:(?:\\.|[^\\|])*\|.*(?:\n|$))*)(?=\n|$)/, - i, m; - if (m = block.match(leading_pipe)) { - // remove leading pipes in contents - // (header and horizontal rule already have the leading pipe left out) - m[3] = m[3].replace(/^\s*\|/gm, ''); - } else if (! ( m = block.match(no_leading_pipe))) { - return undefined; - } - - var table = [ "table", [ "thead", [ "tr" ] ], [ "tbody" ] ]; - - // remove trailing pipes, then split on pipes - // (no escaped pipes are allowed in horizontal rule) - m[2] = m[2].replace(/\|\s*$/, '').split('|'); - - // process alignment - var html_attrs = [ ]; - forEach (m[2], function (s) { - if (s.match(/^\s*-+:\s*$/)) html_attrs.push({align: "right"}); - else if (s.match(/^\s*:-+\s*$/)) html_attrs.push({align: "left"}); - else if (s.match(/^\s*:-+:\s*$/)) html_attrs.push({align: "center"}); - else html_attrs.push({}); - }); - - // now for the header, avoid escaped pipes - m[1] = _split_on_unescaped(m[1].replace(/\|\s*$/, ''), '|'); - for (i = 0; i < m[1].length; i++) { - table[1][1].push(['th', html_attrs[i] || {}].concat( - this.processInline(m[1][i].trim()))); - } - - // now for body contents - forEach (m[3].replace(/\|\s*$/mg, '').split('\n'), function (row) { - var html_row = ['tr']; - row = _split_on_unescaped(row, '|'); - for (i = 0; i < row.length; i++) { - html_row.push(['td', html_attrs[i] || {}].concat(this.processInline(row[i].trim()))); - } - table[2].push(html_row); - }, this); - - return [table]; -} - -Markdown.dialects.Maruku.inline[ "{:" ] = function inline_meta( text, matches, out ) { - if ( !out.length ) { - return [ 2, "{:" ]; - } - - // get the preceeding element - var before = out[ out.length - 1 ]; - - if ( typeof before === "string" ) { - return [ 2, "{:" ]; - } - - // match a meta hash - var m = text.match( /^\{:\s*((?:\\\}|[^\}])*)\s*\}/ ); - - // no match, false alarm - if ( !m ) { - return [ 2, "{:" ]; - } - - // attach the attributes to the preceeding element - var meta = this.dialect.processMetaHash( m[ 1 ] ), - attr = extract_attr( before ); - - if ( !attr ) { - attr = {}; - before.splice( 1, 0, attr ); - } - - for ( var k in meta ) { - attr[ k ] = meta[ k ]; - } - - // cut out the string and replace it with nothing - return [ m[ 0 ].length, "" ]; -}; - -Markdown.dialects.Maruku.inline.__escape__ = /^\\[\\`\*_{}\[\]()#\+.!\-|:]/; - -Markdown.buildBlockOrder ( Markdown.dialects.Maruku.block ); -Markdown.buildInlinePatterns( Markdown.dialects.Maruku.inline ); - -var isArray = Array.isArray || function(obj) { - return Object.prototype.toString.call(obj) == "[object Array]"; -}; - -var forEach; -// Don't mess with Array.prototype. Its not friendly -if ( Array.prototype.forEach ) { - forEach = function( arr, cb, thisp ) { - return arr.forEach( cb, thisp ); - }; -} -else { - forEach = function(arr, cb, thisp) { - for (var i = 0; i < arr.length; i++) { - cb.call(thisp || arr, arr[i], i, arr); - } - } -} - -var isEmpty = function( obj ) { - for ( var key in obj ) { - if ( hasOwnProperty.call( obj, key ) ) { - return false; - } - } - - return true; -} - -function extract_attr( jsonml ) { - return isArray(jsonml) - && jsonml.length > 1 - && typeof jsonml[ 1 ] === "object" - && !( isArray(jsonml[ 1 ]) ) - ? jsonml[ 1 ] - : undefined; -} - - - -/** - * renderJsonML( jsonml[, options] ) -> String - * - jsonml (Array): JsonML array to render to XML - * - options (Object): options - * - * Converts the given JsonML into well-formed XML. - * - * The options currently understood are: - * - * - root (Boolean): wether or not the root node should be included in the - * output, or just its children. The default `false` is to not include the - * root itself. - */ -expose.renderJsonML = function( jsonml, options ) { - options = options || {}; - // include the root element in the rendered output? - options.root = options.root || false; - - var content = []; - - if ( options.root ) { - content.push( render_tree( jsonml ) ); - } - else { - jsonml.shift(); // get rid of the tag - if ( jsonml.length && typeof jsonml[ 0 ] === "object" && !( jsonml[ 0 ] instanceof Array ) ) { - jsonml.shift(); // get rid of the attributes - } - - while ( jsonml.length ) { - content.push( render_tree( jsonml.shift() ) ); - } - } - - return content.join( "\n\n" ); -}; - -function escapeHTML( text ) { - return text.replace( /&/g, "&" ) - .replace( //g, ">" ) - .replace( /"/g, """ ) - .replace( /'/g, "'" ); -} - -function render_tree( jsonml ) { - // basic case - if ( typeof jsonml === "string" ) { - return escapeHTML( jsonml ); - } - - var tag = jsonml.shift(), - attributes = {}, - content = []; - - if ( jsonml.length && typeof jsonml[ 0 ] === "object" && !( jsonml[ 0 ] instanceof Array ) ) { - attributes = jsonml.shift(); - } - - while ( jsonml.length ) { - content.push( render_tree( jsonml.shift() ) ); - } - - var tag_attrs = ""; - for ( var a in attributes ) { - tag_attrs += " " + a + '="' + escapeHTML( attributes[ a ] ) + '"'; - } - - // be careful about adding whitespace here for inline elements - if ( tag == "img" || tag == "br" || tag == "hr" ) { - return "<"+ tag + tag_attrs + "/>"; - } - else { - return "<"+ tag + tag_attrs + ">" + content.join( "" ) + ""; - } -} - -function convert_tree_to_html( tree, references, options ) { - var i; - options = options || {}; - - // shallow clone - var jsonml = tree.slice( 0 ); - - if ( typeof options.preprocessTreeNode === "function" ) { - jsonml = options.preprocessTreeNode(jsonml, references); - } - - // Clone attributes if they exist - var attrs = extract_attr( jsonml ); - if ( attrs ) { - jsonml[ 1 ] = {}; - for ( i in attrs ) { - jsonml[ 1 ][ i ] = attrs[ i ]; - } - attrs = jsonml[ 1 ]; - } - - // basic case - if ( typeof jsonml === "string" ) { - return jsonml; - } - - // convert this node - switch ( jsonml[ 0 ] ) { - case "header": - jsonml[ 0 ] = "h" + jsonml[ 1 ].level; - delete jsonml[ 1 ].level; - break; - case "bulletlist": - jsonml[ 0 ] = "ul"; - break; - case "numberlist": - jsonml[ 0 ] = "ol"; - break; - case "listitem": - jsonml[ 0 ] = "li"; - break; - case "para": - jsonml[ 0 ] = "p"; - break; - case "markdown": - jsonml[ 0 ] = "html"; - if ( attrs ) delete attrs.references; - break; - case "code_block": - jsonml[ 0 ] = "pre"; - i = attrs ? 2 : 1; - var code = [ "code" ]; - code.push.apply( code, jsonml.splice( i, jsonml.length - i ) ); - jsonml[ i ] = code; - break; - case "inlinecode": - jsonml[ 0 ] = "code"; - break; - case "img": - jsonml[ 1 ].src = jsonml[ 1 ].href; - delete jsonml[ 1 ].href; - break; - case "linebreak": - jsonml[ 0 ] = "br"; - break; - case "link": - jsonml[ 0 ] = "a"; - break; - case "link_ref": - jsonml[ 0 ] = "a"; - - // grab this ref and clean up the attribute node - var ref = references[ attrs.ref ]; - - // if the reference exists, make the link - if ( ref ) { - delete attrs.ref; - - // add in the href and title, if present - attrs.href = ref.href; - if ( ref.title ) { - attrs.title = ref.title; - } - - // get rid of the unneeded original text - delete attrs.original; - } - // the reference doesn't exist, so revert to plain text - else { - return attrs.original; - } - break; - case "img_ref": - jsonml[ 0 ] = "img"; - - // grab this ref and clean up the attribute node - var ref = references[ attrs.ref ]; - - // if the reference exists, make the link - if ( ref ) { - delete attrs.ref; - - // add in the href and title, if present - attrs.src = ref.href; - if ( ref.title ) { - attrs.title = ref.title; - } - - // get rid of the unneeded original text - delete attrs.original; - } - // the reference doesn't exist, so revert to plain text - else { - return attrs.original; - } - break; - } - - // convert all the children - i = 1; - - // deal with the attribute node, if it exists - if ( attrs ) { - // if there are keys, skip over it - for ( var key in jsonml[ 1 ] ) { - i = 2; - break; - } - // if there aren't, remove it - if ( i === 1 ) { - jsonml.splice( i, 1 ); - } - } - - for ( ; i < jsonml.length; ++i ) { - jsonml[ i ] = convert_tree_to_html( jsonml[ i ], references, options ); - } - - return jsonml; -} - - -// merges adjacent text nodes into a single node -function merge_text_nodes( jsonml ) { - // skip the tag name and attribute hash - var i = extract_attr( jsonml ) ? 2 : 1; - - while ( i < jsonml.length ) { - // if it's a string check the next item too - if ( typeof jsonml[ i ] === "string" ) { - if ( i + 1 < jsonml.length && typeof jsonml[ i + 1 ] === "string" ) { - // merge the second string into the first and remove it - jsonml[ i ] += jsonml.splice( i + 1, 1 )[ 0 ]; - } - else { - ++i; - } - } - // if it's not a string recurse - else { - merge_text_nodes( jsonml[ i ] ); - ++i; - } - } -} - -} )( (function() { - if ( typeof exports === "undefined" ) { - window.markdown = {}; - return window.markdown; - } - else { - return exports; - } -} )() ); diff --git a/plugins/tiddlywiki/markdown/files/remarkable.js b/plugins/tiddlywiki/markdown/files/remarkable.js new file mode 100644 index 000000000..cebb38f56 --- /dev/null +++ b/plugins/tiddlywiki/markdown/files/remarkable.js @@ -0,0 +1 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).remarkable={})}(this,function(e){"use strict";var t={Aacute:"Á",aacute:"á",Abreve:"Ă",abreve:"ă",ac:"∾",acd:"∿",acE:"∾̳",Acirc:"Â",acirc:"â",acute:"´",Acy:"А",acy:"а",AElig:"Æ",aelig:"æ",af:"⁡",Afr:"𝔄",afr:"𝔞",Agrave:"À",agrave:"à",alefsym:"ℵ",aleph:"ℵ",Alpha:"Α",alpha:"α",Amacr:"Ā",amacr:"ā",amalg:"⨿",AMP:"&",amp:"&",And:"⩓",and:"∧",andand:"⩕",andd:"⩜",andslope:"⩘",andv:"⩚",ang:"∠",ange:"⦤",angle:"∠",angmsd:"∡",angmsdaa:"⦨",angmsdab:"⦩",angmsdac:"⦪",angmsdad:"⦫",angmsdae:"⦬",angmsdaf:"⦭",angmsdag:"⦮",angmsdah:"⦯",angrt:"∟",angrtvb:"⊾",angrtvbd:"⦝",angsph:"∢",angst:"Å",angzarr:"⍼",Aogon:"Ą",aogon:"ą",Aopf:"𝔸",aopf:"𝕒",ap:"≈",apacir:"⩯",apE:"⩰",ape:"≊",apid:"≋",apos:"'",ApplyFunction:"⁡",approx:"≈",approxeq:"≊",Aring:"Å",aring:"å",Ascr:"𝒜",ascr:"𝒶",Assign:"≔",ast:"*",asymp:"≈",asympeq:"≍",Atilde:"Ã",atilde:"ã",Auml:"Ä",auml:"ä",awconint:"∳",awint:"⨑",backcong:"≌",backepsilon:"϶",backprime:"‵",backsim:"∽",backsimeq:"⋍",Backslash:"∖",Barv:"⫧",barvee:"⊽",Barwed:"⌆",barwed:"⌅",barwedge:"⌅",bbrk:"⎵",bbrktbrk:"⎶",bcong:"≌",Bcy:"Б",bcy:"б",bdquo:"„",becaus:"∵",Because:"∵",because:"∵",bemptyv:"⦰",bepsi:"϶",bernou:"ℬ",Bernoullis:"ℬ",Beta:"Β",beta:"β",beth:"ℶ",between:"≬",Bfr:"𝔅",bfr:"𝔟",bigcap:"⋂",bigcirc:"◯",bigcup:"⋃",bigodot:"⨀",bigoplus:"⨁",bigotimes:"⨂",bigsqcup:"⨆",bigstar:"★",bigtriangledown:"▽",bigtriangleup:"△",biguplus:"⨄",bigvee:"⋁",bigwedge:"⋀",bkarow:"⤍",blacklozenge:"⧫",blacksquare:"▪",blacktriangle:"▴",blacktriangledown:"▾",blacktriangleleft:"◂",blacktriangleright:"▸",blank:"␣",blk12:"▒",blk14:"░",blk34:"▓",block:"█",bne:"=⃥",bnequiv:"≡⃥",bNot:"⫭",bnot:"⌐",Bopf:"𝔹",bopf:"𝕓",bot:"⊥",bottom:"⊥",bowtie:"⋈",boxbox:"⧉",boxDL:"╗",boxDl:"╖",boxdL:"╕",boxdl:"┐",boxDR:"╔",boxDr:"╓",boxdR:"╒",boxdr:"┌",boxH:"═",boxh:"─",boxHD:"╦",boxHd:"╤",boxhD:"╥",boxhd:"┬",boxHU:"╩",boxHu:"╧",boxhU:"╨",boxhu:"┴",boxminus:"⊟",boxplus:"⊞",boxtimes:"⊠",boxUL:"╝",boxUl:"╜",boxuL:"╛",boxul:"┘",boxUR:"╚",boxUr:"╙",boxuR:"╘",boxur:"└",boxV:"║",boxv:"│",boxVH:"╬",boxVh:"╫",boxvH:"╪",boxvh:"┼",boxVL:"╣",boxVl:"╢",boxvL:"╡",boxvl:"┤",boxVR:"╠",boxVr:"╟",boxvR:"╞",boxvr:"├",bprime:"‵",Breve:"˘",breve:"˘",brvbar:"¦",Bscr:"ℬ",bscr:"𝒷",bsemi:"⁏",bsim:"∽",bsime:"⋍",bsol:"\\",bsolb:"⧅",bsolhsub:"⟈",bull:"•",bullet:"•",bump:"≎",bumpE:"⪮",bumpe:"≏",Bumpeq:"≎",bumpeq:"≏",Cacute:"Ć",cacute:"ć",Cap:"⋒",cap:"∩",capand:"⩄",capbrcup:"⩉",capcap:"⩋",capcup:"⩇",capdot:"⩀",CapitalDifferentialD:"ⅅ",caps:"∩︀",caret:"⁁",caron:"ˇ",Cayleys:"ℭ",ccaps:"⩍",Ccaron:"Č",ccaron:"č",Ccedil:"Ç",ccedil:"ç",Ccirc:"Ĉ",ccirc:"ĉ",Cconint:"∰",ccups:"⩌",ccupssm:"⩐",Cdot:"Ċ",cdot:"ċ",cedil:"¸",Cedilla:"¸",cemptyv:"⦲",cent:"¢",CenterDot:"·",centerdot:"·",Cfr:"ℭ",cfr:"𝔠",CHcy:"Ч",chcy:"ч",check:"✓",checkmark:"✓",Chi:"Χ",chi:"χ",cir:"○",circ:"ˆ",circeq:"≗",circlearrowleft:"↺",circlearrowright:"↻",circledast:"⊛",circledcirc:"⊚",circleddash:"⊝",CircleDot:"⊙",circledR:"®",circledS:"Ⓢ",CircleMinus:"⊖",CirclePlus:"⊕",CircleTimes:"⊗",cirE:"⧃",cire:"≗",cirfnint:"⨐",cirmid:"⫯",cirscir:"⧂",ClockwiseContourIntegral:"∲",CloseCurlyDoubleQuote:"”",CloseCurlyQuote:"’",clubs:"♣",clubsuit:"♣",Colon:"∷",colon:":",Colone:"⩴",colone:"≔",coloneq:"≔",comma:",",commat:"@",comp:"∁",compfn:"∘",complement:"∁",complexes:"ℂ",cong:"≅",congdot:"⩭",Congruent:"≡",Conint:"∯",conint:"∮",ContourIntegral:"∮",Copf:"ℂ",copf:"𝕔",coprod:"∐",Coproduct:"∐",COPY:"©",copy:"©",copysr:"℗",CounterClockwiseContourIntegral:"∳",crarr:"↵",Cross:"⨯",cross:"✗",Cscr:"𝒞",cscr:"𝒸",csub:"⫏",csube:"⫑",csup:"⫐",csupe:"⫒",ctdot:"⋯",cudarrl:"⤸",cudarrr:"⤵",cuepr:"⋞",cuesc:"⋟",cularr:"↶",cularrp:"⤽",Cup:"⋓",cup:"∪",cupbrcap:"⩈",CupCap:"≍",cupcap:"⩆",cupcup:"⩊",cupdot:"⊍",cupor:"⩅",cups:"∪︀",curarr:"↷",curarrm:"⤼",curlyeqprec:"⋞",curlyeqsucc:"⋟",curlyvee:"⋎",curlywedge:"⋏",curren:"¤",curvearrowleft:"↶",curvearrowright:"↷",cuvee:"⋎",cuwed:"⋏",cwconint:"∲",cwint:"∱",cylcty:"⌭",Dagger:"‡",dagger:"†",daleth:"ℸ",Darr:"↡",dArr:"⇓",darr:"↓",dash:"‐",Dashv:"⫤",dashv:"⊣",dbkarow:"⤏",dblac:"˝",Dcaron:"Ď",dcaron:"ď",Dcy:"Д",dcy:"д",DD:"ⅅ",dd:"ⅆ",ddagger:"‡",ddarr:"⇊",DDotrahd:"⤑",ddotseq:"⩷",deg:"°",Del:"∇",Delta:"Δ",delta:"δ",demptyv:"⦱",dfisht:"⥿",Dfr:"𝔇",dfr:"𝔡",dHar:"⥥",dharl:"⇃",dharr:"⇂",DiacriticalAcute:"´",DiacriticalDot:"˙",DiacriticalDoubleAcute:"˝",DiacriticalGrave:"`",DiacriticalTilde:"˜",diam:"⋄",Diamond:"⋄",diamond:"⋄",diamondsuit:"♦",diams:"♦",die:"¨",DifferentialD:"ⅆ",digamma:"ϝ",disin:"⋲",div:"÷",divide:"÷",divideontimes:"⋇",divonx:"⋇",DJcy:"Ђ",djcy:"ђ",dlcorn:"⌞",dlcrop:"⌍",dollar:"$",Dopf:"𝔻",dopf:"𝕕",Dot:"¨",dot:"˙",DotDot:"⃜",doteq:"≐",doteqdot:"≑",DotEqual:"≐",dotminus:"∸",dotplus:"∔",dotsquare:"⊡",doublebarwedge:"⌆",DoubleContourIntegral:"∯",DoubleDot:"¨",DoubleDownArrow:"⇓",DoubleLeftArrow:"⇐",DoubleLeftRightArrow:"⇔",DoubleLeftTee:"⫤",DoubleLongLeftArrow:"⟸",DoubleLongLeftRightArrow:"⟺",DoubleLongRightArrow:"⟹",DoubleRightArrow:"⇒",DoubleRightTee:"⊨",DoubleUpArrow:"⇑",DoubleUpDownArrow:"⇕",DoubleVerticalBar:"∥",DownArrow:"↓",Downarrow:"⇓",downarrow:"↓",DownArrowBar:"⤓",DownArrowUpArrow:"⇵",DownBreve:"̑",downdownarrows:"⇊",downharpoonleft:"⇃",downharpoonright:"⇂",DownLeftRightVector:"⥐",DownLeftTeeVector:"⥞",DownLeftVector:"↽",DownLeftVectorBar:"⥖",DownRightTeeVector:"⥟",DownRightVector:"⇁",DownRightVectorBar:"⥗",DownTee:"⊤",DownTeeArrow:"↧",drbkarow:"⤐",drcorn:"⌟",drcrop:"⌌",Dscr:"𝒟",dscr:"𝒹",DScy:"Ѕ",dscy:"ѕ",dsol:"⧶",Dstrok:"Đ",dstrok:"đ",dtdot:"⋱",dtri:"▿",dtrif:"▾",duarr:"⇵",duhar:"⥯",dwangle:"⦦",DZcy:"Џ",dzcy:"џ",dzigrarr:"⟿",Eacute:"É",eacute:"é",easter:"⩮",Ecaron:"Ě",ecaron:"ě",ecir:"≖",Ecirc:"Ê",ecirc:"ê",ecolon:"≕",Ecy:"Э",ecy:"э",eDDot:"⩷",Edot:"Ė",eDot:"≑",edot:"ė",ee:"ⅇ",efDot:"≒",Efr:"𝔈",efr:"𝔢",eg:"⪚",Egrave:"È",egrave:"è",egs:"⪖",egsdot:"⪘",el:"⪙",Element:"∈",elinters:"⏧",ell:"ℓ",els:"⪕",elsdot:"⪗",Emacr:"Ē",emacr:"ē",empty:"∅",emptyset:"∅",EmptySmallSquare:"◻",emptyv:"∅",EmptyVerySmallSquare:"▫",emsp:" ",emsp13:" ",emsp14:" ",ENG:"Ŋ",eng:"ŋ",ensp:" ",Eogon:"Ę",eogon:"ę",Eopf:"𝔼",eopf:"𝕖",epar:"⋕",eparsl:"⧣",eplus:"⩱",epsi:"ε",Epsilon:"Ε",epsilon:"ε",epsiv:"ϵ",eqcirc:"≖",eqcolon:"≕",eqsim:"≂",eqslantgtr:"⪖",eqslantless:"⪕",Equal:"⩵",equals:"=",EqualTilde:"≂",equest:"≟",Equilibrium:"⇌",equiv:"≡",equivDD:"⩸",eqvparsl:"⧥",erarr:"⥱",erDot:"≓",Escr:"ℰ",escr:"ℯ",esdot:"≐",Esim:"⩳",esim:"≂",Eta:"Η",eta:"η",ETH:"Ð",eth:"ð",Euml:"Ë",euml:"ë",euro:"€",excl:"!",exist:"∃",Exists:"∃",expectation:"ℰ",ExponentialE:"ⅇ",exponentiale:"ⅇ",fallingdotseq:"≒",Fcy:"Ф",fcy:"ф",female:"♀",ffilig:"ffi",fflig:"ff",ffllig:"ffl",Ffr:"𝔉",ffr:"𝔣",filig:"fi",FilledSmallSquare:"◼",FilledVerySmallSquare:"▪",fjlig:"fj",flat:"♭",fllig:"fl",fltns:"▱",fnof:"ƒ",Fopf:"𝔽",fopf:"𝕗",ForAll:"∀",forall:"∀",fork:"⋔",forkv:"⫙",Fouriertrf:"ℱ",fpartint:"⨍",frac12:"½",frac13:"⅓",frac14:"¼",frac15:"⅕",frac16:"⅙",frac18:"⅛",frac23:"⅔",frac25:"⅖",frac34:"¾",frac35:"⅗",frac38:"⅜",frac45:"⅘",frac56:"⅚",frac58:"⅝",frac78:"⅞",frasl:"⁄",frown:"⌢",Fscr:"ℱ",fscr:"𝒻",gacute:"ǵ",Gamma:"Γ",gamma:"γ",Gammad:"Ϝ",gammad:"ϝ",gap:"⪆",Gbreve:"Ğ",gbreve:"ğ",Gcedil:"Ģ",Gcirc:"Ĝ",gcirc:"ĝ",Gcy:"Г",gcy:"г",Gdot:"Ġ",gdot:"ġ",gE:"≧",ge:"≥",gEl:"⪌",gel:"⋛",geq:"≥",geqq:"≧",geqslant:"⩾",ges:"⩾",gescc:"⪩",gesdot:"⪀",gesdoto:"⪂",gesdotol:"⪄",gesl:"⋛︀",gesles:"⪔",Gfr:"𝔊",gfr:"𝔤",Gg:"⋙",gg:"≫",ggg:"⋙",gimel:"ℷ",GJcy:"Ѓ",gjcy:"ѓ",gl:"≷",gla:"⪥",glE:"⪒",glj:"⪤",gnap:"⪊",gnapprox:"⪊",gnE:"≩",gne:"⪈",gneq:"⪈",gneqq:"≩",gnsim:"⋧",Gopf:"𝔾",gopf:"𝕘",grave:"`",GreaterEqual:"≥",GreaterEqualLess:"⋛",GreaterFullEqual:"≧",GreaterGreater:"⪢",GreaterLess:"≷",GreaterSlantEqual:"⩾",GreaterTilde:"≳",Gscr:"𝒢",gscr:"ℊ",gsim:"≳",gsime:"⪎",gsiml:"⪐",GT:">",Gt:"≫",gt:">",gtcc:"⪧",gtcir:"⩺",gtdot:"⋗",gtlPar:"⦕",gtquest:"⩼",gtrapprox:"⪆",gtrarr:"⥸",gtrdot:"⋗",gtreqless:"⋛",gtreqqless:"⪌",gtrless:"≷",gtrsim:"≳",gvertneqq:"≩︀",gvnE:"≩︀",Hacek:"ˇ",hairsp:" ",half:"½",hamilt:"ℋ",HARDcy:"Ъ",hardcy:"ъ",hArr:"⇔",harr:"↔",harrcir:"⥈",harrw:"↭",Hat:"^",hbar:"ℏ",Hcirc:"Ĥ",hcirc:"ĥ",hearts:"♥",heartsuit:"♥",hellip:"…",hercon:"⊹",Hfr:"ℌ",hfr:"𝔥",HilbertSpace:"ℋ",hksearow:"⤥",hkswarow:"⤦",hoarr:"⇿",homtht:"∻",hookleftarrow:"↩",hookrightarrow:"↪",Hopf:"ℍ",hopf:"𝕙",horbar:"―",HorizontalLine:"─",Hscr:"ℋ",hscr:"𝒽",hslash:"ℏ",Hstrok:"Ħ",hstrok:"ħ",HumpDownHump:"≎",HumpEqual:"≏",hybull:"⁃",hyphen:"‐",Iacute:"Í",iacute:"í",ic:"⁣",Icirc:"Î",icirc:"î",Icy:"И",icy:"и",Idot:"İ",IEcy:"Е",iecy:"е",iexcl:"¡",iff:"⇔",Ifr:"ℑ",ifr:"𝔦",Igrave:"Ì",igrave:"ì",ii:"ⅈ",iiiint:"⨌",iiint:"∭",iinfin:"⧜",iiota:"℩",IJlig:"IJ",ijlig:"ij",Im:"ℑ",Imacr:"Ī",imacr:"ī",image:"ℑ",ImaginaryI:"ⅈ",imagline:"ℐ",imagpart:"ℑ",imath:"ı",imof:"⊷",imped:"Ƶ",Implies:"⇒",in:"∈",incare:"℅",infin:"∞",infintie:"⧝",inodot:"ı",Int:"∬",int:"∫",intcal:"⊺",integers:"ℤ",Integral:"∫",intercal:"⊺",Intersection:"⋂",intlarhk:"⨗",intprod:"⨼",InvisibleComma:"⁣",InvisibleTimes:"⁢",IOcy:"Ё",iocy:"ё",Iogon:"Į",iogon:"į",Iopf:"𝕀",iopf:"𝕚",Iota:"Ι",iota:"ι",iprod:"⨼",iquest:"¿",Iscr:"ℐ",iscr:"𝒾",isin:"∈",isindot:"⋵",isinE:"⋹",isins:"⋴",isinsv:"⋳",isinv:"∈",it:"⁢",Itilde:"Ĩ",itilde:"ĩ",Iukcy:"І",iukcy:"і",Iuml:"Ï",iuml:"ï",Jcirc:"Ĵ",jcirc:"ĵ",Jcy:"Й",jcy:"й",Jfr:"𝔍",jfr:"𝔧",jmath:"ȷ",Jopf:"𝕁",jopf:"𝕛",Jscr:"𝒥",jscr:"𝒿",Jsercy:"Ј",jsercy:"ј",Jukcy:"Є",jukcy:"є",Kappa:"Κ",kappa:"κ",kappav:"ϰ",Kcedil:"Ķ",kcedil:"ķ",Kcy:"К",kcy:"к",Kfr:"𝔎",kfr:"𝔨",kgreen:"ĸ",KHcy:"Х",khcy:"х",KJcy:"Ќ",kjcy:"ќ",Kopf:"𝕂",kopf:"𝕜",Kscr:"𝒦",kscr:"𝓀",lAarr:"⇚",Lacute:"Ĺ",lacute:"ĺ",laemptyv:"⦴",lagran:"ℒ",Lambda:"Λ",lambda:"λ",Lang:"⟪",lang:"⟨",langd:"⦑",langle:"⟨",lap:"⪅",Laplacetrf:"ℒ",laquo:"«",Larr:"↞",lArr:"⇐",larr:"←",larrb:"⇤",larrbfs:"⤟",larrfs:"⤝",larrhk:"↩",larrlp:"↫",larrpl:"⤹",larrsim:"⥳",larrtl:"↢",lat:"⪫",lAtail:"⤛",latail:"⤙",late:"⪭",lates:"⪭︀",lBarr:"⤎",lbarr:"⤌",lbbrk:"❲",lbrace:"{",lbrack:"[",lbrke:"⦋",lbrksld:"⦏",lbrkslu:"⦍",Lcaron:"Ľ",lcaron:"ľ",Lcedil:"Ļ",lcedil:"ļ",lceil:"⌈",lcub:"{",Lcy:"Л",lcy:"л",ldca:"⤶",ldquo:"“",ldquor:"„",ldrdhar:"⥧",ldrushar:"⥋",ldsh:"↲",lE:"≦",le:"≤",LeftAngleBracket:"⟨",LeftArrow:"←",Leftarrow:"⇐",leftarrow:"←",LeftArrowBar:"⇤",LeftArrowRightArrow:"⇆",leftarrowtail:"↢",LeftCeiling:"⌈",LeftDoubleBracket:"⟦",LeftDownTeeVector:"⥡",LeftDownVector:"⇃",LeftDownVectorBar:"⥙",LeftFloor:"⌊",leftharpoondown:"↽",leftharpoonup:"↼",leftleftarrows:"⇇",LeftRightArrow:"↔",Leftrightarrow:"⇔",leftrightarrow:"↔",leftrightarrows:"⇆",leftrightharpoons:"⇋",leftrightsquigarrow:"↭",LeftRightVector:"⥎",LeftTee:"⊣",LeftTeeArrow:"↤",LeftTeeVector:"⥚",leftthreetimes:"⋋",LeftTriangle:"⊲",LeftTriangleBar:"⧏",LeftTriangleEqual:"⊴",LeftUpDownVector:"⥑",LeftUpTeeVector:"⥠",LeftUpVector:"↿",LeftUpVectorBar:"⥘",LeftVector:"↼",LeftVectorBar:"⥒",lEg:"⪋",leg:"⋚",leq:"≤",leqq:"≦",leqslant:"⩽",les:"⩽",lescc:"⪨",lesdot:"⩿",lesdoto:"⪁",lesdotor:"⪃",lesg:"⋚︀",lesges:"⪓",lessapprox:"⪅",lessdot:"⋖",lesseqgtr:"⋚",lesseqqgtr:"⪋",LessEqualGreater:"⋚",LessFullEqual:"≦",LessGreater:"≶",lessgtr:"≶",LessLess:"⪡",lesssim:"≲",LessSlantEqual:"⩽",LessTilde:"≲",lfisht:"⥼",lfloor:"⌊",Lfr:"𝔏",lfr:"𝔩",lg:"≶",lgE:"⪑",lHar:"⥢",lhard:"↽",lharu:"↼",lharul:"⥪",lhblk:"▄",LJcy:"Љ",ljcy:"љ",Ll:"⋘",ll:"≪",llarr:"⇇",llcorner:"⌞",Lleftarrow:"⇚",llhard:"⥫",lltri:"◺",Lmidot:"Ŀ",lmidot:"ŀ",lmoust:"⎰",lmoustache:"⎰",lnap:"⪉",lnapprox:"⪉",lnE:"≨",lne:"⪇",lneq:"⪇",lneqq:"≨",lnsim:"⋦",loang:"⟬",loarr:"⇽",lobrk:"⟦",LongLeftArrow:"⟵",Longleftarrow:"⟸",longleftarrow:"⟵",LongLeftRightArrow:"⟷",Longleftrightarrow:"⟺",longleftrightarrow:"⟷",longmapsto:"⟼",LongRightArrow:"⟶",Longrightarrow:"⟹",longrightarrow:"⟶",looparrowleft:"↫",looparrowright:"↬",lopar:"⦅",Lopf:"𝕃",lopf:"𝕝",loplus:"⨭",lotimes:"⨴",lowast:"∗",lowbar:"_",LowerLeftArrow:"↙",LowerRightArrow:"↘",loz:"◊",lozenge:"◊",lozf:"⧫",lpar:"(",lparlt:"⦓",lrarr:"⇆",lrcorner:"⌟",lrhar:"⇋",lrhard:"⥭",lrm:"‎",lrtri:"⊿",lsaquo:"‹",Lscr:"ℒ",lscr:"𝓁",Lsh:"↰",lsh:"↰",lsim:"≲",lsime:"⪍",lsimg:"⪏",lsqb:"[",lsquo:"‘",lsquor:"‚",Lstrok:"Ł",lstrok:"ł",LT:"<",Lt:"≪",lt:"<",ltcc:"⪦",ltcir:"⩹",ltdot:"⋖",lthree:"⋋",ltimes:"⋉",ltlarr:"⥶",ltquest:"⩻",ltri:"◃",ltrie:"⊴",ltrif:"◂",ltrPar:"⦖",lurdshar:"⥊",luruhar:"⥦",lvertneqq:"≨︀",lvnE:"≨︀",macr:"¯",male:"♂",malt:"✠",maltese:"✠",Map:"⤅",map:"↦",mapsto:"↦",mapstodown:"↧",mapstoleft:"↤",mapstoup:"↥",marker:"▮",mcomma:"⨩",Mcy:"М",mcy:"м",mdash:"—",mDDot:"∺",measuredangle:"∡",MediumSpace:" ",Mellintrf:"ℳ",Mfr:"𝔐",mfr:"𝔪",mho:"℧",micro:"µ",mid:"∣",midast:"*",midcir:"⫰",middot:"·",minus:"−",minusb:"⊟",minusd:"∸",minusdu:"⨪",MinusPlus:"∓",mlcp:"⫛",mldr:"…",mnplus:"∓",models:"⊧",Mopf:"𝕄",mopf:"𝕞",mp:"∓",Mscr:"ℳ",mscr:"𝓂",mstpos:"∾",Mu:"Μ",mu:"μ",multimap:"⊸",mumap:"⊸",nabla:"∇",Nacute:"Ń",nacute:"ń",nang:"∠⃒",nap:"≉",napE:"⩰̸",napid:"≋̸",napos:"ʼn",napprox:"≉",natur:"♮",natural:"♮",naturals:"ℕ",nbsp:" ",nbump:"≎̸",nbumpe:"≏̸",ncap:"⩃",Ncaron:"Ň",ncaron:"ň",Ncedil:"Ņ",ncedil:"ņ",ncong:"≇",ncongdot:"⩭̸",ncup:"⩂",Ncy:"Н",ncy:"н",ndash:"–",ne:"≠",nearhk:"⤤",neArr:"⇗",nearr:"↗",nearrow:"↗",nedot:"≐̸",NegativeMediumSpace:"​",NegativeThickSpace:"​",NegativeThinSpace:"​",NegativeVeryThinSpace:"​",nequiv:"≢",nesear:"⤨",nesim:"≂̸",NestedGreaterGreater:"≫",NestedLessLess:"≪",NewLine:"\n",nexist:"∄",nexists:"∄",Nfr:"𝔑",nfr:"𝔫",ngE:"≧̸",nge:"≱",ngeq:"≱",ngeqq:"≧̸",ngeqslant:"⩾̸",nges:"⩾̸",nGg:"⋙̸",ngsim:"≵",nGt:"≫⃒",ngt:"≯",ngtr:"≯",nGtv:"≫̸",nhArr:"⇎",nharr:"↮",nhpar:"⫲",ni:"∋",nis:"⋼",nisd:"⋺",niv:"∋",NJcy:"Њ",njcy:"њ",nlArr:"⇍",nlarr:"↚",nldr:"‥",nlE:"≦̸",nle:"≰",nLeftarrow:"⇍",nleftarrow:"↚",nLeftrightarrow:"⇎",nleftrightarrow:"↮",nleq:"≰",nleqq:"≦̸",nleqslant:"⩽̸",nles:"⩽̸",nless:"≮",nLl:"⋘̸",nlsim:"≴",nLt:"≪⃒",nlt:"≮",nltri:"⋪",nltrie:"⋬",nLtv:"≪̸",nmid:"∤",NoBreak:"⁠",NonBreakingSpace:" ",Nopf:"ℕ",nopf:"𝕟",Not:"⫬",not:"¬",NotCongruent:"≢",NotCupCap:"≭",NotDoubleVerticalBar:"∦",NotElement:"∉",NotEqual:"≠",NotEqualTilde:"≂̸",NotExists:"∄",NotGreater:"≯",NotGreaterEqual:"≱",NotGreaterFullEqual:"≧̸",NotGreaterGreater:"≫̸",NotGreaterLess:"≹",NotGreaterSlantEqual:"⩾̸",NotGreaterTilde:"≵",NotHumpDownHump:"≎̸",NotHumpEqual:"≏̸",notin:"∉",notindot:"⋵̸",notinE:"⋹̸",notinva:"∉",notinvb:"⋷",notinvc:"⋶",NotLeftTriangle:"⋪",NotLeftTriangleBar:"⧏̸",NotLeftTriangleEqual:"⋬",NotLess:"≮",NotLessEqual:"≰",NotLessGreater:"≸",NotLessLess:"≪̸",NotLessSlantEqual:"⩽̸",NotLessTilde:"≴",NotNestedGreaterGreater:"⪢̸",NotNestedLessLess:"⪡̸",notni:"∌",notniva:"∌",notnivb:"⋾",notnivc:"⋽",NotPrecedes:"⊀",NotPrecedesEqual:"⪯̸",NotPrecedesSlantEqual:"⋠",NotReverseElement:"∌",NotRightTriangle:"⋫",NotRightTriangleBar:"⧐̸",NotRightTriangleEqual:"⋭",NotSquareSubset:"⊏̸",NotSquareSubsetEqual:"⋢",NotSquareSuperset:"⊐̸",NotSquareSupersetEqual:"⋣",NotSubset:"⊂⃒",NotSubsetEqual:"⊈",NotSucceeds:"⊁",NotSucceedsEqual:"⪰̸",NotSucceedsSlantEqual:"⋡",NotSucceedsTilde:"≿̸",NotSuperset:"⊃⃒",NotSupersetEqual:"⊉",NotTilde:"≁",NotTildeEqual:"≄",NotTildeFullEqual:"≇",NotTildeTilde:"≉",NotVerticalBar:"∤",npar:"∦",nparallel:"∦",nparsl:"⫽⃥",npart:"∂̸",npolint:"⨔",npr:"⊀",nprcue:"⋠",npre:"⪯̸",nprec:"⊀",npreceq:"⪯̸",nrArr:"⇏",nrarr:"↛",nrarrc:"⤳̸",nrarrw:"↝̸",nRightarrow:"⇏",nrightarrow:"↛",nrtri:"⋫",nrtrie:"⋭",nsc:"⊁",nsccue:"⋡",nsce:"⪰̸",Nscr:"𝒩",nscr:"𝓃",nshortmid:"∤",nshortparallel:"∦",nsim:"≁",nsime:"≄",nsimeq:"≄",nsmid:"∤",nspar:"∦",nsqsube:"⋢",nsqsupe:"⋣",nsub:"⊄",nsubE:"⫅̸",nsube:"⊈",nsubset:"⊂⃒",nsubseteq:"⊈",nsubseteqq:"⫅̸",nsucc:"⊁",nsucceq:"⪰̸",nsup:"⊅",nsupE:"⫆̸",nsupe:"⊉",nsupset:"⊃⃒",nsupseteq:"⊉",nsupseteqq:"⫆̸",ntgl:"≹",Ntilde:"Ñ",ntilde:"ñ",ntlg:"≸",ntriangleleft:"⋪",ntrianglelefteq:"⋬",ntriangleright:"⋫",ntrianglerighteq:"⋭",Nu:"Ν",nu:"ν",num:"#",numero:"№",numsp:" ",nvap:"≍⃒",nVDash:"⊯",nVdash:"⊮",nvDash:"⊭",nvdash:"⊬",nvge:"≥⃒",nvgt:">⃒",nvHarr:"⤄",nvinfin:"⧞",nvlArr:"⤂",nvle:"≤⃒",nvlt:"<⃒",nvltrie:"⊴⃒",nvrArr:"⤃",nvrtrie:"⊵⃒",nvsim:"∼⃒",nwarhk:"⤣",nwArr:"⇖",nwarr:"↖",nwarrow:"↖",nwnear:"⤧",Oacute:"Ó",oacute:"ó",oast:"⊛",ocir:"⊚",Ocirc:"Ô",ocirc:"ô",Ocy:"О",ocy:"о",odash:"⊝",Odblac:"Ő",odblac:"ő",odiv:"⨸",odot:"⊙",odsold:"⦼",OElig:"Œ",oelig:"œ",ofcir:"⦿",Ofr:"𝔒",ofr:"𝔬",ogon:"˛",Ograve:"Ò",ograve:"ò",ogt:"⧁",ohbar:"⦵",ohm:"Ω",oint:"∮",olarr:"↺",olcir:"⦾",olcross:"⦻",oline:"‾",olt:"⧀",Omacr:"Ō",omacr:"ō",Omega:"Ω",omega:"ω",Omicron:"Ο",omicron:"ο",omid:"⦶",ominus:"⊖",Oopf:"𝕆",oopf:"𝕠",opar:"⦷",OpenCurlyDoubleQuote:"“",OpenCurlyQuote:"‘",operp:"⦹",oplus:"⊕",Or:"⩔",or:"∨",orarr:"↻",ord:"⩝",order:"ℴ",orderof:"ℴ",ordf:"ª",ordm:"º",origof:"⊶",oror:"⩖",orslope:"⩗",orv:"⩛",oS:"Ⓢ",Oscr:"𝒪",oscr:"ℴ",Oslash:"Ø",oslash:"ø",osol:"⊘",Otilde:"Õ",otilde:"õ",Otimes:"⨷",otimes:"⊗",otimesas:"⨶",Ouml:"Ö",ouml:"ö",ovbar:"⌽",OverBar:"‾",OverBrace:"⏞",OverBracket:"⎴",OverParenthesis:"⏜",par:"∥",para:"¶",parallel:"∥",parsim:"⫳",parsl:"⫽",part:"∂",PartialD:"∂",Pcy:"П",pcy:"п",percnt:"%",period:".",permil:"‰",perp:"⊥",pertenk:"‱",Pfr:"𝔓",pfr:"𝔭",Phi:"Φ",phi:"φ",phiv:"ϕ",phmmat:"ℳ",phone:"☎",Pi:"Π",pi:"π",pitchfork:"⋔",piv:"ϖ",planck:"ℏ",planckh:"ℎ",plankv:"ℏ",plus:"+",plusacir:"⨣",plusb:"⊞",pluscir:"⨢",plusdo:"∔",plusdu:"⨥",pluse:"⩲",PlusMinus:"±",plusmn:"±",plussim:"⨦",plustwo:"⨧",pm:"±",Poincareplane:"ℌ",pointint:"⨕",Popf:"ℙ",popf:"𝕡",pound:"£",Pr:"⪻",pr:"≺",prap:"⪷",prcue:"≼",prE:"⪳",pre:"⪯",prec:"≺",precapprox:"⪷",preccurlyeq:"≼",Precedes:"≺",PrecedesEqual:"⪯",PrecedesSlantEqual:"≼",PrecedesTilde:"≾",preceq:"⪯",precnapprox:"⪹",precneqq:"⪵",precnsim:"⋨",precsim:"≾",Prime:"″",prime:"′",primes:"ℙ",prnap:"⪹",prnE:"⪵",prnsim:"⋨",prod:"∏",Product:"∏",profalar:"⌮",profline:"⌒",profsurf:"⌓",prop:"∝",Proportion:"∷",Proportional:"∝",propto:"∝",prsim:"≾",prurel:"⊰",Pscr:"𝒫",pscr:"𝓅",Psi:"Ψ",psi:"ψ",puncsp:" ",Qfr:"𝔔",qfr:"𝔮",qint:"⨌",Qopf:"ℚ",qopf:"𝕢",qprime:"⁗",Qscr:"𝒬",qscr:"𝓆",quaternions:"ℍ",quatint:"⨖",quest:"?",questeq:"≟",QUOT:'"',quot:'"',rAarr:"⇛",race:"∽̱",Racute:"Ŕ",racute:"ŕ",radic:"√",raemptyv:"⦳",Rang:"⟫",rang:"⟩",rangd:"⦒",range:"⦥",rangle:"⟩",raquo:"»",Rarr:"↠",rArr:"⇒",rarr:"→",rarrap:"⥵",rarrb:"⇥",rarrbfs:"⤠",rarrc:"⤳",rarrfs:"⤞",rarrhk:"↪",rarrlp:"↬",rarrpl:"⥅",rarrsim:"⥴",Rarrtl:"⤖",rarrtl:"↣",rarrw:"↝",rAtail:"⤜",ratail:"⤚",ratio:"∶",rationals:"ℚ",RBarr:"⤐",rBarr:"⤏",rbarr:"⤍",rbbrk:"❳",rbrace:"}",rbrack:"]",rbrke:"⦌",rbrksld:"⦎",rbrkslu:"⦐",Rcaron:"Ř",rcaron:"ř",Rcedil:"Ŗ",rcedil:"ŗ",rceil:"⌉",rcub:"}",Rcy:"Р",rcy:"р",rdca:"⤷",rdldhar:"⥩",rdquo:"”",rdquor:"”",rdsh:"↳",Re:"ℜ",real:"ℜ",realine:"ℛ",realpart:"ℜ",reals:"ℝ",rect:"▭",REG:"®",reg:"®",ReverseElement:"∋",ReverseEquilibrium:"⇋",ReverseUpEquilibrium:"⥯",rfisht:"⥽",rfloor:"⌋",Rfr:"ℜ",rfr:"𝔯",rHar:"⥤",rhard:"⇁",rharu:"⇀",rharul:"⥬",Rho:"Ρ",rho:"ρ",rhov:"ϱ",RightAngleBracket:"⟩",RightArrow:"→",Rightarrow:"⇒",rightarrow:"→",RightArrowBar:"⇥",RightArrowLeftArrow:"⇄",rightarrowtail:"↣",RightCeiling:"⌉",RightDoubleBracket:"⟧",RightDownTeeVector:"⥝",RightDownVector:"⇂",RightDownVectorBar:"⥕",RightFloor:"⌋",rightharpoondown:"⇁",rightharpoonup:"⇀",rightleftarrows:"⇄",rightleftharpoons:"⇌",rightrightarrows:"⇉",rightsquigarrow:"↝",RightTee:"⊢",RightTeeArrow:"↦",RightTeeVector:"⥛",rightthreetimes:"⋌",RightTriangle:"⊳",RightTriangleBar:"⧐",RightTriangleEqual:"⊵",RightUpDownVector:"⥏",RightUpTeeVector:"⥜",RightUpVector:"↾",RightUpVectorBar:"⥔",RightVector:"⇀",RightVectorBar:"⥓",ring:"˚",risingdotseq:"≓",rlarr:"⇄",rlhar:"⇌",rlm:"‏",rmoust:"⎱",rmoustache:"⎱",rnmid:"⫮",roang:"⟭",roarr:"⇾",robrk:"⟧",ropar:"⦆",Ropf:"ℝ",ropf:"𝕣",roplus:"⨮",rotimes:"⨵",RoundImplies:"⥰",rpar:")",rpargt:"⦔",rppolint:"⨒",rrarr:"⇉",Rrightarrow:"⇛",rsaquo:"›",Rscr:"ℛ",rscr:"𝓇",Rsh:"↱",rsh:"↱",rsqb:"]",rsquo:"’",rsquor:"’",rthree:"⋌",rtimes:"⋊",rtri:"▹",rtrie:"⊵",rtrif:"▸",rtriltri:"⧎",RuleDelayed:"⧴",ruluhar:"⥨",rx:"℞",Sacute:"Ś",sacute:"ś",sbquo:"‚",Sc:"⪼",sc:"≻",scap:"⪸",Scaron:"Š",scaron:"š",sccue:"≽",scE:"⪴",sce:"⪰",Scedil:"Ş",scedil:"ş",Scirc:"Ŝ",scirc:"ŝ",scnap:"⪺",scnE:"⪶",scnsim:"⋩",scpolint:"⨓",scsim:"≿",Scy:"С",scy:"с",sdot:"⋅",sdotb:"⊡",sdote:"⩦",searhk:"⤥",seArr:"⇘",searr:"↘",searrow:"↘",sect:"§",semi:";",seswar:"⤩",setminus:"∖",setmn:"∖",sext:"✶",Sfr:"𝔖",sfr:"𝔰",sfrown:"⌢",sharp:"♯",SHCHcy:"Щ",shchcy:"щ",SHcy:"Ш",shcy:"ш",ShortDownArrow:"↓",ShortLeftArrow:"←",shortmid:"∣",shortparallel:"∥",ShortRightArrow:"→",ShortUpArrow:"↑",shy:"­",Sigma:"Σ",sigma:"σ",sigmaf:"ς",sigmav:"ς",sim:"∼",simdot:"⩪",sime:"≃",simeq:"≃",simg:"⪞",simgE:"⪠",siml:"⪝",simlE:"⪟",simne:"≆",simplus:"⨤",simrarr:"⥲",slarr:"←",SmallCircle:"∘",smallsetminus:"∖",smashp:"⨳",smeparsl:"⧤",smid:"∣",smile:"⌣",smt:"⪪",smte:"⪬",smtes:"⪬︀",SOFTcy:"Ь",softcy:"ь",sol:"/",solb:"⧄",solbar:"⌿",Sopf:"𝕊",sopf:"𝕤",spades:"♠",spadesuit:"♠",spar:"∥",sqcap:"⊓",sqcaps:"⊓︀",sqcup:"⊔",sqcups:"⊔︀",Sqrt:"√",sqsub:"⊏",sqsube:"⊑",sqsubset:"⊏",sqsubseteq:"⊑",sqsup:"⊐",sqsupe:"⊒",sqsupset:"⊐",sqsupseteq:"⊒",squ:"□",Square:"□",square:"□",SquareIntersection:"⊓",SquareSubset:"⊏",SquareSubsetEqual:"⊑",SquareSuperset:"⊐",SquareSupersetEqual:"⊒",SquareUnion:"⊔",squarf:"▪",squf:"▪",srarr:"→",Sscr:"𝒮",sscr:"𝓈",ssetmn:"∖",ssmile:"⌣",sstarf:"⋆",Star:"⋆",star:"☆",starf:"★",straightepsilon:"ϵ",straightphi:"ϕ",strns:"¯",Sub:"⋐",sub:"⊂",subdot:"⪽",subE:"⫅",sube:"⊆",subedot:"⫃",submult:"⫁",subnE:"⫋",subne:"⊊",subplus:"⪿",subrarr:"⥹",Subset:"⋐",subset:"⊂",subseteq:"⊆",subseteqq:"⫅",SubsetEqual:"⊆",subsetneq:"⊊",subsetneqq:"⫋",subsim:"⫇",subsub:"⫕",subsup:"⫓",succ:"≻",succapprox:"⪸",succcurlyeq:"≽",Succeeds:"≻",SucceedsEqual:"⪰",SucceedsSlantEqual:"≽",SucceedsTilde:"≿",succeq:"⪰",succnapprox:"⪺",succneqq:"⪶",succnsim:"⋩",succsim:"≿",SuchThat:"∋",Sum:"∑",sum:"∑",sung:"♪",Sup:"⋑",sup:"⊃",sup1:"¹",sup2:"²",sup3:"³",supdot:"⪾",supdsub:"⫘",supE:"⫆",supe:"⊇",supedot:"⫄",Superset:"⊃",SupersetEqual:"⊇",suphsol:"⟉",suphsub:"⫗",suplarr:"⥻",supmult:"⫂",supnE:"⫌",supne:"⊋",supplus:"⫀",Supset:"⋑",supset:"⊃",supseteq:"⊇",supseteqq:"⫆",supsetneq:"⊋",supsetneqq:"⫌",supsim:"⫈",supsub:"⫔",supsup:"⫖",swarhk:"⤦",swArr:"⇙",swarr:"↙",swarrow:"↙",swnwar:"⤪",szlig:"ß",Tab:"\t",target:"⌖",Tau:"Τ",tau:"τ",tbrk:"⎴",Tcaron:"Ť",tcaron:"ť",Tcedil:"Ţ",tcedil:"ţ",Tcy:"Т",tcy:"т",tdot:"⃛",telrec:"⌕",Tfr:"𝔗",tfr:"𝔱",there4:"∴",Therefore:"∴",therefore:"∴",Theta:"Θ",theta:"θ",thetasym:"ϑ",thetav:"ϑ",thickapprox:"≈",thicksim:"∼",ThickSpace:"  ",thinsp:" ",ThinSpace:" ",thkap:"≈",thksim:"∼",THORN:"Þ",thorn:"þ",Tilde:"∼",tilde:"˜",TildeEqual:"≃",TildeFullEqual:"≅",TildeTilde:"≈",times:"×",timesb:"⊠",timesbar:"⨱",timesd:"⨰",tint:"∭",toea:"⤨",top:"⊤",topbot:"⌶",topcir:"⫱",Topf:"𝕋",topf:"𝕥",topfork:"⫚",tosa:"⤩",tprime:"‴",TRADE:"™",trade:"™",triangle:"▵",triangledown:"▿",triangleleft:"◃",trianglelefteq:"⊴",triangleq:"≜",triangleright:"▹",trianglerighteq:"⊵",tridot:"◬",trie:"≜",triminus:"⨺",TripleDot:"⃛",triplus:"⨹",trisb:"⧍",tritime:"⨻",trpezium:"⏢",Tscr:"𝒯",tscr:"𝓉",TScy:"Ц",tscy:"ц",TSHcy:"Ћ",tshcy:"ћ",Tstrok:"Ŧ",tstrok:"ŧ",twixt:"≬",twoheadleftarrow:"↞",twoheadrightarrow:"↠",Uacute:"Ú",uacute:"ú",Uarr:"↟",uArr:"⇑",uarr:"↑",Uarrocir:"⥉",Ubrcy:"Ў",ubrcy:"ў",Ubreve:"Ŭ",ubreve:"ŭ",Ucirc:"Û",ucirc:"û",Ucy:"У",ucy:"у",udarr:"⇅",Udblac:"Ű",udblac:"ű",udhar:"⥮",ufisht:"⥾",Ufr:"𝔘",ufr:"𝔲",Ugrave:"Ù",ugrave:"ù",uHar:"⥣",uharl:"↿",uharr:"↾",uhblk:"▀",ulcorn:"⌜",ulcorner:"⌜",ulcrop:"⌏",ultri:"◸",Umacr:"Ū",umacr:"ū",uml:"¨",UnderBar:"_",UnderBrace:"⏟",UnderBracket:"⎵",UnderParenthesis:"⏝",Union:"⋃",UnionPlus:"⊎",Uogon:"Ų",uogon:"ų",Uopf:"𝕌",uopf:"𝕦",UpArrow:"↑",Uparrow:"⇑",uparrow:"↑",UpArrowBar:"⤒",UpArrowDownArrow:"⇅",UpDownArrow:"↕",Updownarrow:"⇕",updownarrow:"↕",UpEquilibrium:"⥮",upharpoonleft:"↿",upharpoonright:"↾",uplus:"⊎",UpperLeftArrow:"↖",UpperRightArrow:"↗",Upsi:"ϒ",upsi:"υ",upsih:"ϒ",Upsilon:"Υ",upsilon:"υ",UpTee:"⊥",UpTeeArrow:"↥",upuparrows:"⇈",urcorn:"⌝",urcorner:"⌝",urcrop:"⌎",Uring:"Ů",uring:"ů",urtri:"◹",Uscr:"𝒰",uscr:"𝓊",utdot:"⋰",Utilde:"Ũ",utilde:"ũ",utri:"▵",utrif:"▴",uuarr:"⇈",Uuml:"Ü",uuml:"ü",uwangle:"⦧",vangrt:"⦜",varepsilon:"ϵ",varkappa:"ϰ",varnothing:"∅",varphi:"ϕ",varpi:"ϖ",varpropto:"∝",vArr:"⇕",varr:"↕",varrho:"ϱ",varsigma:"ς",varsubsetneq:"⊊︀",varsubsetneqq:"⫋︀",varsupsetneq:"⊋︀",varsupsetneqq:"⫌︀",vartheta:"ϑ",vartriangleleft:"⊲",vartriangleright:"⊳",Vbar:"⫫",vBar:"⫨",vBarv:"⫩",Vcy:"В",vcy:"в",VDash:"⊫",Vdash:"⊩",vDash:"⊨",vdash:"⊢",Vdashl:"⫦",Vee:"⋁",vee:"∨",veebar:"⊻",veeeq:"≚",vellip:"⋮",Verbar:"‖",verbar:"|",Vert:"‖",vert:"|",VerticalBar:"∣",VerticalLine:"|",VerticalSeparator:"❘",VerticalTilde:"≀",VeryThinSpace:" ",Vfr:"𝔙",vfr:"𝔳",vltri:"⊲",vnsub:"⊂⃒",vnsup:"⊃⃒",Vopf:"𝕍",vopf:"𝕧",vprop:"∝",vrtri:"⊳",Vscr:"𝒱",vscr:"𝓋",vsubnE:"⫋︀",vsubne:"⊊︀",vsupnE:"⫌︀",vsupne:"⊋︀",Vvdash:"⊪",vzigzag:"⦚",Wcirc:"Ŵ",wcirc:"ŵ",wedbar:"⩟",Wedge:"⋀",wedge:"∧",wedgeq:"≙",weierp:"℘",Wfr:"𝔚",wfr:"𝔴",Wopf:"𝕎",wopf:"𝕨",wp:"℘",wr:"≀",wreath:"≀",Wscr:"𝒲",wscr:"𝓌",xcap:"⋂",xcirc:"◯",xcup:"⋃",xdtri:"▽",Xfr:"𝔛",xfr:"𝔵",xhArr:"⟺",xharr:"⟷",Xi:"Ξ",xi:"ξ",xlArr:"⟸",xlarr:"⟵",xmap:"⟼",xnis:"⋻",xodot:"⨀",Xopf:"𝕏",xopf:"𝕩",xoplus:"⨁",xotime:"⨂",xrArr:"⟹",xrarr:"⟶",Xscr:"𝒳",xscr:"𝓍",xsqcup:"⨆",xuplus:"⨄",xutri:"△",xvee:"⋁",xwedge:"⋀",Yacute:"Ý",yacute:"ý",YAcy:"Я",yacy:"я",Ycirc:"Ŷ",ycirc:"ŷ",Ycy:"Ы",ycy:"ы",yen:"¥",Yfr:"𝔜",yfr:"𝔶",YIcy:"Ї",yicy:"ї",Yopf:"𝕐",yopf:"𝕪",Yscr:"𝒴",yscr:"𝓎",YUcy:"Ю",yucy:"ю",Yuml:"Ÿ",yuml:"ÿ",Zacute:"Ź",zacute:"ź",Zcaron:"Ž",zcaron:"ž",Zcy:"З",zcy:"з",Zdot:"Ż",zdot:"ż",zeetrf:"ℨ",ZeroWidthSpace:"​",Zeta:"Ζ",zeta:"ζ",Zfr:"ℨ",zfr:"𝔷",ZHcy:"Ж",zhcy:"ж",zigrarr:"⇝",Zopf:"ℤ",zopf:"𝕫",Zscr:"𝒵",zscr:"𝓏",zwj:"‍",zwnj:"‌"},r=Object.prototype.hasOwnProperty;function n(e){return o=e,(n=t)&&r.call(n,o)?t[e]:e;var n,o}var o=Object.prototype.hasOwnProperty;function s(e,t){return!!e&&o.call(e,t)}function i(e){return[].slice.call(arguments,1).forEach(function(t){if(t){if("object"!=typeof t)throw new TypeError(t+"must be object");Object.keys(t).forEach(function(r){e[r]=t[r]})}}),e}var a=/\\([\\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;function u(e){return e.indexOf("\\")<0?e:e.replace(a,"$1")}function l(e){return!(e>=55296&&e<=57343)&&(!(e>=64976&&e<=65007)&&(65535!=(65535&e)&&65534!=(65535&e)&&(!(e>=0&&e<=8)&&(11!==e&&(!(e>=14&&e<=31)&&(!(e>=127&&e<=159)&&!(e>1114111)))))))}function c(e){if(e>65535){var t=55296+((e-=65536)>>10),r=56320+(1023&e);return String.fromCharCode(t,r)}return String.fromCharCode(e)}var p=/&([a-z#][a-z0-9]{1,31});/gi,h=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i;function f(e,t){var r=0,o=n(t);return t!==o?o:35===t.charCodeAt(0)&&h.test(t)&&l(r="x"===t[1].toLowerCase()?parseInt(t.slice(2),16):parseInt(t.slice(1),10))?c(r):e}function g(e){return e.indexOf("&")<0?e:e.replace(p,f)}var d=/[&<>"]/,m=/[&<>"]/g,b={"&":"&","<":"<",">":">",'"':"""};function v(e){return b[e]}function k(e){return d.test(e)?e.replace(m,v):e}var A=Object.freeze({isString:function(e){return"[object String]"===function(e){return Object.prototype.toString.call(e)}(e)},has:s,assign:i,unescapeMd:u,isValidEntityCode:l,fromCodePoint:c,replaceEntities:g,escapeHtml:k}),y={};y.blockquote_open=function(){return"
    \n"},y.blockquote_close=function(e,t){return"
    "+x(e,t)},y.code=function(e,t){return e[t].block?"
    "+k(e[t].content)+"
    "+x(e,t):""+k(e[t].content)+""},y.fence=function(e,t,r,n,o){var i,a,l=e[t],c="",p=r.langPrefix;if(l.params){if(a=(i=l.params.split(/\s+/g)).join(" "),s(o.rules.fence_custom,i[0]))return o.rules.fence_custom[i[0]](e,t,r,n,o);c=' class="'+p+k(g(u(a)))+'"'}return"
    "+(r.highlight&&r.highlight.apply(r.highlight,[l.content].concat(i))||k(l.content))+"
    "+x(e,t)},y.fence_custom={},y.heading_open=function(e,t){return""},y.heading_close=function(e,t){return"\n"},y.hr=function(e,t,r){return(r.xhtmlOut?"
    ":"
    ")+x(e,t)},y.bullet_list_open=function(){return""+x(e,t)},y.list_item_open=function(){return"
  • "},y.list_item_close=function(){return"
  • \n"},y.ordered_list_open=function(e,t){var r=e[t];return"1?' start="'+r.order+'"':"")+">\n"},y.ordered_list_close=function(e,t){return""+x(e,t)},y.paragraph_open=function(e,t){return e[t].tight?"":"

    "},y.paragraph_close=function(e,t){var r=!(e[t].tight&&t&&"inline"===e[t-1].type&&!e[t-1].content);return(e[t].tight?"":"

    ")+(r?x(e,t):"")},y.link_open=function(e,t,r){var n=e[t].title?' title="'+k(g(e[t].title))+'"':"",o=r.linkTarget?' target="'+r.linkTarget+'"':"";return'"},y.link_close=function(){return""},y.image=function(e,t,r){var n=' src="'+k(e[t].src)+'"',o=e[t].title?' title="'+k(g(e[t].title))+'"':"";return""},y.table_open=function(){return"\n"},y.table_close=function(){return"
    \n"},y.thead_open=function(){return"\n"},y.thead_close=function(){return"\n"},y.tbody_open=function(){return"\n"},y.tbody_close=function(){return"\n"},y.tr_open=function(){return""},y.tr_close=function(){return"\n"},y.th_open=function(e,t){var r=e[t];return""},y.th_close=function(){return""},y.td_open=function(e,t){var r=e[t];return""},y.td_close=function(){return""},y.strong_open=function(){return""},y.strong_close=function(){return""},y.em_open=function(){return""},y.em_close=function(){return""},y.del_open=function(){return""},y.del_close=function(){return""},y.ins_open=function(){return""},y.ins_close=function(){return""},y.mark_open=function(){return""},y.mark_close=function(){return""},y.sub=function(e,t){return""+k(e[t].content)+""},y.sup=function(e,t){return""+k(e[t].content)+""},y.hardbreak=function(e,t,r){return r.xhtmlOut?"
    \n":"
    \n"},y.softbreak=function(e,t,r){return r.breaks?r.xhtmlOut?"
    \n":"
    \n":"\n"},y.text=function(e,t){return k(e[t].content)},y.htmlblock=function(e,t){return e[t].content},y.htmltag=function(e,t){return e[t].content},y.abbr_open=function(e,t){return''},y.abbr_close=function(){return""},y.footnote_ref=function(e,t){var r=Number(e[t].id+1).toString(),n="fnref"+r;return e[t].subId>0&&(n+=":"+e[t].subId),'['+r+"]"},y.footnote_block_open=function(e,t,r){return(r.xhtmlOut?'
    \n':'
    \n')+'
    \n
      \n'},y.footnote_block_close=function(){return"
    \n
    \n"},y.footnote_open=function(e,t){return'
  • '},y.footnote_close=function(){return"
  • \n"},y.footnote_anchor=function(e,t){var r="fnref"+Number(e[t].id+1).toString();return e[t].subId>0&&(r+=":"+e[t].subId),' '},y.dl_open=function(){return"
    \n"},y.dt_open=function(){return"
    "},y.dd_open=function(){return"
    "},y.dl_close=function(){return"
    \n"},y.dt_close=function(){return"\n"},y.dd_close=function(){return"\n"};var x=y.getBreak=function(e,t){return(t=function e(t,r){return++r>=t.length-2?r:"paragraph_open"===t[r].type&&t[r].tight&&"inline"===t[r+1].type&&0===t[r+1].content.length&&"paragraph_close"===t[r+2].type&&t[r+2].tight?e(t,r+2):r}(e,t))1)break;if(41===r&&--n<0)break;t++}return s!==t&&(o=u(e.src.slice(s,t)),!!e.parser.validateLink(o)&&(e.linkContent=o,e.pos=t,!0))}function F(e,t){var r,n=t,o=e.posMax,s=e.src.charCodeAt(t);if(34!==s&&39!==s&&40!==s)return!1;for(t++,40===s&&(s=41);t=e.length)&&!I.test(e[t])}function H(e,t,r){return e.substr(0,t)+r+e.substr(t+1)}var V=[["block",function(e){e.inlineMode?e.tokens.push({type:"inline",content:e.src.replace(/\n/g," ").trim(),level:0,lines:[0,1],children:[]}):e.block.parse(e.src,e.options,e.env,e.tokens)}],["abbr",function(e){var t,r,n,o,s=e.tokens;if(!e.inlineMode)for(t=1,r=s.length-1;t0?i[t].count:1,n=0;n=0;t--)if("text"===(s=o[t]).type){for(u=0,i=s.content,c.lastIndex=0,l=s.level,a=[];p=c.exec(i);)c.lastIndex>u&&a.push({type:"text",content:i.slice(u,p.index+p[1].length),level:l}),a.push({type:"abbr_open",title:e.env.abbreviations[":"+p[2]],level:l++}),a.push({type:"text",content:p[2],level:l}),a.push({type:"abbr_close",level:--l}),u=c.lastIndex-p[3].length;a.length&&(u=0;s--)if("inline"===e.tokens[s].type)for(t=(o=e.tokens[s].children).length-1;t>=0;t--)"text"===(r=o[t]).type&&(n=r.content,n=(i=n).indexOf("(")<0?i:i.replace(N,function(e,t){return z[t.toLowerCase()]}),R.test(n)&&(n=n.replace(/\+-/g,"±").replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---([^-]|$)/gm,"$1—$2").replace(/(^|\s)--(\s|$)/gm,"$1–$2").replace(/(^|[^-\s])--([^-\s]|$)/gm,"$1–$2")),r.content=n)}],["smartquotes",function(e){var t,r,n,o,s,i,a,u,l,c,p,h,f,g,d,m,b;if(e.options.typographer)for(b=[],d=e.tokens.length-1;d>=0;d--)if("inline"===e.tokens[d].type)for(m=e.tokens[d].children,b.length=0,t=0;t=0&&!(b[f].level<=a);f--);b.length=f+1,s=0,i=(n=r.content).length;e:for(;s=0&&(c=b[f],!(b[f].level=(o=e.eMarks[t])?-1:42!==(r=e.src.charCodeAt(n++))&&45!==r&&43!==r?-1:n=o)return-1;if((r=e.src.charCodeAt(n++))<48||r>57)return-1;for(;;){if(n>=o)return-1;if(!((r=e.src.charCodeAt(n++))>=48&&r<=57)){if(41===r||46===r)break;return-1}}return n=this.eMarks[e]},$.prototype.skipEmptyLines=function(e){for(var t=this.lineMax;er;)if(t!==this.src.charCodeAt(--e))return e+1;return e},$.prototype.getLines=function(e,t,r,n){var o,s,i,a,u,l=e;if(e>=t)return"";if(l+1===t)return s=this.bMarks[l]+Math.min(this.tShift[l],r),i=n?this.eMarks[l]+1:this.eMarks[l],this.src.slice(s,i);for(a=new Array(t-e),o=0;lr&&(u=r),u<0&&(u=0),s=this.bMarks[l]+u,i=l+1]/,K=/^<\/([a-zA-Z]{1,15})[\s>]/;function Q(e,t){var r=e.bMarks[t]+e.blkIndent,n=e.eMarks[t];return e.src.substr(r,n-r)}function X(e,t){var r,n,o=e.bMarks[t]+e.tShift[t],s=e.eMarks[t];return o>=s?-1:126!==(n=e.src.charCodeAt(o++))&&58!==n?-1:o===(r=e.skipSpaces(o))?-1:r>=s?-1:r}var ee=[["code",function(e,t,r){var n,o;if(e.tShift[t]-e.blkIndent<4)return!1;for(o=n=t+1;n=4))break;o=++n}return e.line=n,e.tokens.push({type:"code",content:e.getLines(t,o,4+e.blkIndent,!0),block:!0,lines:[t,e.line],level:e.level}),!0}],["fences",function(e,t,r,n){var o,s,i,a,u,l=!1,c=e.bMarks[t]+e.tShift[t],p=e.eMarks[t];if(c+3>p)return!1;if(126!==(o=e.src.charCodeAt(c))&&96!==o)return!1;if(u=c,(s=(c=e.skipChars(c,o))-u)<3)return!1;if((i=e.src.slice(c,p).trim()).indexOf("`")>=0)return!1;if(n)return!0;for(a=t;!(++a>=r||(c=u=e.bMarks[a]+e.tShift[a])<(p=e.eMarks[a])&&e.tShift[a]=4||(c=e.skipChars(c,o))-um)return!1;if(62!==e.src.charCodeAt(d++))return!1;if(e.level>=e.options.maxNesting)return!1;if(n)return!0;for(32===e.src.charCodeAt(d)&&d++,u=e.blkIndent,e.blkIndent=0,a=[e.bMarks[t]],e.bMarks[t]=d,s=(d=d=m,i=[e.tShift[t]],e.tShift[t]=d-e.bMarks[t],p=e.parser.ruler.getRules("blockquote"),o=t+1;o=(m=e.eMarks[o]));o++)if(62!==e.src.charCodeAt(d++)){if(s)break;for(g=!1,h=0,f=p.length;h=m,i.push(e.tShift[o]),e.tShift[o]=d-e.bMarks[o];for(l=e.parentType,e.parentType="blockquote",e.tokens.push({type:"blockquote_open",lines:c=[t,0],level:e.level++}),e.parser.tokenize(e,t,o),e.tokens.push({type:"blockquote_close",level:--e.level}),e.parentType=l,c[1]=e.line,h=0;hu)return!1;if(42!==(o=e.src.charCodeAt(a++))&&45!==o&&95!==o)return!1;for(s=1;a=0)d=!0;else{if(!((p=Z(e,t))>=0))return!1;d=!1}if(e.level>=e.options.maxNesting)return!1;if(g=e.src.charCodeAt(p-1),n)return!0;for(b=e.tokens.length,d?(c=e.bMarks[t]+e.tShift[t],f=Number(e.src.substr(c,p-c-1)),e.tokens.push({type:"ordered_list_open",order:f,lines:k=[t,0],level:e.level++})):e.tokens.push({type:"bullet_list_open",lines:k=[t,0],level:e.level++}),o=t,v=!1,y=e.parser.ruler.getRules("list");!(!(o=e.eMarks[o]?1:m-p)>4&&(h=1),h<1&&(h=1),s=p-e.bMarks[o]+h,e.tokens.push({type:"list_item_open",lines:A=[t,0],level:e.level++}),a=e.blkIndent,u=e.tight,i=e.tShift[t],l=e.parentType,e.tShift[t]=m-e.bMarks[t],e.blkIndent=s,e.tight=!0,e.parentType="list",e.parser.tokenize(e,t,r,!0),e.tight&&!v||(E=!1),v=e.line-t>1&&e.isEmpty(e.line-1),e.blkIndent=a,e.tShift[t]=i,e.tight=u,e.parentType=l,e.tokens.push({type:"list_item_close",level:--e.level}),o=t=e.line,A[1]=o,m=e.bMarks[t],o>=r)||e.isEmpty(o)||e.tShift[o]c)return!1;if(91!==e.src.charCodeAt(l))return!1;if(94!==e.src.charCodeAt(l+1))return!1;if(e.level>=e.options.maxNesting)return!1;for(a=l+2;a=c||58!==e.src.charCodeAt(++a)||!n&&(a++,e.env.footnotes||(e.env.footnotes={}),e.env.footnotes.refs||(e.env.footnotes.refs={}),u=e.src.slice(l+2,a-2),e.env.footnotes.refs[":"+u]=-1,e.tokens.push({type:"footnote_reference_open",label:u,level:e.level++}),o=e.bMarks[t],s=e.tShift[t],i=e.parentType,e.tShift[t]=e.skipSpaces(a)-a,e.bMarks[t]=a,e.blkIndent+=4,e.parentType="footnote",e.tShift[t]=u)return!1;if(35!==(o=e.src.charCodeAt(a))||a>=u)return!1;for(s=1,o=e.src.charCodeAt(++a);35===o&&a6||aa&&32===e.src.charCodeAt(i-1)&&(u=i),e.line=t+1,e.tokens.push({type:"heading_open",hLevel:s,lines:[t,e.line],level:e.level}),a=r||e.tShift[i]3||(o=e.bMarks[i]+e.tShift[i])>=(s=e.eMarks[i])||45!==(n=e.src.charCodeAt(o))&&61!==n||(o=e.skipChars(o,n),(o=e.skipSpaces(o))3||a+2>=u)return!1;if(60!==e.src.charCodeAt(a))return!1;if(33===(o=e.src.charCodeAt(a+1))||63===o){if(n)return!0}else{if(47!==o&&!function(e){var t=32|e;return t>=97&&t<=122}(o))return!1;if(47===o){if(!(s=e.src.slice(a,u).match(K)))return!1}else if(!(s=e.src.slice(a,u).match(Y)))return!1;if(!0!==J[s[1].toLowerCase()])return!1;if(n)return!0}for(i=t+1;ir)return!1;if(u=t+1,e.tShift[u]=e.eMarks[u])return!1;if(124!==(o=e.src.charCodeAt(i))&&45!==o&&58!==o)return!1;if(s=Q(e,t+1),!/^[-:| ]+$/.test(s))return!1;if((l=s.split("|"))<=2)return!1;for(p=[],a=0;a=0;if(c=t+1,e.isEmpty(c)&&++c>r)return!1;if(e.tShift[c]=e.options.maxNesting)return!1;l=e.tokens.length,e.tokens.push({type:"dl_open",lines:u=[t,0],level:e.level++}),i=t,s=c;e:for(;;){for(b=!0,m=!1,e.tokens.push({type:"dt_open",lines:[i,i],level:e.level++}),e.tokens.push({type:"inline",content:e.getLines(i,i+1,e.blkIndent,!1).trim(),level:e.level+1,lines:[i,i],children:[]}),e.tokens.push({type:"dt_close",level:--e.level});;){if(e.tokens.push({type:"dd_open",lines:a=[c,0],level:e.level++}),d=e.tight,h=e.ddIndent,p=e.blkIndent,g=e.tShift[s],f=e.parentType,e.blkIndent=e.ddIndent=e.tShift[s]+2,e.tShift[s]=o-e.bMarks[s],e.tight=!0,e.parentType="deflist",e.parser.tokenize(e,s,r,!0),e.tight&&!m||(b=!1),m=e.line-s>1&&e.isEmpty(e.line-1),e.tShift[s]=g,e.tight=d,e.parentType=f,e.blkIndent=p,e.ddIndent=h,e.tokens.push({type:"dd_close",level:--e.level}),a[1]=c=e.line,c>=r)break e;if(e.tShift[c]=r)break;if(i=c,e.isEmpty(i))break;if(e.tShift[i]=r)break;if(e.isEmpty(s)&&s++,s>=r)break;if(e.tShift[s]3)){for(o=!1,s=0,i=a.length;s=r))&&!(e.tShift[i]=0&&(e=e.replace(re,function(t,r){var n;return 10===e.charCodeAt(r)?(s=r+1,i=0,t):(n=" ".slice((r-s-i)%4),i=r-s+1,n)})),o=new $(e,this,t,r,n),this.tokenize(o,o.line,o.lineMax)};for(var ie=[],ae=0;ae<256;ae++)ie.push(0);function ue(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122}function le(e,t){var r,n,o,s=t,i=!0,a=!0,u=e.posMax,l=e.src.charCodeAt(t);for(r=t>0?e.src.charCodeAt(t-1):-1;s=u&&(i=!1),(o=s-t)>=4?i=a=!1:(32!==(n=s?@[]^_`{|}~-".split("").forEach(function(e){ie[e.charCodeAt(0)]=1});var ce=/\\([ \\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;var pe=/\\([ \\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;var he=["coap","doi","javascript","aaa","aaas","about","acap","cap","cid","crid","data","dav","dict","dns","file","ftp","geo","go","gopher","h323","http","https","iax","icap","im","imap","info","ipp","iris","iris.beep","iris.xpc","iris.xpcs","iris.lwz","ldap","mailto","mid","msrp","msrps","mtqp","mupdate","news","nfs","ni","nih","nntp","opaquelocktoken","pop","pres","rtsp","service","session","shttp","sieve","sip","sips","sms","snmp","soap.beep","soap.beeps","tag","tel","telnet","tftp","thismessage","tn3270","tip","tv","urn","vemmi","ws","wss","xcon","xcon-userid","xmlrpc.beep","xmlrpc.beeps","xmpp","z39.50r","z39.50s","adiumxtra","afp","afs","aim","apt","attachment","aw","beshare","bitcoin","bolo","callto","chrome","chrome-extension","com-eventbrite-attendee","content","cvs","dlna-playsingle","dlna-playcontainer","dtn","dvb","ed2k","facetime","feed","finger","fish","gg","git","gizmoproject","gtalk","hcp","icon","ipn","irc","irc6","ircs","itms","jar","jms","keyparc","lastfm","ldaps","magnet","maps","market","message","mms","ms-help","msnim","mumble","mvn","notes","oid","palm","paparazzi","platform","proxy","psyc","query","res","resource","rmi","rsync","rtmp","secondlife","sftp","sgn","skype","smb","soldat","spotify","ssh","steam","svn","teamspeak","things","udp","unreal","ut2004","ventrilo","view-source","webcal","wtai","wyciwyg","xfire","xri","ymsgr"],fe=/^<([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)>/,ge=/^<([a-zA-Z.\-]{1,25}):([^<>\x00-\x20]*)>/;function de(e,t){return e=e.source,t=t||"",function r(n,o){return n?(o=o.source||o,e=e.replace(n,o),r):new RegExp(e,t)}}var me=de(/(?:unquoted|single_quoted|double_quoted)/)("unquoted",/[^"'=<>`\x00-\x20]+/)("single_quoted",/'[^']*'/)("double_quoted",/"[^"]*"/)(),be=de(/(?:\s+attr_name(?:\s*=\s*attr_value)?)/)("attr_name",/[a-zA-Z_:][a-zA-Z0-9:._-]*/)("attr_value",me)(),ve=de(/<[A-Za-z][A-Za-z0-9]*attribute*\s*\/?>/)("attribute",be)(),ke=de(/^(?:open_tag|close_tag|comment|processing|declaration|cdata)/)("open_tag",ve)("close_tag",/<\/[A-Za-z][A-Za-z0-9]*\s*>/)("comment",/|/)("processing",/<[?].*?[?]>/)("declaration",/]*>/)("cdata",//)();var Ae=/^&#((?:x[a-f0-9]{1,8}|[0-9]{1,8}));/i,ye=/^&([a-z][a-z0-9]{1,31});/i;var xe=[["text",function(e,t){for(var r=e.pos;r=0&&32===e.pending.charCodeAt(r))if(r>=1&&32===e.pending.charCodeAt(r-1)){for(var s=r-2;s>=0;s--)if(32!==e.pending.charCodeAt(s)){e.pending=e.pending.substring(0,s+1);break}e.push({type:"hardbreak",level:e.level})}else e.pending=e.pending.slice(0,-1),e.push({type:"softbreak",level:e.level});else e.push({type:"softbreak",level:e.level});for(o++;o=a)return!1;if(126!==e.src.charCodeAt(u+1))return!1;if(e.level>=e.options.maxNesting)return!1;if(s=u>0?e.src.charCodeAt(u-1):-1,i=e.src.charCodeAt(u+2),126===s)return!1;if(126===i)return!1;if(32===i||10===i)return!1;for(n=u+2;nu+3)return e.pos+=n-u,t||(e.pending+=e.src.slice(u,n)),!0;for(e.pos=u+2,o=1;e.pos+1=a)return!1;if(43!==e.src.charCodeAt(u+1))return!1;if(e.level>=e.options.maxNesting)return!1;if(s=u>0?e.src.charCodeAt(u-1):-1,i=e.src.charCodeAt(u+2),43===s)return!1;if(43===i)return!1;if(32===i||10===i)return!1;for(n=u+2;n=a)return!1;if(61!==e.src.charCodeAt(u+1))return!1;if(e.level>=e.options.maxNesting)return!1;if(s=u>0?e.src.charCodeAt(u-1):-1,i=e.src.charCodeAt(u+2),61===s)return!1;if(61===i)return!1;if(32===i||10===i)return!1;for(n=u+2;n=e.options.maxNesting)return!1;for(e.pos=c+r,a=[r];e.pos=o)return!1;if(e.level>=e.options.maxNesting)return!1;for(e.pos=s+1;e.pos=o)return!1;if(e.level>=e.options.maxNesting)return!1;for(e.pos=s+1;e.pos=e.options.maxNesting)return!1;if(r=f+1,(n=D(e,f))<0)return!1;if((a=n+1)=h)return!1;for(f=a,q(e,a)?(s=e.linkContent,a=e.pos):s="",f=a;a=h||41!==e.src.charCodeAt(a))return e.pos=p,!1;a++}else{if(e.linkLevel>0)return!1;for(;a=0?o=e.src.slice(f,a++):a=f-1),o||(void 0===o&&(a=n+1),o=e.src.slice(r,n)),!(u=e.env.references[M(o)]))return e.pos=p,!1;s=u.href,i=u.title}return t||(e.pos=r,e.posMax=n,c?e.push({type:"image",src:s,title:i,alt:e.src.substr(r,n-r),level:e.level}):(e.push({type:"link_open",href:s,title:i,level:e.level++}),e.linkLevel++,e.parser.tokenize(e),e.linkLevel--,e.push({type:"link_close",level:--e.level}))),e.pos=a,e.posMax=h,!0}],["footnote_inline",function(e,t){var r,n,o,s,i=e.posMax,a=e.pos;return!(a+2>=i||94!==e.src.charCodeAt(a)||91!==e.src.charCodeAt(a+1)||e.level>=e.options.maxNesting||(r=a+2,(n=D(e,a+1))<0||(t||(e.env.footnotes||(e.env.footnotes={}),e.env.footnotes.list||(e.env.footnotes.list=[]),o=e.env.footnotes.list.length,e.pos=r,e.posMax=n,e.push({type:"footnote_ref",id:o,level:e.level}),e.linkLevel++,s=e.tokens.length,e.parser.tokenize(e),e.env.footnotes.list[o]={tokens:e.tokens.splice(s)},e.linkLevel--),e.pos=n+1,e.posMax=i,0)))}],["footnote_ref",function(e,t){var r,n,o,s,i=e.posMax,a=e.pos;if(a+3>i)return!1;if(!e.env.footnotes||!e.env.footnotes.refs)return!1;if(91!==e.src.charCodeAt(a))return!1;if(94!==e.src.charCodeAt(a+1))return!1;if(e.level>=e.options.maxNesting)return!1;for(n=a+2;n=i||(n++,r=e.src.slice(a+2,n-1),void 0===e.env.footnotes.refs[":"+r]||(t||(e.env.footnotes.list||(e.env.footnotes.list=[]),e.env.footnotes.refs[":"+r]<0?(o=e.env.footnotes.list.length,e.env.footnotes.list[o]={label:r,count:0},e.env.footnotes.refs[":"+r]=o):o=e.env.footnotes.refs[":"+r],s=e.env.footnotes.list[o].count,e.env.footnotes.list[o].count++,e.push({type:"footnote_ref",id:o,subId:s,level:e.level})),e.pos=n,e.posMax=i,0)))}],["autolink",function(e,t){var r,n,o,s,i,a=e.pos;return!(60!==e.src.charCodeAt(a)||(r=e.src.slice(a)).indexOf(">")<0||((n=r.match(ge))?he.indexOf(n[1].toLowerCase())<0||(i=B(s=n[0].slice(1,-1)),!e.parser.validateLink(s)||(t||(e.push({type:"link_open",href:i,level:e.level}),e.push({type:"text",content:s,level:e.level+1}),e.push({type:"link_close",level:e.level})),e.pos+=n[0].length,0)):!(o=r.match(fe))||(i=B("mailto:"+(s=o[0].slice(1,-1))),!e.parser.validateLink(i)||(t||(e.push({type:"link_open",href:i,level:e.level}),e.push({type:"text",content:s,level:e.level+1}),e.push({type:"link_close",level:e.level})),e.pos+=o[0].length,0))))}],["htmltag",function(e,t){var r,n,o,s=e.pos;return!(!e.options.html||(o=e.posMax,60!==e.src.charCodeAt(s)||s+2>=o||33!==(r=e.src.charCodeAt(s+1))&&63!==r&&47!==r&&!function(e){var t=32|e;return t>=97&&t<=122}(r)||!(n=e.src.slice(s).match(ke))||(t||e.push({type:"htmltag",content:e.src.slice(s,s+n[0].length),level:e.level}),e.pos+=n[0].length,0)))}],["entity",function(e,t){var r,o,s=e.pos,i=e.posMax;if(38!==e.src.charCodeAt(s))return!1;if(s+10)e.pos=r;else{for(t=0;t=s)break}else e.pending+=e.src[e.pos++]}e.pending&&e.pushPending()},we.prototype.parse=function(e,t,r,n){var o=new E(e,this,t,r,n);this.tokenize(o)};var Ee={default:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkTarget:"",typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["block","inline","references","replacements","smartquotes","references","abbr2","footnote_tail"]},block:{rules:["blockquote","code","fences","footnote","heading","hr","htmlblock","lheading","list","paragraph","table"]},inline:{rules:["autolink","backticks","del","emphasis","entity","escape","footnote_ref","htmltag","links","newline","text"]}}},full:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkTarget:"",typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{},block:{},inline:{}}},commonmark:{options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:"language-",linkTarget:"",typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["block","inline","references","abbr2"]},block:{rules:["blockquote","code","fences","heading","hr","htmlblock","lheading","list","paragraph"]},inline:{rules:["autolink","backticks","emphasis","entity","escape","htmltag","links","newline","text"]}}}};function De(e,t,r){this.src=t,this.env=r,this.options=e.options,this.tokens=[],this.inlineMode=!1,this.inline=e.inline,this.block=e.block,this.renderer=e.renderer,this.typographer=e.typographer}function _e(e,t){"string"!=typeof e&&(t=e,e="default"),t&&null!=t.linkify&&console.warn("linkify option is removed. Use linkify plugin instead:\n\nimport Remarkable from 'remarkable';\nimport linkify from 'remarkable/linkify';\nnew Remarkable().use(linkify)\n"),this.inline=new we,this.block=new te,this.core=new G,this.renderer=new w,this.ruler=new C,this.options={},this.configure(Ee[e]),this.set(t||{})}function Be(e,t){if(Array.prototype.indexOf)return e.indexOf(t);for(var r=0,n=e.length;r=0;r--)!0===t(e[r])&&e.splice(r,1)}function Fe(e){throw new Error("Unhandled case for value: '"+e+"'")}_e.prototype.set=function(e){i(this.options,e)},_e.prototype.configure=function(e){var t=this;if(!e)throw new Error("Wrong `remarkable` preset, check name/content");e.options&&t.set(e.options),e.components&&Object.keys(e.components).forEach(function(r){e.components[r].rules&&t[r].ruler.enable(e.components[r].rules,!0)})},_e.prototype.use=function(e,t){return e(this,t),this},_e.prototype.parse=function(e,t){var r=new De(this,e,t);return this.core.process(r),r.tokens},_e.prototype.render=function(e,t){return t=t||{},this.renderer.render(this.parse(e,t),this.options,t)},_e.prototype.parseInline=function(e,t){var r=new De(this,e,t);return r.inlineMode=!0,this.core.process(r),r.tokens},_e.prototype.renderInline=function(e,t){return t=t||{},this.renderer.render(this.parseInline(e,t),this.options,t)};var Me=function(){function e(e){void 0===e&&(e={}),this.tagName="",this.attrs={},this.innerHTML="",this.whitespaceRegex=/\s+/,this.tagName=e.tagName||"",this.attrs=e.attrs||{},this.innerHTML=e.innerHtml||e.innerHTML||""}return e.prototype.setTagName=function(e){return this.tagName=e,this},e.prototype.getTagName=function(){return this.tagName||""},e.prototype.setAttr=function(e,t){return this.getAttrs()[e]=t,this},e.prototype.getAttr=function(e){return this.getAttrs()[e]},e.prototype.setAttrs=function(e){return Object.assign(this.getAttrs(),e),this},e.prototype.getAttrs=function(){return this.attrs||(this.attrs={})},e.prototype.setClass=function(e){return this.setAttr("class",e)},e.prototype.addClass=function(e){for(var t,r=this.getClass(),n=this.whitespaceRegex,o=r?r.split(n):[],s=e.split(n);t=s.shift();)-1===Be(o,t)&&o.push(t);return this.getAttrs().class=o.join(" "),this},e.prototype.removeClass=function(e){for(var t,r=this.getClass(),n=this.whitespaceRegex,o=r?r.split(n):[],s=e.split(n);o.length&&(t=s.shift());){var i=Be(o,t);-1!==i&&o.splice(i,1)}return this.getAttrs().class=o.join(" "),this},e.prototype.getClass=function(){return this.getAttrs().class||""},e.prototype.hasClass=function(e){return-1!==(" "+this.getClass()+" ").indexOf(" "+e+" ")},e.prototype.setInnerHTML=function(e){return this.innerHTML=e,this},e.prototype.setInnerHtml=function(e){return this.setInnerHTML(e)},e.prototype.getInnerHTML=function(){return this.innerHTML||""},e.prototype.getInnerHtml=function(){return this.getInnerHTML()},e.prototype.toAnchorString=function(){var e=this.getTagName(),t=this.buildAttrsStr();return["<",e,t=t?" "+t:"",">",this.getInnerHtml(),""].join("")},e.prototype.buildAttrsStr=function(){if(!this.attrs)return"";var e=this.getAttrs(),t=[];for(var r in e)e.hasOwnProperty(r)&&t.push(r+'="'+e[r]+'"');return t.join(" ")},e}();var Se=function(){function e(e){void 0===e&&(e={}),this.newWindow=!1,this.truncate={},this.className="",this.newWindow=e.newWindow||!1,this.truncate=e.truncate||{},this.className=e.className||""}return e.prototype.build=function(e){return new Me({tagName:"a",attrs:this.createAttrs(e),innerHtml:this.processAnchorText(e.getAnchorText())})},e.prototype.createAttrs=function(e){var t={href:e.getAnchorHref()},r=this.createCssClass(e);return r&&(t.class=r),this.newWindow&&(t.target="_blank",t.rel="noopener noreferrer"),this.truncate&&this.truncate.length&&this.truncate.length=a)return u.host.length==t?(u.host.substr(0,t-o)+r).substr(0,a+n):i(c,a).substr(0,a+n);var p="";if(u.path&&(p+="/"+u.path),u.query&&(p+="?"+u.query),p){if((c+p).length>=a)return(c+p).length==t?(c+p).substr(0,t):(c+i(p,a-c.length)).substr(0,a+n);c+=p}if(u.fragment){var h="#"+u.fragment;if((c+h).length>=a)return(c+h).length==t?(c+h).substr(0,t):(c+i(h,a-c.length)).substr(0,a+n);c+=h}if(u.scheme&&u.host){var f=u.scheme+"://";if((c+f).length0&&(g=c.substr(-1*Math.floor(a/2))),(c.substr(0,Math.ceil(a/2))+r+g).substr(0,a+n)}(e,r):"middle"===n?function(e,t,r){if(e.length<=t)return e;var n,o;null==r?(r="…",n=8,o=3):(n=r.length,o=r.length);var s=t-o,i="";return s>0&&(i=e.substr(-1*Math.floor(s/2))),(e.substr(0,Math.ceil(s/2))+r+i).substr(0,s+n)}(e,r):function(e,t,r){return function(e,t,r){var n;return e.length>t&&(null==r?(r="…",n=3):n=r.length,e=e.substring(0,t-n)+r),e}(e,t,r)}(e,r)},e}(),Te=function(){function e(e){this.__jsduckDummyDocProp=null,this.matchedText="",this.offset=0,this.tagBuilder=e.tagBuilder,this.matchedText=e.matchedText,this.offset=e.offset}return e.prototype.getMatchedText=function(){return this.matchedText},e.prototype.setOffset=function(e){this.offset=e},e.prototype.getOffset=function(){return this.offset},e.prototype.getCssClassSuffixes=function(){return[this.getType()]},e.prototype.buildTag=function(){return this.tagBuilder.build(this)},e}(),Le=function(e,t){return(Le=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function Re(e,t){function r(){this.constructor=e}Le(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var Ne=function(){return(Ne=Object.assign||function(e){for(var t,r=1,n=arguments.length;r-1},e.isValidUriScheme=function(e){var t=e.match(this.uriSchemeRegex),r=t&&t[0].toLowerCase();return"javascript:"!==r&&"vbscript:"!==r},e.urlMatchDoesNotHaveProtocolOrDot=function(e,t){return!(!e||t&&this.hasFullProtocolRegex.test(t)||-1!==e.indexOf("."))},e.urlMatchDoesNotHaveAtLeastOneWordChar=function(e,t){return!(!e||!t)&&!this.hasWordCharAfterProtocolRegex.test(e)},e.hasFullProtocolRegex=/^[A-Za-z][-.+A-Za-z0-9]*:\/\//,e.uriSchemeRegex=/^[A-Za-z][-.+A-Za-z0-9]*:/,e.hasWordCharAfterProtocolRegex=new RegExp(":[^\\s]*?["+We+"]"),e.ipRegex=/[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?(:[0-9]*)?\/?$/,e}(),ut=function(e){function t(t){var r,n=e.call(this,t)||this;return n.stripPrefix={scheme:!0,www:!0},n.stripTrailingSlash=!0,n.decodePercentEncoding=!0,n.matcherRegex=(r=new RegExp("[/?#](?:["+Qe+"\\-+&@#/%=~_()|'$*\\[\\]?!:,.;✓]*["+Qe+"\\-+&@#/%=~_()|'$*\\[\\]✓])?"),new RegExp(["(?:","(",/(?:[A-Za-z][-.+A-Za-z0-9]{0,63}:(?![A-Za-z][-.+A-Za-z0-9]{0,63}:\/\/)(?!\d+\/?)(?:\/\/)?)/.source,rt(2),")","|","(","(//)?",/(?:www\.)/.source,rt(6),")","|","(","(//)?",rt(10)+"\\.",ot.source,"(?![-"+Ke+"])",")",")","(?::[0-9]+)?","(?:"+r.source+")?"].join(""),"gi")),n.wordCharRegExp=new RegExp("["+Qe+"]"),n.stripPrefix=t.stripPrefix,n.stripTrailingSlash=t.stripTrailingSlash,n.decodePercentEncoding=t.decodePercentEncoding,n}return Re(t,e),t.prototype.parseMatches=function(e){for(var t,r=this.matcherRegex,n=this.stripPrefix,o=this.stripTrailingSlash,s=this.decodePercentEncoding,i=this.tagBuilder,a=[],u=function(){var r=t[0],u=t[1],c=t[4],p=t[5],h=t[9],f=t.index,g=p||h,d=e.charAt(f-1);if(!at.isValid(r,u))return"continue";if(f>0&&"@"===d)return"continue";if(f>0&&g&&l.wordCharRegExp.test(d))return"continue";if(/\?$/.test(r)&&(r=r.substr(0,r.length-1)),l.matchHasUnbalancedClosingParen(r))r=r.substr(0,r.length-1);else{var m=l.matchHasInvalidCharAfterTld(r,u);m>-1&&(r=r.substr(0,m))}var b=["http://","https://"].find(function(e){return!!u&&-1!==u.indexOf(e)});if(b){var v=r.indexOf(b);r=r.substr(v),u=u.substr(v),f+=v}var k=u?"scheme":c?"www":"tld",A=!!u;a.push(new Oe({tagBuilder:i,matchedText:r,offset:f,urlMatchType:k,url:r,protocolUrlMatch:A,protocolRelativeMatch:!!g,stripPrefix:n,stripTrailingSlash:o,decodePercentEncoding:s}))},l=this;null!==(t=r.exec(e));)u();return a},t.prototype.matchHasUnbalancedClosingParen=function(e){var t,r=e.charAt(e.length-1);if(")"===r)t="(";else{if("]"!==r)return!1;t="["}for(var n=0,o=0,s=e.length-1;o"===e?(h=new ft(Ne({},h,{name:P()})),z()):He.test(e)||Ve.test(e)||":"===e||R()}function b(e){">"===e?R():He.test(e)?c=3:R()}function v(e){Ge.test(e)||("/"===e?c=12:">"===e?z():"<"===e?N():"="===e||$e.test(e)||Ze.test(e)?R():c=5)}function k(e){Ge.test(e)?c=6:"/"===e?c=12:"="===e?c=7:">"===e?z():"<"===e?N():$e.test(e)&&R()}function A(e){Ge.test(e)||("/"===e?c=12:"="===e?c=7:">"===e?z():"<"===e?N():$e.test(e)?R():c=5)}function y(e){Ge.test(e)||('"'===e?c=8:"'"===e?c=9:/[>=`]/.test(e)?R():"<"===e?N():c=10)}function x(e){'"'===e&&(c=11)}function w(e){"'"===e&&(c=11)}function C(e){Ge.test(e)?c=4:">"===e?z():"<"===e&&N()}function E(e){Ge.test(e)?c=4:"/"===e?c=12:">"===e?z():"<"===e?N():(c=4,u--)}function D(e){">"===e?(h=new ft(Ne({},h,{isClosing:!0})),z()):c=4}function _(t){"--"===e.substr(u,2)?(u+=2,h=new ft(Ne({},h,{type:"comment"})),c=14):"DOCTYPE"===e.substr(u,7).toUpperCase()?(u+=7,h=new ft(Ne({},h,{type:"doctype"})),c=20):R()}function B(e){"-"===e?c=15:">"===e?R():c=16}function q(e){"-"===e?c=18:">"===e?R():c=16}function F(e){"-"===e&&(c=17)}function M(e){c="-"===e?18:16}function S(e){">"===e?z():"!"===e?c=19:"-"===e||(c=16)}function T(e){"-"===e?c=17:">"===e?z():c=16}function L(e){">"===e?z():"<"===e&&N()}function R(){c=0,h=a}function N(){c=1,h=new ft({idx:u})}function z(){var t=e.slice(p,h.idx);t&&o(t,p),"comment"===h.type?s(h.idx):"doctype"===h.type?i(h.idx):(h.isOpening&&r(h.name,h.idx),h.isClosing&&n(h.name,h.idx)),R(),p=u+1}function P(){var t=h.idx+(h.isClosing?2:1);return e.slice(t,u).toLowerCase()}p=0&&n++},onText:function(e,r){if(0===n){var s=function(e,t){if(!t.global)throw new Error("`splitRegex` must have the 'g' flag set");for(var r,n=[],o=0;r=t.exec(e);)n.push(e.substring(o,r.index)),n.push(r[0]),o=r.index+r[0].length;return n.push(e.substring(o)),n}(e,/( | |<|<|>|>|"|"|')/gi),i=r;s.forEach(function(e,r){if(r%2==0){var n=t.parseText(e,i);o.push.apply(o,n)}i+=e.length})}},onCloseTag:function(e){r.indexOf(e)>=0&&(n=Math.max(n-1,0))},onComment:function(e){},onDoctype:function(e){}}),o=this.compactMatches(o),o=this.removeUnwantedMatches(o)},e.prototype.compactMatches=function(e){e.sort(function(e,t){return e.getOffset()-t.getOffset()});for(var t=0;to?t:t+1;e.splice(i,1);continue}e[t+1].getOffset()/i.test(e)}function bt(){var e=[],t=new gt({stripPrefix:!1,url:!0,email:!0,replaceFn:function(t){switch(t.getType()){case"url":e.push({text:t.matchedText,url:t.getUrl()});break;case"email":e.push({text:t.matchedText,url:"mailto:"+t.getEmail().replace(/^mailto:/i,"")})}return!1}});return{links:e,autolinker:t}}function vt(e){var t,r,n,o,s,i,a,u,l,c,p,h,f,g,d=e.tokens,m=null;for(r=0,n=d.length;r=0;t--)if("link_close"!==(s=o[t]).type){if("htmltag"===s.type&&(g=s.content,/^\s]/i.test(g)&&p>0&&p--,mt(s.content)&&p++),!(p>0)&&"text"===s.type&&dt.test(s.content)){if(m||(h=(m=bt()).links,f=m.autolinker),i=s.content,h.length=0,f.link(i),!h.length)continue;for(a=[],c=s.level,u=0;u[[breaks|$:/config/markdown/breaks]]| ``false``|Remarkable library config: Convert '\n' in paragraphs into ``
    `` | +| [[linkify|$:/config/markdown/linkify]]| ``false``|Remarkable library config: Autoconvert URL-like text to links | +| [[linkNewWindow|$:/config/markdown/linkNewWindow]]| ``true``|For external links, should clicking on them open a new window/tab automatically? | +| [[quotes|$:/config/markdown/quotes]]| ``“”‘’``|Remarkable library config: Double + single quotes replacement pairs, when ``typographer`` enabled | +| [[renderWikiText|$:/config/markdown/renderWikiText]]| ``true``|After Markdown is parsed, should any text elements be handed off to the ~WikiText parser for further processing? | +| [[renderWikiTextPragma|$:/config/markdown/renderWikiTextPragma]]| ``\rules only html image macrocallinline syslink transcludeinline wikilink filteredtranscludeblock macrocallblock transcludeblock``|When handing off to the ~WikiText parser, what pragma rules should it follow? | +| [[typographer|$:/config/markdown/typographer]]| ``false``|Remarkable library config: Enable some language-neutral replacement + quotes beautification | ! Creating ~WikiLinks @@ -19,6 +19,12 @@ Create wiki links with the usual Markdown link syntax targeting `#` and the targ [link text](#TiddlerTitle) ``` +If the target tiddler has a space in its name, that name must be URL-escaped to be detected as a URL: + +``` +[link text](#Test%20Tiddler) +``` + ! Images Markdown image syntax can be used to reference images by tiddler title or an external URI. For example: diff --git a/plugins/tiddlywiki/markdown/wrapper.js b/plugins/tiddlywiki/markdown/wrapper.js index 0eab2e200..5c048f6d6 100755 --- a/plugins/tiddlywiki/markdown/wrapper.js +++ b/plugins/tiddlywiki/markdown/wrapper.js @@ -3,7 +3,7 @@ title: $:/plugins/tiddlywiki/markdown/wrapper.js type: application/javascript module-type: parser -Wraps up the markdown-js parser for use in TiddlyWiki5 +Wraps up the remarkable parser for use as a Parser in TiddlyWiki \*/ (function(){ @@ -12,78 +12,211 @@ Wraps up the markdown-js parser for use in TiddlyWiki5 /*global $tw: false */ "use strict"; -var markdown = require("$:/plugins/tiddlywiki/markdown/markdown.js"); +const { Remarkable, linkify, utils } = require("$:/plugins/tiddlywiki/markdown/remarkable.js"); -var CONFIG_DIALECT_TIDDLER = "$:/config/markdown/dialect", - DEFAULT_DIALECT = "Gruber"; - -function transformNodes(nodes) { - var results = []; - for(var index=0; index 0 + && rs[0].type === "text" + && currentNode.content[0] === " " + ) { + rs[0].text = " " + rs[0].text; + } + out = out.concat(rs); + } + } else { + console.error("Unknown node type: " + currentNode.type, currentNode); + out.push({ + type: "text", + text: currentNode.content + }); + } + } + return out; +} + +var MarkdownParser = function(type, text, options) { + var tree = md.parse(text, {}); + //console.debug(tree); + tree = convertNodes(tree); + //console.debug(tree); + + this.tree = tree; +}; exports["text/x-markdown"] = MarkdownParser; })(); -