jekyll-textile-converter 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b686c1122d58c93344727d3cc56f2de6de0110b1
4
- data.tar.gz: b244544e42ee63871f4e77412be64f683aee2b7d
3
+ metadata.gz: 09a7dd127ba4921e7b01e404aed9066173cf5d89
4
+ data.tar.gz: 38717e409e42c815fc070cf343aa43961ad2f6a6
5
5
  SHA512:
6
- metadata.gz: 7eb6611682061fa975d9ecf77c6912a70453f25016ac493995f78603f1557e6c74f09c4f3bc4dff6137d8d08c16be2f64e019ebe3959988021ff25050e85b90d
7
- data.tar.gz: c306cd98b0284042d8e79a6f6411ac37a246276350e54652fc799e9f9d573d17918b42463c4f2970697e04464ab6abb118f0e972f181152a502916f3bb48cd96
6
+ metadata.gz: d027a553de478371eda41e2b44d4c6f0e01d340124ecdcd471d2a0f53a5b5a3f49957ea2f925b89d827821a0070da6d884d30a7e0066e6867af5e6dde002a20e
7
+ data.tar.gz: dfb82fa8babb53b16ee6413774f954d5da333191be2f67a66d2e957e89d6dff79f9eeb7ff94d3eb787e2c7f1987cf136fde380e4aef9a6829a4f2039e3fdc550
@@ -0,0 +1,6 @@
1
+ -
2
+ title: Simple build
3
+ build: true
4
+ -
5
+ title: Compare build
6
+ compare: _expected _site
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ spec/source/_site
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0
4
+ - 2.1
5
+ - 2.2
6
+ sudo: false
7
+ cache: bundler
8
+ before_script: bundle update
9
+ script: script/cibuild
10
+ notifications:
11
+ email: false
12
+ env:
13
+ - JEKYLL_VERSION=tip
14
+ - JEKYLL_VERSION=latest
data/Gemfile CHANGED
@@ -2,3 +2,15 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in jekyll-textile-converter.gemspec
4
4
  gemspec
5
+
6
+ gem "clash", "~> 1.0"
7
+
8
+ if ENV["JEKYLL_VERSION"]
9
+ if ENV["JEKYLL_VERSION"].eql?("tip")
10
+ gem "jekyll", github: "jekyll/jekyll", branch: ENV["JEKYLL_BRANCH"]
11
+ else
12
+ gem "jekyll", "2.5.3"
13
+ end
14
+ else
15
+ gem "jekyll", ">= 2.0"
16
+ end
@@ -0,0 +1,7 @@
1
+ ## 0.1.0 / 2014-01-17
2
+
3
+ * First working iteration.
4
+
5
+ ## 0.0.1 / 2014-01-17
6
+
7
+ * Birthday!
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Jekyll::Textile::Converter
2
2
 
