Merge pull request #3319 from jekyll/split-off-textile
This commit is contained in:
commit
c378f741a8
1
Gemfile
1
Gemfile
|
@ -7,7 +7,6 @@ gem 'redgreen', '~> 1.2'
|
|||
gem 'shoulda', '~> 3.5'
|
||||
gem 'rr', '~> 1.1'
|
||||
gem 'cucumber', '1.3.18'
|
||||
gem 'RedCloth', '~> 4.2'
|
||||
gem 'maruku', '~> 0.7.0'
|
||||
gem 'rdiscount', '~> 2.0'
|
||||
gem 'launchy', '~> 2.3'
|
||||
|
|
|
@ -43,4 +43,4 @@ Feature: Draft Posts
|
|||
| Recipe | 2009-03-27 | simple | Post path: {{ page.path }} |
|
||||
When I run jekyll build --drafts
|
||||
Then the _site directory should exist
|
||||
And I should see "Post path: _drafts/recipe.textile" in "_site/recipe.html"
|
||||
And I should see "Post path: _drafts/recipe.markdown" in "_site/recipe.html"
|
||||
|
|
|
@ -20,8 +20,6 @@ Feature: Embed filters
|
|||
And I have the following post:
|
||||
| title | date | layout | content |
|
||||
| Star & Wars | 2009-03-27 | default | These aren't the droids you're looking for. |
|
||||
|
||||
|
||||
And I have a default layout that contains "{{ page.title | xml_escape }}"
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
|
@ -33,7 +31,7 @@ Feature: Embed filters
|
|||
And I have the following post:
|
||||
| title | date | layout | content |
|
||||
| Star Wars | 2009-03-27 | default | These aren't the droids you're looking for. |
|
||||
And I have a default layout that contains "{{ content | xml_escape }}"
|
||||
And I have a default layout that contains "{{ content | number_of_words }}"
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "7" in "_site/2009/03/27/star-wars.html"
|
||||
|
@ -49,13 +47,13 @@ Feature: Embed filters
|
|||
Then the _site directory should exist
|
||||
And I should see "scifi, movies, and force" in "_site/2009/03/27/star-wars.html"
|
||||
|
||||
Scenario: Textilize a given string
|
||||
Scenario: Markdownify a given string
|
||||
Given I have a _posts directory
|
||||
And I have a _layouts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | content |
|
||||
| Star Wars | 2009-03-27 | default | These aren't the droids you're looking for. |
|
||||
And I have a default layout that contains "By {{ '_Obi-wan_' | textilize }}"
|
||||
And I have a default layout that contains "By {{ '_Obi-wan_' | markdownify }}"
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "By <p><em>Obi-wan</em></p>" in "_site/2009/03/27/star-wars.html"
|
||||
|
|
|
@ -25,7 +25,7 @@ Feature: frontmatter defaults
|
|||
And I have a configuration file with "defaults" set to "[{scope: {path: ""}, values: {custom: "some special data", author: "Ben"}}]"
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "<p>some special data</p><div>Ben</div>" in "_site/2013/09/11/default-data.html"
|
||||
And I should see "<p>some special data</p>\n<div>Ben</div>" in "_site/2013/09/11/default-data.html"
|
||||
And I should see "just some special data by Ben" in "_site/index.html"
|
||||
|
||||
Scenario: Override frontmatter defaults by path
|
||||
|
|
|
@ -9,15 +9,15 @@ Feature: Include tags
|
|||
And I have an "_includes/params.html" file that contains "Parameters:<ul>{% for param in include %}<li>{{param[0]}} = {{param[1]}}</li>{% endfor %}</ul>"
|
||||
And I have an "_includes/ignore.html" file that contains "<footer>My blog footer</footer>"
|
||||
And I have a _posts directory
|
||||
And I have the following post:
|
||||
| title | date | layout | content |
|
||||
| Include Files | 2013-03-21 | default | {% include header.html param="myparam" %} |
|
||||
| Ignore params if unused | 2013-03-21 | default | {% include ignore.html date="today" %} |
|
||||
| List multiple parameters | 2013-03-21 | default | {% include params.html date="today" start="tomorrow" %} |
|
||||
| Dont keep parameters | 2013-03-21 | default | {% include ignore.html param="test" %}\n{% include header.html %} |
|
||||
| Allow params with spaces and quotes | 2013-04-07 | default | {% include params.html cool="param with spaces" super="\"quoted\"" single='has "quotes"' escaped='\'single\' quotes' %} |
|
||||
| Parameter syntax | 2013-04-12 | default | {% include params.html param1_or_2="value" %} |
|
||||
| Pass a variable | 2013-06-22 | default | {% assign var = 'some text' %}{% include params.html local=var layout=page.layout %} |
|
||||
And I have the following posts:
|
||||
| title | date | type | content |
|
||||
| Include Files | 2013-03-21 | html | {% include header.html param="myparam" %} |
|
||||
| Ignore params if unused | 2013-03-21 | html | {% include ignore.html date="today" %} |
|
||||
| List multiple parameters | 2013-03-21 | html | {% include params.html date="today" start="tomorrow" %} |
|
||||
| Dont keep parameters | 2013-03-21 | html | {% include ignore.html param="test" %}\n{% include header.html %} |
|
||||
| Allow params with spaces and quotes | 2013-04-07 | html | {% include params.html cool="param with spaces" super="\"quoted\"" single='has "quotes"' escaped='\'single\' quotes' %} |
|
||||
| Parameter syntax | 2013-04-12 | html | {% include params.html param1_or_2="value" %} |
|
||||
| Pass a variable | 2013-06-22 | html | {% assign var = 'some text' %}{% include params.html local=var title=page.title %} |
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "<header>My awesome blog header: myparam</header>" in "_site/2013/03/21/include-files.html"
|
||||
|
@ -27,12 +27,12 @@ Feature: Include tags
|
|||
And I should not see "<header>My awesome blog header: myparam</header>" in "_site/2013/03/21/dont-keep-parameters.html"
|
||||
But I should see "<header>My awesome blog header: </header>" in "_site/2013/03/21/dont-keep-parameters.html"
|
||||
And I should see "<li>cool = param with spaces</li>" in "_site/2013/04/07/allow-params-with-spaces-and-quotes.html"
|
||||
And I should see "<li>super = “quoted”</li>" in "_site/2013/04/07/allow-params-with-spaces-and-quotes.html"
|
||||
And I should see "<li>single = has “quotes”</li>" in "_site/2013/04/07/allow-params-with-spaces-and-quotes.html"
|
||||
And I should see "<li>escaped = ‘single’ quotes</li>" in "_site/2013/04/07/allow-params-with-spaces-and-quotes.html"
|
||||
And I should see "<li>super = \"quoted\"</li>" in "_site/2013/04/07/allow-params-with-spaces-and-quotes.html"
|
||||
And I should see "<li>single = has \"quotes\"</li>" in "_site/2013/04/07/allow-params-with-spaces-and-quotes.html"
|
||||
And I should see "<li>escaped = 'single' quotes</li>" in "_site/2013/04/07/allow-params-with-spaces-and-quotes.html"
|
||||
And I should see "<li>param1_or_2 = value</li>" in "_site/2013/04/12/parameter-syntax.html"
|
||||
And I should see "<li>local = some text</li>" in "_site/2013/06/22/pass-a-variable.html"
|
||||
And I should see "<li>layout = default</li>" in "_site/2013/06/22/pass-a-variable.html"
|
||||
And I should see "<li>title = Pass a variable</li>" in "_site/2013/06/22/pass-a-variable.html"
|
||||
|
||||
Scenario: Include a file from a variable
|
||||
Given I have an _includes directory
|
||||
|
|
|
@ -46,5 +46,5 @@ Feature: Post excerpts
|
|||
And the _site/2007/12 directory should exist
|
||||
And the _site/2007/12/31 directory should exist
|
||||
And the "_site/2007/12/31/entry1.html" file should exist
|
||||
And I should see exactly "<p>content for entry1.</p>" in "_site/index.html"
|
||||
And I should see exactly "<html><head></head><body><p>content for entry1.</p></body></html>" in "_site/2007/12/31/entry1.html"
|
||||
And I should see "<p>content for entry1.</p>" in "_site/index.html"
|
||||
And I should see "<html><head></head><body><p>content for entry1.</p>\n\n</body></html>" in "_site/2007/12/31/entry1.html"
|
||||
|
|
|
@ -170,8 +170,8 @@ Feature: Site configuration
|
|||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "Page Layout: 2" in "_site/index.html"
|
||||
And I should see "Post Layout: <p>content for entry1.</p> built at 2013-04-09T23:22:00-04:00" in "_site/2013/04/09/entry1.html"
|
||||
And I should see "Post Layout: <p>content for entry2.</p> built at 2013-04-10T03:14:00-04:00" in "_site/2013/04/10/entry2.html"
|
||||
And I should see "Post Layout: <p>content for entry1.</p>\n built at 2013-04-09T23:22:00-04:00" in "_site/2013/04/09/entry1.html"
|
||||
And I should see "Post Layout: <p>content for entry2.</p>\n built at 2013-04-10T03:14:00-04:00" in "_site/2013/04/10/entry2.html"
|
||||
|
||||
Scenario: Generate proper dates with explicitly set timezone (different than posts' time)
|
||||
Given I have a _layouts directory
|
||||
|
@ -180,19 +180,19 @@ Feature: Site configuration
|
|||
And I have an "index.html" page with layout "page" that contains "site index page"
|
||||
And I have a configuration file with:
|
||||
| key | value |
|
||||
| timezone | Australia/Melbourne |
|
||||
| timezone | Pacific/Honolulu |
|
||||
And I have a _posts directory
|
||||
And I have the following posts:
|
||||
| title | date | layout | content |
|
||||
| entry1 | 2013-04-09 23:22 -0400 | post | content for entry1. |
|
||||
| entry2 | 2013-04-10 03:14 -0400 | post | content for entry2. |
|
||||
| entry1 | 2013-04-09 23:22 +0400 | post | content for entry1. |
|
||||
| entry2 | 2013-04-10 03:14 +0400 | post | content for entry2. |
|
||||
When I run jekyll build
|
||||
Then the _site directory should exist
|
||||
And I should see "Page Layout: 2" in "_site/index.html"
|
||||
And the "_site/2013/04/10/entry1.html" file should exist
|
||||
And the "_site/2013/04/10/entry2.html" file should exist
|
||||
And I should see escaped "Post Layout: <p>content for entry1.</p> built at 2013-04-10T13:22:00+10:00" in "_site/2013/04/10/entry1.html"
|
||||
And I should see escaped "Post Layout: <p>content for entry2.</p> built at 2013-04-10T17:14:00+10:00" in "_site/2013/04/10/entry2.html"
|
||||
And the "_site/2013/04/09/entry1.html" file should exist
|
||||
And the "_site/2013/04/09/entry2.html" file should exist
|
||||
And I should see "Post Layout: <p>content for entry1.</p>\n built at 2013-04-09T09:22:00-10:00" in "_site/2013/04/09/entry1.html"
|
||||
And I should see "Post Layout: <p>content for entry2.</p>\n built at 2013-04-09T13:14:00-10:00" in "_site/2013/04/09/entry2.html"
|
||||
|
||||
Scenario: Limit the number of posts generated by most recent date
|
||||
Given I have a _posts directory
|
||||
|
|
|
@ -8,7 +8,7 @@ def file_content_from_hash(input_hash)
|
|||
input_hash['content']
|
||||
end
|
||||
|
||||
<<EOF
|
||||
<<-EOF
|
||||
---
|
||||
#{matter}
|
||||
---
|
||||
|
@ -40,7 +40,7 @@ end
|
|||
# Like "I have a foo file" but gives a yaml front matter so jekyll actually processes it
|
||||
Given /^I have an? "(.*)" page(?: with (.*) "(.*)")? that contains "(.*)"$/ do |file, key, value, text|
|
||||
File.open(file, 'w') do |f|
|
||||
f.write <<EOF
|
||||
f.write <<-EOF
|
||||
---
|
||||
#{key || 'layout'}: #{value || 'nil'}
|
||||
---
|
||||
|
@ -84,7 +84,7 @@ end
|
|||
Given /^I have the following (draft|page|post)s?(?: (in|under) "([^"]+)")?:$/ do |status, direction, folder, table|
|
||||
table.hashes.each do |input_hash|
|
||||
title = slug(input_hash['title'])
|
||||
ext = input_hash['type'] || 'textile'
|
||||
ext = input_hash['type'] || 'markdown'
|
||||
before, after = location(folder, direction)
|
||||
|
||||
case status
|
||||
|
|
|
@ -21,7 +21,6 @@ module Jekyll
|
|||
'keep_files' => ['.git','.svn'],
|
||||
'encoding' => 'utf-8',
|
||||
'markdown_ext' => 'markdown,mkdown,mkdn,mkd,md',
|
||||
'textile_ext' => 'textile',
|
||||
'full_rebuild' => false,
|
||||
|
||||
# Filtering Content
|
||||
|
@ -90,10 +89,6 @@ module Jekyll
|
|||
'coderay_bold_every' => 10,
|
||||
'coderay_css' => 'style'
|
||||
}
|
||||
},
|
||||
|
||||
'redcloth' => {
|
||||
'hard_breaks' => true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
module Jekyll
|
||||
module Converters
|
||||
class Textile < Converter
|
||||
safe true
|
||||
|
||||
highlighter_prefix '<notextile>'
|
||||
highlighter_suffix '</notextile>'
|
||||
|
||||
def setup
|
||||
return if @setup
|
||||
require 'redcloth'
|
||||
@setup = true
|
||||
rescue LoadError
|
||||
STDERR.puts 'You are missing a library required for Textile. Please run:'
|
||||
STDERR.puts ' $ [sudo] gem install RedCloth'
|
||||
raise Errors::FatalException.new("Missing dependency: RedCloth")
|
||||
end
|
||||
|
||||
def extname_matches_regexp
|
||||
@extname_matches_regexp ||= Regexp.new(
|
||||
'(' + @config['textile_ext'].gsub(',','|') +')$',
|
||||
Regexp::IGNORECASE
|
||||
)
|
||||
end
|
||||
|
||||
def matches(ext)
|
||||
ext =~ extname_matches_regexp
|
||||
end
|
||||
|
||||
def output_ext(ext)
|
||||
".html"
|
||||
end
|
||||
|
||||
def convert(content)
|
||||
setup
|
||||
|
||||
# Shortcut if config doesn't contain RedCloth section
|
||||
return RedCloth.new(content).to_html if @config['redcloth'].nil?
|
||||
|
||||
# List of attributes defined on RedCloth
|
||||
# (from https://github.com/jgarber/redcloth/blob/master/lib/redcloth/textile_doc.rb)
|
||||
attrs = ['filter_classes', 'filter_html', 'filter_ids', 'filter_styles',
|
||||
'hard_breaks', 'lite_mode', 'no_span_caps', 'sanitize_html']
|
||||
|
||||
r = RedCloth.new(content)
|
||||
|
||||
# Set attributes in r if they are NOT nil in the config
|
||||
attrs.each do |attr|
|
||||
r.instance_variable_set("@#{attr}".to_sym, @config['redcloth'][attr]) unless @config['redcloth'][attr].nil?
|
||||
end
|
||||
|
||||
r.to_html
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -4,17 +4,6 @@ require 'date'
|
|||
|
||||
module Jekyll
|
||||
module Filters
|
||||
# Convert a Textile string into HTML output.
|
||||
#
|
||||
# input - The Textile String to convert.
|
||||
#
|
||||
# Returns the HTML formatted String.
|
||||
def textilize(input)
|
||||
site = @context.registers[:site]
|
||||
converter = site.find_converter_instance(Jekyll::Converters::Textile)
|
||||
converter.convert(input)
|
||||
end
|
||||
|
||||
# Convert a Markdown string into HTML output.
|
||||
#
|
||||
# input - The Markdown String to convert.
|
||||
|
|
|
@ -303,7 +303,7 @@ module Jekyll
|
|||
[posts, pages].flatten.each do |page_or_post|
|
||||
page_or_post.render(layouts, payload) if page_or_post.regenerate?
|
||||
end
|
||||
rescue Errno::ENOENT => e
|
||||
rescue Errno::ENOENT
|
||||
# ignore missing layout dir
|
||||
end
|
||||
|
||||
|
|
|
@ -477,7 +477,6 @@ exclude: []
|
|||
keep_files: [".git", ".svn"]
|
||||
encoding: "utf-8"
|
||||
markdown_ext: "markdown,mkdown,mkdn,mkd,md"
|
||||
textile_ext: "textile"
|
||||
|
||||
# Filtering Content
|
||||
show_drafts: null
|
||||
|
@ -542,9 +541,6 @@ kramdown:
|
|||
coderay_tab_width: 4
|
||||
coderay_bold_every: 10
|
||||
coderay_css: style
|
||||
|
||||
redcloth:
|
||||
hard_breaks: true
|
||||
{% endhighlight %}
|
||||
|
||||
## Markdown Options
|
||||
|
|
|
@ -14,10 +14,9 @@ development of Jekyll itself.
|
|||
|
||||
Jekyll is a simple, blog-aware, static site generator. It takes a template
|
||||
directory containing raw text files in various formats, runs it through
|
||||
[Markdown](http://daringfireball.net/projects/markdown/) (or
|
||||
[Textile](http://redcloth.org/textile)) and
|
||||
[Liquid](https://github.com/Shopify/liquid/wiki)
|
||||
converters, and spits out a complete, ready-to-publish static website suitable
|
||||
a converter (like [Markdown](http://daringfireball.net/projects/markdown/))
|
||||
and our [Liquid](https://github.com/Shopify/liquid/wiki) renderer, and
|
||||
spits out a complete, ready-to-publish static website suitable
|
||||
for serving with your favorite web server. Jekyll also happens to be the engine
|
||||
behind [GitHub Pages](http://pages.github.com), which means you can use Jekyll
|
||||
to host your project’s page, blog, or website from GitHub’s servers **for
|
||||
|
|
|
@ -149,7 +149,7 @@ enough to fix it all!
|
|||
|
||||
## Permalink style examples
|
||||
|
||||
Given a post named: `/2009-04-29-slap-chop.textile`
|
||||
Given a post named: `/2009-04-29-slap-chop.md`
|
||||
|
||||
<div class="mobile-side-scroller">
|
||||
<table>
|
||||
|
|
|
@ -164,8 +164,9 @@ Generators are only required to implement one method:
|
|||
## Converters
|
||||
|
||||
If you have a new markup language you’d like to use with your site, you can
|
||||
include it by implementing your own converter. Both the Markdown and Textile
|
||||
markup languages are implemented using this method.
|
||||
include it by implementing your own converter. Both the Markdown and
|
||||
[Textile](https://github.com/jekyll/jekyll-textile-converter) markup
|
||||
languages are implemented using this method.
|
||||
|
||||
<div class="note info">
|
||||
<h5>Remember your YAML Front Matter</h5>
|
||||
|
@ -495,6 +496,7 @@ You can find a few useful plugins at the following locations:
|
|||
|
||||
#### Converters
|
||||
|
||||
- [Textile converter](https://github.com/jekyll/jekyll-textile-converter): Convert `.textile` files into HTML. Also includes the `textilize` Liquid filter.
|
||||
- [Slim plugin](https://github.com/slim-template/jekyll-slim): Slim converter and includes for Jekyll with support for Liquid tags.
|
||||
- [Jade plugin by John Papandriopoulos](https://github.com/snappylabs/jade-jekyll-plugin): Jade converter for Jekyll.
|
||||
- [HAML plugin by Sam Z](https://gist.github.com/517556): HAML converter for Jekyll.
|
||||
|
|
|
@ -14,11 +14,12 @@ and web-based CMS systems, this will be a welcome change!
|
|||
## The Posts Folder
|
||||
|
||||
As explained on the [directory structure](../structure/) page, the `_posts`
|
||||
folder is where your blog posts will live. These files can be either
|
||||
[Markdown](http://daringfireball.net/projects/markdown/) or
|
||||
[Textile](http://redcloth.org/textile) formatted text files, and as long as
|
||||
they have [YAML Front Matter](../frontmatter/), they will be converted from their
|
||||
source format into an HTML page that is part of your static site.
|
||||
folder is where your blog posts will live. These files are generally
|
||||
[Markdown](http://daringfireball.net/projects/markdown/) or HTML, but can
|
||||
be other formats with the proper converter installed.
|
||||
All posts must have [YAML Front Matter](../frontmatter/), and they will be
|
||||
converted from their source format into an HTML page that is part of your
|
||||
static site.
|
||||
|
||||
### Creating Post Files
|
||||
|
||||
|
@ -52,12 +53,12 @@ file. For example, the following are examples of valid post filenames:
|
|||
|
||||
All blog post files must begin with [YAML Front Matter](../frontmatter/). After
|
||||
that, it's simply a matter of deciding which format you prefer. Jekyll supports
|
||||
two popular content markup formats:
|
||||
[Markdown](http://daringfireball.net/projects/markdown/) and
|
||||
[Textile](http://redcloth.org/textile). These formats each have their own way
|
||||
of marking up different types of content within a post, so you should
|
||||
familiarize yourself with these formats and decide which one best suits your
|
||||
needs.
|
||||
[Markdown](http://daringfireball.net/projects/markdown/) out of the box,
|
||||
and has [myriad extensions for other formats as well](/docs/plugins/#converters-1),
|
||||
including the popular [Textile](http://redcloth.org/textile) format. These
|
||||
formats each have their own way of marking up different types of content
|
||||
within a post, so you should familiarize yourself with these formats and
|
||||
decide which one best suits your needs.
|
||||
|
||||
<div class="note info">
|
||||
<h5>Be aware of character sets</h5>
|
||||
|
|
|
@ -175,17 +175,6 @@ common tasks easier.
|
|||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p class="name"><strong>Textilize</strong></p>
|
||||
<p>Convert a Textile-formatted string into HTML, formatted via RedCloth</p>
|
||||
</td>
|
||||
<td class="align-center">
|
||||
<p>
|
||||
<code class="filter">{% raw %}{{ page.excerpt | textilize }}{% endraw %}</code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p class="name"><strong>Markdownify</strong></p>
|
||||
|
|
|
@ -8,11 +8,9 @@ end
|
|||
require 'rubygems'
|
||||
require 'test/unit'
|
||||
require 'ostruct'
|
||||
gem 'RedCloth', '>= 4.2.1'
|
||||
|
||||
require 'jekyll'
|
||||
|
||||
require 'RedCloth'
|
||||
require 'rdiscount'
|
||||
require 'kramdown'
|
||||
require 'redcarpet'
|
||||
|
@ -28,6 +26,10 @@ STDERR.reopen(test(?e, '/dev/null') ? '/dev/null' : 'NUL:')
|
|||
class Test::Unit::TestCase
|
||||
include RR::Adapters::TestUnit
|
||||
|
||||
def fixture_site(overrides = {})
|
||||
Jekyll::Site.new(site_configuration(overrides))
|
||||
end
|
||||
|
||||
def build_configs(overrides, base_hash = Jekyll::Configuration::DEFAULTS)
|
||||
Utils.deep_merge_hashes(base_hash, overrides)
|
||||
end
|
||||
|
|
|
@ -3,6 +3,6 @@ layout: default
|
|||
title: Foo Bar
|
||||
---
|
||||
|
||||
h1. {{ page.title }}
|
||||
# {{ page.title }}
|
||||
|
||||
Best *post* ever
|
||||
Best **post** ever
|
|
@ -9,11 +9,7 @@ class TestCleaner < Test::Unit::TestCase
|
|||
FileUtils.touch(File.join(dest_dir('to_keep'), 'index.html'))
|
||||
FileUtils.touch(File.join(dest_dir('to_keep/child_dir'), 'index.html'))
|
||||
|
||||
@site = Site.new(Jekyll.configuration({
|
||||
"skip_config_files" => true,
|
||||
"source" => source_dir,
|
||||
"destination" => dest_dir
|
||||
}))
|
||||
@site = fixture_site
|
||||
@site.keep_files = ['to_keep/child_dir']
|
||||
|
||||
@cleaner = Site::Cleaner.new(@site)
|
||||
|
@ -48,11 +44,7 @@ class TestCleaner < Test::Unit::TestCase
|
|||
FileUtils.mkdir_p(source_dir('no_files_inside/child_dir'))
|
||||
FileUtils.touch(File.join(source_dir('no_files_inside/child_dir'), 'index.html'))
|
||||
|
||||
@site = Site.new(Jekyll.configuration({
|
||||
"skip_config_files" => true,
|
||||
"source" => source_dir,
|
||||
"destination" => dest_dir
|
||||
}))
|
||||
@site = fixture_site
|
||||
@site.process
|
||||
|
||||
@cleaner = Site::Cleaner.new(@site)
|
||||
|
|
|
@ -3,10 +3,7 @@ require 'helper'
|
|||
class TestCoffeeScript < Test::Unit::TestCase
|
||||
context "converting CoffeeScript" do
|
||||
setup do
|
||||
@site = Jekyll::Site.new(Jekyll.configuration({
|
||||
"source" => source_dir,
|
||||
"destination" => dest_dir
|
||||
}))
|
||||
@site = fixture_site
|
||||
@site.process
|
||||
@test_coffeescript_file = dest_dir("js/coffeescript.js")
|
||||
@js_output = <<-JS
|
||||
|
|
|
@ -1,16 +1,6 @@
|
|||
require 'helper'
|
||||
|
||||
class TestCollections < Test::Unit::TestCase
|
||||
|
||||
def fixture_site(overrides = {})
|
||||
Jekyll::Site.new(Jekyll.configuration(
|
||||
overrides.merge({
|
||||
"source" => source_dir,
|
||||
"destination" => dest_dir
|
||||
})
|
||||
))
|
||||
end
|
||||
|
||||
context "an evil collection" do
|
||||
setup do
|
||||
@collection = Jekyll::Collection.new(fixture_site, "../../etc/password")
|
||||
|
|
|
@ -27,10 +27,6 @@ class TestFilters < Test::Unit::TestCase
|
|||
]
|
||||
end
|
||||
|
||||
should "textilize with simple string" do
|
||||
assert_equal "<p>something <strong>really</strong> simple</p>", @filter.textilize("something *really* simple")
|
||||
end
|
||||
|
||||
should "markdownify with simple string" do
|
||||
assert_equal "<p>something <strong>really</strong> simple</p>\n", @filter.markdownify("something **really** simple")
|
||||
end
|
||||
|
|
|
@ -15,18 +15,17 @@ class TestPost < Test::Unit::TestCase
|
|||
context "A Post" do
|
||||
setup do
|
||||
clear_dest
|
||||
@site = Site.new(Jekyll.configuration({
|
||||
"skip_config_files" => true,
|
||||
"source" => source_dir,
|
||||
"destination" => dest_dir
|
||||
}))
|
||||
@site = fixture_site
|
||||
end
|
||||
|
||||
should "ensure valid posts are valid" do
|
||||
assert Post.valid?("2008-09-09-foo-bar.textile")
|
||||
assert Post.valid?("foo/bar/2008-09-09-foo-bar.textile")
|
||||
assert Post.valid?("2008-09-09-foo-bar.markdown")
|
||||
assert Post.valid?("foo/bar/2008-09-09-foo-bar.markdown")
|
||||
|
||||
assert !Post.valid?("lol2008-09-09-foo-bar.textile")
|
||||
assert !Post.valid?("lol2008-09-09-foo-bar.markdown")
|
||||
assert !Post.valid?("blah")
|
||||
end
|
||||
|
||||
|
@ -63,8 +62,8 @@ class TestPost < Test::Unit::TestCase
|
|||
@post = Post.allocate
|
||||
@post.site = @site
|
||||
|
||||
@real_file = "2008-10-18-foo-bar.textile"
|
||||
@fake_file = "2008-09-09-foo-bar.textile"
|
||||
@real_file = "2008-10-18-foo-bar.markdown"
|
||||
@fake_file = "2008-09-09-foo-bar.markdown"
|
||||
@source = source_dir('_posts')
|
||||
end
|
||||
|
||||
|
@ -74,7 +73,7 @@ class TestPost < Test::Unit::TestCase
|
|||
|
||||
assert_equal Time.parse("2008-09-09"), @post.date
|
||||
assert_equal "foo-bar", @post.slug
|
||||
assert_equal ".textile", @post.ext
|
||||
assert_equal ".markdown", @post.ext
|
||||
assert_equal "/2008/09/09", @post.dir
|
||||
assert_equal "/2008/09/09/foo-bar", @post.id
|
||||
end
|
||||
|
@ -367,13 +366,13 @@ class TestPost < Test::Unit::TestCase
|
|||
@post.read_yaml(@source, @real_file)
|
||||
|
||||
assert_equal({"title" => "Foo Bar", "layout" => "default"}, @post.data)
|
||||
assert_equal "h1. {{ page.title }}\n\nBest *post* ever", @post.content
|
||||
assert_equal "# {{ page.title }}\n\nBest **post** ever", @post.content
|
||||
end
|
||||
|
||||
should "transform textile" do
|
||||
@post.process(@real_file)
|
||||
@post.read_yaml(@source, @real_file)
|
||||
assert_equal "<h1>{{ page.title }}</h1>\n<p>Best <strong>post</strong> ever</p>", @post.transform
|
||||
assert_equal "<h1 id=\"pagetitle-\">{{ page.title }}</h1>\n\n<p>Best <strong>post</strong> ever</p>", @post.transform.strip
|
||||
end
|
||||
|
||||
context "#excerpt" do
|
||||
|
@ -461,8 +460,7 @@ class TestPost < Test::Unit::TestCase
|
|||
context "when in a site" do
|
||||
setup do
|
||||
clear_dest
|
||||
stub(Jekyll).configuration { Jekyll::Configuration::DEFAULTS }
|
||||
@site = Site.new(Jekyll.configuration)
|
||||
@site = fixture_site
|
||||
@site.posts = [setup_post('2008-02-02-published.textile'),
|
||||
setup_post('2009-01-27-categories.textile')]
|
||||
end
|
||||
|
@ -486,30 +484,30 @@ class TestPost < Test::Unit::TestCase
|
|||
|
||||
context "initializing posts" do
|
||||
should "recognize date in yaml" do
|
||||
post = setup_post("2010-01-09-date-override.textile")
|
||||
post = setup_post("2010-01-09-date-override.markdown")
|
||||
do_render(post)
|
||||
assert_equal Time, post.date.class
|
||||
assert_equal Time, post.to_liquid["date"].class
|
||||
assert_equal "/2010/01/10/date-override.html", post.url
|
||||
assert_equal "<p>Post with a front matter date</p>\n<p>10 Jan 2010</p>", post.output
|
||||
assert_equal "<p>Post with a front matter date</p>\n\n<p>10 Jan 2010</p>", post.output.strip
|
||||
end
|
||||
|
||||
should "recognize time in yaml" do
|
||||
post = setup_post("2010-01-09-time-override.textile")
|
||||
post = setup_post("2010-01-09-time-override.markdown")
|
||||
do_render(post)
|
||||
assert_equal Time, post.date.class
|
||||
assert_equal Time, post.to_liquid["date"].class
|
||||
assert_equal "/2010/01/10/time-override.html", post.url
|
||||
assert_equal "<p>Post with a front matter time</p>\n<p>10 Jan 2010</p>", post.output
|
||||
assert_equal "<p>Post with a front matter time</p>\n\n<p>10 Jan 2010</p>", post.output.strip
|
||||
end
|
||||
|
||||
should "recognize time with timezone in yaml" do
|
||||
post = setup_post("2010-01-09-timezone-override.textile")
|
||||
post = setup_post("2010-01-09-timezone-override.markdown")
|
||||
do_render(post)
|
||||
assert_equal Time, post.date.class
|
||||
assert_equal Time, post.to_liquid["date"].class
|
||||
assert_equal "/2010/01/10/timezone-override.html", post.url
|
||||
assert_equal "<p>Post with a front matter time with timezone</p>\n<p>10 Jan 2010</p>", post.output
|
||||
assert_equal "<p>Post with a front matter time with timezone</p>\n\n<p>10 Jan 2010</p>", post.output.strip
|
||||
end
|
||||
|
||||
should "to_liquid prioritizes post attributes over data" do
|
||||
|
@ -603,13 +601,13 @@ class TestPost < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
should "render properly" do
|
||||
post = setup_post("2008-10-18-foo-bar.textile")
|
||||
post = setup_post("2008-10-18-foo-bar.markdown")
|
||||
do_render(post)
|
||||
assert_equal "<<< <h1>Foo Bar</h1>\n<p>Best <strong>post</strong> ever</p> >>>", post.output
|
||||
assert_equal "<<< <h1 id=\"foo-bar\">Foo Bar</h1>\n\n<p>Best <strong>post</strong> ever</p>\n >>>", post.output
|
||||
end
|
||||
|
||||
should "write properly" do
|
||||
post = setup_post("2008-10-18-foo-bar.textile")
|
||||
post = setup_post("2008-10-18-foo-bar.markdown")
|
||||
do_render(post)
|
||||
post.write(dest_dir)
|
||||
|
||||
|
@ -652,7 +650,7 @@ class TestPost < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
should "write properly without html extension" do
|
||||
post = setup_post("2008-10-18-foo-bar.textile")
|
||||
post = setup_post("2008-10-18-foo-bar.markdown")
|
||||
post.site.permalink_style = ":title/"
|
||||
do_render(post)
|
||||
post.write(dest_dir)
|
||||
|
@ -662,32 +660,31 @@ class TestPost < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
should "insert data" do
|
||||
post = setup_post("2008-11-21-complex.textile")
|
||||
post = setup_post("2008-11-21-complex.markdown")
|
||||
do_render(post)
|
||||
|
||||
assert_equal "<<< <p>url: /2008/11/21/complex.html<br />\ndate: #{Time.parse("2008-11-21")}<br />\nid: /2008/11/21/complex</p> >>>", post.output
|
||||
assert_equal "<<< <p>url: /2008/11/21/complex.html\ndate: #{Time.parse("2008-11-21")}\nid: /2008/11/21/complex</p>\n >>>", post.output
|
||||
end
|
||||
|
||||
should "include templates" do
|
||||
post = setup_post("2008-12-13-include.markdown")
|
||||
post.site.instance_variable_set(:@source, File.join(File.dirname(__FILE__), 'source'))
|
||||
do_render(post)
|
||||
|
||||
assert_equal "<<< <hr />\n<p>Tom Preston-Werner\ngithub.com/mojombo</p>\n\n<p>This <em>is</em> cool</p>\n >>>", post.output
|
||||
end
|
||||
|
||||
should "render date specified in front matter properly" do
|
||||
post = setup_post("2010-01-09-date-override.textile")
|
||||
post = setup_post("2010-01-09-date-override.markdown")
|
||||
do_render(post)
|
||||
|
||||
assert_equal "<p>Post with a front matter date</p>\n<p>10 Jan 2010</p>", post.output
|
||||
assert_equal "<p>Post with a front matter date</p>\n\n<p>10 Jan 2010</p>", post.output.strip
|
||||
end
|
||||
|
||||
should "render time specified in front matter properly" do
|
||||
post = setup_post("2010-01-09-time-override.textile")
|
||||
post = setup_post("2010-01-09-time-override.markdown")
|
||||
do_render(post)
|
||||
|
||||
assert_equal "<p>Post with a front matter time</p>\n<p>10 Jan 2010</p>", post.output
|
||||
assert_equal "<p>Post with a front matter time</p>\n\n<p>10 Jan 2010</p>", post.output.strip
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -701,8 +698,7 @@ class TestPost < Test::Unit::TestCase
|
|||
|
||||
context "converter file extension settings" do
|
||||
setup do
|
||||
stub(Jekyll).configuration { Jekyll::Configuration::DEFAULTS }
|
||||
@site = Site.new(Jekyll.configuration)
|
||||
@site = fixture_site
|
||||
end
|
||||
|
||||
should "process .md as markdown under default configuration" do
|
||||
|
@ -746,28 +742,17 @@ class TestPost < Test::Unit::TestCase
|
|||
assert conv.kind_of?(Jekyll::Converters::Identity), "The converter for .Rmd should be the Identity converter."
|
||||
end
|
||||
|
||||
should "process .text as textile under alternate configuration" do
|
||||
@site.config['textile_ext'] = 'textile,text'
|
||||
post = setup_post '2011-04-12-text-extension.text'
|
||||
conv = post.converters.first
|
||||
assert conv.kind_of? Jekyll::Converters::Textile
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "site config with category" do
|
||||
setup do
|
||||
config = site_configuration({
|
||||
'defaults' => [
|
||||
'scope' => {
|
||||
'path' => ''
|
||||
},
|
||||
'values' => {
|
||||
'category' => 'article'
|
||||
front_matter_defaults = {
|
||||
'defaults' => [{
|
||||
'scope' => { 'path' => '' },
|
||||
'values' => { 'category' => 'article' }
|
||||
}]
|
||||
}
|
||||
]
|
||||
})
|
||||
@site = Site.new(config)
|
||||
@site = fixture_site(front_matter_defaults)
|
||||
end
|
||||
|
||||
should "return category if post does not specify category" do
|
||||
|
@ -784,17 +769,13 @@ class TestPost < Test::Unit::TestCase
|
|||
|
||||
context "site config with categories" do
|
||||
setup do
|
||||
config = site_configuration({
|
||||
'defaults' => [
|
||||
'scope' => {
|
||||
'path' => ''
|
||||
},
|
||||
'values' => {
|
||||
'categories' => ['article']
|
||||
front_matter_defaults = {
|
||||
'defaults' => [{
|
||||
'scope' => { 'path' => '' },
|
||||
'values' => { 'categories' => ['article'] }
|
||||
}]
|
||||
}
|
||||
]
|
||||
})
|
||||
@site = Site.new(config)
|
||||
@site = fixture_site(front_matter_defaults)
|
||||
end
|
||||
|
||||
should "return categories if post does not specify categories" do
|
||||
|
|
|
@ -1,86 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/helper'
|
||||
|
||||
class TestRedCloth < Test::Unit::TestCase
|
||||
|
||||
context "RedCloth default (no explicit config) hard_breaks enabled" do
|
||||
setup do
|
||||
@textile = Converters::Textile.new
|
||||
end
|
||||
|
||||
should "preserve single line breaks in HTML output" do
|
||||
assert_equal "<p>line1<br />\nline2</p>", @textile.convert("p. line1\nline2").strip
|
||||
end
|
||||
end
|
||||
|
||||
context "Default hard_breaks enabled w/ redcloth section, no hard_breaks value" do
|
||||
setup do
|
||||
config = {
|
||||
'redcloth' => {}
|
||||
}
|
||||
@textile = Converters::Textile.new config
|
||||
end
|
||||
|
||||
should "preserve single line breaks in HTML output" do
|
||||
assert_equal "<p>line1<br />\nline2</p>", @textile.convert("p. line1\nline2").strip
|
||||
end
|
||||
end
|
||||
|
||||
context "RedCloth with hard_breaks enabled" do
|
||||
setup do
|
||||
config = {
|
||||
'redcloth' => {
|
||||
'hard_breaks' => true # default
|
||||
}
|
||||
}
|
||||
@textile = Converters::Textile.new config
|
||||
end
|
||||
|
||||
should "preserve single line breaks in HTML output" do
|
||||
assert_equal "<p>line1<br />\nline2</p>", @textile.convert("p. line1\nline2").strip
|
||||
end
|
||||
end
|
||||
|
||||
context "RedCloth with hard_breaks disabled" do
|
||||
setup do
|
||||
config = {
|
||||
'redcloth' => {
|
||||
'hard_breaks' => false
|
||||
}
|
||||
}
|
||||
@textile = Converters::Textile.new config
|
||||
end
|
||||
|
||||
should "not generate break tags in HTML output" do
|
||||
assert_equal "<p>line1\nline2</p>", @textile.convert("p. line1\nline2").strip
|
||||
end
|
||||
end
|
||||
|
||||
context "RedCloth w/no_span_caps set to false" do
|
||||
setup do
|
||||
config = {
|
||||
'redcloth' => {
|
||||
'no_span_caps' => false
|
||||
}
|
||||
}
|
||||
@textile = Converters::Textile.new config
|
||||
end
|
||||
should "generate span tags around capitalized words" do
|
||||
assert_equal "<p><span class=\"caps\">NSC</span></p>", @textile.convert("NSC").strip
|
||||
end
|
||||
end
|
||||
|
||||
context "RedCloth w/no_span_caps set to true" do
|
||||
setup do
|
||||
config = {
|
||||
'redcloth' => {
|
||||
'no_span_caps' => true
|
||||
}
|
||||
}
|
||||
@textile = Converters::Textile.new config
|
||||
end
|
||||
|
||||
should "not generate span tags around capitalized words" do
|
||||
assert_equal "<p>NSC</p>", @textile.convert("NSC").strip
|
||||
end
|
||||
end
|
||||
end
|
|
@ -231,17 +231,6 @@ puts "3..2..1.."
|
|||
CONTENT
|
||||
end
|
||||
|
||||
context "using Textile" do
|
||||
setup do
|
||||
create_post(@content, {}, Jekyll::Converters::Textile)
|
||||
end
|
||||
|
||||
# Broken in RedCloth 4.1.9
|
||||
should "not textilize highlight block" do
|
||||
assert_no_match %r{3\.\.2\.\.1\.\."</span><br />}, @result
|
||||
end
|
||||
end
|
||||
|
||||
context "using Maruku" do
|
||||
setup do
|
||||
create_post(@content)
|
||||
|
|
Loading…
Reference in New Issue