administrate-field-simple_mde_markdown 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +72 -0
- data/.circleci/setup-rubygems.sh +3 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +196 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +8 -0
- data/administrate-field-simple_mde_markdown.gemspec +31 -0
- data/app/assets/javascripts/administrate-field-simple_mde_markdown/application.js +6 -0
- data/app/assets/stylesheets/administrate-field-simple_mde_markdown/application.css +3 -0
- data/app/views/fields/simple_mde_markdown/_form.html.erb +6 -0
- data/app/views/fields/simple_mde_markdown/_index.html.erb +1 -0
- data/app/views/fields/simple_mde_markdown/_show.html.erb +1 -0
- data/lib/administrate/field/simple_mde_markdown.rb +31 -0
- data/node_modules/.bin/marked +1 -0
- data/node_modules/codemirror-spell-checker/.eslintrc +23 -0
- data/node_modules/codemirror-spell-checker/.npmignore +2 -0
- data/node_modules/codemirror-spell-checker/.travis.yml +18 -0
- data/node_modules/codemirror-spell-checker/CONTRIBUTING 2.md +10 -0
- data/node_modules/codemirror-spell-checker/CONTRIBUTING.md +10 -0
- data/node_modules/codemirror-spell-checker/LICENSE +22 -0
- data/node_modules/codemirror-spell-checker/README.md +50 -0
- data/node_modules/codemirror-spell-checker/bower.json +27 -0
- data/node_modules/codemirror-spell-checker/debug/.spell-checker 2.css.icloud +0 -0
- data/node_modules/codemirror-spell-checker/debug/spell-checker.css +9 -0
- data/node_modules/codemirror-spell-checker/debug/spell-checker.debug.js +2844 -0
- data/node_modules/codemirror-spell-checker/debug/spell-checker.js +2841 -0
- data/node_modules/codemirror-spell-checker/dist/.spell-checker.min 2.css.icloud +0 -0
- data/node_modules/codemirror-spell-checker/dist/en_US.aff +201 -0
- data/node_modules/codemirror-spell-checker/dist/en_US.dic +62120 -0
- data/node_modules/codemirror-spell-checker/dist/spell-checker.min 2.js +7 -0
- data/node_modules/codemirror-spell-checker/dist/spell-checker.min.css +7 -0
- data/node_modules/codemirror-spell-checker/dist/spell-checker.min.js +7 -0
- data/node_modules/codemirror-spell-checker/gulpfile.js +94 -0
- data/node_modules/codemirror-spell-checker/package.json +75 -0
- data/node_modules/codemirror-spell-checker/src/css/spell-checker.css +3 -0
- data/node_modules/codemirror-spell-checker/src/data/en_US.aff +201 -0
- data/node_modules/codemirror-spell-checker/src/data/en_US.dic +62120 -0
- data/node_modules/codemirror-spell-checker/src/js/spell-checker.js +119 -0
- data/node_modules/codemirror/.package 2.json.icloud +0 -0
- data/node_modules/codemirror/AUTHORS +773 -0
- data/node_modules/codemirror/CHANGELOG.md +1486 -0
- data/node_modules/codemirror/CONTRIBUTING.md +92 -0
- data/node_modules/codemirror/LICENSE +21 -0
- data/node_modules/codemirror/README.md +49 -0
- data/node_modules/codemirror/addon/comment/comment.js +209 -0
- data/node_modules/codemirror/addon/comment/continuecomment.js +78 -0
- data/node_modules/codemirror/addon/dialog/dialog.css +32 -0
- data/node_modules/codemirror/addon/dialog/dialog.js +161 -0
- data/node_modules/codemirror/addon/display/autorefresh.js +47 -0
- data/node_modules/codemirror/addon/display/fullscreen.css +6 -0
- data/node_modules/codemirror/addon/display/fullscreen.js +41 -0
- data/node_modules/codemirror/addon/display/panel.js +127 -0
- data/node_modules/codemirror/addon/display/placeholder.js +63 -0
- data/node_modules/codemirror/addon/display/rulers.js +51 -0
- data/node_modules/codemirror/addon/edit/closebrackets.js +187 -0
- data/node_modules/codemirror/addon/edit/closetag.js +175 -0
- data/node_modules/codemirror/addon/edit/continuelist.js +89 -0
- data/node_modules/codemirror/addon/edit/matchbrackets.js +145 -0
- data/node_modules/codemirror/addon/edit/matchtags.js +66 -0
- data/node_modules/codemirror/addon/edit/trailingspace.js +27 -0
- data/node_modules/codemirror/addon/fold/brace-fold.js +105 -0
- data/node_modules/codemirror/addon/fold/comment-fold.js +59 -0
- data/node_modules/codemirror/addon/fold/foldcode.js +152 -0
- data/node_modules/codemirror/addon/fold/foldgutter.css +20 -0
- data/node_modules/codemirror/addon/fold/foldgutter.js +146 -0
- data/node_modules/codemirror/addon/fold/indent-fold.js +48 -0
- data/node_modules/codemirror/addon/fold/markdown-fold.js +49 -0
- data/node_modules/codemirror/addon/fold/xml-fold.js +184 -0
- data/node_modules/codemirror/addon/hint/anyword-hint.js +41 -0
- data/node_modules/codemirror/addon/hint/css-hint.js +60 -0
- data/node_modules/codemirror/addon/hint/html-hint.js +348 -0
- data/node_modules/codemirror/addon/hint/javascript-hint.js +157 -0
- data/node_modules/codemirror/addon/hint/show-hint.css +36 -0
- data/node_modules/codemirror/addon/hint/show-hint.js +434 -0
- data/node_modules/codemirror/addon/hint/sql-hint.js +299 -0
- data/node_modules/codemirror/addon/hint/xml-hint.js +110 -0
- data/node_modules/codemirror/addon/lint/coffeescript-lint.js +47 -0
- data/node_modules/codemirror/addon/lint/css-lint.js +40 -0
- data/node_modules/codemirror/addon/lint/html-lint.js +53 -0
- data/node_modules/codemirror/addon/lint/javascript-lint.js +63 -0
- data/node_modules/codemirror/addon/lint/json-lint.js +40 -0
- data/node_modules/codemirror/addon/lint/lint.css +73 -0
- data/node_modules/codemirror/addon/lint/lint.js +252 -0
- data/node_modules/codemirror/addon/lint/yaml-lint.js +41 -0
- data/node_modules/codemirror/addon/merge/merge.css +119 -0
- data/node_modules/codemirror/addon/merge/merge.js +1002 -0
- data/node_modules/codemirror/addon/mode/loadmode.js +64 -0
- data/node_modules/codemirror/addon/mode/multiplex.js +131 -0
- data/node_modules/codemirror/addon/mode/multiplex_test.js +33 -0
- data/node_modules/codemirror/addon/mode/overlay.js +90 -0
- data/node_modules/codemirror/addon/mode/simple.js +216 -0
- data/node_modules/codemirror/addon/runmode/colorize.js +40 -0
- data/node_modules/codemirror/addon/runmode/runmode-standalone.js +158 -0
- data/node_modules/codemirror/addon/runmode/runmode.js +72 -0
- data/node_modules/codemirror/addon/runmode/runmode.node.js +197 -0
- data/node_modules/codemirror/addon/scroll/annotatescrollbar.js +122 -0
- data/node_modules/codemirror/addon/scroll/scrollpastend.js +48 -0
- data/node_modules/codemirror/addon/scroll/simplescrollbars.css +66 -0
- data/node_modules/codemirror/addon/scroll/simplescrollbars.js +152 -0
- data/node_modules/codemirror/addon/search/jump-to-line.js +50 -0
- data/node_modules/codemirror/addon/search/match-highlighter.js +165 -0
- data/node_modules/codemirror/addon/search/matchesonscrollbar.css +8 -0
- data/node_modules/codemirror/addon/search/matchesonscrollbar.js +97 -0
- data/node_modules/codemirror/addon/search/search.js +258 -0
- data/node_modules/codemirror/addon/search/searchcursor.js +293 -0
- data/node_modules/codemirror/addon/selection/active-line.js +72 -0
- data/node_modules/codemirror/addon/selection/mark-selection.js +119 -0
- data/node_modules/codemirror/addon/selection/selection-pointer.js +98 -0
- data/node_modules/codemirror/addon/tern/tern.css +87 -0
- data/node_modules/codemirror/addon/tern/tern.js +718 -0
- data/node_modules/codemirror/addon/tern/worker.js +44 -0
- data/node_modules/codemirror/addon/wrap/hardwrap.js +145 -0
- data/node_modules/codemirror/bin/source-highlight +48 -0
- data/node_modules/codemirror/keymap/emacs.js +417 -0
- data/node_modules/codemirror/keymap/sublime.js +691 -0
- data/node_modules/codemirror/keymap/vim.js +5467 -0
- data/node_modules/codemirror/lib/codemirror.css +346 -0
- data/node_modules/codemirror/lib/codemirror.js +9698 -0
- data/node_modules/codemirror/mode/apl/apl.js +174 -0
- data/node_modules/codemirror/mode/asciiarmor/asciiarmor.js +74 -0
- data/node_modules/codemirror/mode/asn.1/asn.1.js +204 -0
- data/node_modules/codemirror/mode/asterisk/asterisk.js +196 -0
- data/node_modules/codemirror/mode/brainfuck/brainfuck.js +85 -0
- data/node_modules/codemirror/mode/clike/clike.js +879 -0
- data/node_modules/codemirror/mode/clojure/clojure.js +292 -0
- data/node_modules/codemirror/mode/cmake/cmake.js +97 -0
- data/node_modules/codemirror/mode/cobol/cobol.js +255 -0
- data/node_modules/codemirror/mode/coffeescript/coffeescript.js +359 -0
- data/node_modules/codemirror/mode/commonlisp/commonlisp.js +124 -0
- data/node_modules/codemirror/mode/crystal/crystal.js +433 -0
- data/node_modules/codemirror/mode/css/css.js +832 -0
- data/node_modules/codemirror/mode/cypher/cypher.js +150 -0
- data/node_modules/codemirror/mode/d/d.js +223 -0
- data/node_modules/codemirror/mode/dart/dart.js +157 -0
- data/node_modules/codemirror/mode/diff/diff.js +47 -0
- data/node_modules/codemirror/mode/django/django.js +356 -0
- data/node_modules/codemirror/mode/dockerfile/dockerfile.js +211 -0
- data/node_modules/codemirror/mode/dtd/dtd.js +142 -0
- data/node_modules/codemirror/mode/dylan/dylan.js +352 -0
- data/node_modules/codemirror/mode/ebnf/ebnf.js +195 -0
- data/node_modules/codemirror/mode/ecl/ecl.js +206 -0
- data/node_modules/codemirror/mode/eiffel/eiffel.js +160 -0
- data/node_modules/codemirror/mode/elm/elm.js +205 -0
- data/node_modules/codemirror/mode/erlang/erlang.js +619 -0
- data/node_modules/codemirror/mode/factor/factor.js +85 -0
- data/node_modules/codemirror/mode/fcl/fcl.js +173 -0
- data/node_modules/codemirror/mode/forth/forth.js +180 -0
- data/node_modules/codemirror/mode/fortran/fortran.js +188 -0
- data/node_modules/codemirror/mode/gas/gas.js +345 -0
- data/node_modules/codemirror/mode/gfm/gfm.js +129 -0
- data/node_modules/codemirror/mode/gherkin/gherkin.js +178 -0
- data/node_modules/codemirror/mode/go/go.js +187 -0
- data/node_modules/codemirror/mode/groovy/groovy.js +230 -0
- data/node_modules/codemirror/mode/haml/haml.js +161 -0
- data/node_modules/codemirror/mode/handlebars/handlebars.js +66 -0
- data/node_modules/codemirror/mode/haskell-literate/haskell-literate.js +43 -0
- data/node_modules/codemirror/mode/haskell/haskell.js +268 -0
- data/node_modules/codemirror/mode/haxe/haxe.js +515 -0
- data/node_modules/codemirror/mode/htmlembedded/htmlembedded.js +37 -0
- data/node_modules/codemirror/mode/htmlmixed/htmlmixed.js +152 -0
- data/node_modules/codemirror/mode/http/http.js +113 -0
- data/node_modules/codemirror/mode/idl/idl.js +290 -0
- data/node_modules/codemirror/mode/javascript/javascript.js +899 -0
- data/node_modules/codemirror/mode/jinja2/jinja2.js +144 -0
- data/node_modules/codemirror/mode/jsx/jsx.js +148 -0
- data/node_modules/codemirror/mode/julia/julia.js +433 -0
- data/node_modules/codemirror/mode/livescript/livescript.js +280 -0
- data/node_modules/codemirror/mode/lua/lua.js +159 -0
- data/node_modules/codemirror/mode/markdown/markdown.js +884 -0
- data/node_modules/codemirror/mode/mathematica/mathematica.js +176 -0
- data/node_modules/codemirror/mode/mbox/mbox.js +129 -0
- data/node_modules/codemirror/mode/meta.js +217 -0
- data/node_modules/codemirror/mode/mirc/mirc.js +193 -0
- data/node_modules/codemirror/mode/mllike/mllike.js +359 -0
- data/node_modules/codemirror/mode/modelica/modelica.js +245 -0
- data/node_modules/codemirror/mode/mscgen/mscgen.js +175 -0
- data/node_modules/codemirror/mode/mumps/mumps.js +148 -0
- data/node_modules/codemirror/mode/nginx/nginx.js +178 -0
- data/node_modules/codemirror/mode/nsis/nsis.js +95 -0
- data/node_modules/codemirror/mode/ntriples/ntriples.js +195 -0
- data/node_modules/codemirror/mode/octave/octave.js +139 -0
- data/node_modules/codemirror/mode/oz/oz.js +252 -0
- data/node_modules/codemirror/mode/pascal/pascal.js +121 -0
- data/node_modules/codemirror/mode/pegjs/pegjs.js +114 -0
- data/node_modules/codemirror/mode/perl/perl.js +837 -0
- data/node_modules/codemirror/mode/php/php.js +234 -0
- data/node_modules/codemirror/mode/pig/pig.js +178 -0
- data/node_modules/codemirror/mode/powershell/powershell.js +398 -0
- data/node_modules/codemirror/mode/properties/properties 2.js +78 -0
- data/node_modules/codemirror/mode/properties/properties.js +78 -0
- data/node_modules/codemirror/mode/protobuf/protobuf.js +69 -0
- data/node_modules/codemirror/mode/pug/pug.js +591 -0
- data/node_modules/codemirror/mode/puppet/puppet.js +220 -0
- data/node_modules/codemirror/mode/python/python.js +409 -0
- data/node_modules/codemirror/mode/q/q.js +139 -0
- data/node_modules/codemirror/mode/r/r.js +190 -0
- data/node_modules/codemirror/mode/rpm/changes/index.html +66 -0
- data/node_modules/codemirror/mode/rpm/rpm.js +109 -0
- data/node_modules/codemirror/mode/rst/rst.js +557 -0
- data/node_modules/codemirror/mode/ruby/ruby.js +296 -0
- data/node_modules/codemirror/mode/rust/rust.js +72 -0
- data/node_modules/codemirror/mode/sas/sas.js +303 -0
- data/node_modules/codemirror/mode/sass/sass.js +454 -0
- data/node_modules/codemirror/mode/scheme/scheme.js +265 -0
- data/node_modules/codemirror/mode/shell/shell.js +152 -0
- data/node_modules/codemirror/mode/sieve/sieve.js +193 -0
- data/node_modules/codemirror/mode/slim/slim.js +575 -0
- data/node_modules/codemirror/mode/smalltalk/smalltalk.js +168 -0
- data/node_modules/codemirror/mode/smarty/smarty.js +225 -0
- data/node_modules/codemirror/mode/solr/solr.js +104 -0
- data/node_modules/codemirror/mode/soy/soy 2.js +359 -0
- data/node_modules/codemirror/mode/soy/soy.js +235 -0
- data/node_modules/codemirror/mode/sparql/sparql.js +180 -0
- data/node_modules/codemirror/mode/spreadsheet/spreadsheet.js +112 -0
- data/node_modules/codemirror/mode/sql/sql.js +499 -0
- data/node_modules/codemirror/mode/stex/stex.js +264 -0
- data/node_modules/codemirror/mode/stylus/stylus.js +771 -0
- data/node_modules/codemirror/mode/swift/swift.js +219 -0
- data/node_modules/codemirror/mode/tcl/tcl.js +139 -0
- data/node_modules/codemirror/mode/textile/textile.js +469 -0
- data/node_modules/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
- data/node_modules/codemirror/mode/tiddlywiki/tiddlywiki.js +308 -0
- data/node_modules/codemirror/mode/tiki/tiki.css +26 -0
- data/node_modules/codemirror/mode/tiki/tiki.js +312 -0
- data/node_modules/codemirror/mode/toml/toml.js +88 -0
- data/node_modules/codemirror/mode/tornado/tornado.js +68 -0
- data/node_modules/codemirror/mode/troff/troff.js +84 -0
- data/node_modules/codemirror/mode/ttcn-cfg/ttcn-cfg.js +214 -0
- data/node_modules/codemirror/mode/ttcn/ttcn.js +283 -0
- data/node_modules/codemirror/mode/turtle/turtle.js +162 -0
- data/node_modules/codemirror/mode/twig/twig.js +141 -0
- data/node_modules/codemirror/mode/vb/vb.js +275 -0
- data/node_modules/codemirror/mode/vbscript/vbscript.js +350 -0
- data/node_modules/codemirror/mode/velocity/velocity.js +201 -0
- data/node_modules/codemirror/mode/verilog/verilog.js +675 -0
- data/node_modules/codemirror/mode/vhdl/vhdl.js +189 -0
- data/node_modules/codemirror/mode/vue/vue.js +77 -0
- data/node_modules/codemirror/mode/webidl/webidl.js +195 -0
- data/node_modules/codemirror/mode/xml/xml.js +402 -0
- data/node_modules/codemirror/mode/xquery/xquery.js +448 -0
- data/node_modules/codemirror/mode/yacas/yacas.js +204 -0
- data/node_modules/codemirror/mode/yaml-frontmatter/yaml-frontmatter.js +68 -0
- data/node_modules/codemirror/mode/yaml/yaml.js +120 -0
- data/node_modules/codemirror/mode/z80/z80.js +116 -0
- data/node_modules/codemirror/package.json +2395 -0
- data/node_modules/codemirror/rollup.config.js +20 -0
- data/node_modules/codemirror/src/codemirror.js +3 -0
- data/node_modules/codemirror/src/display/Display.js +106 -0
- data/node_modules/codemirror/src/display/focus.js +47 -0
- data/node_modules/codemirror/src/display/gutters.js +34 -0
- data/node_modules/codemirror/src/display/highlight_worker.js +55 -0
- data/node_modules/codemirror/src/display/line_numbers.js +48 -0
- data/node_modules/codemirror/src/display/mode_state.js +22 -0
- data/node_modules/codemirror/src/display/operations.js +205 -0
- data/node_modules/codemirror/src/display/scroll_events.js +115 -0
- data/node_modules/codemirror/src/display/scrollbars.js +193 -0
- data/node_modules/codemirror/src/display/scrolling.js +184 -0
- data/node_modules/codemirror/src/display/selection.js +158 -0
- data/node_modules/codemirror/src/display/update_display.js +260 -0
- data/node_modules/codemirror/src/display/update_line.js +188 -0
- data/node_modules/codemirror/src/display/update_lines.js +64 -0
- data/node_modules/codemirror/src/display/view_tracking.js +153 -0
- data/node_modules/codemirror/src/edit/CodeMirror.js +215 -0
- data/node_modules/codemirror/src/edit/commands.js +178 -0
- data/node_modules/codemirror/src/edit/deleteNearSelection.js +30 -0
- data/node_modules/codemirror/src/edit/drop_events.js +119 -0
- data/node_modules/codemirror/src/edit/fromTextArea.js +61 -0
- data/node_modules/codemirror/src/edit/global_events.js +42 -0
- data/node_modules/codemirror/src/edit/key_events.js +159 -0
- data/node_modules/codemirror/src/edit/legacy.js +62 -0
- data/node_modules/codemirror/src/edit/main.js +69 -0
- data/node_modules/codemirror/src/edit/methods.js +544 -0
- data/node_modules/codemirror/src/edit/mouse_events.js +407 -0
- data/node_modules/codemirror/src/edit/options.js +193 -0
- data/node_modules/codemirror/src/edit/utils.js +7 -0
- data/node_modules/codemirror/src/input/ContentEditableInput.js +527 -0
- data/node_modules/codemirror/src/input/TextareaInput.js +355 -0
- data/node_modules/codemirror/src/input/indent.js +71 -0
- data/node_modules/codemirror/src/input/input.js +135 -0
- data/node_modules/codemirror/src/input/keymap.js +148 -0
- data/node_modules/codemirror/src/input/keynames.js +17 -0
- data/node_modules/codemirror/src/input/movement.js +110 -0
- data/node_modules/codemirror/src/line/highlight.js +284 -0
- data/node_modules/codemirror/src/line/line_data.js +339 -0
- data/node_modules/codemirror/src/line/pos.js +40 -0
- data/node_modules/codemirror/src/line/saw_special_spans.js +10 -0
- data/node_modules/codemirror/src/line/spans.js +382 -0
- data/node_modules/codemirror/src/line/utils_line.js +85 -0
- data/node_modules/codemirror/src/measurement/position_measurement.js +699 -0
- data/node_modules/codemirror/src/measurement/widgets.js +26 -0
- data/node_modules/codemirror/src/model/Doc.js +432 -0
- data/node_modules/codemirror/src/model/change_measurement.js +61 -0
- data/node_modules/codemirror/src/model/changes.js +333 -0
- data/node_modules/codemirror/src/model/chunk.js +167 -0
- data/node_modules/codemirror/src/model/document_data.js +111 -0
- data/node_modules/codemirror/src/model/history.js +228 -0
- data/node_modules/codemirror/src/model/line_widget.js +78 -0
- data/node_modules/codemirror/src/model/mark_text.js +292 -0
- data/node_modules/codemirror/src/model/selection.js +84 -0
- data/node_modules/codemirror/src/model/selection_updates.js +208 -0
- data/node_modules/codemirror/src/modes.js +96 -0
- data/node_modules/codemirror/src/util/StringStream.js +90 -0
- data/node_modules/codemirror/src/util/bidi.js +214 -0
- data/node_modules/codemirror/src/util/browser.js +33 -0
- data/node_modules/codemirror/src/util/dom.js +97 -0
- data/node_modules/codemirror/src/util/event.js +103 -0
- data/node_modules/codemirror/src/util/feature_detection.js +84 -0
- data/node_modules/codemirror/src/util/misc.js +150 -0
- data/node_modules/codemirror/src/util/operation_group.js +72 -0
- data/node_modules/codemirror/theme/3024-day.css +41 -0
- data/node_modules/codemirror/theme/3024-night.css +39 -0
- data/node_modules/codemirror/theme/abcdef.css +32 -0
- data/node_modules/codemirror/theme/ambiance-mobile.css +5 -0
- data/node_modules/codemirror/theme/ambiance.css +74 -0
- data/node_modules/codemirror/theme/base16-dark.css +38 -0
- data/node_modules/codemirror/theme/base16-light.css +38 -0
- data/node_modules/codemirror/theme/bespin.css +34 -0
- data/node_modules/codemirror/theme/blackboard.css +32 -0
- data/node_modules/codemirror/theme/cobalt.css +25 -0
- data/node_modules/codemirror/theme/colorforth.css +33 -0
- data/node_modules/codemirror/theme/darcula.css +46 -0
- data/node_modules/codemirror/theme/dracula.css +40 -0
- data/node_modules/codemirror/theme/duotone-dark.css +35 -0
- data/node_modules/codemirror/theme/duotone-light.css +36 -0
- data/node_modules/codemirror/theme/eclipse.css +23 -0
- data/node_modules/codemirror/theme/elegant.css +13 -0
- data/node_modules/codemirror/theme/erlang-dark.css +34 -0
- data/node_modules/codemirror/theme/gruvbox-dark.css +37 -0
- data/node_modules/codemirror/theme/hopscotch.css +34 -0
- data/node_modules/codemirror/theme/icecoder.css +43 -0
- data/node_modules/codemirror/theme/idea.css +42 -0
- data/node_modules/codemirror/theme/isotope.css +34 -0
- data/node_modules/codemirror/theme/lesser-dark.css +47 -0
- data/node_modules/codemirror/theme/liquibyte.css +95 -0
- data/node_modules/codemirror/theme/lucario.css +37 -0
- data/node_modules/codemirror/theme/material.css +53 -0
- data/node_modules/codemirror/theme/mbo.css +37 -0
- data/node_modules/codemirror/theme/mdn-like.css +46 -0
- data/node_modules/codemirror/theme/midnight.css +43 -0
- data/node_modules/codemirror/theme/monokai.css +41 -0
- data/node_modules/codemirror/theme/neat.css +12 -0
- data/node_modules/codemirror/theme/neo.css +43 -0
- data/node_modules/codemirror/theme/night.css +27 -0
- data/node_modules/codemirror/theme/oceanic-next.css +44 -0
- data/node_modules/codemirror/theme/panda-syntax.css +85 -0
- data/node_modules/codemirror/theme/paraiso-dark.css +38 -0
- data/node_modules/codemirror/theme/paraiso-light.css +38 -0
- data/node_modules/codemirror/theme/pastel-on-dark.css +52 -0
- data/node_modules/codemirror/theme/railscasts.css +34 -0
- data/node_modules/codemirror/theme/rubyblue.css +25 -0
- data/node_modules/codemirror/theme/seti.css +44 -0
- data/node_modules/codemirror/theme/shadowfox.css +52 -0
- data/node_modules/codemirror/theme/solarized.css +168 -0
- data/node_modules/codemirror/theme/ssms.css +16 -0
- data/node_modules/codemirror/theme/the-matrix.css +30 -0
- data/node_modules/codemirror/theme/tomorrow-night-bright.css +35 -0
- data/node_modules/codemirror/theme/tomorrow-night-eighties.css +38 -0
- data/node_modules/codemirror/theme/ttcn.css +64 -0
- data/node_modules/codemirror/theme/twilight.css +32 -0
- data/node_modules/codemirror/theme/vibrant-ink.css +34 -0
- data/node_modules/codemirror/theme/xq-dark.css +53 -0
- data/node_modules/codemirror/theme/xq-light.css +43 -0
- data/node_modules/codemirror/theme/yeti.css +44 -0
- data/node_modules/codemirror/theme/zenburn.css +37 -0
- data/node_modules/marked/.editorconfig +16 -0
- data/node_modules/marked/.eslintignore +1 -0
- data/node_modules/marked/.eslintrc.json +28 -0
- data/node_modules/marked/.package 2.json.icloud +0 -0
- data/node_modules/marked/.travis.yml +47 -0
- data/node_modules/marked/Makefile +15 -0
- data/node_modules/marked/Makefile 2 +15 -0
- data/node_modules/marked/README 2.md +75 -0
- data/node_modules/marked/README.md +75 -0
- data/node_modules/marked/bin/marked +199 -0
- data/node_modules/marked/bower.json +23 -0
- data/node_modules/marked/component.json +10 -0
- data/node_modules/marked/index.js +1 -0
- data/node_modules/marked/jasmine.json +11 -0
- data/node_modules/marked/lib/marked 2.js +1604 -0
- data/node_modules/marked/lib/marked.js +1604 -0
- data/node_modules/marked/man/marked.1 +91 -0
- data/node_modules/marked/man/marked.1.txt +96 -0
- data/node_modules/marked/marked.min.js +6 -0
- data/node_modules/marked/package.json +95 -0
- data/node_modules/simplemde/.eslintrc +23 -0
- data/node_modules/simplemde/.npmignore +9 -0
- data/node_modules/simplemde/.travis.yml +18 -0
- data/node_modules/simplemde/CONTRIBUTING 2.md +10 -0
- data/node_modules/simplemde/CONTRIBUTING.md +10 -0
- data/node_modules/simplemde/LICENSE +22 -0
- data/node_modules/simplemde/README.md +331 -0
- data/node_modules/simplemde/bower.json +23 -0
- data/node_modules/simplemde/debug/.simplemde 2.css.icloud +0 -0
- data/node_modules/simplemde/debug/simplemde.css +676 -0
- data/node_modules/simplemde/debug/simplemde.debug.js +17023 -0
- data/node_modules/simplemde/debug/simplemde.js +17019 -0
- data/node_modules/simplemde/dist/simplemde.min.css +7 -0
- data/node_modules/simplemde/dist/simplemde.min.js +15 -0
- data/node_modules/simplemde/gulpfile.js +96 -0
- data/node_modules/simplemde/package.json +73 -0
- data/node_modules/simplemde/src/css/simplemde.css +328 -0
- data/node_modules/simplemde/src/js/codemirror/tablist 2.js +44 -0
- data/node_modules/simplemde/src/js/codemirror/tablist.js +44 -0
- data/node_modules/simplemde/src/js/simplemde.js +2028 -0
- data/node_modules/typo-js/README.md +45 -0
- data/node_modules/typo-js/dictionaries/en_US/.en_US 2.dic.icloud +0 -0
- data/node_modules/typo-js/dictionaries/en_US/README.md +7 -0
- data/node_modules/typo-js/dictionaries/en_US/en_US.aff +201 -0
- data/node_modules/typo-js/dictionaries/en_US/en_US.dic +62120 -0
- data/node_modules/typo-js/package.json +56 -0
- data/node_modules/typo-js/typo.js +931 -0
- data/package-lock.json +40 -0
- data/package.json +7 -0
- metadata +557 -0
@@ -0,0 +1,75 @@
|
|
1
|
+
<a href="https://marked.js.org">
|
2
|
+
<img width="60px" height="60px" src="https://marked.js.org/img/logo-black.svg" align="right" />
|
3
|
+
</a>
|
4
|
+
|
5
|
+
# Marked
|
6
|
+
|
7
|
+
[![npm](https://badgen.net/npm/v/marked)](https://www.npmjs.com/package/marked)
|
8
|
+
[![gzip size](https://badgen.net/badgesize/gzip/https://cdn.jsdelivr.net/npm/marked/marked.min.js)](https://cdn.jsdelivr.net/npm/marked/marked.min.js)
|
9
|
+
[![install size](https://badgen.net/packagephobia/install/marked)](https://packagephobia.now.sh/result?p=marked)
|
10
|
+
[![downloads](https://badgen.net/npm/dt/marked)](https://www.npmjs.com/package/marked)
|
11
|
+
[![dep](https://badgen.net/david/dep/markedjs/marked)](https://david-dm.org/markedjs/marked)
|
12
|
+
[![dev dep](https://badgen.net/david/dev/markedjs/marked)](https://david-dm.org/markedjs/marked?type=dev)
|
13
|
+
[![travis](https://badgen.net/travis/markedjs/marked)](https://travis-ci.org/markedjs/marked)
|
14
|
+
|
15
|
+
- ⚡ built for speed
|
16
|
+
- ⬇️ low-level compiler for parsing markdown without caching or blocking for long periods of time
|
17
|
+
- ⚖️ light-weight while implementing all markdown features from the supported flavors & specifications
|
18
|
+
- 🌐 works in a browser, on a server, or from a command line interface (CLI)
|
19
|
+
|
20
|
+
## Demo
|
21
|
+
|
22
|
+
Checkout the [demo page](https://marked.js.org/demo/) to see marked in action ⛹️
|
23
|
+
|
24
|
+
## Docs
|
25
|
+
|
26
|
+
Our [documentation pages](https://marked.js.org) are also rendered using marked 💯
|
27
|
+
|
28
|
+
Also read about:
|
29
|
+
|
30
|
+
* [Options](https://marked.js.org/#/USING_ADVANCED.md)
|
31
|
+
* [Extensibility](https://marked.js.org/#/USING_PRO.md)
|
32
|
+
|
33
|
+
## Installation
|
34
|
+
|
35
|
+
**CLI:** `npm install -g marked`
|
36
|
+
|
37
|
+
**In-browser:** `npm install marked --save`
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
### Warning: 🚨 Marked does not [sanitize](https://marked.js.org/#/USING_ADVANCED.md#options) the output HTML by default 🚨
|
42
|
+
|
43
|
+
**CLI**
|
44
|
+
|
45
|
+
``` bash
|
46
|
+
$ marked -o hello.html
|
47
|
+
hello world
|
48
|
+
^D
|
49
|
+
$ cat hello.html
|
50
|
+
<p>hello world</p>
|
51
|
+
```
|
52
|
+
|
53
|
+
**Browser**
|
54
|
+
|
55
|
+
```html
|
56
|
+
<!doctype html>
|
57
|
+
<html>
|
58
|
+
<head>
|
59
|
+
<meta charset="utf-8"/>
|
60
|
+
<title>Marked in the browser</title>
|
61
|
+
</head>
|
62
|
+
<body>
|
63
|
+
<div id="content"></div>
|
64
|
+
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
65
|
+
<script>
|
66
|
+
document.getElementById('content').innerHTML =
|
67
|
+
marked('# Marked in the browser\n\nRendered by **marked**.');
|
68
|
+
</script>
|
69
|
+
</body>
|
70
|
+
</html>
|
71
|
+
```
|
72
|
+
|
73
|
+
## License
|
74
|
+
|
75
|
+
Copyright (c) 2011-2018, Christopher Jeffrey. (MIT License)
|
@@ -0,0 +1,75 @@
|
|
1
|
+
<a href="https://marked.js.org">
|
2
|
+
<img width="60px" height="60px" src="https://marked.js.org/img/logo-black.svg" align="right" />
|
3
|
+
</a>
|
4
|
+
|
5
|
+
# Marked
|
6
|
+
|
7
|
+
[![npm](https://badgen.net/npm/v/marked)](https://www.npmjs.com/package/marked)
|
8
|
+
[![gzip size](https://badgen.net/badgesize/gzip/https://cdn.jsdelivr.net/npm/marked/marked.min.js)](https://cdn.jsdelivr.net/npm/marked/marked.min.js)
|
9
|
+
[![install size](https://badgen.net/packagephobia/install/marked)](https://packagephobia.now.sh/result?p=marked)
|
10
|
+
[![downloads](https://badgen.net/npm/dt/marked)](https://www.npmjs.com/package/marked)
|
11
|
+
[![dep](https://badgen.net/david/dep/markedjs/marked)](https://david-dm.org/markedjs/marked)
|
12
|
+
[![dev dep](https://badgen.net/david/dev/markedjs/marked)](https://david-dm.org/markedjs/marked?type=dev)
|
13
|
+
[![travis](https://badgen.net/travis/markedjs/marked)](https://travis-ci.org/markedjs/marked)
|
14
|
+
|
15
|
+
- ⚡ built for speed
|
16
|
+
- ⬇️ low-level compiler for parsing markdown without caching or blocking for long periods of time
|
17
|
+
- ⚖️ light-weight while implementing all markdown features from the supported flavors & specifications
|
18
|
+
- 🌐 works in a browser, on a server, or from a command line interface (CLI)
|
19
|
+
|
20
|
+
## Demo
|
21
|
+
|
22
|
+
Checkout the [demo page](https://marked.js.org/demo/) to see marked in action ⛹️
|
23
|
+
|
24
|
+
## Docs
|
25
|
+
|
26
|
+
Our [documentation pages](https://marked.js.org) are also rendered using marked 💯
|
27
|
+
|
28
|
+
Also read about:
|
29
|
+
|
30
|
+
* [Options](https://marked.js.org/#/USING_ADVANCED.md)
|
31
|
+
* [Extensibility](https://marked.js.org/#/USING_PRO.md)
|
32
|
+
|
33
|
+
## Installation
|
34
|
+
|
35
|
+
**CLI:** `npm install -g marked`
|
36
|
+
|
37
|
+
**In-browser:** `npm install marked --save`
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
### Warning: 🚨 Marked does not [sanitize](https://marked.js.org/#/USING_ADVANCED.md#options) the output HTML by default 🚨
|
42
|
+
|
43
|
+
**CLI**
|
44
|
+
|
45
|
+
``` bash
|
46
|
+
$ marked -o hello.html
|
47
|
+
hello world
|
48
|
+
^D
|
49
|
+
$ cat hello.html
|
50
|
+
<p>hello world</p>
|
51
|
+
```
|
52
|
+
|
53
|
+
**Browser**
|
54
|
+
|
55
|
+
```html
|
56
|
+
<!doctype html>
|
57
|
+
<html>
|
58
|
+
<head>
|
59
|
+
<meta charset="utf-8"/>
|
60
|
+
<title>Marked in the browser</title>
|
61
|
+
</head>
|
62
|
+
<body>
|
63
|
+
<div id="content"></div>
|
64
|
+
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
65
|
+
<script>
|
66
|
+
document.getElementById('content').innerHTML =
|
67
|
+
marked('# Marked in the browser\n\nRendered by **marked**.');
|
68
|
+
</script>
|
69
|
+
</body>
|
70
|
+
</html>
|
71
|
+
```
|
72
|
+
|
73
|
+
## License
|
74
|
+
|
75
|
+
Copyright (c) 2011-2018, Christopher Jeffrey. (MIT License)
|
@@ -0,0 +1,199 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Marked CLI
|
5
|
+
* Copyright (c) 2011-2013, Christopher Jeffrey (MIT License)
|
6
|
+
*/
|
7
|
+
|
8
|
+
var fs = require('fs'),
|
9
|
+
path = require('path'),
|
10
|
+
marked = require('../');
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Man Page
|
14
|
+
*/
|
15
|
+
|
16
|
+
function help() {
|
17
|
+
var spawn = require('child_process').spawn;
|
18
|
+
|
19
|
+
var options = {
|
20
|
+
cwd: process.cwd(),
|
21
|
+
env: process.env,
|
22
|
+
setsid: false,
|
23
|
+
stdio: 'inherit'
|
24
|
+
};
|
25
|
+
|
26
|
+
spawn('man', [path.resolve(__dirname, '/../man/marked.1')], options)
|
27
|
+
.on('error', function() {
|
28
|
+
fs.readFile(path.resolve(__dirname, '/../man/marked.1.txt'), 'utf8', function(err, data) {
|
29
|
+
if (err) throw err;
|
30
|
+
console.log(data);
|
31
|
+
});
|
32
|
+
});
|
33
|
+
}
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Main
|
37
|
+
*/
|
38
|
+
|
39
|
+
function main(argv, callback) {
|
40
|
+
var files = [],
|
41
|
+
options = {},
|
42
|
+
input,
|
43
|
+
output,
|
44
|
+
string,
|
45
|
+
arg,
|
46
|
+
tokens,
|
47
|
+
opt;
|
48
|
+
|
49
|
+
function getarg() {
|
50
|
+
var arg = argv.shift();
|
51
|
+
|
52
|
+
if (arg.indexOf('--') === 0) {
|
53
|
+
// e.g. --opt
|
54
|
+
arg = arg.split('=');
|
55
|
+
if (arg.length > 1) {
|
56
|
+
// e.g. --opt=val
|
57
|
+
argv.unshift(arg.slice(1).join('='));
|
58
|
+
}
|
59
|
+
arg = arg[0];
|
60
|
+
} else if (arg[0] === '-') {
|
61
|
+
if (arg.length > 2) {
|
62
|
+
// e.g. -abc
|
63
|
+
argv = arg.substring(1).split('').map(function(ch) {
|
64
|
+
return '-' + ch;
|
65
|
+
}).concat(argv);
|
66
|
+
arg = argv.shift();
|
67
|
+
} else {
|
68
|
+
// e.g. -a
|
69
|
+
}
|
70
|
+
} else {
|
71
|
+
// e.g. foo
|
72
|
+
}
|
73
|
+
|
74
|
+
return arg;
|
75
|
+
}
|
76
|
+
|
77
|
+
while (argv.length) {
|
78
|
+
arg = getarg();
|
79
|
+
switch (arg) {
|
80
|
+
case '--test':
|
81
|
+
return require('../test').main(process.argv.slice());
|
82
|
+
case '-o':
|
83
|
+
case '--output':
|
84
|
+
output = argv.shift();
|
85
|
+
break;
|
86
|
+
case '-i':
|
87
|
+
case '--input':
|
88
|
+
input = argv.shift();
|
89
|
+
break;
|
90
|
+
case '-s':
|
91
|
+
case '--string':
|
92
|
+
string = argv.shift();
|
93
|
+
break;
|
94
|
+
case '-t':
|
95
|
+
case '--tokens':
|
96
|
+
tokens = true;
|
97
|
+
break;
|
98
|
+
case '-h':
|
99
|
+
case '--help':
|
100
|
+
return help();
|
101
|
+
default:
|
102
|
+
if (arg.indexOf('--') === 0) {
|
103
|
+
opt = camelize(arg.replace(/^--(no-)?/, ''));
|
104
|
+
if (!marked.defaults.hasOwnProperty(opt)) {
|
105
|
+
continue;
|
106
|
+
}
|
107
|
+
if (arg.indexOf('--no-') === 0) {
|
108
|
+
options[opt] = typeof marked.defaults[opt] !== 'boolean'
|
109
|
+
? null
|
110
|
+
: false;
|
111
|
+
} else {
|
112
|
+
options[opt] = typeof marked.defaults[opt] !== 'boolean'
|
113
|
+
? argv.shift()
|
114
|
+
: true;
|
115
|
+
}
|
116
|
+
} else {
|
117
|
+
files.push(arg);
|
118
|
+
}
|
119
|
+
break;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
function getData(callback) {
|
124
|
+
if (!input) {
|
125
|
+
if (files.length <= 2) {
|
126
|
+
if (string) {
|
127
|
+
return callback(null, string);
|
128
|
+
}
|
129
|
+
return getStdin(callback);
|
130
|
+
}
|
131
|
+
input = files.pop();
|
132
|
+
}
|
133
|
+
return fs.readFile(input, 'utf8', callback);
|
134
|
+
}
|
135
|
+
|
136
|
+
return getData(function(err, data) {
|
137
|
+
if (err) return callback(err);
|
138
|
+
|
139
|
+
data = tokens
|
140
|
+
? JSON.stringify(marked.lexer(data, options), null, 2)
|
141
|
+
: marked(data, options);
|
142
|
+
|
143
|
+
if (!output) {
|
144
|
+
process.stdout.write(data + '\n');
|
145
|
+
return callback();
|
146
|
+
}
|
147
|
+
|
148
|
+
return fs.writeFile(output, data, callback);
|
149
|
+
});
|
150
|
+
}
|
151
|
+
|
152
|
+
/**
|
153
|
+
* Helpers
|
154
|
+
*/
|
155
|
+
|
156
|
+
function getStdin(callback) {
|
157
|
+
var stdin = process.stdin,
|
158
|
+
buff = '';
|
159
|
+
|
160
|
+
stdin.setEncoding('utf8');
|
161
|
+
|
162
|
+
stdin.on('data', function(data) {
|
163
|
+
buff += data;
|
164
|
+
});
|
165
|
+
|
166
|
+
stdin.on('error', function(err) {
|
167
|
+
return callback(err);
|
168
|
+
});
|
169
|
+
|
170
|
+
stdin.on('end', function() {
|
171
|
+
return callback(null, buff);
|
172
|
+
});
|
173
|
+
|
174
|
+
try {
|
175
|
+
stdin.resume();
|
176
|
+
} catch (e) {
|
177
|
+
callback(e);
|
178
|
+
}
|
179
|
+
}
|
180
|
+
|
181
|
+
function camelize(text) {
|
182
|
+
return text.replace(/(\w)-(\w)/g, function(_, a, b) {
|
183
|
+
return a + b.toUpperCase();
|
184
|
+
});
|
185
|
+
}
|
186
|
+
|
187
|
+
/**
|
188
|
+
* Expose / Entry Point
|
189
|
+
*/
|
190
|
+
|
191
|
+
if (!module.parent) {
|
192
|
+
process.title = 'marked';
|
193
|
+
main(process.argv.slice(), function(err, code) {
|
194
|
+
if (err) throw err;
|
195
|
+
return process.exit(code || 0);
|
196
|
+
});
|
197
|
+
} else {
|
198
|
+
module.exports = main;
|
199
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
{
|
2
|
+
"name": "marked",
|
3
|
+
"homepage": "https://github.com/markedjs/marked",
|
4
|
+
"authors": [
|
5
|
+
"Christopher Jeffrey <chjjeffrey@gmail.com>"
|
6
|
+
],
|
7
|
+
"description": "A markdown parser built for speed",
|
8
|
+
"keywords": [
|
9
|
+
"markdown",
|
10
|
+
"markup",
|
11
|
+
"html"
|
12
|
+
],
|
13
|
+
"main": "lib/marked.js",
|
14
|
+
"license": "MIT",
|
15
|
+
"ignore": [
|
16
|
+
"**/.*",
|
17
|
+
"node_modules",
|
18
|
+
"bower_components",
|
19
|
+
"app/bower_components",
|
20
|
+
"test",
|
21
|
+
"tests"
|
22
|
+
]
|
23
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
module.exports = require('./lib/marked');
|
@@ -0,0 +1,1604 @@
|
|
1
|
+
/**
|
2
|
+
* marked - a markdown parser
|
3
|
+
* Copyright (c) 2011-2018, Christopher Jeffrey. (MIT Licensed)
|
4
|
+
* https://github.com/markedjs/marked
|
5
|
+
*/
|
6
|
+
|
7
|
+
;(function(root) {
|
8
|
+
'use strict';
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Block-Level Grammar
|
12
|
+
*/
|
13
|
+
|
14
|
+
var block = {
|
15
|
+
newline: /^\n+/,
|
16
|
+
code: /^( {4}[^\n]+\n*)+/,
|
17
|
+
fences: noop,
|
18
|
+
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
|
19
|
+
heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,
|
20
|
+
nptable: noop,
|
21
|
+
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
|
22
|
+
list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
|
23
|
+
html: '^ {0,3}(?:' // optional indentation
|
24
|
+
+ '<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
|
25
|
+
+ '|comment[^\\n]*(\\n+|$)' // (2)
|
26
|
+
+ '|<\\?[\\s\\S]*?\\?>\\n*' // (3)
|
27
|
+
+ '|<![A-Z][\\s\\S]*?>\\n*' // (4)
|
28
|
+
+ '|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*' // (5)
|
29
|
+
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)' // (6)
|
30
|
+
+ '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)' // (7) open tag
|
31
|
+
+ '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)' // (7) closing tag
|
32
|
+
+ ')',
|
33
|
+
def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
|
34
|
+
table: noop,
|
35
|
+
lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
|
36
|
+
paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading| {0,3}>|<\/?(?:tag)(?: +|\n|\/?>)|<(?:script|pre|style|!--))[^\n]+)*)/,
|
37
|
+
text: /^[^\n]+/
|
38
|
+
};
|
39
|
+
|
40
|
+
block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
|
41
|
+
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
|
42
|
+
block.def = edit(block.def)
|
43
|
+
.replace('label', block._label)
|
44
|
+
.replace('title', block._title)
|
45
|
+
.getRegex();
|
46
|
+
|
47
|
+
block.bullet = /(?:[*+-]|\d+\.)/;
|
48
|
+
block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
|
49
|
+
block.item = edit(block.item, 'gm')
|
50
|
+
.replace(/bull/g, block.bullet)
|
51
|
+
.getRegex();
|
52
|
+
|
53
|
+
block.list = edit(block.list)
|
54
|
+
.replace(/bull/g, block.bullet)
|
55
|
+
.replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))')
|
56
|
+
.replace('def', '\\n+(?=' + block.def.source + ')')
|
57
|
+
.getRegex();
|
58
|
+
|
59
|
+
block._tag = 'address|article|aside|base|basefont|blockquote|body|caption'
|
60
|
+
+ '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption'
|
61
|
+
+ '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe'
|
62
|
+
+ '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option'
|
63
|
+
+ '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr'
|
64
|
+
+ '|track|ul';
|
65
|
+
block._comment = /<!--(?!-?>)[\s\S]*?-->/;
|
66
|
+
block.html = edit(block.html, 'i')
|
67
|
+
.replace('comment', block._comment)
|
68
|
+
.replace('tag', block._tag)
|
69
|
+
.replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/)
|
70
|
+
.getRegex();
|
71
|
+
|
72
|
+
block.paragraph = edit(block.paragraph)
|
73
|
+
.replace('hr', block.hr)
|
74
|
+
.replace('heading', block.heading)
|
75
|
+
.replace('lheading', block.lheading)
|
76
|
+
.replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
|
77
|
+
.getRegex();
|
78
|
+
|
79
|
+
block.blockquote = edit(block.blockquote)
|
80
|
+
.replace('paragraph', block.paragraph)
|
81
|
+
.getRegex();
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Normal Block Grammar
|
85
|
+
*/
|
86
|
+
|
87
|
+
block.normal = merge({}, block);
|
88
|
+
|
89
|
+
/**
|
90
|
+
* GFM Block Grammar
|
91
|
+
*/
|
92
|
+
|
93
|
+
block.gfm = merge({}, block.normal, {
|
94
|
+
fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\n? *\1 *(?:\n+|$)/,
|
95
|
+
paragraph: /^/,
|
96
|
+
heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
|
97
|
+
});
|
98
|
+
|
99
|
+
block.gfm.paragraph = edit(block.paragraph)
|
100
|
+
.replace('(?!', '(?!'
|
101
|
+
+ block.gfm.fences.source.replace('\\1', '\\2') + '|'
|
102
|
+
+ block.list.source.replace('\\1', '\\3') + '|')
|
103
|
+
.getRegex();
|
104
|
+
|
105
|
+
/**
|
106
|
+
* GFM + Tables Block Grammar
|
107
|
+
*/
|
108
|
+
|
109
|
+
block.tables = merge({}, block.gfm, {
|
110
|
+
nptable: /^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/,
|
111
|
+
table: /^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/
|
112
|
+
});
|
113
|
+
|
114
|
+
/**
|
115
|
+
* Pedantic grammar
|
116
|
+
*/
|
117
|
+
|
118
|
+
block.pedantic = merge({}, block.normal, {
|
119
|
+
html: edit(
|
120
|
+
'^ *(?:comment *(?:\\n|\\s*$)'
|
121
|
+
+ '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
|
122
|
+
+ '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))')
|
123
|
+
.replace('comment', block._comment)
|
124
|
+
.replace(/tag/g, '(?!(?:'
|
125
|
+
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub'
|
126
|
+
+ '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)'
|
127
|
+
+ '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b')
|
128
|
+
.getRegex(),
|
129
|
+
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/
|
130
|
+
});
|
131
|
+
|
132
|
+
/**
|
133
|
+
* Block Lexer
|
134
|
+
*/
|
135
|
+
|
136
|
+
function Lexer(options) {
|
137
|
+
this.tokens = [];
|
138
|
+
this.tokens.links = Object.create(null);
|
139
|
+
this.options = options || marked.defaults;
|
140
|
+
this.rules = block.normal;
|
141
|
+
|
142
|
+
if (this.options.pedantic) {
|
143
|
+
this.rules = block.pedantic;
|
144
|
+
} else if (this.options.gfm) {
|
145
|
+
if (this.options.tables) {
|
146
|
+
this.rules = block.tables;
|
147
|
+
} else {
|
148
|
+
this.rules = block.gfm;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
/**
|
154
|
+
* Expose Block Rules
|
155
|
+
*/
|
156
|
+
|
157
|
+
Lexer.rules = block;
|
158
|
+
|
159
|
+
/**
|
160
|
+
* Static Lex Method
|
161
|
+
*/
|
162
|
+
|
163
|
+
Lexer.lex = function(src, options) {
|
164
|
+
var lexer = new Lexer(options);
|
165
|
+
return lexer.lex(src);
|
166
|
+
};
|
167
|
+
|
168
|
+
/**
|
169
|
+
* Preprocessing
|
170
|
+
*/
|
171
|
+
|
172
|
+
Lexer.prototype.lex = function(src) {
|
173
|
+
src = src
|
174
|
+
.replace(/\r\n|\r/g, '\n')
|
175
|
+
.replace(/\t/g, ' ')
|
176
|
+
.replace(/\u00a0/g, ' ')
|
177
|
+
.replace(/\u2424/g, '\n');
|
178
|
+
|
179
|
+
return this.token(src, true);
|
180
|
+
};
|
181
|
+
|
182
|
+
/**
|
183
|
+
* Lexing
|
184
|
+
*/
|
185
|
+
|
186
|
+
Lexer.prototype.token = function(src, top) {
|
187
|
+
src = src.replace(/^ +$/gm, '');
|
188
|
+
var next,
|
189
|
+
loose,
|
190
|
+
cap,
|
191
|
+
bull,
|
192
|
+
b,
|
193
|
+
item,
|
194
|
+
listStart,
|
195
|
+
listItems,
|
196
|
+
t,
|
197
|
+
space,
|
198
|
+
i,
|
199
|
+
tag,
|
200
|
+
l,
|
201
|
+
isordered,
|
202
|
+
istask,
|
203
|
+
ischecked;
|
204
|
+
|
205
|
+
while (src) {
|
206
|
+
// newline
|
207
|
+
if (cap = this.rules.newline.exec(src)) {
|
208
|
+
src = src.substring(cap[0].length);
|
209
|
+
if (cap[0].length > 1) {
|
210
|
+
this.tokens.push({
|
211
|
+
type: 'space'
|
212
|
+
});
|
213
|
+
}
|
214
|
+
}
|
215
|
+
|
216
|
+
// code
|
217
|
+
if (cap = this.rules.code.exec(src)) {
|
218
|
+
src = src.substring(cap[0].length);
|
219
|
+
cap = cap[0].replace(/^ {4}/gm, '');
|
220
|
+
this.tokens.push({
|
221
|
+
type: 'code',
|
222
|
+
text: !this.options.pedantic
|
223
|
+
? rtrim(cap, '\n')
|
224
|
+
: cap
|
225
|
+
});
|
226
|
+
continue;
|
227
|
+
}
|
228
|
+
|
229
|
+
// fences (gfm)
|
230
|
+
if (cap = this.rules.fences.exec(src)) {
|
231
|
+
src = src.substring(cap[0].length);
|
232
|
+
this.tokens.push({
|
233
|
+
type: 'code',
|
234
|
+
lang: cap[2],
|
235
|
+
text: cap[3] || ''
|
236
|
+
});
|
237
|
+
continue;
|
238
|
+
}
|
239
|
+
|
240
|
+
// heading
|
241
|
+
if (cap = this.rules.heading.exec(src)) {
|
242
|
+
src = src.substring(cap[0].length);
|
243
|
+
this.tokens.push({
|
244
|
+
type: 'heading',
|
245
|
+
depth: cap[1].length,
|
246
|
+
text: cap[2]
|
247
|
+
});
|
248
|
+
continue;
|
249
|
+
}
|
250
|
+
|
251
|
+
// table no leading pipe (gfm)
|
252
|
+
if (top && (cap = this.rules.nptable.exec(src))) {
|
253
|
+
item = {
|
254
|
+
type: 'table',
|
255
|
+
header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
|
256
|
+
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
257
|
+
cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
|
258
|
+
};
|
259
|
+
|
260
|
+
if (item.header.length === item.align.length) {
|
261
|
+
src = src.substring(cap[0].length);
|
262
|
+
|
263
|
+
for (i = 0; i < item.align.length; i++) {
|
264
|
+
if (/^ *-+: *$/.test(item.align[i])) {
|
265
|
+
item.align[i] = 'right';
|
266
|
+
} else if (/^ *:-+: *$/.test(item.align[i])) {
|
267
|
+
item.align[i] = 'center';
|
268
|
+
} else if (/^ *:-+ *$/.test(item.align[i])) {
|
269
|
+
item.align[i] = 'left';
|
270
|
+
} else {
|
271
|
+
item.align[i] = null;
|
272
|
+
}
|
273
|
+
}
|
274
|
+
|
275
|
+
for (i = 0; i < item.cells.length; i++) {
|
276
|
+
item.cells[i] = splitCells(item.cells[i], item.header.length);
|
277
|
+
}
|
278
|
+
|
279
|
+
this.tokens.push(item);
|
280
|
+
|
281
|
+
continue;
|
282
|
+
}
|
283
|
+
}
|
284
|
+
|
285
|
+
// hr
|
286
|
+
if (cap = this.rules.hr.exec(src)) {
|
287
|
+
src = src.substring(cap[0].length);
|
288
|
+
this.tokens.push({
|
289
|
+
type: 'hr'
|
290
|
+
});
|
291
|
+
continue;
|
292
|
+
}
|
293
|
+
|
294
|
+
// blockquote
|
295
|
+
if (cap = this.rules.blockquote.exec(src)) {
|
296
|
+
src = src.substring(cap[0].length);
|
297
|
+
|
298
|
+
this.tokens.push({
|
299
|
+
type: 'blockquote_start'
|
300
|
+
});
|
301
|
+
|
302
|
+
cap = cap[0].replace(/^ *> ?/gm, '');
|
303
|
+
|
304
|
+
// Pass `top` to keep the current
|
305
|
+
// "toplevel" state. This is exactly
|
306
|
+
// how markdown.pl works.
|
307
|
+
this.token(cap, top);
|
308
|
+
|
309
|
+
this.tokens.push({
|
310
|
+
type: 'blockquote_end'
|
311
|
+
});
|
312
|
+
|
313
|
+
continue;
|
314
|
+
}
|
315
|
+
|
316
|
+
// list
|
317
|
+
if (cap = this.rules.list.exec(src)) {
|
318
|
+
src = src.substring(cap[0].length);
|
319
|
+
bull = cap[2];
|
320
|
+
isordered = bull.length > 1;
|
321
|
+
|
322
|
+
listStart = {
|
323
|
+
type: 'list_start',
|
324
|
+
ordered: isordered,
|
325
|
+
start: isordered ? +bull : '',
|
326
|
+
loose: false
|
327
|
+
};
|
328
|
+
|
329
|
+
this.tokens.push(listStart);
|
330
|
+
|
331
|
+
// Get each top-level item.
|
332
|
+
cap = cap[0].match(this.rules.item);
|
333
|
+
|
334
|
+
listItems = [];
|
335
|
+
next = false;
|
336
|
+
l = cap.length;
|
337
|
+
i = 0;
|
338
|
+
|
339
|
+
for (; i < l; i++) {
|
340
|
+
item = cap[i];
|
341
|
+
|
342
|
+
// Remove the list item's bullet
|
343
|
+
// so it is seen as the next token.
|
344
|
+
space = item.length;
|
345
|
+
item = item.replace(/^ *([*+-]|\d+\.) +/, '');
|
346
|
+
|
347
|
+
// Outdent whatever the
|
348
|
+
// list item contains. Hacky.
|
349
|
+
if (~item.indexOf('\n ')) {
|
350
|
+
space -= item.length;
|
351
|
+
item = !this.options.pedantic
|
352
|
+
? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '')
|
353
|
+
: item.replace(/^ {1,4}/gm, '');
|
354
|
+
}
|
355
|
+
|
356
|
+
// Determine whether the next list item belongs here.
|
357
|
+
// Backpedal if it does not belong in this list.
|
358
|
+
if (this.options.smartLists && i !== l - 1) {
|
359
|
+
b = block.bullet.exec(cap[i + 1])[0];
|
360
|
+
if (bull !== b && !(bull.length > 1 && b.length > 1)) {
|
361
|
+
src = cap.slice(i + 1).join('\n') + src;
|
362
|
+
i = l - 1;
|
363
|
+
}
|
364
|
+
}
|
365
|
+
|
366
|
+
// Determine whether item is loose or not.
|
367
|
+
// Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
|
368
|
+
// for discount behavior.
|
369
|
+
loose = next || /\n\n(?!\s*$)/.test(item);
|
370
|
+
if (i !== l - 1) {
|
371
|
+
next = item.charAt(item.length - 1) === '\n';
|
372
|
+
if (!loose) loose = next;
|
373
|
+
}
|
374
|
+
|
375
|
+
if (loose) {
|
376
|
+
listStart.loose = true;
|
377
|
+
}
|
378
|
+
|
379
|
+
// Check for task list items
|
380
|
+
istask = /^\[[ xX]\] /.test(item);
|
381
|
+
ischecked = undefined;
|
382
|
+
if (istask) {
|
383
|
+
ischecked = item[1] !== ' ';
|
384
|
+
item = item.replace(/^\[[ xX]\] +/, '');
|
385
|
+
}
|
386
|
+
|
387
|
+
t = {
|
388
|
+
type: 'list_item_start',
|
389
|
+
task: istask,
|
390
|
+
checked: ischecked,
|
391
|
+
loose: loose
|
392
|
+
};
|
393
|
+
|
394
|
+
listItems.push(t);
|
395
|
+
this.tokens.push(t);
|
396
|
+
|
397
|
+
// Recurse.
|
398
|
+
this.token(item, false);
|
399
|
+
|
400
|
+
this.tokens.push({
|
401
|
+
type: 'list_item_end'
|
402
|
+
});
|
403
|
+
}
|
404
|
+
|
405
|
+
if (listStart.loose) {
|
406
|
+
l = listItems.length;
|
407
|
+
i = 0;
|
408
|
+
for (; i < l; i++) {
|
409
|
+
listItems[i].loose = true;
|
410
|
+
}
|
411
|
+
}
|
412
|
+
|
413
|
+
this.tokens.push({
|
414
|
+
type: 'list_end'
|
415
|
+
});
|
416
|
+
|
417
|
+
continue;
|
418
|
+
}
|
419
|
+
|
420
|
+
// html
|
421
|
+
if (cap = this.rules.html.exec(src)) {
|
422
|
+
src = src.substring(cap[0].length);
|
423
|
+
this.tokens.push({
|
424
|
+
type: this.options.sanitize
|
425
|
+
? 'paragraph'
|
426
|
+
: 'html',
|
427
|
+
pre: !this.options.sanitizer
|
428
|
+
&& (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
|
429
|
+
text: cap[0]
|
430
|
+
});
|
431
|
+
continue;
|
432
|
+
}
|
433
|
+
|
434
|
+
// def
|
435
|
+
if (top && (cap = this.rules.def.exec(src))) {
|
436
|
+
src = src.substring(cap[0].length);
|
437
|
+
if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
|
438
|
+
tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
|
439
|
+
if (!this.tokens.links[tag]) {
|
440
|
+
this.tokens.links[tag] = {
|
441
|
+
href: cap[2],
|
442
|
+
title: cap[3]
|
443
|
+
};
|
444
|
+
}
|
445
|
+
continue;
|
446
|
+
}
|
447
|
+
|
448
|
+
// table (gfm)
|
449
|
+
if (top && (cap = this.rules.table.exec(src))) {
|
450
|
+
item = {
|
451
|
+
type: 'table',
|
452
|
+
header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
|
453
|
+
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
|
454
|
+
cells: cap[3] ? cap[3].replace(/(?: *\| *)?\n$/, '').split('\n') : []
|
455
|
+
};
|
456
|
+
|
457
|
+
if (item.header.length === item.align.length) {
|
458
|
+
src = src.substring(cap[0].length);
|
459
|
+
|
460
|
+
for (i = 0; i < item.align.length; i++) {
|
461
|
+
if (/^ *-+: *$/.test(item.align[i])) {
|
462
|
+
item.align[i] = 'right';
|
463
|
+
} else if (/^ *:-+: *$/.test(item.align[i])) {
|
464
|
+
item.align[i] = 'center';
|
465
|
+
} else if (/^ *:-+ *$/.test(item.align[i])) {
|
466
|
+
item.align[i] = 'left';
|
467
|
+
} else {
|
468
|
+
item.align[i] = null;
|
469
|
+
}
|
470
|
+
}
|
471
|
+
|
472
|
+
for (i = 0; i < item.cells.length; i++) {
|
473
|
+
item.cells[i] = splitCells(
|
474
|
+
item.cells[i].replace(/^ *\| *| *\| *$/g, ''),
|
475
|
+
item.header.length);
|
476
|
+
}
|
477
|
+
|
478
|
+
this.tokens.push(item);
|
479
|
+
|
480
|
+
continue;
|
481
|
+
}
|
482
|
+
}
|
483
|
+
|
484
|
+
// lheading
|
485
|
+
if (cap = this.rules.lheading.exec(src)) {
|
486
|
+
src = src.substring(cap[0].length);
|
487
|
+
this.tokens.push({
|
488
|
+
type: 'heading',
|
489
|
+
depth: cap[2] === '=' ? 1 : 2,
|
490
|
+
text: cap[1]
|
491
|
+
});
|
492
|
+
continue;
|
493
|
+
}
|
494
|
+
|
495
|
+
// top-level paragraph
|
496
|
+
if (top && (cap = this.rules.paragraph.exec(src))) {
|
497
|
+
src = src.substring(cap[0].length);
|
498
|
+
this.tokens.push({
|
499
|
+
type: 'paragraph',
|
500
|
+
text: cap[1].charAt(cap[1].length - 1) === '\n'
|
501
|
+
? cap[1].slice(0, -1)
|
502
|
+
: cap[1]
|
503
|
+
});
|
504
|
+
continue;
|
505
|
+
}
|
506
|
+
|
507
|
+
// text
|
508
|
+
if (cap = this.rules.text.exec(src)) {
|
509
|
+
// Top-level should never reach here.
|
510
|
+
src = src.substring(cap[0].length);
|
511
|
+
this.tokens.push({
|
512
|
+
type: 'text',
|
513
|
+
text: cap[0]
|
514
|
+
});
|
515
|
+
continue;
|
516
|
+
}
|
517
|
+
|
518
|
+
if (src) {
|
519
|
+
throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
|
520
|
+
}
|
521
|
+
}
|
522
|
+
|
523
|
+
return this.tokens;
|
524
|
+
};
|
525
|
+
|
526
|
+
/**
|
527
|
+
* Inline-Level Grammar
|
528
|
+
*/
|
529
|
+
|
530
|
+
var inline = {
|
531
|
+
escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
|
532
|
+
autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
|
533
|
+
url: noop,
|
534
|
+
tag: '^comment'
|
535
|
+
+ '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
|
536
|
+
+ '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
|
537
|
+
+ '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
|
538
|
+
+ '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
|
539
|
+
+ '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>', // CDATA section
|
540
|
+
link: /^!?\[(label)\]\(href(?:\s+(title))?\s*\)/,
|
541
|
+
reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
|
542
|
+
nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
|
543
|
+
strong: /^__([^\s])__(?!_)|^\*\*([^\s])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,
|
544
|
+
em: /^_([^\s_])_(?!_)|^\*([^\s*"<\[])\*(?!\*)|^_([^\s][\s\S]*?[^\s_])_(?!_)|^_([^\s_][\s\S]*?[^\s])_(?!_)|^\*([^\s"<\[][\s\S]*?[^\s*])\*(?!\*)|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/,
|
545
|
+
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
|
546
|
+
br: /^( {2,}|\\)\n(?!\s*$)/,
|
547
|
+
del: noop,
|
548
|
+
text: /^(`+|[^`])[\s\S]*?(?=[\\<!\[`*]|\b_| {2,}\n|$)/
|
549
|
+
};
|
550
|
+
|
551
|
+
inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
|
552
|
+
|
553
|
+
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
|
554
|
+
inline._email = /[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])?)+(?![-_])/;
|
555
|
+
inline.autolink = edit(inline.autolink)
|
556
|
+
.replace('scheme', inline._scheme)
|
557
|
+
.replace('email', inline._email)
|
558
|
+
.getRegex();
|
559
|
+
|
560
|
+
inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
|
561
|
+
|
562
|
+
inline.tag = edit(inline.tag)
|
563
|
+
.replace('comment', block._comment)
|
564
|
+
.replace('attribute', inline._attribute)
|
565
|
+
.getRegex();
|
566
|
+
|
567
|
+
inline._label = /(?:\[[^\[\]]*\]|\\[\[\]]?|`[^`]*`|[^\[\]\\])*?/;
|
568
|
+
inline._href = /\s*(<(?:\\[<>]?|[^\s<>\\])*>|(?:\\[()]?|\([^\s\x00-\x1f\\]*\)|[^\s\x00-\x1f()\\])*?)/;
|
569
|
+
inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
|
570
|
+
|
571
|
+
inline.link = edit(inline.link)
|
572
|
+
.replace('label', inline._label)
|
573
|
+
.replace('href', inline._href)
|
574
|
+
.replace('title', inline._title)
|
575
|
+
.getRegex();
|
576
|
+
|
577
|
+
inline.reflink = edit(inline.reflink)
|
578
|
+
.replace('label', inline._label)
|
579
|
+
.getRegex();
|
580
|
+
|
581
|
+
/**
|
582
|
+
* Normal Inline Grammar
|
583
|
+
*/
|
584
|
+
|
585
|
+
inline.normal = merge({}, inline);
|
586
|
+
|
587
|
+
/**
|
588
|
+
* Pedantic Inline Grammar
|
589
|
+
*/
|
590
|
+
|
591
|
+
inline.pedantic = merge({}, inline.normal, {
|
592
|
+
strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
593
|
+
em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,
|
594
|
+
link: edit(/^!?\[(label)\]\((.*?)\)/)
|
595
|
+
.replace('label', inline._label)
|
596
|
+
.getRegex(),
|
597
|
+
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/)
|
598
|
+
.replace('label', inline._label)
|
599
|
+
.getRegex()
|
600
|
+
});
|
601
|
+
|
602
|
+
/**
|
603
|
+
* GFM Inline Grammar
|
604
|
+
*/
|
605
|
+
|
606
|
+
inline.gfm = merge({}, inline.normal, {
|
607
|
+
escape: edit(inline.escape).replace('])', '~|])').getRegex(),
|
608
|
+
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
|
609
|
+
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
|
610
|
+
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
|
611
|
+
del: /^~+(?=\S)([\s\S]*?\S)~+/,
|
612
|
+
text: edit(inline.text)
|
613
|
+
.replace(']|', '~]|')
|
614
|
+
.replace('|$', '|https?://|ftp://|www\\.|[a-zA-Z0-9.!#$%&\'*+/=?^_`{\\|}~-]+@|$')
|
615
|
+
.getRegex()
|
616
|
+
});
|
617
|
+
|
618
|
+
inline.gfm.url = edit(inline.gfm.url)
|
619
|
+
.replace('email', inline.gfm._extended_email)
|
620
|
+
.getRegex();
|
621
|
+
/**
|
622
|
+
* GFM + Line Breaks Inline Grammar
|
623
|
+
*/
|
624
|
+
|
625
|
+
inline.breaks = merge({}, inline.gfm, {
|
626
|
+
br: edit(inline.br).replace('{2,}', '*').getRegex(),
|
627
|
+
text: edit(inline.gfm.text).replace('{2,}', '*').getRegex()
|
628
|
+
});
|
629
|
+
|
630
|
+
/**
|
631
|
+
* Inline Lexer & Compiler
|
632
|
+
*/
|
633
|
+
|
634
|
+
function InlineLexer(links, options) {
|
635
|
+
this.options = options || marked.defaults;
|
636
|
+
this.links = links;
|
637
|
+
this.rules = inline.normal;
|
638
|
+
this.renderer = this.options.renderer || new Renderer();
|
639
|
+
this.renderer.options = this.options;
|
640
|
+
|
641
|
+
if (!this.links) {
|
642
|
+
throw new Error('Tokens array requires a `links` property.');
|
643
|
+
}
|
644
|
+
|
645
|
+
if (this.options.pedantic) {
|
646
|
+
this.rules = inline.pedantic;
|
647
|
+
} else if (this.options.gfm) {
|
648
|
+
if (this.options.breaks) {
|
649
|
+
this.rules = inline.breaks;
|
650
|
+
} else {
|
651
|
+
this.rules = inline.gfm;
|
652
|
+
}
|
653
|
+
}
|
654
|
+
}
|
655
|
+
|
656
|
+
/**
|
657
|
+
* Expose Inline Rules
|
658
|
+
*/
|
659
|
+
|
660
|
+
InlineLexer.rules = inline;
|
661
|
+
|
662
|
+
/**
|
663
|
+
* Static Lexing/Compiling Method
|
664
|
+
*/
|
665
|
+
|
666
|
+
InlineLexer.output = function(src, links, options) {
|
667
|
+
var inline = new InlineLexer(links, options);
|
668
|
+
return inline.output(src);
|
669
|
+
};
|
670
|
+
|
671
|
+
/**
|
672
|
+
* Lexing/Compiling
|
673
|
+
*/
|
674
|
+
|
675
|
+
InlineLexer.prototype.output = function(src) {
|
676
|
+
var out = '',
|
677
|
+
link,
|
678
|
+
text,
|
679
|
+
href,
|
680
|
+
title,
|
681
|
+
cap,
|
682
|
+
prevCapZero;
|
683
|
+
|
684
|
+
while (src) {
|
685
|
+
// escape
|
686
|
+
if (cap = this.rules.escape.exec(src)) {
|
687
|
+
src = src.substring(cap[0].length);
|
688
|
+
out += cap[1];
|
689
|
+
continue;
|
690
|
+
}
|
691
|
+
|
692
|
+
// autolink
|
693
|
+
if (cap = this.rules.autolink.exec(src)) {
|
694
|
+
src = src.substring(cap[0].length);
|
695
|
+
if (cap[2] === '@') {
|
696
|
+
text = escape(this.mangle(cap[1]));
|
697
|
+
href = 'mailto:' + text;
|
698
|
+
} else {
|
699
|
+
text = escape(cap[1]);
|
700
|
+
href = text;
|
701
|
+
}
|
702
|
+
out += this.renderer.link(href, null, text);
|
703
|
+
continue;
|
704
|
+
}
|
705
|
+
|
706
|
+
// url (gfm)
|
707
|
+
if (!this.inLink && (cap = this.rules.url.exec(src))) {
|
708
|
+
if (cap[2] === '@') {
|
709
|
+
text = escape(cap[0]);
|
710
|
+
href = 'mailto:' + text;
|
711
|
+
} else {
|
712
|
+
// do extended autolink path validation
|
713
|
+
do {
|
714
|
+
prevCapZero = cap[0];
|
715
|
+
cap[0] = this.rules._backpedal.exec(cap[0])[0];
|
716
|
+
} while (prevCapZero !== cap[0]);
|
717
|
+
text = escape(cap[0]);
|
718
|
+
if (cap[1] === 'www.') {
|
719
|
+
href = 'http://' + text;
|
720
|
+
} else {
|
721
|
+
href = text;
|
722
|
+
}
|
723
|
+
}
|
724
|
+
src = src.substring(cap[0].length);
|
725
|
+
out += this.renderer.link(href, null, text);
|
726
|
+
continue;
|
727
|
+
}
|
728
|
+
|
729
|
+
// tag
|
730
|
+
if (cap = this.rules.tag.exec(src)) {
|
731
|
+
if (!this.inLink && /^<a /i.test(cap[0])) {
|
732
|
+
this.inLink = true;
|
733
|
+
} else if (this.inLink && /^<\/a>/i.test(cap[0])) {
|
734
|
+
this.inLink = false;
|
735
|
+
}
|
736
|
+
if (!this.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
737
|
+
this.inRawBlock = true;
|
738
|
+
} else if (this.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
|
739
|
+
this.inRawBlock = false;
|
740
|
+
}
|
741
|
+
|
742
|
+
src = src.substring(cap[0].length);
|
743
|
+
out += this.options.sanitize
|
744
|
+
? this.options.sanitizer
|
745
|
+
? this.options.sanitizer(cap[0])
|
746
|
+
: escape(cap[0])
|
747
|
+
: cap[0]
|
748
|
+
continue;
|
749
|
+
}
|
750
|
+
|
751
|
+
// link
|
752
|
+
if (cap = this.rules.link.exec(src)) {
|
753
|
+
src = src.substring(cap[0].length);
|
754
|
+
this.inLink = true;
|
755
|
+
href = cap[2];
|
756
|
+
if (this.options.pedantic) {
|
757
|
+
link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
|
758
|
+
|
759
|
+
if (link) {
|
760
|
+
href = link[1];
|
761
|
+
title = link[3];
|
762
|
+
} else {
|
763
|
+
title = '';
|
764
|
+
}
|
765
|
+
} else {
|
766
|
+
title = cap[3] ? cap[3].slice(1, -1) : '';
|
767
|
+
}
|
768
|
+
href = href.trim().replace(/^<([\s\S]*)>$/, '$1');
|
769
|
+
out += this.outputLink(cap, {
|
770
|
+
href: InlineLexer.escapes(href),
|
771
|
+
title: InlineLexer.escapes(title)
|
772
|
+
});
|
773
|
+
this.inLink = false;
|
774
|
+
continue;
|
775
|
+
}
|
776
|
+
|
777
|
+
// reflink, nolink
|
778
|
+
if ((cap = this.rules.reflink.exec(src))
|
779
|
+
|| (cap = this.rules.nolink.exec(src))) {
|
780
|
+
src = src.substring(cap[0].length);
|
781
|
+
link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
|
782
|
+
link = this.links[link.toLowerCase()];
|
783
|
+
if (!link || !link.href) {
|
784
|
+
out += cap[0].charAt(0);
|
785
|
+
src = cap[0].substring(1) + src;
|
786
|
+
continue;
|
787
|
+
}
|
788
|
+
this.inLink = true;
|
789
|
+
out += this.outputLink(cap, link);
|
790
|
+
this.inLink = false;
|
791
|
+
continue;
|
792
|
+
}
|
793
|
+
|
794
|
+
// strong
|
795
|
+
if (cap = this.rules.strong.exec(src)) {
|
796
|
+
src = src.substring(cap[0].length);
|
797
|
+
out += this.renderer.strong(this.output(cap[4] || cap[3] || cap[2] || cap[1]));
|
798
|
+
continue;
|
799
|
+
}
|
800
|
+
|
801
|
+
// em
|
802
|
+
if (cap = this.rules.em.exec(src)) {
|
803
|
+
src = src.substring(cap[0].length);
|
804
|
+
out += this.renderer.em(this.output(cap[6] || cap[5] || cap[4] || cap[3] || cap[2] || cap[1]));
|
805
|
+
continue;
|
806
|
+
}
|
807
|
+
|
808
|
+
// code
|
809
|
+
if (cap = this.rules.code.exec(src)) {
|
810
|
+
src = src.substring(cap[0].length);
|
811
|
+
out += this.renderer.codespan(escape(cap[2].trim(), true));
|
812
|
+
continue;
|
813
|
+
}
|
814
|
+
|
815
|
+
// br
|
816
|
+
if (cap = this.rules.br.exec(src)) {
|
817
|
+
src = src.substring(cap[0].length);
|
818
|
+
out += this.renderer.br();
|
819
|
+
continue;
|
820
|
+
}
|
821
|
+
|
822
|
+
// del (gfm)
|
823
|
+
if (cap = this.rules.del.exec(src)) {
|
824
|
+
src = src.substring(cap[0].length);
|
825
|
+
out += this.renderer.del(this.output(cap[1]));
|
826
|
+
continue;
|
827
|
+
}
|
828
|
+
|
829
|
+
// text
|
830
|
+
if (cap = this.rules.text.exec(src)) {
|
831
|
+
src = src.substring(cap[0].length);
|
832
|
+
if (this.inRawBlock) {
|
833
|
+
out += this.renderer.text(cap[0]);
|
834
|
+
} else {
|
835
|
+
out += this.renderer.text(escape(this.smartypants(cap[0])));
|
836
|
+
}
|
837
|
+
continue;
|
838
|
+
}
|
839
|
+
|
840
|
+
if (src) {
|
841
|
+
throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
|
842
|
+
}
|
843
|
+
}
|
844
|
+
|
845
|
+
return out;
|
846
|
+
};
|
847
|
+
|
848
|
+
InlineLexer.escapes = function(text) {
|
849
|
+
return text ? text.replace(InlineLexer.rules._escapes, '$1') : text;
|
850
|
+
}
|
851
|
+
|
852
|
+
/**
|
853
|
+
* Compile Link
|
854
|
+
*/
|
855
|
+
|
856
|
+
InlineLexer.prototype.outputLink = function(cap, link) {
|
857
|
+
var href = link.href,
|
858
|
+
title = link.title ? escape(link.title) : null;
|
859
|
+
|
860
|
+
return cap[0].charAt(0) !== '!'
|
861
|
+
? this.renderer.link(href, title, this.output(cap[1]))
|
862
|
+
: this.renderer.image(href, title, escape(cap[1]));
|
863
|
+
};
|
864
|
+
|
865
|
+
/**
|
866
|
+
* Smartypants Transformations
|
867
|
+
*/
|
868
|
+
|
869
|
+
InlineLexer.prototype.smartypants = function(text) {
|
870
|
+
if (!this.options.smartypants) return text;
|
871
|
+
return text
|
872
|
+
// em-dashes
|
873
|
+
.replace(/---/g, '\u2014')
|
874
|
+
// en-dashes
|
875
|
+
.replace(/--/g, '\u2013')
|
876
|
+
// opening singles
|
877
|
+
.replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
|
878
|
+
// closing singles & apostrophes
|
879
|
+
.replace(/'/g, '\u2019')
|
880
|
+
// opening doubles
|
881
|
+
.replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
|
882
|
+
// closing doubles
|
883
|
+
.replace(/"/g, '\u201d')
|
884
|
+
// ellipses
|
885
|
+
.replace(/\.{3}/g, '\u2026');
|
886
|
+
};
|
887
|
+
|
888
|
+
/**
|
889
|
+
* Mangle Links
|
890
|
+
*/
|
891
|
+
|
892
|
+
InlineLexer.prototype.mangle = function(text) {
|
893
|
+
if (!this.options.mangle) return text;
|
894
|
+
var out = '',
|
895
|
+
l = text.length,
|
896
|
+
i = 0,
|
897
|
+
ch;
|
898
|
+
|
899
|
+
for (; i < l; i++) {
|
900
|
+
ch = text.charCodeAt(i);
|
901
|
+
if (Math.random() > 0.5) {
|
902
|
+
ch = 'x' + ch.toString(16);
|
903
|
+
}
|
904
|
+
out += '&#' + ch + ';';
|
905
|
+
}
|
906
|
+
|
907
|
+
return out;
|
908
|
+
};
|
909
|
+
|
910
|
+
/**
|
911
|
+
* Renderer
|
912
|
+
*/
|
913
|
+
|
914
|
+
function Renderer(options) {
|
915
|
+
this.options = options || marked.defaults;
|
916
|
+
}
|
917
|
+
|
918
|
+
Renderer.prototype.code = function(code, lang, escaped) {
|
919
|
+
if (this.options.highlight) {
|
920
|
+
var out = this.options.highlight(code, lang);
|
921
|
+
if (out != null && out !== code) {
|
922
|
+
escaped = true;
|
923
|
+
code = out;
|
924
|
+
}
|
925
|
+
}
|
926
|
+
|
927
|
+
if (!lang) {
|
928
|
+
return '<pre><code>'
|
929
|
+
+ (escaped ? code : escape(code, true))
|
930
|
+
+ '</code></pre>';
|
931
|
+
}
|
932
|
+
|
933
|
+
return '<pre><code class="'
|
934
|
+
+ this.options.langPrefix
|
935
|
+
+ escape(lang, true)
|
936
|
+
+ '">'
|
937
|
+
+ (escaped ? code : escape(code, true))
|
938
|
+
+ '</code></pre>\n';
|
939
|
+
};
|
940
|
+
|
941
|
+
Renderer.prototype.blockquote = function(quote) {
|
942
|
+
return '<blockquote>\n' + quote + '</blockquote>\n';
|
943
|
+
};
|
944
|
+
|
945
|
+
Renderer.prototype.html = function(html) {
|
946
|
+
return html;
|
947
|
+
};
|
948
|
+
|
949
|
+
Renderer.prototype.heading = function(text, level, raw) {
|
950
|
+
if (this.options.headerIds) {
|
951
|
+
return '<h'
|
952
|
+
+ level
|
953
|
+
+ ' id="'
|
954
|
+
+ this.options.headerPrefix
|
955
|
+
+ raw.toLowerCase().replace(/[^\w]+/g, '-')
|
956
|
+
+ '">'
|
957
|
+
+ text
|
958
|
+
+ '</h'
|
959
|
+
+ level
|
960
|
+
+ '>\n';
|
961
|
+
}
|
962
|
+
// ignore IDs
|
963
|
+
return '<h' + level + '>' + text + '</h' + level + '>\n';
|
964
|
+
};
|
965
|
+
|
966
|
+
Renderer.prototype.hr = function() {
|
967
|
+
return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
|
968
|
+
};
|
969
|
+
|
970
|
+
Renderer.prototype.list = function(body, ordered, start) {
|
971
|
+
var type = ordered ? 'ol' : 'ul',
|
972
|
+
startatt = (ordered && start !== 1) ? (' start="' + start + '"') : '';
|
973
|
+
return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
|
974
|
+
};
|
975
|
+
|
976
|
+
Renderer.prototype.listitem = function(text) {
|
977
|
+
return '<li>' + text + '</li>\n';
|
978
|
+
};
|
979
|
+
|
980
|
+
Renderer.prototype.checkbox = function(checked) {
|
981
|
+
return '<input '
|
982
|
+
+ (checked ? 'checked="" ' : '')
|
983
|
+
+ 'disabled="" type="checkbox"'
|
984
|
+
+ (this.options.xhtml ? ' /' : '')
|
985
|
+
+ '> ';
|
986
|
+
}
|
987
|
+
|
988
|
+
Renderer.prototype.paragraph = function(text) {
|
989
|
+
return '<p>' + text + '</p>\n';
|
990
|
+
};
|
991
|
+
|
992
|
+
Renderer.prototype.table = function(header, body) {
|
993
|
+
if (body) body = '<tbody>' + body + '</tbody>';
|
994
|
+
|
995
|
+
return '<table>\n'
|
996
|
+
+ '<thead>\n'
|
997
|
+
+ header
|
998
|
+
+ '</thead>\n'
|
999
|
+
+ body
|
1000
|
+
+ '</table>\n';
|
1001
|
+
};
|
1002
|
+
|
1003
|
+
Renderer.prototype.tablerow = function(content) {
|
1004
|
+
return '<tr>\n' + content + '</tr>\n';
|
1005
|
+
};
|
1006
|
+
|
1007
|
+
Renderer.prototype.tablecell = function(content, flags) {
|
1008
|
+
var type = flags.header ? 'th' : 'td';
|
1009
|
+
var tag = flags.align
|
1010
|
+
? '<' + type + ' align="' + flags.align + '">'
|
1011
|
+
: '<' + type + '>';
|
1012
|
+
return tag + content + '</' + type + '>\n';
|
1013
|
+
};
|
1014
|
+
|
1015
|
+
// span level renderer
|
1016
|
+
Renderer.prototype.strong = function(text) {
|
1017
|
+
return '<strong>' + text + '</strong>';
|
1018
|
+
};
|
1019
|
+
|
1020
|
+
Renderer.prototype.em = function(text) {
|
1021
|
+
return '<em>' + text + '</em>';
|
1022
|
+
};
|
1023
|
+
|
1024
|
+
Renderer.prototype.codespan = function(text) {
|
1025
|
+
return '<code>' + text + '</code>';
|
1026
|
+
};
|
1027
|
+
|
1028
|
+
Renderer.prototype.br = function() {
|
1029
|
+
return this.options.xhtml ? '<br/>' : '<br>';
|
1030
|
+
};
|
1031
|
+
|
1032
|
+
Renderer.prototype.del = function(text) {
|
1033
|
+
return '<del>' + text + '</del>';
|
1034
|
+
};
|
1035
|
+
|
1036
|
+
Renderer.prototype.link = function(href, title, text) {
|
1037
|
+
if (this.options.sanitize) {
|
1038
|
+
try {
|
1039
|
+
var prot = decodeURIComponent(unescape(href))
|
1040
|
+
.replace(/[^\w:]/g, '')
|
1041
|
+
.toLowerCase();
|
1042
|
+
} catch (e) {
|
1043
|
+
return text;
|
1044
|
+
}
|
1045
|
+
if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
|
1046
|
+
return text;
|
1047
|
+
}
|
1048
|
+
}
|
1049
|
+
if (this.options.baseUrl && !originIndependentUrl.test(href)) {
|
1050
|
+
href = resolveUrl(this.options.baseUrl, href);
|
1051
|
+
}
|
1052
|
+
try {
|
1053
|
+
href = encodeURI(href).replace(/%25/g, '%');
|
1054
|
+
} catch (e) {
|
1055
|
+
return text;
|
1056
|
+
}
|
1057
|
+
var out = '<a href="' + escape(href) + '"';
|
1058
|
+
if (title) {
|
1059
|
+
out += ' title="' + title + '"';
|
1060
|
+
}
|
1061
|
+
out += '>' + text + '</a>';
|
1062
|
+
return out;
|
1063
|
+
};
|
1064
|
+
|
1065
|
+
Renderer.prototype.image = function(href, title, text) {
|
1066
|
+
if (this.options.baseUrl && !originIndependentUrl.test(href)) {
|
1067
|
+
href = resolveUrl(this.options.baseUrl, href);
|
1068
|
+
}
|
1069
|
+
var out = '<img src="' + href + '" alt="' + text + '"';
|
1070
|
+
if (title) {
|
1071
|
+
out += ' title="' + title + '"';
|
1072
|
+
}
|
1073
|
+
out += this.options.xhtml ? '/>' : '>';
|
1074
|
+
return out;
|
1075
|
+
};
|
1076
|
+
|
1077
|
+
Renderer.prototype.text = function(text) {
|
1078
|
+
return text;
|
1079
|
+
};
|
1080
|
+
|
1081
|
+
/**
|
1082
|
+
* TextRenderer
|
1083
|
+
* returns only the textual part of the token
|
1084
|
+
*/
|
1085
|
+
|
1086
|
+
function TextRenderer() {}
|
1087
|
+
|
1088
|
+
// no need for block level renderers
|
1089
|
+
|
1090
|
+
TextRenderer.prototype.strong =
|
1091
|
+
TextRenderer.prototype.em =
|
1092
|
+
TextRenderer.prototype.codespan =
|
1093
|
+
TextRenderer.prototype.del =
|
1094
|
+
TextRenderer.prototype.text = function (text) {
|
1095
|
+
return text;
|
1096
|
+
}
|
1097
|
+
|
1098
|
+
TextRenderer.prototype.link =
|
1099
|
+
TextRenderer.prototype.image = function(href, title, text) {
|
1100
|
+
return '' + text;
|
1101
|
+
}
|
1102
|
+
|
1103
|
+
TextRenderer.prototype.br = function() {
|
1104
|
+
return '';
|
1105
|
+
}
|
1106
|
+
|
1107
|
+
/**
|
1108
|
+
* Parsing & Compiling
|
1109
|
+
*/
|
1110
|
+
|
1111
|
+
function Parser(options) {
|
1112
|
+
this.tokens = [];
|
1113
|
+
this.token = null;
|
1114
|
+
this.options = options || marked.defaults;
|
1115
|
+
this.options.renderer = this.options.renderer || new Renderer();
|
1116
|
+
this.renderer = this.options.renderer;
|
1117
|
+
this.renderer.options = this.options;
|
1118
|
+
}
|
1119
|
+
|
1120
|
+
/**
|
1121
|
+
* Static Parse Method
|
1122
|
+
*/
|
1123
|
+
|
1124
|
+
Parser.parse = function(src, options) {
|
1125
|
+
var parser = new Parser(options);
|
1126
|
+
return parser.parse(src);
|
1127
|
+
};
|
1128
|
+
|
1129
|
+
/**
|
1130
|
+
* Parse Loop
|
1131
|
+
*/
|
1132
|
+
|
1133
|
+
Parser.prototype.parse = function(src) {
|
1134
|
+
this.inline = new InlineLexer(src.links, this.options);
|
1135
|
+
// use an InlineLexer with a TextRenderer to extract pure text
|
1136
|
+
this.inlineText = new InlineLexer(
|
1137
|
+
src.links,
|
1138
|
+
merge({}, this.options, {renderer: new TextRenderer()})
|
1139
|
+
);
|
1140
|
+
this.tokens = src.reverse();
|
1141
|
+
|
1142
|
+
var out = '';
|
1143
|
+
while (this.next()) {
|
1144
|
+
out += this.tok();
|
1145
|
+
}
|
1146
|
+
|
1147
|
+
return out;
|
1148
|
+
};
|
1149
|
+
|
1150
|
+
/**
|
1151
|
+
* Next Token
|
1152
|
+
*/
|
1153
|
+
|
1154
|
+
Parser.prototype.next = function() {
|
1155
|
+
return this.token = this.tokens.pop();
|
1156
|
+
};
|
1157
|
+
|
1158
|
+
/**
|
1159
|
+
* Preview Next Token
|
1160
|
+
*/
|
1161
|
+
|
1162
|
+
Parser.prototype.peek = function() {
|
1163
|
+
return this.tokens[this.tokens.length - 1] || 0;
|
1164
|
+
};
|
1165
|
+
|
1166
|
+
/**
|
1167
|
+
* Parse Text Tokens
|
1168
|
+
*/
|
1169
|
+
|
1170
|
+
Parser.prototype.parseText = function() {
|
1171
|
+
var body = this.token.text;
|
1172
|
+
|
1173
|
+
while (this.peek().type === 'text') {
|
1174
|
+
body += '\n' + this.next().text;
|
1175
|
+
}
|
1176
|
+
|
1177
|
+
return this.inline.output(body);
|
1178
|
+
};
|
1179
|
+
|
1180
|
+
/**
|
1181
|
+
* Parse Current Token
|
1182
|
+
*/
|
1183
|
+
|
1184
|
+
Parser.prototype.tok = function() {
|
1185
|
+
switch (this.token.type) {
|
1186
|
+
case 'space': {
|
1187
|
+
return '';
|
1188
|
+
}
|
1189
|
+
case 'hr': {
|
1190
|
+
return this.renderer.hr();
|
1191
|
+
}
|
1192
|
+
case 'heading': {
|
1193
|
+
return this.renderer.heading(
|
1194
|
+
this.inline.output(this.token.text),
|
1195
|
+
this.token.depth,
|
1196
|
+
unescape(this.inlineText.output(this.token.text)));
|
1197
|
+
}
|
1198
|
+
case 'code': {
|
1199
|
+
return this.renderer.code(this.token.text,
|
1200
|
+
this.token.lang,
|
1201
|
+
this.token.escaped);
|
1202
|
+
}
|
1203
|
+
case 'table': {
|
1204
|
+
var header = '',
|
1205
|
+
body = '',
|
1206
|
+
i,
|
1207
|
+
row,
|
1208
|
+
cell,
|
1209
|
+
j;
|
1210
|
+
|
1211
|
+
// header
|
1212
|
+
cell = '';
|
1213
|
+
for (i = 0; i < this.token.header.length; i++) {
|
1214
|
+
cell += this.renderer.tablecell(
|
1215
|
+
this.inline.output(this.token.header[i]),
|
1216
|
+
{ header: true, align: this.token.align[i] }
|
1217
|
+
);
|
1218
|
+
}
|
1219
|
+
header += this.renderer.tablerow(cell);
|
1220
|
+
|
1221
|
+
for (i = 0; i < this.token.cells.length; i++) {
|
1222
|
+
row = this.token.cells[i];
|
1223
|
+
|
1224
|
+
cell = '';
|
1225
|
+
for (j = 0; j < row.length; j++) {
|
1226
|
+
cell += this.renderer.tablecell(
|
1227
|
+
this.inline.output(row[j]),
|
1228
|
+
{ header: false, align: this.token.align[j] }
|
1229
|
+
);
|
1230
|
+
}
|
1231
|
+
|
1232
|
+
body += this.renderer.tablerow(cell);
|
1233
|
+
}
|
1234
|
+
return this.renderer.table(header, body);
|
1235
|
+
}
|
1236
|
+
case 'blockquote_start': {
|
1237
|
+
body = '';
|
1238
|
+
|
1239
|
+
while (this.next().type !== 'blockquote_end') {
|
1240
|
+
body += this.tok();
|
1241
|
+
}
|
1242
|
+
|
1243
|
+
return this.renderer.blockquote(body);
|
1244
|
+
}
|
1245
|
+
case 'list_start': {
|
1246
|
+
body = '';
|
1247
|
+
var ordered = this.token.ordered,
|
1248
|
+
start = this.token.start;
|
1249
|
+
|
1250
|
+
while (this.next().type !== 'list_end') {
|
1251
|
+
body += this.tok();
|
1252
|
+
}
|
1253
|
+
|
1254
|
+
return this.renderer.list(body, ordered, start);
|
1255
|
+
}
|
1256
|
+
case 'list_item_start': {
|
1257
|
+
body = '';
|
1258
|
+
var loose = this.token.loose;
|
1259
|
+
|
1260
|
+
if (this.token.task) {
|
1261
|
+
body += this.renderer.checkbox(this.token.checked);
|
1262
|
+
}
|
1263
|
+
|
1264
|
+
while (this.next().type !== 'list_item_end') {
|
1265
|
+
body += !loose && this.token.type === 'text'
|
1266
|
+
? this.parseText()
|
1267
|
+
: this.tok();
|
1268
|
+
}
|
1269
|
+
|
1270
|
+
return this.renderer.listitem(body);
|
1271
|
+
}
|
1272
|
+
case 'html': {
|
1273
|
+
// TODO parse inline content if parameter markdown=1
|
1274
|
+
return this.renderer.html(this.token.text);
|
1275
|
+
}
|
1276
|
+
case 'paragraph': {
|
1277
|
+
return this.renderer.paragraph(this.inline.output(this.token.text));
|
1278
|
+
}
|
1279
|
+
case 'text': {
|
1280
|
+
return this.renderer.paragraph(this.parseText());
|
1281
|
+
}
|
1282
|
+
}
|
1283
|
+
};
|
1284
|
+
|
1285
|
+
/**
|
1286
|
+
* Helpers
|
1287
|
+
*/
|
1288
|
+
|
1289
|
+
function escape(html, encode) {
|
1290
|
+
if (encode) {
|
1291
|
+
if (escape.escapeTest.test(html)) {
|
1292
|
+
return html.replace(escape.escapeReplace, function (ch) { return escape.replacements[ch] });
|
1293
|
+
}
|
1294
|
+
} else {
|
1295
|
+
if (escape.escapeTestNoEncode.test(html)) {
|
1296
|
+
return html.replace(escape.escapeReplaceNoEncode, function (ch) { return escape.replacements[ch] });
|
1297
|
+
}
|
1298
|
+
}
|
1299
|
+
|
1300
|
+
return html;
|
1301
|
+
}
|
1302
|
+
|
1303
|
+
escape.escapeTest = /[&<>"']/;
|
1304
|
+
escape.escapeReplace = /[&<>"']/g;
|
1305
|
+
escape.replacements = {
|
1306
|
+
'&': '&',
|
1307
|
+
'<': '<',
|
1308
|
+
'>': '>',
|
1309
|
+
'"': '"',
|
1310
|
+
"'": '''
|
1311
|
+
};
|
1312
|
+
|
1313
|
+
escape.escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
|
1314
|
+
escape.escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
|
1315
|
+
|
1316
|
+
function unescape(html) {
|
1317
|
+
// explicitly match decimal, hex, and named HTML entities
|
1318
|
+
return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, function(_, n) {
|
1319
|
+
n = n.toLowerCase();
|
1320
|
+
if (n === 'colon') return ':';
|
1321
|
+
if (n.charAt(0) === '#') {
|
1322
|
+
return n.charAt(1) === 'x'
|
1323
|
+
? String.fromCharCode(parseInt(n.substring(2), 16))
|
1324
|
+
: String.fromCharCode(+n.substring(1));
|
1325
|
+
}
|
1326
|
+
return '';
|
1327
|
+
});
|
1328
|
+
}
|
1329
|
+
|
1330
|
+
function edit(regex, opt) {
|
1331
|
+
regex = regex.source || regex;
|
1332
|
+
opt = opt || '';
|
1333
|
+
return {
|
1334
|
+
replace: function(name, val) {
|
1335
|
+
val = val.source || val;
|
1336
|
+
val = val.replace(/(^|[^\[])\^/g, '$1');
|
1337
|
+
regex = regex.replace(name, val);
|
1338
|
+
return this;
|
1339
|
+
},
|
1340
|
+
getRegex: function() {
|
1341
|
+
return new RegExp(regex, opt);
|
1342
|
+
}
|
1343
|
+
};
|
1344
|
+
}
|
1345
|
+
|
1346
|
+
function resolveUrl(base, href) {
|
1347
|
+
if (!baseUrls[' ' + base]) {
|
1348
|
+
// we can ignore everything in base after the last slash of its path component,
|
1349
|
+
// but we might need to add _that_
|
1350
|
+
// https://tools.ietf.org/html/rfc3986#section-3
|
1351
|
+
if (/^[^:]+:\/*[^/]*$/.test(base)) {
|
1352
|
+
baseUrls[' ' + base] = base + '/';
|
1353
|
+
} else {
|
1354
|
+
baseUrls[' ' + base] = rtrim(base, '/', true);
|
1355
|
+
}
|
1356
|
+
}
|
1357
|
+
base = baseUrls[' ' + base];
|
1358
|
+
|
1359
|
+
if (href.slice(0, 2) === '//') {
|
1360
|
+
return base.replace(/:[\s\S]*/, ':') + href;
|
1361
|
+
} else if (href.charAt(0) === '/') {
|
1362
|
+
return base.replace(/(:\/*[^/]*)[\s\S]*/, '$1') + href;
|
1363
|
+
} else {
|
1364
|
+
return base + href;
|
1365
|
+
}
|
1366
|
+
}
|
1367
|
+
var baseUrls = {};
|
1368
|
+
var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
|
1369
|
+
|
1370
|
+
function noop() {}
|
1371
|
+
noop.exec = noop;
|
1372
|
+
|
1373
|
+
function merge(obj) {
|
1374
|
+
var i = 1,
|
1375
|
+
target,
|
1376
|
+
key;
|
1377
|
+
|
1378
|
+
for (; i < arguments.length; i++) {
|
1379
|
+
target = arguments[i];
|
1380
|
+
for (key in target) {
|
1381
|
+
if (Object.prototype.hasOwnProperty.call(target, key)) {
|
1382
|
+
obj[key] = target[key];
|
1383
|
+
}
|
1384
|
+
}
|
1385
|
+
}
|
1386
|
+
|
1387
|
+
return obj;
|
1388
|
+
}
|
1389
|
+
|
1390
|
+
function splitCells(tableRow, count) {
|
1391
|
+
// ensure that every cell-delimiting pipe has a space
|
1392
|
+
// before it to distinguish it from an escaped pipe
|
1393
|
+
var row = tableRow.replace(/\|/g, function (match, offset, str) {
|
1394
|
+
var escaped = false,
|
1395
|
+
curr = offset;
|
1396
|
+
while (--curr >= 0 && str[curr] === '\\') escaped = !escaped;
|
1397
|
+
if (escaped) {
|
1398
|
+
// odd number of slashes means | is escaped
|
1399
|
+
// so we leave it alone
|
1400
|
+
return '|';
|
1401
|
+
} else {
|
1402
|
+
// add space before unescaped |
|
1403
|
+
return ' |';
|
1404
|
+
}
|
1405
|
+
}),
|
1406
|
+
cells = row.split(/ \|/),
|
1407
|
+
i = 0;
|
1408
|
+
|
1409
|
+
if (cells.length > count) {
|
1410
|
+
cells.splice(count);
|
1411
|
+
} else {
|
1412
|
+
while (cells.length < count) cells.push('');
|
1413
|
+
}
|
1414
|
+
|
1415
|
+
for (; i < cells.length; i++) {
|
1416
|
+
// leading or trailing whitespace is ignored per the gfm spec
|
1417
|
+
cells[i] = cells[i].trim().replace(/\\\|/g, '|');
|
1418
|
+
}
|
1419
|
+
return cells;
|
1420
|
+
}
|
1421
|
+
|
1422
|
+
// Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
1423
|
+
// /c*$/ is vulnerable to REDOS.
|
1424
|
+
// invert: Remove suffix of non-c chars instead. Default falsey.
|
1425
|
+
function rtrim(str, c, invert) {
|
1426
|
+
if (str.length === 0) {
|
1427
|
+
return '';
|
1428
|
+
}
|
1429
|
+
|
1430
|
+
// Length of suffix matching the invert condition.
|
1431
|
+
var suffLen = 0;
|
1432
|
+
|
1433
|
+
// Step left until we fail to match the invert condition.
|
1434
|
+
while (suffLen < str.length) {
|
1435
|
+
var currChar = str.charAt(str.length - suffLen - 1);
|
1436
|
+
if (currChar === c && !invert) {
|
1437
|
+
suffLen++;
|
1438
|
+
} else if (currChar !== c && invert) {
|
1439
|
+
suffLen++;
|
1440
|
+
} else {
|
1441
|
+
break;
|
1442
|
+
}
|
1443
|
+
}
|
1444
|
+
|
1445
|
+
return str.substr(0, str.length - suffLen);
|
1446
|
+
}
|
1447
|
+
|
1448
|
+
/**
|
1449
|
+
* Marked
|
1450
|
+
*/
|
1451
|
+
|
1452
|
+
function marked(src, opt, callback) {
|
1453
|
+
// throw error in case of non string input
|
1454
|
+
if (typeof src === 'undefined' || src === null) {
|
1455
|
+
throw new Error('marked(): input parameter is undefined or null');
|
1456
|
+
}
|
1457
|
+
if (typeof src !== 'string') {
|
1458
|
+
throw new Error('marked(): input parameter is of type '
|
1459
|
+
+ Object.prototype.toString.call(src) + ', string expected');
|
1460
|
+
}
|
1461
|
+
|
1462
|
+
if (callback || typeof opt === 'function') {
|
1463
|
+
if (!callback) {
|
1464
|
+
callback = opt;
|
1465
|
+
opt = null;
|
1466
|
+
}
|
1467
|
+
|
1468
|
+
opt = merge({}, marked.defaults, opt || {});
|
1469
|
+
|
1470
|
+
var highlight = opt.highlight,
|
1471
|
+
tokens,
|
1472
|
+
pending,
|
1473
|
+
i = 0;
|
1474
|
+
|
1475
|
+
try {
|
1476
|
+
tokens = Lexer.lex(src, opt)
|
1477
|
+
} catch (e) {
|
1478
|
+
return callback(e);
|
1479
|
+
}
|
1480
|
+
|
1481
|
+
pending = tokens.length;
|
1482
|
+
|
1483
|
+
var done = function(err) {
|
1484
|
+
if (err) {
|
1485
|
+
opt.highlight = highlight;
|
1486
|
+
return callback(err);
|
1487
|
+
}
|
1488
|
+
|
1489
|
+
var out;
|
1490
|
+
|
1491
|
+
try {
|
1492
|
+
out = Parser.parse(tokens, opt);
|
1493
|
+
} catch (e) {
|
1494
|
+
err = e;
|
1495
|
+
}
|
1496
|
+
|
1497
|
+
opt.highlight = highlight;
|
1498
|
+
|
1499
|
+
return err
|
1500
|
+
? callback(err)
|
1501
|
+
: callback(null, out);
|
1502
|
+
};
|
1503
|
+
|
1504
|
+
if (!highlight || highlight.length < 3) {
|
1505
|
+
return done();
|
1506
|
+
}
|
1507
|
+
|
1508
|
+
delete opt.highlight;
|
1509
|
+
|
1510
|
+
if (!pending) return done();
|
1511
|
+
|
1512
|
+
for (; i < tokens.length; i++) {
|
1513
|
+
(function(token) {
|
1514
|
+
if (token.type !== 'code') {
|
1515
|
+
return --pending || done();
|
1516
|
+
}
|
1517
|
+
return highlight(token.text, token.lang, function(err, code) {
|
1518
|
+
if (err) return done(err);
|
1519
|
+
if (code == null || code === token.text) {
|
1520
|
+
return --pending || done();
|
1521
|
+
}
|
1522
|
+
token.text = code;
|
1523
|
+
token.escaped = true;
|
1524
|
+
--pending || done();
|
1525
|
+
});
|
1526
|
+
})(tokens[i]);
|
1527
|
+
}
|
1528
|
+
|
1529
|
+
return;
|
1530
|
+
}
|
1531
|
+
try {
|
1532
|
+
if (opt) opt = merge({}, marked.defaults, opt);
|
1533
|
+
return Parser.parse(Lexer.lex(src, opt), opt);
|
1534
|
+
} catch (e) {
|
1535
|
+
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
|
1536
|
+
if ((opt || marked.defaults).silent) {
|
1537
|
+
return '<p>An error occurred:</p><pre>'
|
1538
|
+
+ escape(e.message + '', true)
|
1539
|
+
+ '</pre>';
|
1540
|
+
}
|
1541
|
+
throw e;
|
1542
|
+
}
|
1543
|
+
}
|
1544
|
+
|
1545
|
+
/**
|
1546
|
+
* Options
|
1547
|
+
*/
|
1548
|
+
|
1549
|
+
marked.options =
|
1550
|
+
marked.setOptions = function(opt) {
|
1551
|
+
merge(marked.defaults, opt);
|
1552
|
+
return marked;
|
1553
|
+
};
|
1554
|
+
|
1555
|
+
marked.getDefaults = function () {
|
1556
|
+
return {
|
1557
|
+
baseUrl: null,
|
1558
|
+
breaks: false,
|
1559
|
+
gfm: true,
|
1560
|
+
headerIds: true,
|
1561
|
+
headerPrefix: '',
|
1562
|
+
highlight: null,
|
1563
|
+
langPrefix: 'language-',
|
1564
|
+
mangle: true,
|
1565
|
+
pedantic: false,
|
1566
|
+
renderer: new Renderer(),
|
1567
|
+
sanitize: false,
|
1568
|
+
sanitizer: null,
|
1569
|
+
silent: false,
|
1570
|
+
smartLists: false,
|
1571
|
+
smartypants: false,
|
1572
|
+
tables: true,
|
1573
|
+
xhtml: false
|
1574
|
+
};
|
1575
|
+
}
|
1576
|
+
|
1577
|
+
marked.defaults = marked.getDefaults();
|
1578
|
+
|
1579
|
+
/**
|
1580
|
+
* Expose
|
1581
|
+
*/
|
1582
|
+
|
1583
|
+
marked.Parser = Parser;
|
1584
|
+
marked.parser = Parser.parse;
|
1585
|
+
|
1586
|
+
marked.Renderer = Renderer;
|
1587
|
+
marked.TextRenderer = TextRenderer;
|
1588
|
+
|
1589
|
+
marked.Lexer = Lexer;
|
1590
|
+
marked.lexer = Lexer.lex;
|
1591
|
+
|
1592
|
+
marked.InlineLexer = InlineLexer;
|
1593
|
+
marked.inlineLexer = InlineLexer.output;
|
1594
|
+
|
1595
|
+
marked.parse = marked;
|
1596
|
+
|
1597
|
+
if (typeof module !== 'undefined' && typeof exports === 'object') {
|
1598
|
+
module.exports = marked;
|
1599
|
+
} else if (typeof define === 'function' && define.amd) {
|
1600
|
+
define(function() { return marked; });
|
1601
|
+
} else {
|
1602
|
+
root.marked = marked;
|
1603
|
+
}
|
1604
|
+
})(this || (typeof window !== 'undefined' ? window : global));
|