3
- TODO: Write a gem description
3
+ Convert your `.textile` Jekyll content. For Jekyll 3.0 and up.
4
+
5
+ [![Build Status](https://travis-ci.org/jekyll/jekyll-textile-converter.svg?branch=master)](https://travis-ci.org/jekyll/jekyll-textile-converter)
4
6
 
5
7
  ## Installation
6
8
 
@@ -18,13 +20,27 @@ Or install it yourself as:
18
20
 
19
21
  $ gem install jekyll-textile-converter
20
22
 
23
+ Lastly, add it to your `_config.yml` file:
24
+
25
+ gems:
26
+ - jekyll-textile-converter
27
+
21
28
  ## Usage
22
29
 
23
- TODO: Write usage instructions here
30
+ Plop in a file with YAML front matter and watch Jekyll gobble it up and spit out beautiful HTML.
31
+
32
+ If you'd like to use a file extension other than `.textile`, you may
33
+ specify a comma-separated list of extensions in your `_config.yml`, like this:
34
+
35
+ textile_ext: "textile,txtl,tl"
36
+
37
+ If that is the given configuration, then all files with `.textile`,
38
+ `.txtl`, and `.tl` file extensions will be read in and interpreted as
39
+ Textile. They must still contain YAML front matter.
24
40
 
25
41
  ## Contributing
26
42
 
27
- 1. Fork it ( https://github.com/[my-github-username]/jekyll-textile-converter/fork )
43
+ 1. Fork it ( https://github.com/jekyll/jekyll-textile-converter/fork )
28
44
  2. Create your feature branch (`git checkout -b my-new-feature`)
29
45
  3. Commit your changes (`git commit -am 'Add some feature'`)
30
46
  4. Push to the branch (`git push origin my-new-feature`)
@@ -1,11 +1,11 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'jekyll/textile/converter/version'
4
+ require 'jekyll-textile-converter/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "jekyll-textile-converter"
8
- spec.version = Jekyll::Textile::Converter::VERSION
8
+ spec.version = Jekyll::TextileConverter::VERSION
9
9
  spec.authors = ["Parker Moore"]
10
10
  spec.email = ["parkrmoore@gmail.com"]
11
11
  spec.summary = %q{Textile converter for Jekyll.}
@@ -17,6 +17,9 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ["lib"]
19
19
 
20
+ spec.add_runtime_dependency "RedCloth", "~> 4.0"
21
+
20
22
  spec.add_development_dependency "bundler", "~> 1.7"
21
23
  spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
22
25
  end
@@ -0,0 +1,12 @@
1
+ require 'jekyll'
2
+
3
+ root = File.expand_path('jekyll-textile-converter', File.dirname(__FILE__))
4
+ require "#{root}/filters"
5
+ require "#{root}/version"
6
+
7
+ require File.expand_path('jekyll/converters/textile', File.dirname(__FILE__))
8
+
9
+ module Jekyll
10
+ module TextileConverter
11
+ end
12
+ end
@@ -0,0 +1,18 @@
1
+ module Jekyll
2
+ module Filters
3
+ # Convert a Textile string into HTML output.
4
+ #
5
+ # input - The Textile String to convert.
6
+ #
7
+ # Returns the HTML formatted String.
8
+ def textilize(input)
9
+ site = @context.registers[:site]
10
+ converter = if site.respond_to?(:find_converter_instance)
11
+ site.find_converter_instance(Jekyll::Converters::Textile)
12
+ else
13
+ site.getConverterImpl(Jekyll::Converters::Textile)
14
+ end
15
+ converter.convert(input)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module TextileConverter
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,65 @@
1
+ module Jekyll
2
+ module Converters
3
+ class Textile < Converter
4
+ safe true
5
+
6
+ highlighter_prefix '<notextile>'
7
+ highlighter_suffix '</notextile>'
8
+
9
+ DEFAULT_CONFIGURATION = {
10
+ 'textile_ext' => 'textile',
11
+ 'redcloth' => {
12
+ 'hard_breaks' => true
13
+ }
14
+ }
15
+
16
+ def initialize(config = {})
17
+ @config = Jekyll::Utils.deep_merge_hashes(DEFAULT_CONFIGURATION, config)
18
+ @setup = false
19
+ end
20
+
21
+ def setup
22
+ return if @setup
23
+ require 'redcloth'
24
+ @setup = true
25
+ rescue LoadError
26
+ STDERR.puts 'You are missing a library required for Textile. Please run:'
27
+ STDERR.puts ' $ [sudo] gem install RedCloth'
28
+ raise Errors::FatalException.new("Missing dependency: RedCloth")
29
+ end
30
+
31
+ def extname_list
32
+ @extname_list ||= @config['textile_ext'].split(',').map { |e| ".#{e}" }
33
+ end
34
+
35
+ def matches(ext)
36
+ extname_list.include? ext.downcase
37
+ end
38
+
39
+ def output_ext(ext)
40
+ ".html"
41
+ end
42
+
43
+ def convert(content)
44
+ setup
45
+
46
+ # Shortcut if config doesn't contain RedCloth section
47
+ return RedCloth.new(content).to_html if @config['redcloth'].nil?
48
+
49
+ # List of attributes defined on RedCloth
50
+ # (from https://github.com/jgarber/redcloth/blob/master/lib/redcloth/textile_doc.rb)
51
+ attrs = ['filter_classes', 'filter_html', 'filter_ids', 'filter_styles',
52
+ 'hard_breaks', 'lite_mode', 'no_span_caps', 'sanitize_html']
53
+
54
+ r = RedCloth.new(content)
55
+
56
+ # Set attributes in r if they are NOT nil in the config
57
+ attrs.each do |attr|
58
+ r.instance_variable_set("@#{attr}".to_sym, @config['redcloth'][attr]) unless @config['redcloth'][attr].nil?
59
+ end
60
+
61
+ r.to_html
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ bundle install -j8 $@
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ script/test $@ && script/clash
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ bundle exec clash spec/source
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ bundle exec rspec --color --require spec_helper $@
@@ -0,0 +1,2 @@
1
+ gems:
2
+ - jekyll-textile-converter
@@ -0,0 +1,3 @@
1
+ <h2>a post about textile</h2>
2
+ <p>line 1<br />
3
+ line 2</p>
@@ -0,0 +1,3 @@
1
+ <h1>Testing the textilize filter</h1>
2
+
3
+ <p>this is a paragraph</p>
@@ -0,0 +1,8 @@
1
+ ---
2
+ title: My textile post
3
+ ---
4
+
5
+ h2. a post about textile
6
+
7
+ p. line 1
8
+ line 2
@@ -0,0 +1,6 @@
1
+ ---
2
+ ---
3
+
4
+ <h1>Testing the textilize filter</h1>
5
+
6
+ {{ "p. this is a paragraph" | textilize }}
@@ -0,0 +1,25 @@
1
+ require 'jekyll'
2
+ require File.expand_path('../../lib/jekyll-textile-converter', __FILE__)
3
+
4
+ RSpec.configure do |config|
5
+ config.expect_with :rspec do |expectations|
6
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
7
+ end
8
+
9
+ config.mock_with :rspec do |mocks|
10
+ mocks.verify_partial_doubles = true
11
+ end
12
+
13
+ config.filter_run :focus
14
+ config.run_all_when_everything_filtered = true
15
+ config.disable_monkey_patching!
16
+
17
+ config.warnings = false
18
+ if config.files_to_run.one?
19
+ config.default_formatter = 'doc'
20
+ end
21
+
22
+ config.profile_examples = 2
23
+ config.order = :random
24
+ Kernel.srand config.seed
25
+ end
@@ -0,0 +1,103 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ RSpec.describe(Jekyll::Converters::Textile) do
4
+ let(:configs) { Hash.new }
5
+ let(:converter) { described_class.new(configs) }
6
+
7
+ context "configuration" do
8
+
9
+ context "`redcloth`" do
10
+ context "no explicit config" do
11
+ it "preserves single line breaks in HTML output" do
12
+ expect(converter.convert("p. line1\nline2").strip).to eq("<p>line1<br />\nline2</p>")
13
+ end
14
+ end
15
+
16
+ context "empty redcloth config" do
17
+ let(:configs) { {'redcloth' => Hash.new} }
18
+
19
+ it "preserves single line breaks in HTML output" do
20
+ expect(converter.convert("p. line1\nline2").strip).to eq("<p>line1<br />\nline2</p>")
21
+ end
22
+ end
23
+
24
+ context "explicity enabled hard_breaks" do
25
+ let(:configs) { {'redcloth' => {'hard_breaks' => true}} }
26
+
27
+ it "preserves single line breaks in HTML output" do
28
+ expect(converter.convert("p. line1\nline2").strip).to eq("<p>line1<br />\nline2</p>")
29
+ end
30
+ end
31
+
32
+ context "explicity disabled hard_breaks" do
33
+ let(:configs) { {'redcloth' => {'hard_breaks' => false}} }
34
+
35
+ it "does not generate break tags in HTML output" do
36
+ expect(converter.convert("p. line1\nline2").strip).to eq("<p>line1\nline2</p>")
37
+ end
38
+ end
39
+
40
+ context "explicity disabled no_span_caps" do
41
+ let(:configs) { {'redcloth' => {'no_span_caps' => false}} }
42
+
43
+ it "generates span tags around capitalized words" do
44
+ expect(converter.convert("NSC").strip).to eq("<p><span class=\"caps\">NSC</span></p>")
45
+ end
46
+ end
47
+
48
+ context "explicitly enabled no_span_caps" do
49
+ let(:configs) { {'redcloth' => {'no_span_caps' => true}} }
50
+
51
+ it "does generates span tags around capitalized words" do
52
+ expect(converter.convert("NSC").strip).to eq("<p>NSC</p>")
53
+ end
54
+ end
55
+ end
56
+
57
+ context "`textile_ext`" do
58
+ context "with a custom list including the default" do
59
+ let(:configs) { {'textile_ext' => 'textile,text'} }
60
+
61
+ it "matches the new ext" do
62
+ expect(converter.matches('.text')).to be_truthy
63
+ end
64
+
65
+ it "matches the old ext" do
66
+ expect(converter.matches('.textile')).to be_truthy
67
+ end
68
+ end
69
+
70
+ context "with a replacement ext" do
71
+ let(:configs) { {'textile_ext' => 'text'} }
72
+
73
+ it "matches the new ext" do
74
+ expect(converter.matches('.text')).to be_truthy
75
+ end
76
+
77
+ it "doesn't match the old ext" do
78
+ expect(converter.matches('.textile')).to be_falsy
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+ context "in code blocks" do
85
+ let(:content) do
86
+ <<-CONTENT
87
+ _FIGHT!_
88
+
89
+ {% highlight ruby %}
90
+ puts "3..2..1.."
91
+ {% endhighlight %}
92
+
93
+ *FINISH HIM*
94
+ CONTENT
95
+ end
96
+
97
+ # Broken in RedCloth 4.1.9
98
+ it "does not textilize highlight block" do
99
+ expect(converter.convert(content)).not_to match(%r{3\.\.2\.\.1\.\.&quot;</span><br />})
100
+ end
101
+ end
102
+
103
+ end
@@ -0,0 +1,19 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ RSpec.describe(Jekyll::Filters) do
4
+ class JekyllFilter
5
+ include Jekyll::Filters
6
+ attr_accessor :site, :context
7
+
8
+ def initialize(opts = {})
9
+ @site = Jekyll::Site.new(Jekyll::Configuration::DEFAULTS)
10
+ @context = Liquid::Context.new({}, {}, { :site => @site })
11
+ end
12
+ end
13
+
14
+ let(:filter) { JekyllFilter.new }
15
+
16
+ it "should convert textile" do
17
+ expect(filter.textilize("something *really* simple")).to eq("<p>something <strong>really</strong> simple</p>")
18
+ end
19
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-textile-converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Parker Moore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-17 00:00:00.000000000 Z
11
+ date: 2015-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: RedCloth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +52,20 @@ dependencies:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
54
  version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
41
69
  description:
42
70
  email:
43
71
  - parkrmoore@gmail.com
@@ -45,14 +73,31 @@ executables: []
45
73
  extensions: []
46
74
  extra_rdoc_files: []
47
75
  files:
76
+ - ".clash.yml"
48
77
  - ".gitignore"
78
+ - ".travis.yml"
49
79
  - Gemfile
80
+ - History.markdown
50
81
  - LICENSE.txt
51
82
  - README.md
52
83
  - Rakefile
53
84
  - jekyll-textile-converter.gemspec
54
- - lib/jekyll/textile/converter.rb
55
- - lib/jekyll/textile/converter/version.rb
85
+ - lib/jekyll-textile-converter.rb
86
+ - lib/jekyll-textile-converter/filters.rb
87
+ - lib/jekyll-textile-converter/version.rb
88
+ - lib/jekyll/converters/textile.rb
89
+ - script/bootstrap
90
+ - script/cibuild
91
+ - script/clash
92
+ - script/test
93
+ - spec/source/_config.yml
94
+ - spec/source/_expected/2015/01/17/my-textile-post.html
95
+ - spec/source/_expected/index.html
96
+ - spec/source/_posts/2015-01-17-my-textile-post.textile
97
+ - spec/source/index.html
98
+ - spec/spec_helper.rb
99
+ - spec/textile_converter_spec.rb
100
+ - spec/textilize_filter_spec.rb
56
101
  homepage: https://github.com/jekyll/jekyll-textile-converter
57
102
  licenses:
58
103
  - MIT
@@ -77,4 +122,12 @@ rubygems_version: 2.2.2
77
122
  signing_key:
78
123
  specification_version: 4
79
124
  summary: Textile converter for Jekyll.
80
- test_files: []
125
+ test_files:
126
+ - spec/source/_config.yml
127
+ - spec/source/_expected/2015/01/17/my-textile-post.html
128
+ - spec/source/_expected/index.html
129
+ - spec/source/_posts/2015-01-17-my-textile-post.textile
130
+ - spec/source/index.html
131
+ - spec/spec_helper.rb
132
+ - spec/textile_converter_spec.rb
133
+ - spec/textilize_filter_spec.rb
@@ -1,9 +0,0 @@
1
- require "jekyll/textile/converter/version"
2
-
3
- module Jekyll
4
- module Textile
5
- module Converter
6
- # Your code goes here...
7
- end
8
- end
9
- end
@@ -1,7 +0,0 @@
1
- module Jekyll
2
- module Textile
3
- module Converter
4
- VERSION = "0.0.1"
5
- end
6
- end
7
- end