tty-markdown 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +9 -1
- data/README.md +4 -0
- data/lib/tty/markdown/version.rb +3 -1
- data/spec/spec_helper.rb +31 -0
- data/spec/unit/parse/abbrev_spec.rb +27 -0
- data/spec/unit/parse/blockquote_spec.rb +77 -0
- data/spec/unit/parse/codeblock_spec.rb +130 -0
- data/spec/unit/parse/emphasis_spec.rb +35 -0
- data/spec/unit/parse/entity_spec.rb +11 -0
- data/spec/unit/parse/header_spec.rb +35 -0
- data/spec/unit/parse/hr_spec.rb +25 -0
- data/spec/unit/parse/link_spec.rb +25 -0
- data/spec/unit/parse/list_spec.rb +90 -0
- data/spec/unit/parse/math_spec.rb +37 -0
- data/spec/unit/parse/paragraph_spec.rb +38 -0
- data/spec/unit/parse/table_spec.rb +164 -0
- data/spec/unit/parse/typography_spec.rb +20 -0
- metadata +25 -20
- data/.gitignore +0 -12
- data/.rspec +0 -3
- data/.travis.yml +0 -23
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -16
- data/appveyor.yml +0 -23
- data/examples/example.md +0 -49
- data/examples/man.md +0 -17
- data/tty-markdown.gemspec +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 921ecfb3d45e680418a18bda8034a67c5e2a82bbe6d8368e2075783e34ff6d9e
|
4
|
+
data.tar.gz: 4acbf4a71b69dc363edae7263447118c504911a1ab452aa7c754c7c2d692b23d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f0e70e1754a9ea1cdd9994f6faf5940b5a5e86ed0f16cd33bde4ef20cd12a7f2f93e76d9edc4216e71f6287e3345d6f58e4b717e38e4278d982c29e6ccd472b
|
7
|
+
data.tar.gz: 2c6bd5c9e87300a70b12464c9a024aa29d3636ae66b03ee3bd0dcccff8f7889ae588b5a38fc9e5b1d97dc67f8c1bbcab1626b611d8d8726eef0a6ef6122cf3c0
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## [v0.5.0] - 2018-12-13
|
4
|
+
|
5
|
+
### Changed
|
6
|
+
* Change gemspec to load files directly
|
7
|
+
* Change to update rouge dependency
|
8
|
+
* Change to relax constraings on tty-screen and tty-color
|
9
|
+
|
3
10
|
## [v0.4.0] - 2018-06-20
|
4
11
|
|
5
12
|
## Fixed
|
@@ -25,7 +32,7 @@
|
|
25
32
|
* Add markdown math formula conversion
|
26
33
|
* Add markdown typogrpahic symbols conversion by Tanaka Masaki(@T-a-n-a-k-a-M-a-s-a-k-i)
|
27
34
|
* Add html entities conversion
|
28
|
-
* Add warnings about unsupported conversions for
|
35
|
+
* Add warnings about unsupported conversions for completeness
|
29
36
|
|
30
37
|
### Changed
|
31
38
|
* Change gemspec to require Ruby >= 2.0.0
|
@@ -37,6 +44,7 @@
|
|
37
44
|
|
38
45
|
* Initial implementation and release
|
39
46
|
|
47
|
+
[v0.5.0]: https://github.com/piotrmurach/tty-markdown/compare/v0.4.0...v0.5.0
|
40
48
|
[v0.4.0]: https://github.com/piotrmurach/tty-markdown/compare/v0.3.0...v0.4.0
|
41
49
|
[v0.3.0]: https://github.com/piotrmurach/tty-markdown/compare/v0.2.0...v0.3.0
|
42
50
|
[v0.2.0]: https://github.com/piotrmurach/tty-markdown/compare/v0.1.0...v0.2.0
|
data/README.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
<div align="center">
|
2
|
+
<a href="https://piotrmurach.github.io/tty" target="_blank"><img width="130" src="https://cdn.rawgit.com/piotrmurach/tty/master/images/tty.png" alt="tty logo" /></a>
|
3
|
+
</div>
|
4
|
+
|
1
5
|
# TTY::Markdown [![Gitter](https://badges.gitter.im/Join%20Chat.svg)][gitter]
|
2
6
|
|
3
7
|
[![Gem Version](https://badge.fury.io/rb/tty-markdown.svg)][gem]
|
data/lib/tty/markdown/version.rb
CHANGED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
if ENV['COVERAGE'] || ENV['TRAVIS']
|
4
|
+
require 'simplecov'
|
5
|
+
require 'coveralls'
|
6
|
+
|
7
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
8
|
+
SimpleCov::Formatter::HTMLFormatter,
|
9
|
+
Coveralls::SimpleCov::Formatter
|
10
|
+
]
|
11
|
+
|
12
|
+
SimpleCov.start do
|
13
|
+
command_name 'spec'
|
14
|
+
add_filter 'spec'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
require "bundler/setup"
|
19
|
+
require "tty/markdown"
|
20
|
+
|
21
|
+
RSpec.configure do |config|
|
22
|
+
# Enable flags like --only-failures and --next-failure
|
23
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
24
|
+
|
25
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
26
|
+
config.disable_monkey_patching!
|
27
|
+
|
28
|
+
config.expect_with :rspec do |c|
|
29
|
+
c.syntax = :expect
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe TTY::Markdown, 'abbrev' do
|
4
|
+
it "abbreviates markdown" do
|
5
|
+
markdown =<<-TEXT
|
6
|
+
*[HTML]: Hyper Text Markup Language
|
7
|
+
test HTML
|
8
|
+
TEXT
|
9
|
+
parsed = TTY::Markdown.parse(markdown)
|
10
|
+
expect(parsed).to eq([
|
11
|
+
"test HTML\n"
|
12
|
+
].join("\n"))
|
13
|
+
end
|
14
|
+
|
15
|
+
it "indents abbreviations correctly" do
|
16
|
+
markdown =<<-TEXT
|
17
|
+
### header
|
18
|
+
*[HTML]: Hyper Text Markup Language
|
19
|
+
test HTML
|
20
|
+
TEXT
|
21
|
+
parsed = TTY::Markdown.parse(markdown)
|
22
|
+
expect(parsed).to eq([
|
23
|
+
" \e[36;1mheader\e[0m",
|
24
|
+
" test HTML\n"
|
25
|
+
].join("\n"))
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe TTY::Markdown, 'blockquote' do
|
4
|
+
let(:bar) { TTY::Markdown.symbols[:bar] }
|
5
|
+
let(:apos) { TTY::Markdown.symbols[:rsquo] }
|
6
|
+
|
7
|
+
it "converts single blockquote" do
|
8
|
+
markdown =<<-TEXT
|
9
|
+
> Oh, you can *put* **Markdown** into a blockquote.
|
10
|
+
TEXT
|
11
|
+
parsed = TTY::Markdown.parse(markdown)
|
12
|
+
expect(parsed).to eq([
|
13
|
+
"\e[33m#{bar}\e[0m Oh, you can \e[33mput\e[0m \e[33;1mMarkdown\e[0m into a blockquote.\n"
|
14
|
+
].join)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "indents blockquote within header" do
|
18
|
+
markdown =<<-TEXT
|
19
|
+
### Quote
|
20
|
+
> Oh, you can *put* **Markdown** into a blockquote.
|
21
|
+
TEXT
|
22
|
+
parsed = TTY::Markdown.parse(markdown)
|
23
|
+
expect(parsed).to eq([
|
24
|
+
" \e[36;1mQuote\e[0m",
|
25
|
+
" \e[33m#{bar}\e[0m Oh, you can \e[33mput\e[0m \e[33;1mMarkdown\e[0m into a blockquote.\n"
|
26
|
+
].join("\n"))
|
27
|
+
end
|
28
|
+
|
29
|
+
it "converts multiple blockquotes without header" do
|
30
|
+
markdown =<<-TEXT
|
31
|
+
> one
|
32
|
+
> two
|
33
|
+
> three
|
34
|
+
TEXT
|
35
|
+
parsed = TTY::Markdown.parse(markdown)
|
36
|
+
expected_output =
|
37
|
+
"\e[33m#{bar}\e[0m one\n" +
|
38
|
+
"\e[33m#{bar}\e[0m two\n" +
|
39
|
+
"\e[33m#{bar}\e[0m three\n"
|
40
|
+
|
41
|
+
expect(parsed).to eq(expected_output)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "converts multiple blockquote" do
|
45
|
+
markdown =<<-TEXT
|
46
|
+
### Quote
|
47
|
+
> Blockquotes are very handy in email to emulate reply text.
|
48
|
+
> This line is part of the same quote.
|
49
|
+
> *Oh*, you can put **Markdown** into a blockquote.
|
50
|
+
TEXT
|
51
|
+
parsed = TTY::Markdown.parse(markdown)
|
52
|
+
expect(parsed).to eq([
|
53
|
+
" \e[36;1mQuote\e[0m\n",
|
54
|
+
" \e[33m#{bar}\e[0m Blockquotes are very handy in email to emulate reply text.\n",
|
55
|
+
" \e[33m#{bar}\e[0m This line is part of the same quote.\n",
|
56
|
+
" \e[33m#{bar}\e[0m \e[33mOh\e[0m, you can put \e[33;1mMarkdown\e[0m into a blockquote.\n"
|
57
|
+
].join)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "converts blockquote into lines" do
|
61
|
+
markdown =<<-TEXT
|
62
|
+
> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote.
|
63
|
+
> Last line to ensure all is fine.
|
64
|
+
TEXT
|
65
|
+
|
66
|
+
parsed = TTY::Markdown.parse(markdown, width: 50)
|
67
|
+
expected_output =
|
68
|
+
"\e[33m#{bar}\e[0m This is a very long line that will still be \n" +
|
69
|
+
"\e[33m#{bar}\e[0m quoted properly when it wraps. Oh boy let\n" +
|
70
|
+
"\e[33m#{bar}\e[0m #{apos}s keep writing to make sure this is long enough \n" +
|
71
|
+
"\e[33m#{bar}\e[0m to actually wrap for everyone. Oh, you can \n" +
|
72
|
+
"\e[33m#{bar}\e[0m \e[33mput\e[0m \e[33;1mMarkdown\e[0m into a blockquote.\n" +
|
73
|
+
"\e[33m#{bar}\e[0m Last line to ensure all is fine.\n"
|
74
|
+
|
75
|
+
expect(parsed).to eq(expected_output)
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe TTY::Markdown, 'codeblock' do
|
4
|
+
it "highlights a fenced code without language" do
|
5
|
+
markdown =<<-TEXT
|
6
|
+
```
|
7
|
+
class Greeter
|
8
|
+
def say
|
9
|
+
end
|
10
|
+
end
|
11
|
+
```
|
12
|
+
TEXT
|
13
|
+
parsed = TTY::Markdown.parse(markdown, colors: 16)
|
14
|
+
expect(parsed).to eq([
|
15
|
+
"\e[33mclass Greeter\e[0m",
|
16
|
+
"\e[33m def say\e[0m",
|
17
|
+
"\e[33m end\e[0m",
|
18
|
+
"\e[33mend\e[0m\n"
|
19
|
+
].join("\n"))
|
20
|
+
end
|
21
|
+
|
22
|
+
it "highlights code without language" do
|
23
|
+
markdown =<<-TEXT
|
24
|
+
class Greeter
|
25
|
+
def say
|
26
|
+
end
|
27
|
+
end
|
28
|
+
TEXT
|
29
|
+
parsed = TTY::Markdown.parse(markdown, colors: 16)
|
30
|
+
expect(parsed).to eq([
|
31
|
+
"\e[33mclass Greeter\e[0m",
|
32
|
+
"\e[33m def say\e[0m",
|
33
|
+
"\e[33m end\e[0m",
|
34
|
+
"\e[33mend\e[0m"
|
35
|
+
].join("\n"))
|
36
|
+
end
|
37
|
+
|
38
|
+
it "highlights fenced code according to language" do
|
39
|
+
markdown =<<-TEXT
|
40
|
+
```ruby
|
41
|
+
class Greeter
|
42
|
+
def say
|
43
|
+
end
|
44
|
+
end
|
45
|
+
```
|
46
|
+
TEXT
|
47
|
+
parsed = TTY::Markdown.parse(markdown, colors: 16)
|
48
|
+
expect(parsed).to eq([
|
49
|
+
"\e[33mclass Greeter\e[0m",
|
50
|
+
"\e[33m def say\e[0m",
|
51
|
+
"\e[33m end\e[0m",
|
52
|
+
"\e[33mend\e[0m\n"
|
53
|
+
].join("\n"))
|
54
|
+
end
|
55
|
+
|
56
|
+
it "indents immediate code correctly" do
|
57
|
+
markdown =<<-TEXT
|
58
|
+
### header
|
59
|
+
```
|
60
|
+
class Greeter
|
61
|
+
def say
|
62
|
+
end
|
63
|
+
end
|
64
|
+
```
|
65
|
+
TEXT
|
66
|
+
parsed = TTY::Markdown.parse(markdown, colors: 16)
|
67
|
+
expect(parsed).to eq([
|
68
|
+
" \e[36;1mheader\e[0m",
|
69
|
+
" \e[33mclass Greeter\e[0m",
|
70
|
+
" \e[33m def say\e[0m",
|
71
|
+
" \e[33m end\e[0m",
|
72
|
+
" \e[33mend\e[0m\n"
|
73
|
+
].join("\n"))
|
74
|
+
end
|
75
|
+
|
76
|
+
it "indents code after blank correctly" do
|
77
|
+
markdown =<<-TEXT
|
78
|
+
### header
|
79
|
+
|
80
|
+
```
|
81
|
+
class Greeter
|
82
|
+
def say
|
83
|
+
end
|
84
|
+
end
|
85
|
+
```
|
86
|
+
TEXT
|
87
|
+
parsed = TTY::Markdown.parse(markdown, colors: 16)
|
88
|
+
expect(parsed).to eq([
|
89
|
+
" \e[36;1mheader\e[0m",
|
90
|
+
"",
|
91
|
+
" \e[33mclass Greeter\e[0m",
|
92
|
+
" \e[33m def say\e[0m",
|
93
|
+
" \e[33m end\e[0m",
|
94
|
+
" \e[33mend\e[0m\n"
|
95
|
+
].join("\n"))
|
96
|
+
end
|
97
|
+
|
98
|
+
it "wraps code exceeding set width" do
|
99
|
+
markdown =<<-TEXT
|
100
|
+
```
|
101
|
+
lexer = Rouge::Lexer.find_fancy(lang, code) || Rouge::Lexers::PlainText
|
102
|
+
```
|
103
|
+
TEXT
|
104
|
+
parsed = TTY::Markdown.parse(markdown, width: 50, colors: 16)
|
105
|
+
|
106
|
+
expected_output =
|
107
|
+
"\e[33mlexer = Rouge::Lexer.find_fancy(lang, code) || \e[0m\n" +
|
108
|
+
"\e[33mRouge::Lexers::PlainText\e[0m\n"
|
109
|
+
|
110
|
+
expect(parsed).to eq(expected_output)
|
111
|
+
end
|
112
|
+
|
113
|
+
it "wraps code exceeding set width preserving indentation" do
|
114
|
+
markdown =<<-TEXT
|
115
|
+
### lexer
|
116
|
+
|
117
|
+
```
|
118
|
+
lexer = Rouge::Lexer.find_fancy(lang, code) || Rouge::Lexers::PlainText
|
119
|
+
```
|
120
|
+
TEXT
|
121
|
+
parsed = TTY::Markdown.parse(markdown, width: 50, colors: 16)
|
122
|
+
|
123
|
+
expected_output =
|
124
|
+
" \e[36;1mlexer\e[0m\n\n" +
|
125
|
+
" \e[33mlexer = Rouge::Lexer.find_fancy(lang, code) || \e[0m\n" +
|
126
|
+
" \e[33mRouge::Lexers::PlainText\e[0m\n"
|
127
|
+
|
128
|
+
expect(parsed).to eq(expected_output)
|
129
|
+
end
|
130
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe TTY::Markdown, 'emphasis' do
|
4
|
+
context 'when strong emphasis' do
|
5
|
+
it "converts asterisks to bold ansi codes" do
|
6
|
+
parsed = TTY::Markdown.parse("Some text with **bold** content.")
|
7
|
+
|
8
|
+
expect(parsed).to eq("Some text with \e[33;1mbold\e[0m content.\n")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'when italics emphasis' do
|
13
|
+
it "converts asterisks to bold ansi codes" do
|
14
|
+
parsed = TTY::Markdown.parse("Some text with *italic* content.")
|
15
|
+
|
16
|
+
expect(parsed).to eq("Some text with \e[33mitalic\e[0m content.\n")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'when strikethrough emphasis' do
|
21
|
+
it "converts two tildes to ansi codes" do
|
22
|
+
parsed = TTY::Markdown.parse("Some text with ~~scratched~~ content.")
|
23
|
+
|
24
|
+
expect(parsed).to eq("Some text with ~~scratched~~ content.\n")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "when backticks" do
|
29
|
+
it "convertrs backtics to ansi codes" do
|
30
|
+
parsed = TTY::Markdown.parse("Some text with `important` content.", colors: 16)
|
31
|
+
|
32
|
+
expect(parsed).to eq("Some text with \e[33mimportant\e[0m content.\n")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe TTY::Markdown, 'entity' do
|
4
|
+
it "converts html entities" do
|
5
|
+
markdown =<<-TEXT
|
6
|
+
© 2018 by me and λ
|
7
|
+
TEXT
|
8
|
+
parsed = TTY::Markdown.parse(markdown)
|
9
|
+
expect(parsed).to eq("© 2018 by me and λ\n")
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe TTY::Markdown, 'header' do
|
4
|
+
it "converts top level header" do
|
5
|
+
parsed = TTY::Markdown.parse("#Header1")
|
6
|
+
|
7
|
+
expect(parsed).to eq("\e[36;1;4mHeader1\e[0m\n")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "converts headers" do
|
11
|
+
headers =<<-TEXT
|
12
|
+
# Header1
|
13
|
+
header1 content
|
14
|
+
|
15
|
+
## Header2
|
16
|
+
header2 content
|
17
|
+
|
18
|
+
### Header3
|
19
|
+
header3 content
|
20
|
+
TEXT
|
21
|
+
parsed = TTY::Markdown.parse(headers)
|
22
|
+
|
23
|
+
expect(parsed).to eq([
|
24
|
+
"\e[36;1;4mHeader1\e[0m",
|
25
|
+
"header1 content",
|
26
|
+
"",
|
27
|
+
" \e[36;1mHeader2\e[0m",
|
28
|
+
" header2 content",
|
29
|
+
"",
|
30
|
+
" \e[36;1mHeader3\e[0m",
|
31
|
+
" header3 content\n"
|
32
|
+
].join("\n"))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe TTY::Markdown, 'horizontal rule' do
|
4
|
+
let(:symbols) { TTY::Markdown.symbols }
|
5
|
+
|
6
|
+
it "draws a horizontal rule" do
|
7
|
+
markdown =<<-TEXT
|
8
|
+
---
|
9
|
+
TEXT
|
10
|
+
parsed = TTY::Markdown.parse(markdown, width: 10)
|
11
|
+
expect(parsed).to eq("\e[33m#{symbols[:diamond]}#{symbols[:line]*8}#{symbols[:diamond]}\e[0m\n")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "draws a horizontal rule within header indentation" do
|
15
|
+
markdown =<<-TEXT
|
16
|
+
### header
|
17
|
+
---
|
18
|
+
TEXT
|
19
|
+
parsed = TTY::Markdown.parse(markdown, width: 20)
|
20
|
+
expect(parsed).to eq([
|
21
|
+
" \e[36;1mheader\e[0m\n",
|
22
|
+
" \e[33m#{symbols[:diamond]}#{symbols[:line]*10}#{symbols[:diamond]}\e[0m\n"
|
23
|
+
].join)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe TTY::Markdown, 'link' do
|
4
|
+
let(:symbols) { TTY::Markdown.symbols }
|
5
|
+
|
6
|
+
it "converts link" do
|
7
|
+
markdown =<<-TEXT
|
8
|
+
[I'm an inline-style link](https://www.google.com)
|
9
|
+
TEXT
|
10
|
+
parsed = TTY::Markdown.parse(markdown)
|
11
|
+
expect(parsed).to eq([
|
12
|
+
"I#{symbols[:rsquo]}m an inline-style link #{symbols[:arrow]} \e[33;4mhttps://www.google.com\e[0m\n"
|
13
|
+
].join)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "converts link with title" do
|
17
|
+
markdown =<<-TEXT
|
18
|
+
[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
|
19
|
+
TEXT
|
20
|
+
parsed = TTY::Markdown.parse(markdown)
|
21
|
+
expect(parsed).to eq([
|
22
|
+
"Google's Homepage #{symbols[:arrow]} \e[33;4mhttps://www.google.com\e[0m\n"
|
23
|
+
].join)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe TTY::Markdown, 'list' do
|
4
|
+
let(:symbols) { TTY::Markdown.symbols }
|
5
|
+
let(:pastel) { Pastel.new}
|
6
|
+
|
7
|
+
it "converts unordered bulleted lists of nested items" do
|
8
|
+
markdown =<<-TEXT
|
9
|
+
- Item 1
|
10
|
+
- Item 2
|
11
|
+
- Item 3
|
12
|
+
- Item 4
|
13
|
+
- Item 5
|
14
|
+
- Item 6
|
15
|
+
TEXT
|
16
|
+
parsed = TTY::Markdown.parse(markdown)
|
17
|
+
expect(parsed).to eq([
|
18
|
+
"#{pastel.yellow(symbols[:bullet])} Item 1",
|
19
|
+
" #{pastel.yellow(symbols[:bullet])} Item 2",
|
20
|
+
" #{pastel.yellow(symbols[:bullet])} Item 3",
|
21
|
+
" #{pastel.yellow(symbols[:bullet])} Item 4",
|
22
|
+
" #{pastel.yellow(symbols[:bullet])} Item 5",
|
23
|
+
"#{pastel.yellow(symbols[:bullet])} Item 6\n"
|
24
|
+
].join("\n"))
|
25
|
+
end
|
26
|
+
|
27
|
+
it "indents unordered list" do
|
28
|
+
markdown =<<-TEXT
|
29
|
+
### header
|
30
|
+
- Item 1
|
31
|
+
- Item 2
|
32
|
+
- Item 3
|
33
|
+
- Item 4
|
34
|
+
- Item 5
|
35
|
+
- Item 6
|
36
|
+
TEXT
|
37
|
+
parsed = TTY::Markdown.parse(markdown)
|
38
|
+
expect(parsed).to eq([
|
39
|
+
" \e[36;1mheader\e[0m",
|
40
|
+
" #{pastel.yellow(symbols[:bullet])} Item 1",
|
41
|
+
" #{pastel.yellow(symbols[:bullet])} Item 2",
|
42
|
+
" #{pastel.yellow(symbols[:bullet])} Item 3",
|
43
|
+
" #{pastel.yellow(symbols[:bullet])} Item 4",
|
44
|
+
" #{pastel.yellow(symbols[:bullet])} Item 5",
|
45
|
+
" #{pastel.yellow(symbols[:bullet])} Item 6\n"
|
46
|
+
].join("\n"))
|
47
|
+
end
|
48
|
+
|
49
|
+
it "indents unordered list with multiline content" do
|
50
|
+
markdown =<<-TEXT
|
51
|
+
### header
|
52
|
+
- First multiline
|
53
|
+
Item 1
|
54
|
+
- Second multiline
|
55
|
+
Item 2
|
56
|
+
- Item 3
|
57
|
+
- Item 4
|
58
|
+
TEXT
|
59
|
+
parsed = TTY::Markdown.parse(markdown)
|
60
|
+
expect(parsed).to eq([
|
61
|
+
" \e[36;1mheader\e[0m",
|
62
|
+
" #{pastel.yellow(symbols[:bullet])} First multiline",
|
63
|
+
" Item 1",
|
64
|
+
" #{pastel.yellow(symbols[:bullet])} Second multiline",
|
65
|
+
" Item 2",
|
66
|
+
" #{pastel.yellow(symbols[:bullet])} Item 3",
|
67
|
+
" #{pastel.yellow(symbols[:bullet])} Item 4\n",
|
68
|
+
].join("\n"))
|
69
|
+
end
|
70
|
+
|
71
|
+
it "convert ordered numbered list of nested items" do
|
72
|
+
markdown =<<-TEXT
|
73
|
+
1. Item 1
|
74
|
+
2. Item 2
|
75
|
+
3. Item 3
|
76
|
+
4. Item 4
|
77
|
+
5. Item 5
|
78
|
+
6. Item 6
|
79
|
+
TEXT
|
80
|
+
parsed = TTY::Markdown.parse(markdown)
|
81
|
+
expect(parsed).to eq([
|
82
|
+
"#{pastel.yellow('1.')} Item 1",
|
83
|
+
" #{pastel.yellow('1.')} Item 2",
|
84
|
+
" #{pastel.yellow('2.')} Item 3",
|
85
|
+
" #{pastel.yellow('1.')} Item 4",
|
86
|
+
" #{pastel.yellow('2.')} Item 5",
|
87
|
+
"#{pastel.yellow('2.')} Item 6\n"
|
88
|
+
].join("\n"))
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,37 @@
|
|
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
|
@@ -0,0 +1,38 @@
|
|
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
|
@@ -0,0 +1,164 @@
|
|
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
|
@@ -0,0 +1,20 @@
|
|
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
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tty-markdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Murach
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -44,56 +44,56 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.
|
47
|
+
version: '3.3'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.
|
54
|
+
version: '3.3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: strings
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.1.
|
61
|
+
version: 0.1.4
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.1.
|
68
|
+
version: 0.1.4
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: tty-color
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.4
|
75
|
+
version: '0.4'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.4
|
82
|
+
version: '0.4'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: tty-screen
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.6
|
89
|
+
version: '0.6'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.6
|
96
|
+
version: '0.6'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: bundler
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,16 +142,10 @@ executables: []
|
|
142
142
|
extensions: []
|
143
143
|
extra_rdoc_files: []
|
144
144
|
files:
|
145
|
-
- ".gitignore"
|
146
|
-
- ".rspec"
|
147
|
-
- ".travis.yml"
|
148
145
|
- CHANGELOG.md
|
149
|
-
- CODE_OF_CONDUCT.md
|
150
|
-
- Gemfile
|
151
146
|
- LICENSE.txt
|
152
147
|
- README.md
|
153
148
|
- Rakefile
|
154
|
-
- appveyor.yml
|
155
149
|
- assets/headers.png
|
156
150
|
- assets/hr.png
|
157
151
|
- assets/link.png
|
@@ -161,8 +155,6 @@ files:
|
|
161
155
|
- assets/table.png
|
162
156
|
- bin/console
|
163
157
|
- bin/setup
|
164
|
-
- examples/example.md
|
165
|
-
- examples/man.md
|
166
158
|
- examples/man.rb
|
167
159
|
- examples/marked.rb
|
168
160
|
- lib/tty-markdown.rb
|
@@ -170,10 +162,23 @@ files:
|
|
170
162
|
- lib/tty/markdown/parser.rb
|
171
163
|
- lib/tty/markdown/syntax_highlighter.rb
|
172
164
|
- lib/tty/markdown/version.rb
|
165
|
+
- spec/spec_helper.rb
|
166
|
+
- spec/unit/parse/abbrev_spec.rb
|
167
|
+
- spec/unit/parse/blockquote_spec.rb
|
168
|
+
- spec/unit/parse/codeblock_spec.rb
|
169
|
+
- spec/unit/parse/emphasis_spec.rb
|
170
|
+
- spec/unit/parse/entity_spec.rb
|
171
|
+
- spec/unit/parse/header_spec.rb
|
172
|
+
- spec/unit/parse/hr_spec.rb
|
173
|
+
- spec/unit/parse/link_spec.rb
|
174
|
+
- spec/unit/parse/list_spec.rb
|
175
|
+
- spec/unit/parse/math_spec.rb
|
176
|
+
- spec/unit/parse/paragraph_spec.rb
|
177
|
+
- spec/unit/parse/table_spec.rb
|
178
|
+
- spec/unit/parse/typography_spec.rb
|
173
179
|
- tasks/console.rake
|
174
180
|
- tasks/coverage.rake
|
175
181
|
- tasks/spec.rake
|
176
|
-
- tty-markdown.gemspec
|
177
182
|
homepage: https://piotrmurach.github.io/tty
|
178
183
|
licenses:
|
179
184
|
- MIT
|
@@ -194,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
199
|
version: '0'
|
195
200
|
requirements: []
|
196
201
|
rubyforge_project:
|
197
|
-
rubygems_version: 2.
|
202
|
+
rubygems_version: 2.7.3
|
198
203
|
signing_key:
|
199
204
|
specification_version: 4
|
200
205
|
summary: Convert a markdown text or document into a terminal friendly output.
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
---
|
2
|
-
language: ruby
|
3
|
-
sudo: false
|
4
|
-
cache: bundler
|
5
|
-
before_install: "gem update bundler"
|
6
|
-
script: "bundle exec rake ci"
|
7
|
-
rvm:
|
8
|
-
- 2.0.0
|
9
|
-
- 2.1.10
|
10
|
-
- 2.2.9
|
11
|
-
- 2.3.6
|
12
|
-
- 2.4.3
|
13
|
-
- 2.5.1
|
14
|
-
- ruby-head
|
15
|
-
- jruby-9000
|
16
|
-
- jruby-head
|
17
|
-
matrix:
|
18
|
-
allow_failures:
|
19
|
-
- rvm: ruby-head
|
20
|
-
- rvm: jruby-head
|
21
|
-
fast_finish: true
|
22
|
-
branches:
|
23
|
-
only: master
|
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
2
|
-
|
3
|
-
## Our Pledge
|
4
|
-
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
-
orientation.
|
11
|
-
|
12
|
-
## Our Standards
|
13
|
-
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
15
|
-
include:
|
16
|
-
|
17
|
-
* Using welcoming and inclusive language
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
19
|
-
* Gracefully accepting constructive criticism
|
20
|
-
* Focusing on what is best for the community
|
21
|
-
* Showing empathy towards other community members
|
22
|
-
|
23
|
-
Examples of unacceptable behavior by participants include:
|
24
|
-
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
-
advances
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
-
* Public or private harassment
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
30
|
-
address, without explicit permission
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
-
professional setting
|
33
|
-
|
34
|
-
## Our Responsibilities
|
35
|
-
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
38
|
-
response to any instances of unacceptable behavior.
|
39
|
-
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
-
threatening, offensive, or harmful.
|
45
|
-
|
46
|
-
## Scope
|
47
|
-
|
48
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
-
when an individual is representing the project or its community. Examples of
|
50
|
-
representing a project or community include using an official project e-mail
|
51
|
-
address, posting via an official social media account, or acting as an appointed
|
52
|
-
representative at an online or offline event. Representation of a project may be
|
53
|
-
further defined and clarified by project maintainers.
|
54
|
-
|
55
|
-
## Enforcement
|
56
|
-
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at [email]. All
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
63
|
-
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
66
|
-
members of the project's leadership.
|
67
|
-
|
68
|
-
## Attribution
|
69
|
-
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
-
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
-
|
73
|
-
[homepage]: http://contributor-covenant.org
|
74
|
-
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
|
-
|
5
|
-
gemspec
|
6
|
-
|
7
|
-
group :test do
|
8
|
-
gem 'benchmark-ips', '~> 2.7.2'
|
9
|
-
gem 'simplecov', '~> 0.14.1'
|
10
|
-
gem 'coveralls', '~> 0.8.21'
|
11
|
-
end
|
12
|
-
|
13
|
-
group :metrics do
|
14
|
-
gem 'yard', '~> 0.9.12'
|
15
|
-
gem 'yardstick', '~> 0.9.9'
|
16
|
-
end
|
data/appveyor.yml
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
---
|
2
|
-
install:
|
3
|
-
- SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
|
4
|
-
- ruby --version
|
5
|
-
- gem --version
|
6
|
-
- bundle install
|
7
|
-
build: off
|
8
|
-
test_script:
|
9
|
-
- bundle exec rake ci
|
10
|
-
environment:
|
11
|
-
matrix:
|
12
|
-
- ruby_version: "200"
|
13
|
-
- ruby_version: "200-x64"
|
14
|
-
- ruby_version: "21"
|
15
|
-
- ruby_version: "21-x64"
|
16
|
-
- ruby_version: "22"
|
17
|
-
- ruby_version: "22-x64"
|
18
|
-
- ruby_version: "23"
|
19
|
-
- ruby_version: "23-x64"
|
20
|
-
- ruby_version: "24"
|
21
|
-
- ruby_version: "24-x64"
|
22
|
-
- ruby_version: "25"
|
23
|
-
- ruby_version: "25-x64"
|
data/examples/example.md
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
|
2
|
-
TTY::Markdown
|
3
|
-
=============
|
4
|
-
|
5
|
-
**tty-markdown** converts markdown document into a terminal friendly output.
|
6
|
-
|
7
|
-
## Examples
|
8
|
-
|
9
|
-
### Nested list items
|
10
|
-
|
11
|
-
- Item 1
|
12
|
-
- Item 2
|
13
|
-
- Item 3
|
14
|
-
- Item 4
|
15
|
-
- Item 5
|
16
|
-
|
17
|
-
### Quote
|
18
|
-
|
19
|
-
> Blockquotes are very handy in email to emulate reply text.
|
20
|
-
> This line is part of the same quote.
|
21
|
-
> *Oh*, you can put **Markdown** into a blockquote.
|
22
|
-
|
23
|
-
### Codeblock
|
24
|
-
|
25
|
-
```ruby
|
26
|
-
class Greeter
|
27
|
-
def hello(name)
|
28
|
-
puts "Hello #{name}"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
```
|
32
|
-
|
33
|
-
### Table
|
34
|
-
|
35
|
-
| Tables | Are | Cool |
|
36
|
-
|----------|:-------------:|------:|
|
37
|
-
| col 1 is | left-aligned | $1600 |
|
38
|
-
| col 2 is | centered | $12 |
|
39
|
-
| col 3 is | right-aligned | $1 |
|
40
|
-
|
41
|
-
### Horizontal line
|
42
|
-
|
43
|
-
***
|
44
|
-
|
45
|
-
### Link
|
46
|
-
|
47
|
-
[I'm an inline-style link](https://www.google.com)
|
48
|
-
|
49
|
-
[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
|
data/examples/man.md
DELETED
data/tty-markdown.gemspec
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
lib = File.expand_path("../lib", __FILE__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require "tty/markdown/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "tty-markdown"
|
7
|
-
spec.version = TTY::Markdown::VERSION
|
8
|
-
spec.authors = ["Piotr Murach"]
|
9
|
-
spec.email = []
|
10
|
-
|
11
|
-
spec.summary = %q{Convert a markdown text or document into a terminal friendly output.}
|
12
|
-
spec.description = %q{Convert a markdown text or document into a terminal friendly output.}
|
13
|
-
spec.homepage = "https://piotrmurach.github.io/tty"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
-
f.match(%r{^(test|spec|features)/})
|
18
|
-
end
|
19
|
-
spec.bindir = "exe"
|
20
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
-
spec.require_paths = ["lib"]
|
22
|
-
|
23
|
-
spec.required_ruby_version = '>= 2.0.0'
|
24
|
-
|
25
|
-
spec.add_dependency "kramdown", '~> 1.16.2'
|
26
|
-
spec.add_dependency "pastel", '~> 0.7.2'
|
27
|
-
spec.add_dependency "rouge", '~> 3.1.0'
|
28
|
-
spec.add_dependency "strings", '~> 0.1.0'
|
29
|
-
spec.add_dependency "tty-color", '~> 0.4.2'
|
30
|
-
spec.add_dependency "tty-screen", '~> 0.6.4'
|
31
|
-
|
32
|
-
spec.add_development_dependency "bundler", "~> 1.16"
|
33
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
35
|
-
end
|