nydp-html 0.0.2

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 40fa5ecff67b7c001d0e445507ce177ceadecf13
4
+ data.tar.gz: c5850142ea885409dc663241084067325f4a4fe7
5
+ SHA512:
6
+ metadata.gz: edd1ef38d177f7a64c73e344722c1a76d7909f768868be3b77b639f2c269f60c182ea3f00af84b53493c67c2908ea7d2b98e259201e99b90d690ef6aba6885fb
7
+ data.tar.gz: 77add9b61ae9d7cba66cc4ed321870ad339610445a7d1e1342104108dcbf48bd276b4292e04e97c54c262e4f5f05cbe320f607aa8331f9375a67034b184e5846
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .#*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nydp-html.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 conanite
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # Nydp::Html
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'nydp-html'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install nydp-html
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/nydp-html/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+ require "nydp"
3
+ require "nydp/html"
4
+
5
+ Nydp.rake_tasks
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'nydp/html'
4
+
5
+ Nydp.tests *ARGV.map(&:to_sym)
@@ -0,0 +1,81 @@
1
+ (register-test
2
+ '(suite "textile"
3
+ ("build a function to render a given textile string with the given arguments"
4
+ (pre-compile '(textile-build-function (a b c) "hello ~context.name this file was in ~(just source.name)."))
5
+ (fn (a b c)
6
+ (string-pieces
7
+ "<p>hello "
8
+ (interpolate (hash-get context 'name))
9
+ " this file was in "
10
+ (interpolate (hash-get source 'name))
11
+ ".</p>")))
12
+
13
+ ("render a plain textile string to html"
14
+ (render-as-textile "h1. header text
15
+
16
+ paragraph text
17
+
18
+ * item 1
19
+ * item 2
20
+ ")
21
+ "<h1>header text</h1>\n<p>paragraph text</p>\n<ul>\n\t<li>item 1</li>\n\t<li>item 2</li>\n</ul>")
22
+
23
+ ("compile a string with interpolations to an instruction to generate textile"
24
+ (compile-as-textile "h1. HEADER
25
+
26
+ ~a and ~b and ~(c 3)
27
+
28
+ * item ~(assign counter (+ counter 1))
29
+ * item ~(assign counter (+ counter 1))
30
+ * item ~(assign counter (+ counter 1))
31
+ ")
32
+
33
+ (string-pieces "<h1>HEADER</h1>\n<p>"
34
+ (interpolate a) " and " (interpolate b) " and " (interpolate (c 3))
35
+ "</p>\n<ul>\n\t<li>item " (interpolate (assign counter (+ counter 1)))
36
+ "</li>\n\t<li>item " (interpolate (assign counter (+ counter 1)))
37
+ "</li>\n\t<li>item " (interpolate (assign counter (+ counter 1)))
38
+ "</li>\n</ul>" nil))
39
+
40
+ ("compile a function invocation to render as textile"
41
+ (compile-as-textile a)
42
+ (textile-to-html a))
43
+
44
+ ("compile a plain string with no interpolations to an instruction to generate textile"
45
+ (compile-as-textile "h1. HEADER
46
+
47
+ para
48
+
49
+ * item 1
50
+ * item 2
51
+ ")
52
+ "<h1>HEADER</h1>\n<p>para</p>\n<ul>\n\t<li>item 1</li>\n\t<li>item 2</li>\n</ul>")
53
+
54
+ ("compile a simple string with one interpolation to render html"
55
+ (compile-as-textile "hello ~name ")
56
+ (string-pieces "<p>hello " (interpolate name) "</p>"))
57
+
58
+ ("render a simple string with one interpolation to html"
59
+ (let name "conan"
60
+ (render-as-textile "hello ~name "))
61
+ "<p>hello conan</p>")
62
+
63
+ ("render a string with interpolations to html"
64
+ (with (a 1 b 2 c (fn (x) (* 2 x)) counter 0)
65
+ (render-as-textile "h1. HEADER
66
+
67
+ ~a and ~b and ~(c 3)
68
+
69
+ * item ~(assign counter (+ counter 1))
70
+ * item ~(assign counter (+ counter 1))
71
+ * item ~(assign counter (+ counter 1))
72
+ "))
73
+
74
+ "<h1>HEADER</h1>\n<p>1 and 2 and 6</p>\n<ul>\n\t<li>item 1</li>\n\t<li>item 2</li>\n\t<li>item 3</li>\n</ul>")
75
+
76
+ ("render a string with interpolations to html"
77
+ (with (a "hello, world") (render-as-textile a))
78
+
79
+ "<p>hello, world</p>")
80
+
81
+ ))
@@ -0,0 +1,71 @@
1
+ ;
2
+ ; render-as-textile:
3
+ ;
4
+ ; ================================================================================
5
+ ;
6
+ ; the simplest case:
7
+ ;
8
+ ; (render-as-textile "hello world")
9
+ ;
10
+ ; expands to
11
+ ;
12
+ ; "<p>hello world</p>"
13
+ ;
14
+ ; ================================================================================
15
+ ;
16
+ ; next case,
17
+ ;
18
+ ; (render-as-textile (get-some-text-from 'somewhere))
19
+ ;
20
+ ; expands to
21
+ ;
22
+ ; (textile-to-html (get-some-text-from 'somewhere))
23
+ ;
24
+ ; ================================================================================
25
+ ;
26
+ ; the most useful case:
27
+ ;
28
+ ; (render-as-textile "hello ~name")
29
+ ;
30
+ ; expands to :
31
+ ;
32
+ ; (string-pieces "<p>hello" name "<p>")
33
+ ;
34
+ ;
35
+
36
+ (def interpolate (arg) arg)
37
+
38
+ (def textile-process-parts (parts)
39
+ (let separator (random-string 20)
40
+ (string-split (textile-to-html (joinstr "==~{separator}=="
41
+ parts))
42
+ separator)))
43
+
44
+ (def textile-interpolatify-arg (tuple)
45
+ (if (cadr tuple)
46
+ `(interpolate ,(cadr tuple))
47
+ nil))
48
+
49
+ (def build-textile-interpolator (pieces)
50
+ (let tuples (pairs pieces)
51
+ `(string-pieces ,@(apply + (zip (textile-process-parts (map car tuples))
52
+ (map textile-interpolatify-arg tuples))))))
53
+
54
+ (mac compile-as-textile (arg)
55
+ (if (isa 'string arg)
56
+ (textile-to-html arg)
57
+ (and (pair? arg)
58
+ (eq? 'string-pieces (car arg)))
59
+ `(build-textile-interpolator ,(quotify (cdr arg)))
60
+ `(list 'textile-to-html ',arg)))
61
+
62
+ (mac textile-build-function (param-names textile-string)
63
+ `(fn ,param-names (render-as-textile ,textile-string)))
64
+
65
+ (mac render-as-textile (arg)
66
+ (if (isa 'string arg)
67
+ (textile-to-html arg)
68
+ (and (pair? arg)
69
+ (eq? 'string-pieces (car arg)))
70
+ (build-textile-interpolator (cdr arg))
71
+ `(textile-to-html ,arg)))
@@ -0,0 +1,43 @@
1
+ require "redcloth"
2
+ require "nydp"
3
+ require "nydp/literal"
4
+ require "nydp/html/version"
5
+
6
+ module Nydp
7
+ module Html
8
+ class Plugin
9
+ def name ; "Nydp/HTML plugin" ; end
10
+
11
+ def relative_path name
12
+ File.expand_path(File.join File.dirname(__FILE__), name)
13
+ end
14
+
15
+ def load_rake_tasks
16
+ end
17
+
18
+ def loadfiles
19
+ b = relative_path('../lisp/textile.nydp')
20
+ [b]
21
+ end
22
+
23
+ def testfiles
24
+ Dir.glob(relative_path '../lisp/tests/**/*.nydp')
25
+ end
26
+
27
+ def setup ns
28
+ Symbol.mk("textile-to-html", ns).assign(Nydp::Html::TextileToHtml.new)
29
+ end
30
+ end
31
+
32
+ class TextileToHtml
33
+ def invoke vm, args
34
+ src = args.car.to_s
35
+ rc = RedCloth.new(src)
36
+ rc.no_span_caps = true
37
+ vm.push_arg Nydp::StringAtom.new rc.to_html
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ Nydp.plug_in Nydp::Html::Plugin.new
@@ -0,0 +1,5 @@
1
+ module Nydp
2
+ module Html
3
+ VERSION = "0.0.2"
4
+ end
5
+ end
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'nydp/html/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nydp-html"
8
+ spec.version = Nydp::Html::VERSION
9
+ spec.authors = ["Conan Dalton"]
10
+ spec.email = ["conan@conandalton.net"]
11
+ spec.summary = %q{nydp interface for HAML and Textile}
12
+ spec.description = %q{provides 'render-textile-to-html and 'render-haml-to-html functions}
13
+ spec.homepage = "http://github.com/conanite/nydp-html"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+
24
+ spec.add_development_dependency 'rspec', '~> 2.9'
25
+ spec.add_development_dependency 'rspec_numbering_formatter'
26
+
27
+ spec.add_dependency 'nydp'
28
+ spec.add_dependency 'haml'
29
+ spec.add_dependency 'RedCloth'
30
+
31
+ end
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nydp-html
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Conan Dalton
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.9'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.9'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec_numbering_formatter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: nydp
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: haml
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: RedCloth
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: provides 'render-textile-to-html and 'render-haml-to-html functions
112
+ email:
113
+ - conan@conandalton.net
114
+ executables:
115
+ - nydp-tests
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - Gemfile
121
+ - LICENSE.txt
122
+ - README.md
123
+ - Rakefile
124
+ - bin/nydp-tests
125
+ - lib/lisp/tests/textile-tests.nydp
126
+ - lib/lisp/textile.nydp
127
+ - lib/nydp/html.rb
128
+ - lib/nydp/html/version.rb
129
+ - nydp-html.gemspec
130
+ homepage: http://github.com/conanite/nydp-html
131
+ licenses:
132
+ - MIT
133
+ metadata: {}
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 2.2.2
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: nydp interface for HAML and Textile
154
+ test_files: []