motion-kramdown 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +84 -0
  3. data/lib/kramdown/compatibility.rb +36 -0
  4. data/lib/kramdown/converter/base.rb +259 -0
  5. data/lib/kramdown/converter/html.rb +461 -0
  6. data/lib/kramdown/converter/kramdown.rb +423 -0
  7. data/lib/kramdown/converter/latex.rb +600 -0
  8. data/lib/kramdown/converter/math_engine/itex2mml.rb +39 -0
  9. data/lib/kramdown/converter/math_engine/mathjax.rb +33 -0
  10. data/lib/kramdown/converter/math_engine/ritex.rb +38 -0
  11. data/lib/kramdown/converter/pdf.rb +624 -0
  12. data/lib/kramdown/converter/remove_html_tags.rb +53 -0
  13. data/lib/kramdown/converter/syntax_highlighter/coderay.rb +78 -0
  14. data/lib/kramdown/converter/syntax_highlighter/rouge.rb +37 -0
  15. data/lib/kramdown/converter/toc.rb +69 -0
  16. data/lib/kramdown/converter.rb +69 -0
  17. data/lib/kramdown/document.rb +144 -0
  18. data/lib/kramdown/element.rb +515 -0
  19. data/lib/kramdown/error.rb +17 -0
  20. data/lib/kramdown/options.rb +584 -0
  21. data/lib/kramdown/parser/base.rb +130 -0
  22. data/lib/kramdown/parser/gfm.rb +55 -0
  23. data/lib/kramdown/parser/html.rb +575 -0
  24. data/lib/kramdown/parser/kramdown/abbreviation.rb +67 -0
  25. data/lib/kramdown/parser/kramdown/autolink.rb +37 -0
  26. data/lib/kramdown/parser/kramdown/blank_line.rb +30 -0
  27. data/lib/kramdown/parser/kramdown/block_boundary.rb +33 -0
  28. data/lib/kramdown/parser/kramdown/blockquote.rb +39 -0
  29. data/lib/kramdown/parser/kramdown/codeblock.rb +56 -0
  30. data/lib/kramdown/parser/kramdown/codespan.rb +44 -0
  31. data/lib/kramdown/parser/kramdown/emphasis.rb +61 -0
  32. data/lib/kramdown/parser/kramdown/eob.rb +26 -0
  33. data/lib/kramdown/parser/kramdown/escaped_chars.rb +25 -0
  34. data/lib/kramdown/parser/kramdown/extensions.rb +201 -0
  35. data/lib/kramdown/parser/kramdown/footnote.rb +56 -0
  36. data/lib/kramdown/parser/kramdown/header.rb +59 -0
  37. data/lib/kramdown/parser/kramdown/horizontal_rule.rb +27 -0
  38. data/lib/kramdown/parser/kramdown/html.rb +160 -0
  39. data/lib/kramdown/parser/kramdown/html_entity.rb +33 -0
  40. data/lib/kramdown/parser/kramdown/line_break.rb +25 -0
  41. data/lib/kramdown/parser/kramdown/link.rb +139 -0
  42. data/lib/kramdown/parser/kramdown/list.rb +256 -0
  43. data/lib/kramdown/parser/kramdown/math.rb +54 -0
  44. data/lib/kramdown/parser/kramdown/paragraph.rb +54 -0
  45. data/lib/kramdown/parser/kramdown/smart_quotes.rb +174 -0
  46. data/lib/kramdown/parser/kramdown/table.rb +171 -0
  47. data/lib/kramdown/parser/kramdown/typographic_symbol.rb +44 -0
  48. data/lib/kramdown/parser/kramdown.rb +359 -0
  49. data/lib/kramdown/parser/markdown.rb +56 -0
  50. data/lib/kramdown/parser.rb +27 -0
  51. data/lib/kramdown/utils/configurable.rb +44 -0
  52. data/lib/kramdown/utils/entities.rb +347 -0
  53. data/lib/kramdown/utils/html.rb +75 -0
  54. data/lib/kramdown/utils/ordered_hash.rb +87 -0
  55. data/lib/kramdown/utils/string_scanner.rb +74 -0
  56. data/lib/kramdown/utils/unidecoder.rb +51 -0
  57. data/lib/kramdown/utils.rb +58 -0
  58. data/lib/kramdown/version.rb +15 -0
  59. data/lib/kramdown.rb +10 -0
  60. data/lib/motion-kramdown.rb +47 -0
  61. data/lib/rubymotion/encodings.rb +37 -0
  62. data/lib/rubymotion/rexml_shim.rb +25 -0
  63. data/lib/rubymotion/set.rb +1349 -0
  64. data/lib/rubymotion/version.rb +6 -0
  65. data/spec/document_tree.rb +48 -0
  66. data/spec/gfm_to_html.rb +95 -0
  67. data/spec/helpers/it_behaves_like.rb +27 -0
  68. data/spec/helpers/option_file.rb +46 -0
  69. data/spec/helpers/spec_options.rb +37 -0
  70. data/spec/helpers/tidy.rb +12 -0
  71. data/spec/html_to_html.rb +40 -0
  72. data/spec/html_to_kramdown_to_html.rb +46 -0
  73. data/spec/kramdown_to_xxx.rb +40 -0
  74. data/spec/test_location.rb +203 -0
  75. data/spec/test_string_scanner_kramdown.rb +19 -0
  76. data/spec/text_to_kramdown_to_html.rb +52 -0
  77. data/spec/text_to_latex.rb +33 -0
  78. 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,10 @@
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
+ require 'kramdown/document'
@@ -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