motion-kramdown 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +84 -0
- data/lib/kramdown/compatibility.rb +36 -0
- data/lib/kramdown/converter/base.rb +259 -0
- data/lib/kramdown/converter/html.rb +461 -0
- data/lib/kramdown/converter/kramdown.rb +423 -0
- data/lib/kramdown/converter/latex.rb +600 -0
- data/lib/kramdown/converter/math_engine/itex2mml.rb +39 -0
- data/lib/kramdown/converter/math_engine/mathjax.rb +33 -0
- data/lib/kramdown/converter/math_engine/ritex.rb +38 -0
- data/lib/kramdown/converter/pdf.rb +624 -0
- data/lib/kramdown/converter/remove_html_tags.rb +53 -0
- data/lib/kramdown/converter/syntax_highlighter/coderay.rb +78 -0
- data/lib/kramdown/converter/syntax_highlighter/rouge.rb +37 -0
- data/lib/kramdown/converter/toc.rb +69 -0
- data/lib/kramdown/converter.rb +69 -0
- data/lib/kramdown/document.rb +144 -0
- data/lib/kramdown/element.rb +515 -0
- data/lib/kramdown/error.rb +17 -0
- data/lib/kramdown/options.rb +584 -0
- data/lib/kramdown/parser/base.rb +130 -0
- data/lib/kramdown/parser/gfm.rb +55 -0
- data/lib/kramdown/parser/html.rb +575 -0
- data/lib/kramdown/parser/kramdown/abbreviation.rb +67 -0
- data/lib/kramdown/parser/kramdown/autolink.rb +37 -0
- data/lib/kramdown/parser/kramdown/blank_line.rb +30 -0
- data/lib/kramdown/parser/kramdown/block_boundary.rb +33 -0
- data/lib/kramdown/parser/kramdown/blockquote.rb +39 -0
- data/lib/kramdown/parser/kramdown/codeblock.rb +56 -0
- data/lib/kramdown/parser/kramdown/codespan.rb +44 -0
- data/lib/kramdown/parser/kramdown/emphasis.rb +61 -0
- data/lib/kramdown/parser/kramdown/eob.rb +26 -0
- data/lib/kramdown/parser/kramdown/escaped_chars.rb +25 -0
- data/lib/kramdown/parser/kramdown/extensions.rb +201 -0
- data/lib/kramdown/parser/kramdown/footnote.rb +56 -0
- data/lib/kramdown/parser/kramdown/header.rb +59 -0
- data/lib/kramdown/parser/kramdown/horizontal_rule.rb +27 -0
- data/lib/kramdown/parser/kramdown/html.rb +160 -0
- data/lib/kramdown/parser/kramdown/html_entity.rb +33 -0
- data/lib/kramdown/parser/kramdown/line_break.rb +25 -0
- data/lib/kramdown/parser/kramdown/link.rb +139 -0
- data/lib/kramdown/parser/kramdown/list.rb +256 -0
- data/lib/kramdown/parser/kramdown/math.rb +54 -0
- data/lib/kramdown/parser/kramdown/paragraph.rb +54 -0
- data/lib/kramdown/parser/kramdown/smart_quotes.rb +174 -0
- data/lib/kramdown/parser/kramdown/table.rb +171 -0
- data/lib/kramdown/parser/kramdown/typographic_symbol.rb +44 -0
- data/lib/kramdown/parser/kramdown.rb +359 -0
- data/lib/kramdown/parser/markdown.rb +56 -0
- data/lib/kramdown/parser.rb +27 -0
- data/lib/kramdown/utils/configurable.rb +44 -0
- data/lib/kramdown/utils/entities.rb +347 -0
- data/lib/kramdown/utils/html.rb +75 -0
- data/lib/kramdown/utils/ordered_hash.rb +87 -0
- data/lib/kramdown/utils/string_scanner.rb +74 -0
- data/lib/kramdown/utils/unidecoder.rb +51 -0
- data/lib/kramdown/utils.rb +58 -0
- data/lib/kramdown/version.rb +15 -0
- data/lib/kramdown.rb +10 -0
- data/lib/motion-kramdown.rb +47 -0
- data/lib/rubymotion/encodings.rb +37 -0
- data/lib/rubymotion/rexml_shim.rb +25 -0
- data/lib/rubymotion/set.rb +1349 -0
- data/lib/rubymotion/version.rb +6 -0
- data/spec/document_tree.rb +48 -0
- data/spec/gfm_to_html.rb +95 -0
- data/spec/helpers/it_behaves_like.rb +27 -0
- data/spec/helpers/option_file.rb +46 -0
- data/spec/helpers/spec_options.rb +37 -0
- data/spec/helpers/tidy.rb +12 -0
- data/spec/html_to_html.rb +40 -0
- data/spec/html_to_kramdown_to_html.rb +46 -0
- data/spec/kramdown_to_xxx.rb +40 -0
- data/spec/test_location.rb +203 -0
- data/spec/test_string_scanner_kramdown.rb +19 -0
- data/spec/text_to_kramdown_to_html.rb +52 -0
- data/spec/text_to_latex.rb +33 -0
- metadata +164 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# Copyright (C) 2009-2014 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
|
+
|
12
|
+
# The kramdown version.
|
13
|
+
VERSION = '1.5.0'
|
14
|
+
|
15
|
+
end
|
data/lib/kramdown.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
unless defined?(Motion::Project::Config)
|
2
|
+
raise 'The motion-kramdown gem must be required within a RubyMotion project Rakefile.'
|
3
|
+
end
|
4
|
+
|
5
|
+
require 'motion-strscan'
|
6
|
+
require 'motion-yaml'
|
7
|
+
|
8
|
+
Motion::Project::App.setup do |app|
|
9
|
+
# scans app.files until it finds app/ (the default)
|
10
|
+
# if found, it inserts just before those files, otherwise it will insert to
|
11
|
+
# the end of the list
|
12
|
+
insert_point = app.files.find_index { |file| file =~ /^(?:\.\/)?app\// } || 0
|
13
|
+
|
14
|
+
# We need the files to be compiled in a top down fashion:
|
15
|
+
# `parser/kramdown.rb` before `parser/kramdown/autolink.rb`
|
16
|
+
# as an example, due to dependencies
|
17
|
+
lib_dir = File.expand_path(File.dirname(__FILE__))
|
18
|
+
excluded_files = ["#{lib_dir}/kramdown/converter/pdf.rb",
|
19
|
+
"#{lib_dir}/kramdown/converter/pdf.rb",
|
20
|
+
"#{lib_dir}/kramdown/converter/math_engine/itex2mml.rb",
|
21
|
+
"#{lib_dir}/kramdown/converter/math_engine/mathjax.rb",
|
22
|
+
"#{lib_dir}/kramdown/converter/math_engine/ritex.rb",
|
23
|
+
"#{lib_dir}/kramdown/converter/syntax_highlighter/coderay.rb",
|
24
|
+
"#{lib_dir}/kramdown/converter/syntax_highlighter/rouge.rb",
|
25
|
+
]
|
26
|
+
Dir.glob(File.join(lib_dir, 'kramdown', '**/*.rb')).each do |file|
|
27
|
+
unless excluded_files.include?(file)
|
28
|
+
app.files.insert(insert_point, file)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
Dir.glob(File.join(lib_dir, 'rubymotion', '**/*.rb')).each do |file|
|
32
|
+
app.files.insert(insert_point, file)
|
33
|
+
end
|
34
|
+
|
35
|
+
app.files_dependencies(
|
36
|
+
"#{lib_dir}/kramdown/parser/kramdown/html.rb" => "#{lib_dir}/kramdown/parser/html.rb",
|
37
|
+
"#{lib_dir}/kramdown/parser/kramdown/paragraph.rb" => "#{lib_dir}/kramdown/parser/html.rb",
|
38
|
+
"#{lib_dir}/kramdown/parser/kramdown/paragraph.rb" => "#{lib_dir}/kramdown/parser/kramdown/list.rb",
|
39
|
+
"#{lib_dir}/kramdown/parser/kramdown/footnote.rb" => "#{lib_dir}/kramdown/parser/kramdown/codeblock.rb",
|
40
|
+
"#{lib_dir}/kramdown/parser/markdown.rb" => "#{lib_dir}/kramdown/parser/kramdown/paragraph.rb",
|
41
|
+
"#{lib_dir}/kramdown/converter/html.rb" => "#{lib_dir}/kramdown/converter/base.rb",
|
42
|
+
"#{lib_dir}/kramdown/converter/kramdown.rb" => "#{lib_dir}/kramdown/converter/base.rb",
|
43
|
+
"#{lib_dir}/kramdown/converter/remove_html_tags.rb" => "#{lib_dir}/kramdown/converter/base.rb",
|
44
|
+
"#{lib_dir}/kramdown/converter/toc.rb" => "#{lib_dir}/kramdown/converter/base.rb",
|
45
|
+
"#{lib_dir}/kramdown/converter/latex.rb" => "#{lib_dir}/kramdown/converter/base.rb"
|
46
|
+
)
|
47
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# There are several issues in how ICU handles encoding between character sets.
|
2
|
+
# This file tries to provide small fixes to these behaviors
|
3
|
+
#------------------------------------------------------------------------------
|
4
|
+
|
5
|
+
# As of RubyMotion 3.5, the String.encode method will always gives a
|
6
|
+
#
|
7
|
+
# RuntimeError: this operation cannot be performed with encoding `UTF-8'
|
8
|
+
# because Apple's ICU does not support it
|
9
|
+
#
|
10
|
+
# However, String.force_encoding seems to work. However, that would support
|
11
|
+
# unsafe conversions. For now, most of our input is already properly encoded
|
12
|
+
# as utf-8, so there is no need to run the actual encode. Check for this.
|
13
|
+
#------------------------------------------------------------------------------
|
14
|
+
class String
|
15
|
+
#------------------------------------------------------------------------------
|
16
|
+
alias_method :orig_encode, :encode
|
17
|
+
def encode(encoding)
|
18
|
+
return self.dup if self.encoding.to_s == encoding.to_s
|
19
|
+
if self.encoding.to_s == 'US-ASCII' && encoding.to_s == 'UTF-8'
|
20
|
+
self.dup.force_encoding('UTF-8')
|
21
|
+
else
|
22
|
+
orig_encode(encoding)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
#------------------------------------------------------------------------------
|
27
|
+
alias_method :orig_encode!, :encode!
|
28
|
+
def encode!(encoding)
|
29
|
+
return self if self.encoding.to_s == encoding.to_s
|
30
|
+
if self.encoding.to_s == 'US-ASCII' && encoding.to_s == 'UTF-8'
|
31
|
+
self.force_encoding('UTF-8')
|
32
|
+
else
|
33
|
+
orig_encode!(encoding)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# REXML doesn't currently play well with RubyMotion, and we only need these
|
2
|
+
# constants, not the actual parser
|
3
|
+
#------------------------------------------------------------------------------
|
4
|
+
module REXML
|
5
|
+
module Parsers
|
6
|
+
class BaseParser
|
7
|
+
LETTER = '[:alpha:]'
|
8
|
+
DIGIT = '[:digit:]'
|
9
|
+
|
10
|
+
COMBININGCHAR = '' # TODO
|
11
|
+
EXTENDER = '' # TODO
|
12
|
+
|
13
|
+
NCNAME_STR= "[#{LETTER}_:][-[:alnum:]._:#{COMBININGCHAR}#{EXTENDER}]*"
|
14
|
+
NAME_STR= "(?:(#{NCNAME_STR}):)?(#{NCNAME_STR})"
|
15
|
+
UNAME_STR= "(?:#{NCNAME_STR}:)?#{NCNAME_STR}"
|
16
|
+
|
17
|
+
NAMECHAR = '[\-\w\.:]'
|
18
|
+
NAME = "([\\w:]#{NAMECHAR}*)"
|
19
|
+
NMTOKEN = "(?:#{NAMECHAR})+"
|
20
|
+
NMTOKENS = "#{NMTOKEN}(\\s+#{NMTOKEN})*"
|
21
|
+
REFERENCE = "&(?:#{NAME};|#\\d+;|#x[0-9a-fA-F]+;)"
|
22
|
+
REFERENCE_RE = /#{REFERENCE}/
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|