motion-kramdown 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +9 -7
- data/lib/kramdown.rb +1 -1
- data/lib/kramdown/compatibility.rb +1 -1
- data/lib/kramdown/converter.rb +1 -1
- data/lib/kramdown/converter/base.rb +2 -1
- data/lib/kramdown/converter/html.rb +10 -5
- data/lib/kramdown/converter/kramdown.rb +13 -7
- data/lib/kramdown/converter/latex.rb +2 -1
- data/lib/kramdown/converter/math_engine/itex2mml.rb +1 -1
- data/lib/kramdown/converter/math_engine/mathjax.rb +18 -3
- data/lib/kramdown/converter/math_engine/ritex.rb +1 -1
- data/lib/kramdown/converter/pdf.rb +3 -2
- data/lib/kramdown/converter/remove_html_tags.rb +3 -1
- data/lib/kramdown/converter/syntax_highlighter.rb +53 -0
- data/lib/kramdown/converter/syntax_highlighter/coderay.rb +1 -1
- data/lib/kramdown/converter/syntax_highlighter/rouge.rb +2 -2
- data/lib/kramdown/converter/toc.rb +2 -2
- data/lib/kramdown/document.rb +5 -5
- data/lib/kramdown/element.rb +4 -1
- data/lib/kramdown/error.rb +1 -1
- data/lib/kramdown/options.rb +4 -3
- data/lib/kramdown/parser.rb +1 -1
- data/lib/kramdown/parser/base.rb +8 -4
- data/lib/kramdown/parser/gfm.rb +9 -1
- data/lib/kramdown/parser/html.rb +18 -3
- data/lib/kramdown/parser/kramdown.rb +8 -5
- data/lib/kramdown/parser/kramdown/abbreviation.rb +10 -2
- data/lib/kramdown/parser/kramdown/autolink.rb +1 -1
- data/lib/kramdown/parser/kramdown/blank_line.rb +1 -1
- data/lib/kramdown/parser/kramdown/block_boundary.rb +1 -1
- data/lib/kramdown/parser/kramdown/blockquote.rb +1 -1
- data/lib/kramdown/parser/kramdown/codeblock.rb +1 -1
- data/lib/kramdown/parser/kramdown/codespan.rb +1 -1
- data/lib/kramdown/parser/kramdown/emphasis.rb +2 -2
- data/lib/kramdown/parser/kramdown/eob.rb +1 -1
- data/lib/kramdown/parser/kramdown/escaped_chars.rb +1 -1
- data/lib/kramdown/parser/kramdown/extensions.rb +8 -7
- data/lib/kramdown/parser/kramdown/footnote.rb +12 -4
- data/lib/kramdown/parser/kramdown/header.rb +1 -1
- data/lib/kramdown/parser/kramdown/horizontal_rule.rb +1 -1
- data/lib/kramdown/parser/kramdown/html.rb +7 -4
- data/lib/kramdown/parser/kramdown/html_entity.rb +1 -1
- data/lib/kramdown/parser/kramdown/line_break.rb +1 -1
- data/lib/kramdown/parser/kramdown/link.rb +8 -5
- data/lib/kramdown/parser/kramdown/list.rb +17 -5
- data/lib/kramdown/parser/kramdown/math.rb +3 -3
- data/lib/kramdown/parser/kramdown/paragraph.rb +3 -3
- data/lib/kramdown/parser/kramdown/smart_quotes.rb +1 -1
- data/lib/kramdown/parser/kramdown/table.rb +1 -1
- data/lib/kramdown/parser/kramdown/typographic_symbol.rb +1 -1
- data/lib/kramdown/parser/markdown.rb +2 -2
- data/lib/kramdown/utils.rb +1 -1
- data/lib/kramdown/utils/configurable.rb +1 -1
- data/lib/kramdown/utils/entities.rb +1 -1
- data/lib/kramdown/utils/html.rb +3 -1
- data/lib/kramdown/utils/ordered_hash.rb +1 -1
- data/lib/kramdown/utils/string_scanner.rb +8 -0
- data/lib/kramdown/utils/unidecoder.rb +1 -1
- data/lib/kramdown/version.rb +2 -2
- data/lib/rubymotion/version.rb +1 -1
- data/spec/bench_mark.rb +43 -30
- data/spec/document_tree.rb +12 -2
- data/spec/gfm_to_html.rb +4 -1
- data/spec/html_to_html.rb +27 -9
- data/spec/html_to_kramdown_to_html.rb +4 -1
- data/spec/kramdown_to_xxx.rb +3 -1
- data/spec/text_to_kramdown_to_html.rb +4 -0
- data/spec/text_to_latex.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9577c71875ad433ef83f571aabd8d174ecc7f3e
|
4
|
+
data.tar.gz: c62c562508e488a2acdccc73b11103f5819e790f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc144943f6ef46416d7f5aa286966f0dbbb055a3a1d7c937e8c9f4a6cfa726abdf77add761eb9a05cb5256e42970d4df3ec299373add3de0e701fabc009162ce
|
7
|
+
data.tar.gz: 1b081491e595b664f22f060a0bb44da88874629b8d8f2a973de5548befc5ed5387553c59f0e0d9e011e5169b2f079b27aed697a139a640dc01742f6f43204c65
|
data/README.md
CHANGED
@@ -1,21 +1,23 @@
|
|
1
1
|
# motion-kramdown
|
2
2
|
|
3
|
-
|
3
|
+
[](http://badge.fury.io/rb/motion-kramdown)
|
4
4
|
|
5
|
-
|
5
|
+
[kramdown](https://github.com/gettalong/kramdown) Markdown parser, for use with RubyMotion on iOS and OS X.
|
6
|
+
|
7
|
+
Currently implements: _kramdown_ 1.6
|
6
8
|
|
7
9
|
## Introduction
|
8
10
|
|
9
|
-
_kramdown_ is
|
11
|
+
_kramdown_ is a fast, pure Ruby Markdown superset converter, using a strict syntax definition and supporting several common extensions.
|
10
12
|
|
11
|
-
The syntax definition for the kramdown syntax can be found
|
13
|
+
The syntax definition for the kramdown syntax can be found online at <http://kramdown.gettalong.org/syntax.html> and a quick reference is available online at <http://kramdown.gettalong.org/quickref.html>.
|
12
14
|
|
13
|
-
The _kramdown_ library is mainly written to support the kramdown-to-HTML conversion chain. However, due to its flexibility it supports other input and output formats as well. Here is a list of the supported formats:
|
15
|
+
The _kramdown_ library is mainly written to support the kramdown-to-HTML conversion chain. However, due to its flexibility (by creating an internal AST) it supports other input and output formats as well. Here is a list of the supported formats:
|
14
16
|
|
15
|
-
* input formats: kramdown (a Markdown superset), Markdown, HTML
|
17
|
+
* input formats: kramdown (a Markdown superset), Markdown, GFM, HTML
|
16
18
|
* output formats: HTML, kramdown (and LaTeX and PDF, though not in _motion-kramdown_)
|
17
19
|
|
18
|
-
All the documentation on the available input and output formats is available
|
20
|
+
All the documentation on the available input and output formats is available online at <http://kramdown.gettalong.org>.
|
19
21
|
|
20
22
|
## Installation
|
21
23
|
|
data/lib/kramdown.rb
CHANGED
data/lib/kramdown/converter.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
@@ -9,6 +9,7 @@
|
|
9
9
|
|
10
10
|
# RM require 'erb'
|
11
11
|
# RM require 'kramdown/utils'
|
12
|
+
# RM require 'kramdown/document'
|
12
13
|
|
13
14
|
module Kramdown
|
14
15
|
|
@@ -1,14 +1,15 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
8
8
|
#
|
9
9
|
|
10
|
-
# RM require '
|
11
|
-
# RM require 'kramdown/
|
10
|
+
# RM require 'kramdown/parser'
|
11
|
+
# RM require 'kramdown/converter'
|
12
|
+
# RM require 'kramdown/utils'
|
12
13
|
|
13
14
|
module Kramdown
|
14
15
|
|
@@ -321,7 +322,9 @@ module Kramdown
|
|
321
322
|
|
322
323
|
def convert_abbreviation(el, indent)
|
323
324
|
title = @root.options[:abbrev_defs][el.value]
|
324
|
-
|
325
|
+
attr = @root.options[:abbrev_attr][el.value].dup
|
326
|
+
attr['title'] = title unless title.empty?
|
327
|
+
format_as_span_html("abbr", attr, el.value)
|
325
328
|
end
|
326
329
|
|
327
330
|
def convert_root(el, indent)
|
@@ -372,7 +375,9 @@ module Kramdown
|
|
372
375
|
toc.each do |level, id, children|
|
373
376
|
li = Element.new(:li, nil, nil, {:level => level})
|
374
377
|
li.children << Element.new(:p, nil, nil, {:transparent => true})
|
375
|
-
a = Element.new(:a, nil
|
378
|
+
a = Element.new(:a, nil)
|
379
|
+
a.attr['href'] = "##{id}"
|
380
|
+
a.attr['id'] = "#{sections.attr['id']}-#{id}"
|
376
381
|
a.children.concat(remove_footnotes(Marshal.load(Marshal.dump(children))))
|
377
382
|
li.children.last.children << a
|
378
383
|
li.children << Element.new(type)
|
@@ -1,13 +1,14 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
8
8
|
#
|
9
9
|
|
10
|
-
# RM require '
|
10
|
+
# RM require 'kramdown/converter'
|
11
|
+
# RM require 'kramdown/utils'
|
11
12
|
|
12
13
|
module Kramdown
|
13
14
|
|
@@ -280,17 +281,17 @@ module Kramdown
|
|
280
281
|
end
|
281
282
|
"[#{inner(el, opts)}][#{index}]"
|
282
283
|
else
|
283
|
-
title = el.attr['title']
|
284
|
+
title = parse_title(el.attr['title'])
|
284
285
|
"[#{inner(el, opts)}](#{el.attr['href']}#{title})"
|
285
286
|
end
|
286
287
|
end
|
287
288
|
|
288
289
|
def convert_img(el, opts)
|
289
|
-
alt_text = el.attr['alt'].gsub(ESCAPED_CHAR_RE) { $1 ? "\\#{$1}" : $2 }
|
290
|
+
alt_text = el.attr['alt'].to_s.gsub(ESCAPED_CHAR_RE) { $1 ? "\\#{$1}" : $2 }
|
290
291
|
if el.attr['src'].empty?
|
291
292
|
"![#{alt_text}]()"
|
292
293
|
else
|
293
|
-
title = (el.attr['title']
|
294
|
+
title = parse_title(el.attr['title'])
|
294
295
|
link = if el.attr['src'].count("()") > 0
|
295
296
|
"<#{el.attr['src']}>"
|
296
297
|
else
|
@@ -369,8 +370,8 @@ module Kramdown
|
|
369
370
|
res = ''
|
370
371
|
res << "\n\n" if @linkrefs.size > 0
|
371
372
|
@linkrefs.each_with_index do |el, i|
|
372
|
-
title = el.attr['title']
|
373
|
-
res << "[#{i+1}]: #{el.attr['href']}#{title
|
373
|
+
title = parse_title(el.attr['title'])
|
374
|
+
res << "[#{i+1}]: #{el.attr['href']}#{title}\n"
|
374
375
|
end
|
375
376
|
res
|
376
377
|
end
|
@@ -389,6 +390,7 @@ module Kramdown
|
|
389
390
|
res = ''
|
390
391
|
@root.options[:abbrev_defs].each do |name, text|
|
391
392
|
res << "*[#{name}]: #{text}\n"
|
393
|
+
res << ial_for_element(Element.new(:unused, nil, @root.options[:abbrev_attr][name])).to_s << "\n\n"
|
392
394
|
end
|
393
395
|
res
|
394
396
|
end
|
@@ -415,6 +417,10 @@ module Kramdown
|
|
415
417
|
res.strip.empty? ? nil : "{:#{res}}"
|
416
418
|
end
|
417
419
|
|
420
|
+
def parse_title(attr)
|
421
|
+
attr.to_s.empty? ? '' : ' "' + attr.gsub(/"/, '"') + '"'
|
422
|
+
end
|
423
|
+
|
418
424
|
# :startdoc:
|
419
425
|
|
420
426
|
end
|
@@ -1,13 +1,14 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
8
8
|
#
|
9
9
|
|
10
10
|
# RM require 'set'
|
11
|
+
# RM require 'kramdown/converter'
|
11
12
|
|
12
13
|
module Kramdown
|
13
14
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
@@ -20,11 +20,26 @@ module Kramdown::Converter::MathEngine
|
|
20
20
|
text = (el.value =~ /<|&/ ? "% <![CDATA[\n#{el.value} %]]>" : el.value)
|
21
21
|
text.gsub!(/<\/?script>?/, '')
|
22
22
|
|
23
|
+
preview = preview_string(converter, el, opts)
|
24
|
+
|
23
25
|
attr = {:type => "math/tex#{type == :block ? '; mode=display' : ''}"}
|
24
26
|
if type == :block
|
25
|
-
converter.format_as_block_html('script', attr, text, opts[:indent])
|
27
|
+
preview << converter.format_as_block_html('script', attr, text, opts[:indent])
|
28
|
+
else
|
29
|
+
preview << converter.format_as_span_html('script', attr, text)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.preview_string(converter, el, opts)
|
34
|
+
preview = converter.options[:math_engine_opts][:preview]
|
35
|
+
return '' unless preview
|
36
|
+
|
37
|
+
preview = (preview == true ? converter.escape_html(el.value) : preview.to_s)
|
38
|
+
|
39
|
+
if el.options[:category] == :block
|
40
|
+
converter.format_as_block_html('div', {'class' => 'MathJax_Preview'}, preview, opts[:indent])
|
26
41
|
else
|
27
|
-
converter.format_as_span_html('
|
42
|
+
converter.format_as_span_html('span', {'class' => 'MathJax_Preview'}, preview)
|
28
43
|
end
|
29
44
|
end
|
30
45
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
@@ -9,7 +9,8 @@
|
|
9
9
|
|
10
10
|
# RM require 'prawn'
|
11
11
|
# RM require 'prawn/table'
|
12
|
-
# RM require 'kramdown/
|
12
|
+
# RM require 'kramdown/converter'
|
13
|
+
# RM require 'kramdown/utils'
|
13
14
|
# RM require 'open-uri'
|
14
15
|
|
15
16
|
module Kramdown
|
@@ -1,12 +1,14 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
8
8
|
#
|
9
9
|
|
10
|
+
# RM require 'kramdown/converter'
|
11
|
+
|
10
12
|
module Kramdown
|
11
13
|
|
12
14
|
module Converter
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
|
+
#
|
6
|
+
# This file is part of kramdown which is licensed under the MIT.
|
7
|
+
#++
|
8
|
+
#
|
9
|
+
|
10
|
+
module Kramdown
|
11
|
+
module Converter
|
12
|
+
|
13
|
+
# == Container for Syntax Highlighters
|
14
|
+
#
|
15
|
+
# This module serves as container for the syntax highlighters that can be used together with
|
16
|
+
# kramdown.
|
17
|
+
#
|
18
|
+
# A syntax highlighter should not store any data itself but should use the provided converter
|
19
|
+
# object to do so (See Kramdown::Converter::Base#data).
|
20
|
+
#
|
21
|
+
# == Implementing a Syntax Highlighter
|
22
|
+
#
|
23
|
+
# Implementing a new syntax highlighter is easy because it is just an object that needs to
|
24
|
+
# respond to #call.
|
25
|
+
#
|
26
|
+
# The method #call needs to take the following arguments:
|
27
|
+
#
|
28
|
+
# converter:: This argument contains the converter object that calls the syntax highlighter. It
|
29
|
+
# can be used, for example, to store data in Kramdown::Converter::Base#data for one
|
30
|
+
# conversion run.
|
31
|
+
#
|
32
|
+
# text:: The raw text that should be highlighted.
|
33
|
+
#
|
34
|
+
# lang:: The language that the text should be highlighted for (e.g. ruby, python, ...).
|
35
|
+
#
|
36
|
+
# type:: The type of text, either :span for span-level code or :block for a codeblock.
|
37
|
+
#
|
38
|
+
# opts:: A Hash with options that may be passed from the converter.
|
39
|
+
#
|
40
|
+
# The return value of the method should be the highlighted text, suitable for the given
|
41
|
+
# converter (e.g. HTML for the HTML converter).
|
42
|
+
#
|
43
|
+
# == Special Implementation Details
|
44
|
+
#
|
45
|
+
# HTML converter:: If the syntax highlighter is used with a HTML converter, it should return
|
46
|
+
# :block type text correctly wrapped (i.e. normally inside a pre-tag, but may
|
47
|
+
# also be a table-tag or just a div-tag) but :span type text *without* a
|
48
|
+
# code-tag!
|
49
|
+
module SyntaxHighlighter
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
@@ -28,7 +28,7 @@ module Kramdown::Converter::SyntaxHighlighter
|
|
28
28
|
|
29
29
|
opts[:wrap] = false if type == :span
|
30
30
|
|
31
|
-
formatter = ::Rouge::Formatters::HTML.new(opts)
|
31
|
+
formatter = (opts.delete(:formatter) || ::Rouge::Formatters::HTML).new(opts)
|
32
32
|
formatter.format(lexer.lex(text))
|
33
33
|
end
|
34
34
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
8
8
|
#
|
9
9
|
|
10
|
-
# RM require '
|
10
|
+
# RM require 'kramdown/converter'
|
11
11
|
|
12
12
|
module Kramdown
|
13
13
|
|
data/lib/kramdown/document.rb
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
3
|
#--
|
4
|
-
# Copyright (C) 2009-
|
4
|
+
# Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at>
|
5
5
|
#
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
7
7
|
#++
|
8
8
|
#
|
9
9
|
# = kramdown
|
10
10
|
#
|
11
|
-
# kramdown is
|
11
|
+
# kramdown is fast, pure Ruby Markdown superset converter, using a strict syntax definition and
|
12
12
|
# supporting several common extensions.
|
13
13
|
#
|
14
14
|
# The kramdown library is mainly written to support the kramdown-to-HTML conversion chain. However,
|
15
15
|
# due to its flexibility it supports other input and output formats as well. Here is a list of the
|
16
16
|
# supported formats:
|
17
17
|
#
|
18
|
-
# * input formats: kramdown (a Markdown superset), Markdown, HTML
|
19
|
-
# * output formats: HTML, kramdown, LaTeX (and therefore PDF)
|
18
|
+
# * input formats: kramdown (a Markdown superset), Markdown, GFM, HTML
|
19
|
+
# * output formats: HTML, kramdown, LaTeX (and therefore PDF), PDF via Prawn
|
20
20
|
#
|
21
21
|
# All the documentation on the available input and output formats is available at
|
22
22
|
# http://kramdown.gettalong.org.
|
23
23
|
#
|
24
24
|
# == Usage
|
25
25
|
#
|
26
|
-
# kramdown has a
|
26
|
+
# kramdown has a simple API, so using kramdown is as easy as
|
27
27
|
#
|
28
28
|
# require 'kramdown'
|
29
29
|
#
|