md-reader 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +21 -0
- data/README.md +48 -0
- data/lib/md_reader/version.rb +1 -1
- data/lib/md_reader.rb +30 -1
- data/md_reader.gemspec +2 -1
- metadata +18 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1d129588e696a1118fab3bad3aff52be9242166e569b964761dd5c41977c9681
|
|
4
|
+
data.tar.gz: 709f61a422b410476670404bb19bf0de5156a22ea96a69e2e8af48548eda22b0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 415e241c867f7b6ca05e8095334d8a44bf0215c98b0aa59d8c003a13fd3da464230b8aa5bacf177ac01bb0e275d089da614976acf19caa698919f665f06f704f
|
|
7
|
+
data.tar.gz: 80dd5f0f191deb6cdacb82cfa1f24f3a933ea1a0eae4a1125109d135071f063366c737c8f4e74940a97b420d302c9e178f4f5c77d411a2a4989277a096eaf0cf
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Italo Matos
|
|
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 all
|
|
13
|
+
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 THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# md-reader
|
|
2
|
+
|
|
3
|
+
[](https://rubygems.org/gems/md-reader)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
A simple Ruby gem that opens Markdown files in your browser as formatted HTML.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
gem install md-reader
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
md-reader README.md
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
That's it. The file opens in your default browser with GitHub-like styling.
|
|
21
|
+
|
|
22
|
+
## Features
|
|
23
|
+
|
|
24
|
+
- Syntax highlighting for fenced code blocks (Ruby, Python, JS, Go, and [200+ languages](https://rouge-ruby.github.io/docs/Rouge/Lexer.html))
|
|
25
|
+
- Tables, strikethrough, autolinks
|
|
26
|
+
- Blockquotes, footnotes
|
|
27
|
+
- Clean GitHub-inspired CSS — no external dependencies at runtime
|
|
28
|
+
- Temporary file is cleaned up automatically on exit
|
|
29
|
+
|
|
30
|
+
## Development
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
git clone https://github.com/italomatos/md-reader
|
|
34
|
+
cd md-reader
|
|
35
|
+
bundle install
|
|
36
|
+
bundle exec bin/md-reader test.md
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Contributing
|
|
40
|
+
|
|
41
|
+
1. Fork the repo
|
|
42
|
+
2. Create a feature branch (`git checkout -b feature/my-feature`)
|
|
43
|
+
3. Commit your changes
|
|
44
|
+
4. Open a Pull Request
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
|
|
48
|
+
MIT — see [LICENSE](LICENSE).
|
data/lib/md_reader/version.rb
CHANGED
data/lib/md_reader.rb
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "redcarpet"
|
|
4
|
+
require "rouge"
|
|
5
|
+
require "rouge/plugins/redcarpet"
|
|
4
6
|
require "md_reader/version"
|
|
5
7
|
|
|
6
8
|
module MdReader
|
|
9
|
+
class HTMLWithHighlight < Redcarpet::Render::HTML
|
|
10
|
+
include Rouge::Plugins::Redcarpet
|
|
11
|
+
end
|
|
12
|
+
|
|
7
13
|
class Converter
|
|
8
14
|
MARKDOWN_EXTENSIONS = {
|
|
9
15
|
fenced_code_blocks: true,
|
|
@@ -17,7 +23,7 @@ module MdReader
|
|
|
17
23
|
}.freeze
|
|
18
24
|
|
|
19
25
|
def call(content, title = "Document")
|
|
20
|
-
renderer =
|
|
26
|
+
renderer = HTMLWithHighlight.new(hard_wrap: true, with_toc_data: true)
|
|
21
27
|
markdown = Redcarpet::Markdown.new(renderer, MARKDOWN_EXTENSIONS)
|
|
22
28
|
body = markdown.render(content)
|
|
23
29
|
html_template(body, title)
|
|
@@ -25,6 +31,10 @@ module MdReader
|
|
|
25
31
|
|
|
26
32
|
private
|
|
27
33
|
|
|
34
|
+
def highlight_css
|
|
35
|
+
Rouge::Themes::Github.render(scope: ".highlight")
|
|
36
|
+
end
|
|
37
|
+
|
|
28
38
|
def html_template(body, title)
|
|
29
39
|
<<~HTML
|
|
30
40
|
<!DOCTYPE html>
|
|
@@ -87,6 +97,23 @@ module MdReader
|
|
|
87
97
|
font-size: 100%;
|
|
88
98
|
}
|
|
89
99
|
|
|
100
|
+
.highlight {
|
|
101
|
+
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
|
|
102
|
+
font-size: 85%;
|
|
103
|
+
background: #f6f8fa;
|
|
104
|
+
border-radius: 6px;
|
|
105
|
+
padding: 1rem;
|
|
106
|
+
overflow: auto;
|
|
107
|
+
line-height: 1.45;
|
|
108
|
+
margin-bottom: 1rem;
|
|
109
|
+
}
|
|
110
|
+
.highlight pre {
|
|
111
|
+
margin: 0;
|
|
112
|
+
padding: 0;
|
|
113
|
+
background: transparent;
|
|
114
|
+
border-radius: 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
90
117
|
blockquote {
|
|
91
118
|
margin: 0 0 1rem 0;
|
|
92
119
|
padding: 0 1em;
|
|
@@ -130,6 +157,8 @@ module MdReader
|
|
|
130
157
|
}
|
|
131
158
|
|
|
132
159
|
mark { background: #fff3b8; border-radius: 2px; padding: 0.1em 0.2em; }
|
|
160
|
+
|
|
161
|
+
#{highlight_css}
|
|
133
162
|
</style>
|
|
134
163
|
</head>
|
|
135
164
|
<body>
|
data/md_reader.gemspec
CHANGED
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
|
|
|
11
11
|
gem.email = ["italomatos@gmail.com"]
|
|
12
12
|
gem.license = "MIT"
|
|
13
13
|
|
|
14
|
-
gem.files = Dir["lib/**/*.rb"] + %w[md_reader.gemspec]
|
|
14
|
+
gem.files = Dir["lib/**/*.rb"] + %w[md_reader.gemspec README.md LICENSE]
|
|
15
15
|
gem.executables = ["md-reader"]
|
|
16
16
|
gem.require_paths = ["lib"]
|
|
17
17
|
|
|
@@ -19,4 +19,5 @@ Gem::Specification.new do |gem|
|
|
|
19
19
|
|
|
20
20
|
gem.add_dependency "redcarpet", "~> 3.6"
|
|
21
21
|
gem.add_dependency "launchy", "~> 2.5"
|
|
22
|
+
gem.add_dependency "rouge", "~> 4.0"
|
|
22
23
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: md-reader
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Italo Matos
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-06-
|
|
11
|
+
date: 2026-06-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: redcarpet
|
|
@@ -38,6 +38,20 @@ dependencies:
|
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '2.5'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rouge
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '4.0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '4.0'
|
|
41
55
|
description: Comando de terminal que converte Markdown em HTML com estilo GitHub e
|
|
42
56
|
abre no browser.
|
|
43
57
|
email:
|
|
@@ -47,6 +61,8 @@ executables:
|
|
|
47
61
|
extensions: []
|
|
48
62
|
extra_rdoc_files: []
|
|
49
63
|
files:
|
|
64
|
+
- LICENSE
|
|
65
|
+
- README.md
|
|
50
66
|
- bin/md-reader
|
|
51
67
|
- lib/md_reader.rb
|
|
52
68
|
- lib/md_reader/version.rb
|