tty-markdown 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe TTY::Markdown, 'math' do
4
- it "converts math formulae" do
5
- markdown =<<-TEXT
6
- $$5+5$$
7
- TEXT
8
- parsed = TTY::Markdown.parse(markdown, colors: 16)
9
- expect(parsed).to eq("\e[33m5+5\e[0m\n")
10
- end
11
-
12
- it "indents maths formulae correctly" do
13
- markdown =<<-TEXT
14
- ### header
15
-
16
- $$5+5$$
17
- TEXT
18
- parsed = TTY::Markdown.parse(markdown, colors: 16)
19
- expect(parsed).to eq([
20
- " \e[36;1mheader\e[0m",
21
- "",
22
- " \e[33m5+5\e[0m\n"
23
- ].join("\n"))
24
- end
25
-
26
- it "indents immediate maths formulae correctly" do
27
- markdown =<<-TEXT
28
- ### header
29
- $$5+5$$
30
- TEXT
31
- parsed = TTY::Markdown.parse(markdown, colors: 16)
32
- expect(parsed).to eq([
33
- " \e[36;1mheader\e[0m",
34
- " \e[33m5+5\e[0m\n"
35
- ].join("\n"))
36
- end
37
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe TTY::Markdown, 'paragraph' do
4
- it "converts multiline paragraphs" do
5
- markdown =<<-TEXT
6
- This is a first paragraph
7
- that spans two lines.
8
-
9
- And this is a next one.
10
- TEXT
11
- parsed = TTY::Markdown.parse(markdown)
12
- expect(parsed).to eq([
13
- "This is a first paragraph",
14
- "that spans two lines.",
15
- "",
16
- "And this is a next one.\n"
17
- ].join("\n"))
18
- end
19
-
20
- it "converts multiline pragraphs within header section" do
21
-
22
- markdown =<<-TEXT
23
- ### header
24
- This is a first paragraph
25
- that spans two lines.
26
-
27
- And this is a next one.
28
- TEXT
29
- parsed = TTY::Markdown.parse(markdown)
30
- expect(parsed).to eq([
31
- " \e[36;1mheader\e[0m",
32
- " This is a first paragraph",
33
- " that spans two lines.",
34
- "",
35
- " And this is a next one.\n"
36
- ].join("\n"))
37
- end
38
- end
@@ -1,164 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe TTY::Markdown, 'table' do
4
- let(:symbols) { TTY::Markdown.symbols }
5
-
6
- it "parses markdown table with header" do
7
- markdown =<<-TEXT
8
- | Tables | Are | Cool |
9
- |----------|:-------------:|------:|
10
- | col 1 is | left-aligned | $1600 |
11
- | col 2 is | centered | $12 |
12
- | col 3 is | right-aligned | $1 |
13
- TEXT
14
-
15
- parsed = TTY::Markdown.parse(markdown)
16
-
17
- expect(parsed).to eq([
18
- "\e[33m#{symbols[:top_left]}#{symbols[:line]*10}#{symbols[:top_center]}",
19
- "#{symbols[:line]*15}#{symbols[:top_center]}",
20
- "#{symbols[:line]*7}#{symbols[:top_right]}",
21
- "\e[0m\n",
22
-
23
- "\e[33m#{symbols[:pipe]} \e[0mTables ",
24
- "\e[33m#{symbols[:pipe]}\e[0m Are ",
25
- "\e[33m#{symbols[:pipe]}\e[0m Cool \e[33m#{symbols[:pipe]}\e[0m \n",
26
-
27
- "\e[33m#{symbols[:mid_left]}#{symbols[:line]*10}#{symbols[:mid_center]}",
28
- "#{symbols[:line]*15}#{symbols[:mid_center]}",
29
- "#{symbols[:line]*7}#{symbols[:mid_right]}",
30
- "\e[0m\n",
31
-
32
- "\e[33m#{symbols[:pipe]} \e[0mcol 1 is ",
33
- "\e[33m#{symbols[:pipe]}\e[0m left-aligned ",
34
- "\e[33m#{symbols[:pipe]}\e[0m $1600 \e[33m#{symbols[:pipe]}\e[0m \n",
35
-
36
- "\e[33m#{symbols[:mid_left]}#{symbols[:line]*10}#{symbols[:mid_center]}",
37
- "#{symbols[:line]*15}#{symbols[:mid_center]}",
38
- "#{symbols[:line]*7}#{symbols[:mid_right]}",
39
- "\e[0m\n",
40
-
41
- "\e[33m#{symbols[:pipe]} \e[0mcol 2 is ",
42
- "\e[33m#{symbols[:pipe]}\e[0m centered ",
43
- "\e[33m#{symbols[:pipe]}\e[0m $12 \e[33m#{symbols[:pipe]}\e[0m \n",
44
-
45
- "\e[33m#{symbols[:mid_left]}#{symbols[:line]*10}#{symbols[:mid_center]}",
46
- "#{symbols[:line]*15}#{symbols[:mid_center]}",
47
- "#{symbols[:line]*7}#{symbols[:mid_right]}",
48
- "\e[0m\n",
49
-
50
- "\e[33m#{symbols[:pipe]} \e[0mcol 3 is ",
51
- "\e[33m#{symbols[:pipe]}\e[0m right-aligned ",
52
- "\e[33m#{symbols[:pipe]}\e[0m $1 \e[33m#{symbols[:pipe]}\e[0m \n",
53
-
54
- "\e[33m#{symbols[:bottom_left]}#{symbols[:line]*10}#{symbols[:bottom_center]}",
55
- "#{symbols[:line]*15}#{symbols[:bottom_center]}",
56
- "#{symbols[:line]*7}#{symbols[:bottom_right]}",
57
- "\e[0m\n"
58
- ].join)
59
- end
60
-
61
- it "parses markdown table without header" do
62
- markdown =<<-TEXT
63
- | col 1 is | left-aligned | $1600 |
64
- | col 2 is | centered | $12 |
65
- | col 3 is | right-aligned | $1 |
66
- TEXT
67
-
68
- parsed = TTY::Markdown.parse(markdown)
69
-
70
- expect(parsed).to eq([
71
- "\e[33m#{symbols[:top_left]}#{symbols[:line]*10}#{symbols[:top_center]}",
72
- "#{symbols[:line]*15}#{symbols[:top_center]}",
73
- "#{symbols[:line]*7}#{symbols[:top_right]}",
74
- "\e[0m\n",
75
-
76
- "\e[33m#{symbols[:pipe]} \e[0mcol 1 is ",
77
- "\e[33m#{symbols[:pipe]}\e[0m left-aligned ",
78
- "\e[33m#{symbols[:pipe]}\e[0m $1600 \e[33m#{symbols[:pipe]}\e[0m \n",
79
-
80
- "\e[33m#{symbols[:mid_left]}#{symbols[:line]*10}#{symbols[:mid_center]}",
81
- "#{symbols[:line]*15}#{symbols[:mid_center]}",
82
- "#{symbols[:line]*7}#{symbols[:mid_right]}",
83
- "\e[0m\n",
84
-
85
- "\e[33m#{symbols[:pipe]} \e[0mcol 2 is ",
86
- "\e[33m#{symbols[:pipe]}\e[0m centered ",
87
- "\e[33m#{symbols[:pipe]}\e[0m $12 \e[33m#{symbols[:pipe]}\e[0m \n",
88
-
89
- "\e[33m#{symbols[:mid_left]}#{symbols[:line]*10}#{symbols[:mid_center]}",
90
- "#{symbols[:line]*15}#{symbols[:mid_center]}",
91
- "#{symbols[:line]*7}#{symbols[:mid_right]}",
92
- "\e[0m\n",
93
-
94
- "\e[33m#{symbols[:pipe]} \e[0mcol 3 is ",
95
- "\e[33m#{symbols[:pipe]}\e[0m right-aligned ",
96
- "\e[33m#{symbols[:pipe]}\e[0m $1 \e[33m#{symbols[:pipe]}\e[0m \n",
97
-
98
- "\e[33m#{symbols[:bottom_left]}#{symbols[:line]*10}#{symbols[:bottom_center]}",
99
- "#{symbols[:line]*15}#{symbols[:bottom_center]}",
100
- "#{symbols[:line]*7}#{symbols[:bottom_right]}",
101
- "\e[0m\n"
102
- ].join)
103
- end
104
-
105
- it "wraps multiline records" do
106
- markdown =<<-TEXT
107
- | Tables | Are | Cool |
108
- |----------|:-------------:|------:|
109
- | col 1 is | left-aligned | $1600 |
110
- | col 2 is | centered | $12 |
111
- | col 3 is a multiline column | right-aligned has also a very long content that wraps around | $1 |
112
- TEXT
113
-
114
- parsed = TTY::Markdown.parse(markdown, width: 80)
115
-
116
- expected_output =
117
- "\e[33m#{symbols[:top_left]}#{symbols[:line]*24}#{symbols[:top_center]}" +
118
- "#{symbols[:line]*51}#{symbols[:top_center]}" +
119
- "#{symbols[:line]*7}#{symbols[:top_right]}" +
120
- "\e[0m\n" +
121
-
122
- "\e[33m#{symbols[:pipe]} \e[0mTables " +
123
- "\e[33m#{symbols[:pipe]}\e[0m Are " +
124
- "\e[33m#{symbols[:pipe]}\e[0m Cool \e[33m#{symbols[:pipe]}\e[0m \n" +
125
-
126
- "\e[33m#{symbols[:mid_left]}#{symbols[:line]*24}#{symbols[:mid_center]}" +
127
- "#{symbols[:line]*51}#{symbols[:mid_center]}" +
128
- "#{symbols[:line]*7}#{symbols[:mid_right]}" +
129
- "\e[0m\n" +
130
-
131
- "\e[33m#{symbols[:pipe]} \e[0mcol 1 is " +
132
- "\e[33m#{symbols[:pipe]}\e[0m left-aligned " +
133
- "\e[33m#{symbols[:pipe]}\e[0m $1600 \e[33m#{symbols[:pipe]}\e[0m \n" +
134
-
135
- "\e[33m#{symbols[:mid_left]}#{symbols[:line]*24}#{symbols[:mid_center]}" +
136
- "#{symbols[:line]*51}#{symbols[:mid_center]}" +
137
- "#{symbols[:line]*7}#{symbols[:mid_right]}" +
138
- "\e[0m\n" +
139
-
140
- "\e[33m#{symbols[:pipe]} \e[0mcol 2 is " +
141
- "\e[33m#{symbols[:pipe]}\e[0m centered " +
142
- "\e[33m#{symbols[:pipe]}\e[0m $12 \e[33m#{symbols[:pipe]}\e[0m \n" +
143
-
144
- "\e[33m#{symbols[:mid_left]}#{symbols[:line]*24}#{symbols[:mid_center]}" +
145
- "#{symbols[:line]*51}#{symbols[:mid_center]}" +
146
- "#{symbols[:line]*7}#{symbols[:mid_right]}" +
147
- "\e[0m\n" +
148
-
149
- "\e[33m#{symbols[:pipe]} \e[0mcol 3 is a multiline " +
150
- "\e[33m#{symbols[:pipe]}\e[0m right-aligned has also a very long content that " +
151
- "\e[33m#{symbols[:pipe]}\e[0m $1 \e[33m#{symbols[:pipe]}\e[0m \n" +
152
-
153
- "\e[33m#{symbols[:pipe]} \e[0mcolumn " +
154
- "\e[33m#{symbols[:pipe]}\e[0m wraps around " +
155
- "\e[33m#{symbols[:pipe]}\e[0m \e[33m#{symbols[:pipe]}\e[0m \n" +
156
-
157
- "\e[33m#{symbols[:bottom_left]}#{symbols[:line]*24}#{symbols[:bottom_center]}" +
158
- "#{symbols[:line]*51}#{symbols[:bottom_center]}" +
159
- "#{symbols[:line]*7}#{symbols[:bottom_right]}" +
160
- "\e[0m\n"
161
-
162
- expect(parsed).to eq(expected_output)
163
- end
164
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe TTY::Markdown, 'typography' do
4
- let(:symbols) { TTY::Markdown.symbols }
5
-
6
- it "converts header with typographic symbols" do
7
- markdown =<<-TEXT
8
- --- << typographic >> ... symbols --
9
- TEXT
10
- parsed = TTY::Markdown.parse(markdown)
11
- expect(parsed).to eq("#{symbols[:mdash]} #{symbols[:laquo]} typographic #{symbols[:raquo]} #{symbols[:hellip]} symbols #{symbols[:ndash]}\n")
12
- end
13
-
14
- it "converts smart quotes to utf-8 chars" do
15
- markdown = "To \"extract\" `script.rb`'s..."
16
- parsed = TTY::Markdown.parse(markdown, colors: 16)
17
-
18
- expect(parsed).to eq("To #{symbols[:ldquo]}extract#{symbols[:rdquo]} \e[33mscript.rb\e[0m#{symbols[:rsquo]}s#{symbols[:hellip]}\n")
19
- end
20
- end
@@ -1,11 +0,0 @@
1
- # encoding: utf-8
2
-
3
- desc 'Load gem inside irb console'
4
- task :console do
5
- require 'irb'
6
- require 'irb/completion'
7
- require File.join(__FILE__, '../../lib/tty-markdown')
8
- ARGV.clear
9
- IRB.start
10
- end
11
- task c: %w[ console ]
@@ -1,11 +0,0 @@
1
- # encoding: utf-8
2
-
3
- desc 'Measure code coverage'
4
- task :coverage do
5
- begin
6
- original, ENV['COVERAGE'] = ENV['COVERAGE'], 'true'
7
- Rake::Task['spec'].invoke
8
- ensure
9
- ENV['COVERAGE'] = original
10
- end
11
- end
@@ -1,29 +0,0 @@
1
- # encoding: utf-8
2
-
3
- begin
4
- require 'rspec/core/rake_task'
5
-
6
- desc 'Run all specs'
7
- RSpec::Core::RakeTask.new(:spec) do |task|
8
- task.pattern = 'spec/{unit,integration}{,/*/**}/*_spec.rb'
9
- end
10
-
11
- namespace :spec do
12
- desc 'Run unit specs'
13
- RSpec::Core::RakeTask.new(:unit) do |task|
14
- task.pattern = 'spec/unit{,/*/**}/*_spec.rb'
15
- end
16
-
17
- desc 'Run integration specs'
18
- RSpec::Core::RakeTask.new(:integration) do |task|
19
- task.pattern = 'spec/integration{,/*/**}/*_spec.rb'
20
- end
21
- end
22
-
23
- rescue LoadError
24
- %w[spec spec:unit spec:integration].each do |name|
25
- task name do
26
- $stderr.puts "In order to run #{name}, do `gem install rspec`"
27
- end
28
- end
29
- end