├── .github
└── workflows
│ └── ci.yml
├── .gitignore
├── .rspec
├── .ruby-version
├── .travis.yml
├── .travis
└── motion_setup.sh
├── CHANGELOG.md
├── Gemfile
├── LICENSE
├── README.md
├── Rakefile
├── benchmark
├── mdbasics.text
└── mdsyntax.text
├── lib
├── motion-markdown-it.rb
└── motion-markdown-it
│ ├── common
│ ├── entities.rb
│ ├── html_blocks.rb
│ ├── html_re.rb
│ ├── simpleidn.rb
│ └── utils.rb
│ ├── helpers
│ ├── helper_wrapper.rb
│ ├── parse_link_destination.rb
│ ├── parse_link_label.rb
│ └── parse_link_title.rb
│ ├── index.rb
│ ├── parser_block.rb
│ ├── parser_core.rb
│ ├── parser_inline.rb
│ ├── presets
│ ├── commonmark.rb
│ ├── default.rb
│ └── zero.rb
│ ├── renderer.rb
│ ├── ruler.rb
│ ├── rules_block
│ ├── blockquote.rb
│ ├── code.rb
│ ├── fence.rb
│ ├── heading.rb
│ ├── hr.rb
│ ├── html_block.rb
│ ├── lheading.rb
│ ├── list.rb
│ ├── paragraph.rb
│ ├── reference.rb
│ ├── state_block.rb
│ └── table.rb
│ ├── rules_core
│ ├── block.rb
│ ├── inline.rb
│ ├── linkify.rb
│ ├── normalize.rb
│ ├── replacements.rb
│ ├── smartquotes.rb
│ ├── state_core.rb
│ └── text_join.rb
│ ├── rules_inline
│ ├── autolink.rb
│ ├── backticks.rb
│ ├── balance_pairs.rb
│ ├── emphasis.rb
│ ├── entity.rb
│ ├── escape.rb
│ ├── fragments_join.rb
│ ├── html_inline.rb
│ ├── image.rb
│ ├── link.rb
│ ├── linkify.rb
│ ├── newline.rb
│ ├── state_inline.rb
│ ├── strikethrough.rb
│ └── text.rb
│ ├── token.rb
│ └── version.rb
├── motion-markdown-it.gemspec
├── rubymotion
├── Gemfile
├── Rakefile
├── app
│ └── app_delegate.rb
└── spec
│ ├── motion-markdown-it
│ ├── _helpers
│ │ └── _testgen_helper.rb
│ ├── bench_mark_spec.rb
│ ├── commonmark_spec.rb
│ ├── markdown_it_spec.rb
│ ├── misc_spec.rb
│ ├── ruler_spec.rb
│ ├── token_spec.rb
│ └── utils_spec.rb
│ └── spec_helper.rb
└── spec
├── motion-markdown-it
├── commonmark_spec.rb
├── fixtures
│ ├── commonmark
│ │ ├── bad.txt
│ │ ├── good.txt
│ │ └── spec.txt
│ └── markdown-it
│ │ ├── commonmark_extras.txt
│ │ ├── fatal.txt
│ │ ├── linkify.txt
│ │ ├── normalize.txt
│ │ ├── proto.txt
│ │ ├── smartquotes.txt
│ │ ├── strikethrough.txt
│ │ ├── tables.txt
│ │ ├── typographer.txt
│ │ └── xss.txt
├── markdown_it_spec.rb
├── misc_spec.rb
├── ruler_spec.rb
├── testgen_helper.rb
├── token_spec.rb
└── utils_spec.rb
└── spec_helper.rb
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: Tests
2 |
3 | on: [push]
4 |
5 | jobs:
6 | ruby:
7 | runs-on: ubuntu-latest
8 | strategy:
9 | matrix:
10 | ruby: ['2.7', '3.0', '3.1']
11 |
12 | env:
13 | BUNDLE_GEMFILE: ${{ github.workspace }}/Gemfile
14 | BUNDLE_PATH_RELATIVE_TO_CWD: true
15 |
16 | steps:
17 | - uses: actions/checkout@master
18 | - name: Set up Ruby
19 | uses: ruby/setup-ruby@v1
20 | with:
21 | ruby-version: ${{ matrix.ruby }}
22 | bundler: default
23 | bundler-cache: true
24 |
25 | - name: Run regular ruby specs
26 | run: |
27 | bundle exec rspec
28 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .repl_history
3 | .idea
4 | .nova
5 | Gemfile.lock
6 | rubymotion/build
7 | rubymotion/build-log
8 |
--------------------------------------------------------------------------------
/.rspec:
--------------------------------------------------------------------------------
1 | --color
2 | --require spec_helper
3 | --format documentation
4 |
--------------------------------------------------------------------------------
/.ruby-version:
--------------------------------------------------------------------------------
1 | 2.7.6
2 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | # test against both regular Ruby and RubyMotion
2 | jobs:
3 | include:
4 | - stage: ruby 2.5
5 | rvm: 2.5.5
6 | script:
7 | - bundle install --jobs=3 --retry=3
8 | - bundle exec rake spec
9 | - stage: ruby 2.6
10 | rvm: 2.6.6
11 | script:
12 | - bundle install --jobs=3 --retry=3
13 | - bundle exec rake spec
14 | - stage: macOS
15 | os: osx
16 | osx_image: xcode11.5
17 | language: objective-c
18 | env:
19 | - RUBYMOTION_LICENSE=1dcac45cc434293009f74b33037bdf7361a3a1ff # Official license key for open-source projects
20 | - TMP_DIR=./tmp # For motion repo, so it doesn't attempt to use /tmp, to which it has no access
21 | - OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
22 | cache:
23 | bundler: false
24 | install:
25 | - ./.travis/motion_setup.sh
26 | script:
27 | - cd rubymotion
28 | - export BUNDLE_GEMFILE=$PWD/Gemfile
29 | - bundle install --jobs=3 --retry=3
30 | - bundle exec rake spec
31 | - stage: iOS
32 | os: osx
33 | osx_image: xcode11.5
34 | language: objective-c
35 | env:
36 | - RUBYMOTION_LICENSE=1dcac45cc434293009f74b33037bdf7361a3a1ff # Official license key for open-source projects
37 | - TMP_DIR=./tmp # For motion repo, so it doesn't attempt to use /tmp, to which it has no access
38 | - OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
39 | cache:
40 | bundler: false
41 | install:
42 | - ./.travis/motion_setup.sh
43 | script:
44 | - cd rubymotion
45 | - export BUNDLE_GEMFILE=$PWD/Gemfile
46 | - bundle install --jobs=3 --retry=3
47 | - bundle exec rake spec platform=ios
--------------------------------------------------------------------------------
/.travis/motion_setup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [ "$TRAVIS_OS_NAME" = "osx" ]; then
4 | brew update
5 | brew outdated xctool || brew upgrade xctool
6 | (xcrun simctl list)
7 | wget http://travisci.rubymotion.com/ -O RubyMotion-TravisCI.pkg
8 | sudo installer -pkg RubyMotion-TravisCI.pkg -target /
9 | cp -r /usr/lib/swift/*.dylib /Applications/Xcode.app/Contents/Frameworks/
10 | touch /Applications/Xcode.app/Contents/Frameworks/.swift-5-staged
11 | sudo mkdir -p ~/Library/RubyMotion/build
12 | sudo chown -R travis ~/Library/RubyMotion
13 | eval "sudo motion activate $RUBYMOTION_LICENSE"
14 | sudo motion update
15 | (motion --version)
16 | (ruby --version)
17 | motion repo
18 | fi
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | 13.0.1 - 2023-01-18
2 | -------
3 |
4 | Synced with markdown-it 13.0.1, see the [CHANGELOG](https://github.com/markdown-it/markdown-it/blob/master/CHANGELOG.md)
5 |
6 | 12.3.2
7 | -------
8 |
9 | Synced with markdown-it 12.3.2, see the [CHANGELOG](https://github.com/markdown-it/markdown-it/blob/master/CHANGELOG.md)
10 |
11 | 12.0.6
12 | -------
13 |
14 | Synced with markdown-it 12.0.6, see the [CHANGELOG](https://github.com/markdown-it/markdown-it/blob/master/CHANGELOG.md)
15 |
16 | 11.0.0
17 | -------
18 |
19 | Synced with markdown-it 11.0.0, see the [CHANGELOG](https://github.com/markdown-it/markdown-it/blob/master/CHANGELOG.md)
20 |
21 | 10.0.0
22 | -------
23 |
24 | Synced with markdown-it 10.0.0, see the [CHANGELOG](https://github.com/markdown-it/markdown-it/blob/master/CHANGELOG.md)
25 |
26 | 9.0.1
27 | -------
28 |
29 | Synced with markdown-it 9.0.1, see the [CHANGELOG](https://github.com/markdown-it/markdown-it/blob/master/CHANGELOG.md)
30 |
31 | 8.4.1
32 | -------
33 |
34 | Synced with markdown-it 8.4.1, see the [CHANGELOG](https://github.com/markdown-it/markdown-it/blob/master/CHANGELOG.md)
35 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | gem 'rake'
4 | gem 'rspec'
5 |
6 | gem 'kramdown', require: 'kramdown'
7 | gem 'commonmarker'
8 | gem 'redcarpet'
9 |
10 | group :development, :test do
11 | gem 'pry-byebug'
12 | end
13 |
14 | gemspec
15 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Ruby version:
2 | Copyright (c) 2015 Brett Walker
3 |
4 | Javascript version:
5 | Copyright (c) 2014 Vitaly Puzrin, Alex Kocharin.
6 |
7 | Permission is hereby granted, free of charge, to any person
8 | obtaining a copy of this software and associated documentation
9 | files (the "Software"), to deal in the Software without
10 | restriction, including without limitation the rights to use,
11 | copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | copies of the Software, and to permit persons to whom the
13 | Software is furnished to do so, subject to the following
14 | conditions:
15 |
16 | The above copyright notice and this permission notice shall be
17 | included in all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 | OTHER DEALINGS IN THE SOFTWARE.
27 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | require 'bundler/gem_tasks'
2 | require 'rspec/core/rake_task'
3 |
4 | RSpec::Core::RakeTask.new
5 |
6 | task :default => :spec
7 | task :test => :spec
8 |
9 | desc 'Run benchmarks for motion-markdown-it, kramdown, and commonmarker'
10 | task :benchmark do
11 | require 'benchmark'
12 | require 'motion-markdown-it'
13 | require 'kramdown'
14 | require 'commonmarker'
15 | require 'redcarpet'
16 |
17 | runs = 500
18 | files = ['mdsyntax.text', 'mdbasics.text']
19 | benchmark_dir = File.join(File.dirname(__FILE__), 'benchmark')
20 |
21 | puts
22 | puts "Running tests on #{Time.now.strftime("%Y-%m-%d")} under #{RUBY_DESCRIPTION}"
23 |
24 | files.each do |file|
25 | data = File.read(File.join(benchmark_dir, file))
26 | puts
27 | puts "==> Test using file #{file} and #{runs} runs"
28 |
29 | results = Benchmark.bmbm(25) do |b|
30 | # results = Benchmark.bm(25) do |b|
31 | b.report("motion-markdown-it #{MotionMarkdownIt::VERSION}") do
32 | parser = MarkdownIt::Parser.new({ html: true, linkify: true, typographer: true })
33 | runs.times { parser.render(data) }
34 | end
35 | b.report("commonmarker #{CommonMarker::VERSION}") { runs.times { CommonMarker.render_html(data, :DEFAULT) } }
36 | b.report("kramdown #{Kramdown::VERSION}") { runs.times { Kramdown::Document.new(data).to_html } }
37 | b.report("redcarpet 3.4.0") do
38 | parser = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, tables: true)
39 | runs.times { parser.render(data) }
40 | end
41 | end
42 |
43 | puts
44 | puts "Real time as a factor of motion-markdown-it"
45 |
46 | md_real = results.first.real
47 | results.each do |result|
48 | puts result.label.ljust(28) << (result.real / md_real).round(4).to_s
49 | end
50 | end
51 | end
--------------------------------------------------------------------------------
/benchmark/mdbasics.text:
--------------------------------------------------------------------------------
1 | Markdown: Basics
2 | ================
3 |
4 |
11 |
12 |
13 | Getting the Gist of Markdown's Formatting Syntax
14 | ------------------------------------------------
15 |
16 | This page offers a brief overview of what it's like to use Markdown.
17 | The [syntax page] [s] provides complete, detailed documentation for
18 | every feature, but Markdown should be very easy to pick up simply by
19 | looking at a few examples of it in action. The examples on this page
20 | are written in a before/after style, showing example syntax and the
21 | HTML output produced by Markdown.
22 |
23 | It's also helpful to simply try Markdown out; the [Dingus] [d] is a
24 | web application that allows you type your own Markdown-formatted text
25 | and translate it to XHTML.
26 |
27 | **Note:** This document is itself written using Markdown; you
28 | can [see the source for it by adding '.text' to the URL] [src].
29 |
30 | [s]: /projects/markdown/syntax "Markdown Syntax"
31 | [d]: /projects/markdown/dingus "Markdown Dingus"
32 | [src]: /projects/markdown/basics.text
33 |
34 |
35 | ## Paragraphs, Headers, Blockquotes ##
36 |
37 | A paragraph is simply one or more consecutive lines of text, separated
38 | by one or more blank lines. (A blank line is any line that looks like a
39 | blank line -- a line containing nothing spaces or tabs is considered
40 | blank.) Normal paragraphs should not be intended with spaces or tabs.
41 |
42 | Markdown offers two styles of headers: *Setext* and *atx*.
43 | Setext-style headers for `` and `` are created by
44 | "underlining" with equal signs (`=`) and hyphens (`-`), respectively.
45 | To create an atx-style header, you put 1-6 hash marks (`#`) at the
46 | beginning of the line -- the number of hashes equals the resulting
47 | HTML header level.
48 |
49 | Blockquotes are indicated using email-style '`>`' angle brackets.
50 |
51 | Markdown:
52 |
53 | A First Level Header
54 | ====================
55 |
56 | A Second Level Header
57 | ---------------------
58 |
59 | Now is the time for all good men to come to
60 | the aid of their country. This is just a
61 | regular paragraph.
62 |
63 | The quick brown fox jumped over the lazy
64 | dog's back.
65 |
66 | ### Header 3
67 |
68 | > This is a blockquote.
69 | >
70 | > This is the second paragraph in the blockquote.
71 | >
72 | > ## This is an H2 in a blockquote
73 |
74 |
75 | Output:
76 |
77 | A First Level Header
78 |
79 | A Second Level Header
80 |
81 |
Now is the time for all good men to come to
82 | the aid of their country. This is just a
83 | regular paragraph.
84 |
85 | The quick brown fox jumped over the lazy
86 | dog's back.
87 |
88 | Header 3
89 |
90 |
91 | This is a blockquote.
92 |
93 | This is the second paragraph in the blockquote.
94 |
95 | This is an H2 in a blockquote
96 |
97 |
98 |
99 |
100 | ### Phrase Emphasis ###
101 |
102 | Markdown uses asterisks and underscores to indicate spans of emphasis.
103 |
104 | Markdown:
105 |
106 | Some of these words *are emphasized*.
107 | Some of these words _are emphasized also_.
108 |
109 | Use two asterisks for **strong emphasis**.
110 | Or, if you prefer, __use two underscores instead__.
111 |
112 | Output:
113 |
114 | Some of these words are emphasized.
115 | Some of these words are emphasized also.
116 |
117 | Use two asterisks for strong emphasis.
118 | Or, if you prefer, use two underscores instead.
119 |
120 |
121 |
122 | ## Lists ##
123 |
124 | Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`,
125 | `+`, and `-`) as list markers. These three markers are
126 | interchangable; this:
127 |
128 | * Candy.
129 | * Gum.
130 | * Booze.
131 |
132 | this:
133 |
134 | + Candy.
135 | + Gum.
136 | + Booze.
137 |
138 | and this:
139 |
140 | - Candy.
141 | - Gum.
142 | - Booze.
143 |
144 | all produce the same output:
145 |
146 |
147 | - Candy.
148 | - Gum.
149 | - Booze.
150 |
151 |
152 | Ordered (numbered) lists use regular numbers, followed by periods, as
153 | list markers:
154 |
155 | 1. Red
156 | 2. Green
157 | 3. Blue
158 |
159 | Output:
160 |
161 |
162 | - Red
163 | - Green
164 | - Blue
165 |
166 |
167 | If you put blank lines between items, you'll get `` tags for the
168 | list item text. You can create multi-paragraph list items by indenting
169 | the paragraphs by 4 spaces or 1 tab:
170 |
171 | * A list item.
172 |
173 | With multiple paragraphs.
174 |
175 | * Another item in the list.
176 |
177 | Output:
178 |
179 |
184 |
185 |
186 |
187 | ### Links ###
188 |
189 | Markdown supports two styles for creating links: *inline* and
190 | *reference*. With both styles, you use square brackets to delimit the
191 | text you want to turn into a link.
192 |
193 | Inline-style links use parentheses immediately after the link text.
194 | For example:
195 |
196 | This is an [example link](http://example.com/).
197 |
198 | Output:
199 |
200 | This is an
201 | example link.
202 |
203 | Optionally, you may include a title attribute in the parentheses:
204 |
205 | This is an [example link](http://example.com/ "With a Title").
206 |
207 | Output:
208 |
209 | This is an
210 | example link.
211 |
212 | Reference-style links allow you to refer to your links by names, which
213 | you define elsewhere in your document:
214 |
215 | I get 10 times more traffic from [Google][1] than from
216 | [Yahoo][2] or [MSN][3].
217 |
218 | [1]: http://google.com/ "Google"
219 | [2]: http://search.yahoo.com/ "Yahoo Search"
220 | [3]: http://search.msn.com/ "MSN Search"
221 |
222 | Output:
223 |
224 | I get 10 times more traffic from Google than from Yahoo or MSN.
228 |
229 | The title attribute is optional. Link names may contain letters,
230 | numbers and spaces, but are *not* case sensitive:
231 |
232 | I start my morning with a cup of coffee and
233 | [The New York Times][NY Times].
234 |
235 | [ny times]: http://www.nytimes.com/
236 |
237 | Output:
238 |
239 | I start my morning with a cup of coffee and
240 | The New York Times.
241 |
242 |
243 | ### Images ###
244 |
245 | Image syntax is very much like link syntax.
246 |
247 | Inline (titles are optional):
248 |
249 | 
250 |
251 | Reference-style:
252 |
253 | ![alt text][id]
254 |
255 | [id]: /path/to/img.jpg "Title"
256 |
257 | Both of the above examples produce the same output:
258 |
259 |
260 |
261 |
262 |
263 | ### Code ###
264 |
265 | In a regular paragraph, you can create code span by wrapping text in
266 | backtick quotes. Any ampersands (`&`) and angle brackets (`<` or
267 | `>`) will automatically be translated into HTML entities. This makes
268 | it easy to use Markdown to write about HTML example code:
269 |
270 | I strongly recommend against using any `