tty-markdown-cli 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fa41056d9d94df9f144f850544da70e883f56f0ef1b00ded5ba88a70c013c60e
4
+ data.tar.gz: 3d46cbb83ac6247c66a6af588d5ed1ce46d5eee8c74a0db1233575159ca61ba3
5
+ SHA512:
6
+ metadata.gz: 2784a6a63b9a3a54440baacf19d5de3b1d107337c9a248158e3ce4cd24f2e485e00907cdf086c26c657f19a7fa979b25f931d5b67f82a4c9b5f94e84daf2d4be
7
+ data.tar.gz: 9c5cb653f168db88a2fe1b325a884ebf0994edae6049ca09d1defc4638cd6e224cfb077d2554763473bf9c418099f21e0d2495899725c02775049516a0af3667
@@ -0,0 +1,7 @@
1
+ # Change log
2
+
3
+ ## [v0.1.0] - 2020-09-03
4
+
5
+ Initial release
6
+
7
+ [v0.1.0]: https://github.com/piotrmurach/tty-markdown-cli/compare/v0.1.0
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Piotr Murach (piotrmurach.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,99 @@
1
+ # TTY::Markdown CLI
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/tty-markdown-cli.svg)][gem]
4
+ [![Build Status](https://secure.travis-ci.org/piotrmurach/tty-markdown-cli.svg?branch=master)][travis]
5
+ [![Build status](https://ci.appveyor.com/api/projects/status/3i2mn2nh9hq1cag2?svg=true)][appveyor]
6
+
7
+ [gem]: http://badge.fury.io/rb/tty-markdown-cli
8
+ [travis]: http://travis-ci.org/piotrmurach/tty-markdown-cli
9
+ [appveyor]: https://ci.appveyor.com/project/piotrmurach/tty-markdown-cli
10
+
11
+ > CLI tool for displaying Markdown documents in a nicely formatted terminal output.
12
+
13
+ **TTY::Markdown CLI** provides cli for [TTY::Markdown](https://github.com/piotrmurach/tty-markdown)
14
+
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ ```ruby
20
+ gem "tty-markdown-cli"
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ $ bundle install
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install tty-markdown-cli
30
+
31
+ ## Usage
32
+
33
+ Run `tty-markdown` with `-h` or `--help` options to print help information:
34
+
35
+ ```bash
36
+ $ tty-markdown --help
37
+ ```
38
+
39
+ To preview a Markdown document like this `README.md`:
40
+
41
+ ```bash
42
+ $ tty-markdown README.md
43
+ ```
44
+
45
+ To pipe a Markdown document like this `README.md` file:
46
+
47
+ ```bash
48
+ $ cat README.md | tty-markdown
49
+ ```
50
+
51
+ By default `UTF-8` symbols are used to display terminal output but you can fallback on more widely supported `ASCII` set with `-a/--ascii`:
52
+
53
+ ```bash
54
+ $ tty-markdown -a README.md
55
+ $ tty-markdown --ascii README.md
56
+ ```
57
+
58
+ Further, you can control the amount of indentation with `-i/--indent` option. By default 2 spaces are used but you can, for example, remove any indentation:
59
+
60
+ ```bash
61
+ $ tty-markdown -i 0 README.md
62
+ $ tty-markdown --indent 0 README.md
63
+ ```
64
+
65
+ You can also use `-w/--width` option to specify the maximum output width. By default the output will span the full terminal width. To make output wrap around `80` characters do:
66
+
67
+ ```bash
68
+ $ tty-markdown -w 80 README.md
69
+ $ tty-markdown --width 80 README.md
70
+ ```
71
+
72
+ To control output coloring, use `-c/--color` option with `always`, `never` or `auto`:
73
+
74
+ ```bash
75
+ $ tty-markdown -c always README
76
+ $ tty-markdown --color always README
77
+ ```
78
+
79
+ ## Development
80
+
81
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
82
+
83
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
84
+
85
+ ## Contributing
86
+
87
+ Bug reports and pull requests are welcome on GitHub at https://github.com/piotrmurach/tty-markdown-cli. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/piotrmurach/tty-markdown-cli/blob/master/CODE_OF_CONDUCT.md).
88
+
89
+ ## License
90
+
91
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
92
+
93
+ ## Code of Conduct
94
+
95
+ Everyone interacting in the `tty-markdown-cli` project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/piotrmurach/tty-markdown-cli/blob/master/CODE_OF_CONDUCT.md).
96
+
97
+ ## Copyright
98
+
99
+ Copyright (c) 2020 Piotr Murach (piotrmurach.com). See LICENSE for further details.
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ Signal.trap("INT") { exit 1 }
4
+
5
+ require "optparse"
6
+ require "tty-markdown"
7
+
8
+ options = {}
9
+
10
+ ARGV << "-h" if ARGV.empty? && $stdin.tty?
11
+
12
+ parser = OptionParser.new do |opts|
13
+ opts.banner = "Usage: #{::File.basename($0)} [options] [file]"
14
+
15
+ opts.on("-a", "--ascii", "Use ASCII symbols (default UTF-8)") do
16
+ options[:symbols] = :ascii
17
+ end
18
+
19
+ opts.on("-m n", "--mode n", "Maximum number of colors (default auto detect)") do |n|
20
+ options[:mode] = n.to_i
21
+ end
22
+
23
+ opts.on("-c when", "--color when",
24
+ "When to color content. Valid values are never, " \
25
+ "always or auto. (default auto)") do |w|
26
+ options[:color] = w
27
+ end
28
+
29
+ opts.on("-i n", "--indent n", "Indentation amount (default 2 spaces)") do |n|
30
+ options[:indent] = n.to_i
31
+ end
32
+
33
+ opts.on("-w n", "--width n", "Maximum output width (default full terminal)") do |n|
34
+ options[:width] = n.to_i
35
+ end
36
+
37
+ opts.on("-h", "--help", "Display help" ) do
38
+ puts opts
39
+ exit
40
+ end
41
+
42
+ opts.on("-v", "--version", "Display the version") do
43
+ puts "0.1.0 (tty-markdown #{TTY::Markdown::VERSION})"
44
+ exit
45
+ end
46
+ end
47
+
48
+ begin
49
+ parser.parse!
50
+ rescue OptionParser::ParseError => error
51
+ $stderr.puts error.message
52
+ exit 1
53
+ end
54
+
55
+ text = ARGV[0] ? ARGV.pop : $stdin.read
56
+
57
+ if ::File.file?(text)
58
+ print TTY::Markdown.parse_file(text, **options)
59
+ else
60
+ print TTY::Markdown.parse(text, **options)
61
+ end
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ load File.expand_path("tty-markdown", __dir__)
@@ -0,0 +1,47 @@
1
+ .\" generated by kramdown
2
+ .TH "TTY\-MARKDOWN" "1"
3
+ .SH "NAME"
4
+ \fBtty\-markdown\fP \- display Markdown documents in a nicely formatted terminal output
5
+ .SH "SYNOPSIS"
6
+ \fBtty\-markdown\fP [options] [file]
7
+ .SH "DESCRIPTION"
8
+ The \fBtty\-markdown\fP utility displays Markdown documents in a nicely formatted terminal output\.
9
+ .P
10
+ The options are as follows:
11
+ .TP
12
+ \fB\-a\fP, \fB\-\-ascii\fP
13
+ Use ASCII symbols\.
14
+ .TP
15
+ \fB\-c when\fP, \fB\-\-color when\fP
16
+ When to color content\. Valid values are \fBnever\fP, \fBalways\fP or \fBauto\fP\&\. (default auto)
17
+ .TP
18
+ \fB\-i n\fP, \fB\-\-indent n\fP
19
+ Indentation amount (default 2 spaces)\.
20
+ .TP
21
+ \fB\-m n\fP, \fB\-\-mode n\fP
22
+ Maximum number of colors supported by the terminal (default auto detect)\.
23
+ .TP
24
+ \fB\-w n\fP, \fB\-\-width n\fP
25
+ Maximum output width (default full terminal width)\.
26
+ .TP
27
+ \fB\-h\fP, \fB\-\-help\fP
28
+ Print the synopsis and list all available options
29
+ .TP
30
+ \fB\-v\fP, \fB\-\-version\fP
31
+ Print the tool version and the tty\-markdown version its using\.
32
+ .SH "EXAMPLES"
33
+ Print a Markdown document to the standard output using ASCII symbol set:
34
+ .P
35
+ \fB tty\-markdown \-a README\.md \fP
36
+ .P
37
+ Read a Markdown content and print it to the standard output at maximum width of 80 characters:
38
+ .P
39
+ \fB cat README\.md | tty\-markdown \-\-width 80 \fP
40
+ .SH "EXIT STATUS"
41
+ The \fBtty\-markdown\fP utility exits 0 on success, and 1 if an error occurs\.
42
+ .SH "SEE ALSO"
43
+ The \fBtty\-markdown\fP readme https://github\.com/piotrmurach/tty\-markdown
44
+ .SH "AUTHOR"
45
+ The \fBtty\-markdown\fP utility is written by Piotr Murach <piotr@piotrmurach\.com>
46
+ .P
47
+ Website: https://ttytoolkit\.org
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tty-markdown-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Piotr Murach
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-09-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tty-markdown
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: kramdown
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.16.2
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.16.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: A command-line tool for displaying Markdown documents in a nicely fromatted
70
+ terminal output.
71
+ email:
72
+ - piotr@piotrmurach.com
73
+ executables:
74
+ - tty-markdown
75
+ - ttymarkdown
76
+ extensions: []
77
+ extra_rdoc_files:
78
+ - README.md
79
+ - CHANGELOG.md
80
+ - LICENSE.txt
81
+ files:
82
+ - CHANGELOG.md
83
+ - LICENSE.txt
84
+ - README.md
85
+ - exe/tty-markdown
86
+ - exe/ttymarkdown
87
+ - man/tty-markdown.1
88
+ homepage: https://ttytoolkit.org
89
+ licenses:
90
+ - MIT
91
+ metadata:
92
+ allowed_push_host: https://rubygems.org
93
+ bug_tracker_uri: https://github.com/piotrmurach/tty-markdown-cli/issues
94
+ changelog_uri: https://github.com/piotrmurach/tty-markdown-cli/blob/master/CHANGELOG.md
95
+ documentation_uri: https://www.rubydoc.info/gems/tty-markdown-cli
96
+ homepage_uri: https://ttytoolkit.org
97
+ source_code_uri: https://github.com/piotrmurach/tty-markdown-cli
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 2.0.0
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubygems_version: 3.1.2
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: A command-line tool for displaying Markdown documents in a nicely formatted
117
+ terminal output.
118
+ test_files: []