1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
#!/usr/bin/env ruby
# encoding: utf-8
BEGIN {
require 'pathname'
basedir = Pathname.new( __FILE__ ).dirname.parent.parent
libdir = basedir + 'lib'
# $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
# $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
}
require 'rspec'
require 'bluecloth'
require 'spec/lib/helpers'
#####################################################################
### C O N T E X T S
#####################################################################
describe BlueCloth, "that contains code blocks or spans" do
it "wraps CODE tags around backticked spans" do
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
Making `code` work for you
---
<p>Making <code>code</code> work for you</p>
---
end
it "allows you to place literal backtick characters at the beginning or end of a code span " +
"by padding the inner string with spaces" do
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
Making `` `code` `` work for you
---
<p>Making <code>`code`</code> work for you</p>
---
end
it "wraps CODE tags around doubled backtick spans with a single literal backtick inside them" do
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
``There is a literal backtick (`) here.``
---
<p><code>There is a literal backtick (`) here.</code></p>
---
end
it "correctly transforms two literal spans in one line" do
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
This `thing` should be `two` spans.
---
<p>This <code>thing</code> should be <code>two</code> spans.</p>
---
end
it "correctly transforms literal spans at the beginning of a line" do
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
I should think that the
`tar` command would be universal.
---
<p>I should think that the
<code>tar</code> command would be universal.</p>
---
end
it "encodes ampersands and angle brackets within code spans as HTML entities" do
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
The left angle-bracket (`<`) can also be written as a decimal-encoded
(`<`) or hex-encoded (`<`) entity. This
also works with `<div>` elements.
---
<p>The left angle-bracket (<code>&lt;</code>) can also be written as a decimal-encoded
(<code>&#060;</code>) or hex-encoded (<code>&#x3c;</code>) entity. This
also works with <code><div></code> elements.</p>
---
end
# At the beginning of a document (Bug #525)
it "correctly transforms code spans at the beginning of paragraphs (bug #525)" do
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
`world` views
---
<p><code>world</code> views</p>
---
end
### [Code blocks]
# Para plus code block (literal tab, no colon)
it "wraps sections indented with a literal tab in a code block" do
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
This is a chunk of code
some.code > some.other_code
Some stuff.
---
<p>This is a chunk of code</p>
<pre><code>some.code > some.other_code
</code></pre>
<p>Some stuff.</p>
---
end
# Para plus code block (tab-width spaces)
it "wraps sections indented with at least 4 spaces in a code block" do
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
This is a chunk of code:
some.code > some.other_code
Some stuff.
---
<p>This is a chunk of code:</p>
<pre><code>some.code > some.other_code
</code></pre>
<p>Some stuff.</p>
---
end
# Preserve leading whitespace (Bug #541)
it "removes one level of indentation (and no more) from code blocks" do
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
Examples:
# (Waste character because first line is flush left !!!)
# Example script1
x = 1
x += 1
puts x
Some stuff.
---
<p>Examples:</p>
<pre><code> # (Waste character because first line is flush left !!!)
# Example script1
x = 1
x += 1
puts x
</code></pre>
<p>Some stuff.</p>
---
end
end
|