caramelize 0.4.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +76 -0
- data/README.md +3 -1
- data/Rakefile +2 -2
- data/bin/caramelize +12 -5
- data/caramelize.gemspec +2 -3
- data/lib/caramelize.rb +2 -1
- data/lib/caramelize/content_transferer.rb +31 -17
- data/lib/caramelize/filter_processor.rb +1 -2
- data/lib/caramelize/filters/remove_table_tab_line_endings.rb +6 -2
- data/lib/caramelize/filters/swap_wiki_links.rb +6 -2
- data/lib/caramelize/filters/wikka_to_markdown.rb +53 -25
- data/lib/caramelize/input_wiki/redmine_wiki.rb +55 -47
- data/lib/caramelize/input_wiki/wikkawiki.rb +15 -11
- data/lib/caramelize/output_wiki/gollum.rb +12 -7
- data/lib/caramelize/version.rb +1 -1
- data/spec/lib/caramelize/filter_processor_spec.rb +7 -5
- data/spec/lib/caramelize/filters/remove_table_tab_line_endings_spec.rb +30 -16
- data/spec/lib/caramelize/filters/swap_wiki_links_spec.rb +33 -17
- data/spec/lib/caramelize/filters/wikka_to_markdown_spec.rb +152 -54
- data/spec/lib/caramelize/output_wiki/gollum_spec.rb +3 -4
- metadata +8 -24
- data/lib/caramelize/ext.rb +0 -17
- data/lib/caramelize/filters/trac_to_markdown.rb +0 -42
- data/lib/caramelize/input_wiki/trac_converter.rb +0 -82
@@ -7,56 +7,20 @@ module Caramelize
|
|
7
7
|
class RedmineWiki < Wiki
|
8
8
|
include DatabaseConnector
|
9
9
|
|
10
|
-
def initialize
|
10
|
+
def initialize(options = {})
|
11
11
|
super(options)
|
12
12
|
@options[:markup] = :textile
|
13
|
-
@options[:filters] << Caramelize::SwapWikiLinks
|
14
|
-
@options[:filters] << Caramelize::RemoveTableTabLineEndings
|
13
|
+
@options[:filters] << Caramelize::SwapWikiLinks
|
14
|
+
@options[:filters] << Caramelize::RemoveTableTabLineEndings
|
15
15
|
@options[:create_namespace_overview] = true
|
16
16
|
end
|
17
17
|
|
18
18
|
# after calling this action, I expect the titles and revisions to be filled
|
19
19
|
def read_pages
|
20
|
-
|
21
|
-
results_projects = database.query("SELECT id, identifier, name FROM projects;")
|
22
|
-
results_projects.each do |row_project|
|
23
|
-
#collect all namespaces
|
24
|
-
namespaces << OpenStruct.new(identifier: row_project["identifier"], name: row_project["name"])
|
25
|
-
end
|
20
|
+
add_projects_as_namespaces
|
26
21
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
# get all lemmas
|
31
|
-
results_pages = database.query("SELECT id, title, wiki_id FROM wiki_pages;")
|
32
|
-
results_pages.each do |row_page|
|
33
|
-
results_contents = database.query("SELECT * FROM wiki_content_versions WHERE page_id='#{row_page["id"]}' ORDER BY updated_on;")
|
34
|
-
|
35
|
-
# get wiki for page
|
36
|
-
wiki_row = nil
|
37
|
-
project_row = nil
|
38
|
-
results_wikis.each do |wiki|
|
39
|
-
wiki_row = wiki if wiki["id"] == row_page["wiki_id"]
|
40
|
-
end
|
41
|
-
|
42
|
-
if wiki_row
|
43
|
-
# get project from wiki-id
|
44
|
-
results_projects.each do |project|
|
45
|
-
project_row = project if project["id"] == wiki_row["project_id"]
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
project_identifier = project_row ? project_row["identifier"] + '/' : ""
|
50
|
-
|
51
|
-
title = project_identifier + row_page["title"]
|
52
|
-
titles << title
|
53
|
-
|
54
|
-
@latest_revisions = {}
|
55
|
-
results_contents.each do |row_content|
|
56
|
-
page = Page.new(build_properties(title, row_content))
|
57
|
-
revisions << page
|
58
|
-
@latest_revisions[title] = page
|
59
|
-
end
|
22
|
+
pages.each do |row_page|
|
23
|
+
build_page(row_page)
|
60
24
|
end
|
61
25
|
titles.uniq!
|
62
26
|
@latest_revisions.each { |rev| rev[1].set_latest }
|
@@ -68,7 +32,7 @@ module Caramelize
|
|
68
32
|
end
|
69
33
|
|
70
34
|
def read_authors
|
71
|
-
results = database.query(
|
35
|
+
results = database.query('SELECT id, login, mail FROM users;')
|
72
36
|
results.each do |row|
|
73
37
|
authors[row["id"]] = OpenStruct.new(id: row["id"],
|
74
38
|
name: row["login"],
|
@@ -79,15 +43,59 @@ module Caramelize
|
|
79
43
|
|
80
44
|
private
|
81
45
|
|
46
|
+
def build_page(row_page)
|
47
|
+
results_contents = database.query("SELECT * FROM wiki_content_versions WHERE page_id='#{row_page["id"]}' ORDER BY updated_on;")
|
48
|
+
|
49
|
+
wiki = wikis.select{ |row| row['id'] == row_page['wiki_id'] }.first
|
50
|
+
|
51
|
+
project_identifier = ''
|
52
|
+
|
53
|
+
if wiki
|
54
|
+
project = projects.select{ |row| row['id'] == wiki['project_id'] }.first
|
55
|
+
project_identifier = project['identifier'] + '/'
|
56
|
+
end
|
57
|
+
|
58
|
+
title = project_identifier + row_page['title']
|
59
|
+
titles << title
|
60
|
+
|
61
|
+
@latest_revisions = {}
|
62
|
+
results_contents.each do |row_content|
|
63
|
+
page = Page.new(build_properties(title, row_content))
|
64
|
+
revisions << page
|
65
|
+
@latest_revisions[title] = page
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def add_projects_as_namespaces
|
70
|
+
projects.each do |row_project|
|
71
|
+
namespace = OpenStruct.new(identifier: row_project['identifier'],
|
72
|
+
name: row_project['name'])
|
73
|
+
namespaces << namespace
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def pages
|
78
|
+
@pages ||= database.query('SELECT id, title, wiki_id FROM wiki_pages;')
|
79
|
+
end
|
80
|
+
|
81
|
+
def projects
|
82
|
+
@projects ||= database.query('SELECT id, identifier, name FROM projects;')
|
83
|
+
end
|
84
|
+
|
85
|
+
def wikis
|
86
|
+
@wikis ||= database.query('SELECT id, project_id FROM wikis;')
|
87
|
+
end
|
88
|
+
|
82
89
|
def build_properties(title, row_content)
|
83
90
|
author = authors[row_content["author_id"]] ? authors[row_content["author_id"]] : nil
|
84
|
-
{
|
91
|
+
{
|
92
|
+
id: row_content['id'],
|
85
93
|
title: title,
|
86
|
-
body: row_content[
|
94
|
+
body: row_content['data'],
|
87
95
|
markup: :textile,
|
88
96
|
latest: false,
|
89
|
-
time: row_content[
|
90
|
-
message: row_content[
|
97
|
+
time: row_content['updated_on'],
|
98
|
+
message: row_content['comments'],
|
91
99
|
author: author,
|
92
100
|
author_name: author.name
|
93
101
|
}
|
@@ -7,18 +7,16 @@ module Caramelize
|
|
7
7
|
class WikkaWiki < Wiki
|
8
8
|
include DatabaseConnector
|
9
9
|
|
10
|
-
def initialize
|
10
|
+
def initialize(options = {})
|
11
11
|
super(options)
|
12
12
|
@options[:markup] = :wikka
|
13
|
-
@options[:filters] << Caramelize::Wikka2Markdown
|
13
|
+
@options[:filters] << Caramelize::Wikka2Markdown
|
14
14
|
end
|
15
15
|
|
16
16
|
# after calling this action, titles and @revisions are expected to be filled
|
17
17
|
def read_pages
|
18
|
-
|
19
|
-
|
20
|
-
results.each do |row|
|
21
|
-
titles << row["tag"]
|
18
|
+
pages.each do |row|
|
19
|
+
titles << row['tag']
|
22
20
|
page = Page.new(build_properties(row))
|
23
21
|
revisions << page
|
24
22
|
end
|
@@ -29,19 +27,25 @@ module Caramelize
|
|
29
27
|
end
|
30
28
|
|
31
29
|
def read_authors
|
32
|
-
sql =
|
30
|
+
sql = 'SELECT name, email FROM wikka_users;'
|
33
31
|
results = database.query(sql)
|
34
32
|
results.each do |row|
|
35
|
-
authors[row[
|
36
|
-
email: row[
|
33
|
+
authors[row['name']] = OpenStruct.new(name: row['name'],
|
34
|
+
email: row['email'] )
|
37
35
|
end
|
38
36
|
end
|
39
37
|
|
40
38
|
private
|
41
39
|
|
40
|
+
def pages
|
41
|
+
sql = 'SELECT id, tag, body, time, latest, user, note FROM wikka_pages ORDER BY time;'
|
42
|
+
@pages ||= database.query(sql)
|
43
|
+
end
|
44
|
+
|
42
45
|
def build_properties(row)
|
43
|
-
author = authors[row[
|
44
|
-
{
|
46
|
+
author = authors[row['user']]
|
47
|
+
{
|
48
|
+
id: row["id"],
|
45
49
|
title: row["tag"],
|
46
50
|
body: row["body"],
|
47
51
|
markup: :wikka,
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'caramelize/ext'
|
2
1
|
module Caramelize
|
3
2
|
module OutputWiki
|
4
3
|
class Gollum
|
@@ -27,6 +26,11 @@ module Caramelize
|
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
29
|
+
def rename_page(page_title, rename)
|
30
|
+
gollum_page = gollum.page(page_title)
|
31
|
+
gollum.rename_page(gollum_page, rename, { message: 'Rename home page' })
|
32
|
+
end
|
33
|
+
|
30
34
|
# Commit all revisions of the given history into this gollum-wiki-repository.
|
31
35
|
def commit_history(revisions, options = {}, &block)
|
32
36
|
revisions.each_with_index do |page, index|
|
@@ -47,10 +51,9 @@ module Caramelize
|
|
47
51
|
def build_commit(page)
|
48
52
|
{
|
49
53
|
message: page.commit_message,
|
50
|
-
name: page.
|
51
|
-
email: page.
|
52
|
-
|
53
|
-
committed_date: page.time
|
54
|
+
name: page.author.name,
|
55
|
+
email: page.author.email,
|
56
|
+
time: page.time
|
54
57
|
}
|
55
58
|
end
|
56
59
|
|
@@ -61,12 +64,14 @@ module Caramelize
|
|
61
64
|
end
|
62
65
|
|
63
66
|
def gollum
|
64
|
-
@gollum ||= ::Gollum::Wiki.new(wiki_path)
|
67
|
+
@gollum ||= ::Gollum::Wiki.new(wiki_path, {repo_is_bare: true})
|
65
68
|
end
|
66
69
|
|
67
70
|
def initialize_repository
|
68
71
|
return if File.exists?(wiki_path)
|
69
|
-
|
72
|
+
Dir.mkdir(wiki_path)
|
73
|
+
#::Gollum::Git::Repo.new(wiki_path, { is_bare: true })
|
74
|
+
::Gollum::Git::Repo.init(wiki_path)
|
70
75
|
end
|
71
76
|
end
|
72
77
|
end
|
data/lib/caramelize/version.rb
CHANGED
@@ -7,8 +7,12 @@ describe Caramelize::FilterProcessor do
|
|
7
7
|
subject(:processor) { described_class.new(input_wiki) }
|
8
8
|
|
9
9
|
class ReverseFilter
|
10
|
-
def
|
11
|
-
body
|
10
|
+
def initialize(body)
|
11
|
+
@body = body
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
@body.reverse
|
12
16
|
end
|
13
17
|
end
|
14
18
|
|
@@ -20,9 +24,7 @@ describe Caramelize::FilterProcessor do
|
|
20
24
|
end
|
21
25
|
|
22
26
|
context 'with reverse filter' do
|
23
|
-
let(:filters)
|
24
|
-
[ReverseFilter.new]
|
25
|
-
end
|
27
|
+
let(:filters) { [ReverseFilter] }
|
26
28
|
|
27
29
|
it 'returns reversed body' do
|
28
30
|
expect(processor.run(body)).to eql body.reverse
|
@@ -1,34 +1,48 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Caramelize::RemoveTableTabLineEndings do
|
4
|
+
let(:filter) { described_class.new(body) }
|
5
|
+
subject { filter.run}
|
4
6
|
|
5
|
-
describe
|
6
|
-
let(:filter) { Caramelize::RemoveTableTabLineEndings.new }
|
7
|
+
describe '#run' do
|
7
8
|
context 'table with tabs at unix line-endings' do
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
let(:body) { "cell1\t|cell2\t|\t\t\n" }
|
10
|
+
|
11
|
+
it 'removes tabs at end of line' do
|
12
|
+
is_expected.to eq "cell1\t|cell2\t|\n"
|
11
13
|
end
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'with spaces on line ending' do
|
17
|
+
let(:body) { "cell1\t|cell2\t|\t \n" }
|
18
|
+
|
19
|
+
it 'removes spaces at end of line' do
|
20
|
+
is_expected.to eq "cell1\t|cell2\t|\n"
|
15
21
|
end
|
22
|
+
|
16
23
|
context 'replace in full file' do
|
24
|
+
let(:body) { File.open(File.join(['spec', 'fixtures', 'markup', 'table-tab-line-endings-input.textile']), 'r').read }
|
25
|
+
|
17
26
|
it 'returns as expected' do
|
18
|
-
input_text = File.open(File.join(['spec', 'fixtures', 'markup', 'table-tab-line-endings-input.textile']), 'r').read
|
19
27
|
output_text = File.open(File.join(['spec', 'fixtures', 'markup', 'table-tab-line-endings-output.textile']), 'r').read
|
20
|
-
|
28
|
+
is_expected.to eq output_text
|
21
29
|
end
|
22
30
|
end
|
23
31
|
end
|
32
|
+
|
24
33
|
context 'table with tabs at windows line-endings' do
|
25
|
-
|
26
|
-
|
27
|
-
|
34
|
+
let(:body) { "cell1\t|cell2\t|\t\t\r\n" }
|
35
|
+
|
36
|
+
it 'removes tabs at end of line' do
|
37
|
+
is_expected.to eq "cell1\t|cell2\t|\n"
|
28
38
|
end
|
29
|
-
|
30
|
-
|
31
|
-
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'with spaces and windows line-endings' do
|
42
|
+
let(:body) { "cell1\t|cell2\t|\t \r\n" }
|
43
|
+
|
44
|
+
it 'removes spaces at end of line' do
|
45
|
+
is_expected.to eq "cell1\t|cell2\t|\n"
|
32
46
|
end
|
33
47
|
end
|
34
48
|
end
|
@@ -1,31 +1,47 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Caramelize::SwapWikiLinks do
|
4
|
+
describe '#run' do
|
5
|
+
let(:filter) { described_class.new(body) }
|
6
|
+
subject { filter.run }
|
4
7
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
it '
|
9
|
-
|
10
|
-
expect(filter.run(body)).to eq '[[Driver & Team Statistics|statistics]]'
|
8
|
+
context 'wiki link with title' do
|
9
|
+
let(:body) { '[[statistics|Driver & Team Statistics]]' }
|
10
|
+
|
11
|
+
it 'swaps title and target' do
|
12
|
+
is_expected.to eq '[[Driver & Team Statistics|statistics]]'
|
11
13
|
end
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'wiki title with spaces' do
|
17
|
+
let(:body) { '[[Release 1 0]]' }
|
18
|
+
|
19
|
+
it 'replaces space with dashes' do
|
20
|
+
is_expected.to eq '[[Release 1 0|Release_1_0]]'
|
15
21
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'wiki title with dashes' do
|
25
|
+
let(:body) { '[[Release 1.0]]' }
|
26
|
+
|
27
|
+
it 'removes dots' do
|
28
|
+
is_expected.to eq '[[Release 1.0|Release_10]]'
|
19
29
|
end
|
20
|
-
|
21
|
-
|
22
|
-
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'wiki link with spaces and without title' do
|
33
|
+
let(:body) { '[[Intra wiki link]]' }
|
34
|
+
|
35
|
+
it 'simples link to hyperlink' do
|
36
|
+
is_expected.to eq '[[Intra wiki link|Intra_wiki_link]]'
|
23
37
|
end
|
38
|
+
|
24
39
|
context 'replace in full file' do
|
40
|
+
let(:body) { File.open(File.join(['spec', 'fixtures', 'markup', 'swap-links-input.textile']), 'r').read }
|
41
|
+
|
25
42
|
it 'returns as expected' do
|
26
|
-
input_text = File.open(File.join(['spec', 'fixtures', 'markup', 'swap-links-input.textile']), 'r').read
|
27
43
|
output_text = File.open(File.join(['spec', 'fixtures', 'markup', 'swap-links-output.textile']), 'r').read
|
28
|
-
|
44
|
+
is_expected.to eq output_text
|
29
45
|
end
|
30
46
|
end
|
31
47
|
end
|
@@ -1,100 +1,198 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Caramelize::Wikka2Markdown do
|
4
|
+
let(:filter) { described_class.new(body) }
|
5
|
+
|
6
|
+
describe '#run' do
|
7
|
+
subject { filter.run }
|
8
|
+
|
9
|
+
xcontext 'keep line breaks' do
|
10
|
+
let(:body) { "line1\nline2" }
|
11
|
+
|
12
|
+
it { is_expected.to eq "line1 \nline2" }
|
13
|
+
end
|
4
14
|
|
5
|
-
describe :run do
|
6
|
-
let(:filter) { Caramelize::Wikka2Markdown.new }
|
7
15
|
context 'headline h1' do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
16
|
+
let(:body) { '======Headline======' }
|
17
|
+
|
18
|
+
it { is_expected.to eq '# Headline' }
|
12
19
|
end
|
13
20
|
|
14
21
|
context 'headline h2' do
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
22
|
+
let(:body) { '=====Headline=====' }
|
23
|
+
|
24
|
+
it { is_expected.to eq '## Headline' }
|
19
25
|
end
|
20
26
|
|
21
27
|
context 'headline h3' do
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
28
|
+
let(:body) { '====Headline===='}
|
29
|
+
|
30
|
+
it { is_expected.to eq '### Headline' }
|
26
31
|
end
|
27
32
|
|
28
33
|
context 'headline h4' do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
34
|
+
let(:body) { '===Headline===' }
|
35
|
+
|
36
|
+
it { is_expected.to eq '#### Headline' }
|
33
37
|
end
|
34
38
|
|
35
|
-
context 'headline
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
39
|
+
context 'headline h5' do
|
40
|
+
let(:body) { '==Headline==' }
|
41
|
+
|
42
|
+
it { is_expected.to eq '##### Headline' }
|
40
43
|
end
|
41
44
|
|
42
45
|
context 'bold' do
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
46
|
+
let(:body) { '**Text is bold**' }
|
47
|
+
|
48
|
+
it { is_expected.to eq '**Text is bold**' }
|
47
49
|
end
|
48
50
|
|
49
51
|
context 'italic' do
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
52
|
+
let(:body) { '//Text is italic//' }
|
53
|
+
|
54
|
+
it { is_expected.to eq '*Text is italic*' }
|
54
55
|
end
|
55
56
|
|
56
57
|
context 'underline' do
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
end
|
58
|
+
let(:body) { '__Text is underlined__' }
|
59
|
+
|
60
|
+
it { is_expected.to eq '<u>Text is underlined</u>' }
|
61
61
|
end
|
62
62
|
|
63
63
|
context 'line break' do
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
64
|
+
let(:body) { 'Text is---\nbroken to two lines.' }
|
65
|
+
|
66
|
+
it { is_expected.to eq 'Text is \nbroken to two lines.' }
|
68
67
|
end
|
69
68
|
|
70
69
|
context 'unordered list entry' do
|
71
70
|
context 'tab based' do
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
71
|
+
let(:body) { "\t-unordered list entry" }
|
72
|
+
|
73
|
+
it { is_expected.to eq '* unordered list entry' }
|
76
74
|
end
|
77
75
|
|
78
76
|
context 'also tab based' do
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
end
|
77
|
+
let(:body) { "~-unordered list entry" }
|
78
|
+
|
79
|
+
it { is_expected.to eq '* unordered list entry' }
|
83
80
|
end
|
84
81
|
|
85
82
|
context 'space based' do
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
83
|
+
let(:body) { " -unordered list entry" }
|
84
|
+
|
85
|
+
it { is_expected.to eq '* unordered list entry' }
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'tab based with space' do
|
89
|
+
let(:body) { "\t- unordered list entry" }
|
90
|
+
|
91
|
+
it { is_expected.to eq '* unordered list entry' }
|
92
|
+
end
|
93
|
+
|
94
|
+
context 'also tab based with space' do
|
95
|
+
let(:body) { "~- unordered list entry" }
|
96
|
+
|
97
|
+
it { is_expected.to eq '* unordered list entry' }
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'space based with space' do
|
101
|
+
let(:body) { " - unordered list entry" }
|
102
|
+
|
103
|
+
it { is_expected.to eq '* unordered list entry' }
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context 'ordered list entry' do
|
108
|
+
context 'without space' do
|
109
|
+
let(:body) { "~1)ordered list entry" }
|
110
|
+
|
111
|
+
it { is_expected.to eq '1. ordered list entry' }
|
112
|
+
end
|
113
|
+
|
114
|
+
context 'with space' do
|
115
|
+
let(:body) { "~1) ordered list entry" }
|
116
|
+
|
117
|
+
it { is_expected.to eq '1. ordered list entry' }
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
context 'wikilink' do
|
122
|
+
context 'only url' do
|
123
|
+
let(:body) { '[[LemmaLemma]]' }
|
124
|
+
|
125
|
+
it { is_expected.to eq '[[LemmaLemma]]' }
|
126
|
+
end
|
127
|
+
|
128
|
+
context 'url and pipe title' do
|
129
|
+
let(:body) { '[[SandBox|Test your formatting skills]]' }
|
130
|
+
|
131
|
+
it { is_expected.to eq '[[Test your formatting skills|SandBox]]' }
|
132
|
+
end
|
133
|
+
|
134
|
+
context 'url and title' do
|
135
|
+
let(:body) { '[[SandBox Test your formatting skills]]' }
|
136
|
+
|
137
|
+
it { is_expected.to eq '[[Test your formatting skills|SandBox]]' }
|
90
138
|
end
|
91
139
|
end
|
92
140
|
|
93
141
|
context 'hyperlink' do
|
94
|
-
|
95
|
-
body
|
96
|
-
|
142
|
+
context 'only url' do
|
143
|
+
let(:body) { '[[http://target]]' }
|
144
|
+
|
145
|
+
it { is_expected.to eq '<http://target>' }
|
146
|
+
end
|
147
|
+
|
148
|
+
context 'url with title' do
|
149
|
+
let(:body) { '[[http://target Title]]' }
|
150
|
+
|
151
|
+
it { is_expected.to eq '[Title](http://target)' }
|
152
|
+
end
|
153
|
+
|
154
|
+
context 'url with pipe' do
|
155
|
+
let(:body) { '[[http://target|Title]]' }
|
156
|
+
|
157
|
+
it { is_expected.to eq '[Title](http://target)' }
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
context 'code block' do
|
162
|
+
let(:body) do
|
163
|
+
<<-EOS
|
164
|
+
Text before
|
165
|
+
|
166
|
+
%%
|
167
|
+
std::cin >> input;
|
168
|
+
++stat[input];
|
169
|
+
%%
|
170
|
+
|
171
|
+
Text after
|
172
|
+
|
173
|
+
%%
|
174
|
+
std::cin >> input;
|
175
|
+
++stat[input];
|
176
|
+
%%
|
177
|
+
|
178
|
+
EOS
|
97
179
|
end
|
180
|
+
let(:expected_result) do
|
181
|
+
<<-EOS
|
182
|
+
Text before
|
183
|
+
|
184
|
+
std::cin >> input;
|
185
|
+
++stat[input];
|
186
|
+
|
187
|
+
Text after
|
188
|
+
|
189
|
+
std::cin >> input;
|
190
|
+
++stat[input];
|
191
|
+
|
192
|
+
EOS
|
193
|
+
end
|
194
|
+
|
195
|
+
it { is_expected.to eq expected_result }
|
98
196
|
end
|
99
197
|
end
|
100
198
|
end
|