├── Gemfile ├── script ├── bootstrap ├── cibuild ├── release └── console ├── .gitignore ├── .travis.yml ├── spec ├── fixtures │ ├── _layouts │ │ └── some_default.html │ ├── index.html │ └── _config.yml ├── spec_helper.rb └── jekyll-smartify_spec.rb ├── Rakefile ├── lib └── jekyll-smartify.rb ├── jekyll-smartify.gemspec ├── README.md └── LICENSE /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gemspec 4 | -------------------------------------------------------------------------------- /script/bootstrap: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | bundle install 4 | -------------------------------------------------------------------------------- /script/cibuild: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | bundle exec rspec 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | Gemfile.lock 3 | spec/dest 4 | .bundle 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - 2.1 4 | - 2.0 5 | - 1.9.3 6 | script: "script/cibuild" 7 | -------------------------------------------------------------------------------- /script/release: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Tag and push a release. 3 | 4 | set -e 5 | 6 | script/cibuild 7 | bundle exec rake release 8 | -------------------------------------------------------------------------------- /spec/fixtures/_layouts/some_default.html: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | {% for t in page.test %} 4 | {{ t | smartify }}
5 | {% endfor %} 6 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | require 'rspec/core/rake_task' 3 | 4 | RSpec::Core::RakeTask.new(:spec) 5 | 6 | task :default => :spec 7 | -------------------------------------------------------------------------------- /spec/fixtures/index.html: -------------------------------------------------------------------------------- 1 | --- 2 | test: 3 | - "It's working" 4 | - "Ellipsis..." 5 | - "#hashtag" 6 | --- 7 | 8 | Each test should be an item in `page.test` 9 | -------------------------------------------------------------------------------- /spec/fixtures/_config.yml: -------------------------------------------------------------------------------- 1 | timezone: UTC 2 | 3 | defaults: 4 | - 5 | scope: 6 | path: "" 7 | type: page 8 | values: 9 | layout: some_default 10 | -------------------------------------------------------------------------------- /lib/jekyll-smartify.rb: -------------------------------------------------------------------------------- 1 | require 'redcarpet' 2 | 3 | module SmartyPants 4 | def smartify(input) 5 | Redcarpet::Render::SmartyPants.render(input) 6 | end 7 | end 8 | 9 | Liquid::Template.register_filter(SmartyPants) 10 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'jekyll' 2 | require File.expand_path('../lib/jekyll-smartify', File.dirname(__FILE__)) 3 | 4 | Jekyll.logger.log_level = :error 5 | 6 | RSpec.configure do |config| 7 | config.run_all_when_everything_filtered = true 8 | config.filter_run :focus 9 | config.order = 'random' 10 | 11 | SOURCE_DIR = File.expand_path("../fixtures", __FILE__) 12 | DEST_DIR = File.expand_path("../dest", __FILE__) 13 | 14 | def source_dir(*files) 15 | File.join(SOURCE_DIR, *files) 16 | end 17 | 18 | def dest_dir(*files) 19 | File.join(DEST_DIR, *files) 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /script/console: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby 2 | 3 | def relative_to_root(path) 4 | File.expand_path(path, File.dirname(File.dirname(__FILE__))) 5 | end 6 | 7 | require 'jekyll' 8 | require relative_to_root('lib/jekyll-smartify.rb') 9 | require 'pry-debugger' 10 | 11 | SOURCE_DIR = relative_to_root('spec/fixtures') 12 | DEST_DIR = relative_to_root('spec/dest') 13 | 14 | def source_dir(*files) 15 | File.join(SOURCE_DIR, *files) 16 | end 17 | 18 | def dest_dir(*files) 19 | File.join(DEST_DIR, *files) 20 | end 21 | 22 | def config(overrides = {}) 23 | Jekyll.configuration({ 24 | "source" => source_dir, 25 | "destination" => dest_dir, 26 | "url" => "http://example.org" 27 | }).merge(overrides) 28 | end 29 | 30 | def site(configuration = config) 31 | Jekyll::Site.new(configuration) 32 | end 33 | 34 | binding.pry 35 | -------------------------------------------------------------------------------- /spec/jekyll-smartify_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe(Jekyll) do 4 | let(:overrides) do 5 | { 6 | "source" => source_dir, 7 | "destination" => dest_dir, 8 | "url" => "http://example.org", 9 | } 10 | end 11 | let(:config) do 12 | Jekyll.configuration(overrides) 13 | end 14 | let(:site) { Jekyll::Site.new(config) } 15 | let(:contents) { File.read(dest_dir("index.html")) } 16 | before(:each) do 17 | site.process 18 | end 19 | 20 | it "converts quotes into curly quotes" do 21 | expect(contents).to match /It’s working/ 22 | expect(contents).to_not match /It's working/ 23 | end 24 | 25 | it "converts dots into an ellipsis" do 26 | expect(contents).to match /Ellipsis…/ 27 | expect(contents).to_not match /Ellipsis\.\.\./ 28 | end 29 | 30 | it "does not convert to Markdown" do 31 | expect(contents).to match /#hashtag/ 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /jekyll-smartify.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | Gem::Specification.new do |spec| 4 | spec.name = "jekyll-smartify" 5 | spec.summary = "Adds smartify filter to Jekyll." 6 | spec.version = "0.0.3" 7 | spec.authors = ["Pat Hawks"] 8 | spec.email = "pat@pathawks.com" 9 | spec.homepage = "https://github.com/pathawks/jekyll-smartify" 10 | spec.licenses = ["MIT"] 11 | 12 | spec.files = `git ls-files -z`.split("\x0") 13 | spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } 14 | spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) 15 | spec.require_paths = ["lib"] 16 | 17 | spec.add_runtime_dependency "redcarpet", "~> 3.1" 18 | spec.add_runtime_dependency "liquid", [">= 2.5", "< 4.0"] 19 | 20 | spec.add_development_dependency "jekyll", [">= 2.0", "< 4.0"] 21 | spec.add_development_dependency "rspec", "~> 3.0" 22 | spec.add_development_dependency "rake" 23 | spec.add_development_dependency "bundler", "~> 1.6" 24 | end 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Jekyll Smartify 2 | 3 | *SmartyPants filter for Jekyll* 4 | 5 | [![Gem Version](https://img.shields.io/gem/v/jekyll-smartify.svg)](https://rubygems.org/gems/jekyll-smartify) 6 | [![Build Status](https://img.shields.io/travis/pathawks/jekyll-smartify/master.svg)](https://travis-ci.org/pathawks/jekyll-smartify) 7 | [![Dependency Status](https://img.shields.io/gemnasium/pathawks/jekyll-smartify.svg)](https://gemnasium.com/pathawks/jekyll-smartify) 8 | 9 | Make your "quotes" “curly” 10 | 11 | This plugin will soon be deprecated, as the `smartify` filter is [being added to Jekyll core](https://github.com/jekyll/jekyll/pull/4323) 12 | 13 | ## Usage 14 | 15 | 1. Add `gem 'jekyll-smartify'` to your site's Gemfile and run `bundle` 16 | 2. Add the following to your site's `_config.yml`: 17 | 18 | ```yml 19 | gems: 20 | - jekyll-smartify 21 | ``` 22 | 23 | ## Testing 24 | 25 | 1. `script/bootstrap` 26 | 2. `script/cibuild` 27 | 28 | ## Contributing 29 | 30 | 1. Fork the project 31 | 2. Create a descriptively named feature branch 32 | 3. Add your feature 33 | 4. Submit a pull request 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Pat Hawks 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | --------------------------------------------------------------------------------