tty-markdown 0.6.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea7da61bd62bfbf0bafb500dc1e5fb041e0c31f6707185c16de535b6f8ded6b3
4
- data.tar.gz: '09c0b125b0eb7f92282d2c190b0a436c999978e1cb8f5e8b0f86bf38ca262c26'
3
+ metadata.gz: 9d66f69be1b2127af4896ee71342a8be1ea8cf9dabcdceed64c696baf23121a8
4
+ data.tar.gz: 7e612092f8fa261a8ae1bff784d4a5f607882c417576978c4f18d8ef87bca9c8
5
5
  SHA512:
6
- metadata.gz: ff8630e97b4ac9107baf7ef9b7a3fdbff7efa27a54858d9eaca2fa5a21b5181119ab2d9d9c50d529c7438a746914ca8286803c47afa19d9e8dc7535ccd46f1bc
7
- data.tar.gz: 9efc7db6f92eca9d144a30a1457affac40a607658c3613d2bcef7c224c516d718fef3a1b8064cc534ddb67ec08945cd32c5feb01e3fc26a49e0940a7b8650f47
6
+ metadata.gz: 219503274cc89c967412401023b4fa194dc018538115d30d45cbe0ed3fb103dbe9f14dfefd29aeef3de03a9d87bcce5def305c9c9f69aeb4a59b171dd96313b5
7
+ data.tar.gz: 5587f2552f75db9e0a053cb7afe2975f5a984329f53d94f3c50868c8253daf3e8f5383c128d59307c782e7395934a58128d5c09d25ca739e02800f51e2694053
data/CHANGELOG.md CHANGED
@@ -1,5 +1,49 @@
1
1
  # Change log
2
2
 
3
+ ## [v0.7.1] - 2022-12-21
4
+
5
+ ### Changed
6
+ * Change the symbols option to accept string value
7
+
8
+ ### Fixed
9
+ * Fix the theme option to allow overriding specific markdown element styles
10
+
11
+ ## [v0.7.0] - 2020-09-03
12
+
13
+ ### Added
14
+ * Add converter for br element by @krage
15
+ * Add configuration of symbols by @krage
16
+ * Add definition list support
17
+ * Add table footer formatting
18
+ * Add formatting of image source location
19
+ * Add footnotes support
20
+ * Add XML comments support
21
+ * Add HTML div/i/em/b/strong/img/a element support
22
+ * Add color configuration setting
23
+
24
+ ### Changed
25
+ * Change #new to accept configuration options as keywords
26
+ * Display links with both label and optional title by @krage
27
+ * Display link without the label when label content is same as link target @krage
28
+ * Change hr formatting to be always full width
29
+ * Differentiate between span and block math elements
30
+ * Display abbreviation with its definition
31
+ * Improve performance by calculating table column widths and row heights only once
32
+ * Change to remove mailto: from email links for brevity @krage
33
+ * Change to update kramdown to support versions >= 1.16 and < 3.0
34
+ * Change to update pastel, tty-color & tty-screen dependencies
35
+ * Change HTML del element formatting to strikethrough
36
+ * Rename colors setting to mode
37
+
38
+ ### Fixed
39
+ * Fix break line handling by @krage
40
+ * Fix links handling by @krage
41
+ * Fix table formatting of empty cells
42
+ * Fix content wrapping to account for the current indentation
43
+ * Fix header wrapping
44
+ * Fix blockquote formatting of content with emphasised style or apostrophe
45
+ * Fix support for HTML del element
46
+
3
47
  ## [v0.6.0] - 2019-03-30
4
48
 
5
49
  ### Added
@@ -15,7 +59,7 @@
15
59
  ### Changed
16
60
  * Change gemspec to load files directly
17
61
  * Change to update rouge dependency
18
- * Change to relax constraings on tty-screen and tty-color
62
+ * Change to relax constraints on tty-screen and tty-color
19
63
 
20
64
  ## [v0.4.0] - 2018-06-20
21
65
 
@@ -54,7 +98,10 @@
54
98
 
55
99
  * Initial implementation and release
56
100
 
57
- [v0.6.0]: https://github.com/piotrmurach/tty-markdown/compare/v0.5.0...v0.6.0
101
+ [v0.7.1]: https://github.com/piotrmurach/tty-markdown/compare/v0.7.0...v0.7.1
102
+ [v0.7.0]: https://github.com/piotrmurach/tty-markdown/compare/v0.6.0...v0.7.0
103
+ [v0.6.0]: https://github.com/piotrmurach/tty-markdown/compare/v0.5.1...v0.6.0
104
+ [v0.5.1]: https://github.com/piotrmurach/tty-markdown/compare/v0.5.0...v0.5.1
58
105
  [v0.5.0]: https://github.com/piotrmurach/tty-markdown/compare/v0.4.0...v0.5.0
59
106
  [v0.4.0]: https://github.com/piotrmurach/tty-markdown/compare/v0.3.0...v0.4.0
60
107
  [v0.3.0]: https://github.com/piotrmurach/tty-markdown/compare/v0.2.0...v0.3.0
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 Piotr Murach
3
+ Copyright (c) 2018 Piotr Murach (piotrmurach.com)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,27 +1,26 @@
1
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>
2
+ <a href="https://ttytoolkit.org"><img width="130" src="https://github.com/piotrmurach/tty/raw/master/images/tty.png" alt="TTY Toolkit logo" /></a>
3
3
  </div>
4
4
 
5
5
  # TTY::Markdown [![Gitter](https://badges.gitter.im/Join%20Chat.svg)][gitter]
6
6
 
7
7
  [![Gem Version](https://badge.fury.io/rb/tty-markdown.svg)][gem]
8
- [![Build Status](https://secure.travis-ci.org/piotrmurach/tty-markdown.svg?branch=master)][travis]
8
+ [![Actions CI](https://github.com/piotrmurach/tty-markdown/workflows/CI/badge.svg?branch=master)][gh_actions_ci]
9
9
  [![Build status](https://ci.appveyor.com/api/projects/status/k4vub4koct329ggd?svg=true)][appveyor]
10
10
  [![Maintainability](https://api.codeclimate.com/v1/badges/1656060107c73ac42c2b/maintainability)][codeclimate]
11
11
  [![Coverage Status](https://coveralls.io/repos/github/piotrmurach/tty-markdown/badge.svg)][coverage]
12
- [![Inline docs](http://inch-ci.org/github/piotrmurach/tty-markdown.svg?branch=master)][inchpages]
12
+ [![Inline docs](https://inch-ci.org/github/piotrmurach/tty-markdown.svg?branch=master)][inchpages]
13
13
 
14
14
  [gitter]: https://gitter.im/piotrmurach/tty
15
- [gem]: http://badge.fury.io/rb/tty-markdown
16
- [travis]: http://travis-ci.org/piotrmurach/tty-markdown
15
+ [gem]: https://badge.fury.io/rb/tty-markdown
16
+ [gh_actions_ci]: https://github.com/piotrmurach/tty-markdown/actions?query=workflow%3ACI
17
17
  [appveyor]: https://ci.appveyor.com/project/piotrmurach/tty-markdown
18
18
  [codeclimate]: https://codeclimate.com/github/piotrmurach/tty-markdown/maintainability
19
19
  [coverage]: https://coveralls.io/github/piotrmurach/tty-markdown
20
- [inchpages]: http://inch-ci.org/github/piotrmurach/tty-markdown
20
+ [inchpages]: https://inch-ci.org/github/piotrmurach/tty-markdown
21
21
 
22
22
  > Convert a markdown document or text into a terminal friendly output.
23
23
 
24
-
25
24
  **TTY::Markdown** provides independent markdown processing component for [TTY](https://github.com/piotrmurach/tty) toolkit.
26
25
 
27
26
  ## Installation
@@ -45,15 +44,21 @@ Or install it yourself as:
45
44
  * [1. Usage](#1-usage)
46
45
  * [1.1 Header](#11-header)
47
46
  * [1.2 List](#12-list)
48
- * [1.3 Link](#13-link)
49
- * [1.4 Blockquote](#14-blockquote)
50
- * [1.5 Code and Syntax Highlighting](#15-code-and-syntax-highlighting)
51
- * [1.6 Table](#16-table)
52
- * [1.7 Horizontal Rule](#17-horizontal-rule)
47
+ * [1.3 Definition List](#13-definition-list)
48
+ * [1.4 Link](#14-link)
49
+ * [1.5 Blockquote](#15-blockquote)
50
+ * [1.6 Code and Syntax Highlighting](#16-code-and-syntax-highlighting)
51
+ * [1.7 Table](#17-table)
52
+ * [1.8 Horizontal Rule](#18-horizontal-rule)
53
+ * [1.9 Footnotes](#19-footnotes)
53
54
  * [2. Options](#2-options)
54
- * [2.1 :colors](#21-colors)
55
+ * [2.1 :mode](#21-mode)
55
56
  * [2.2 :theme](#22-theme)
56
57
  * [2.3 :width](#23-width)
58
+ * [2.4 :symbols](#24-symbols)
59
+ * [2.5 :indent](#25-indent)
60
+ * [2.6 :color](#26-color)
61
+ * [3. Command line tool](#3-command-line-tool)
57
62
 
58
63
  ## 1. Usage
59
64
 
@@ -74,6 +79,8 @@ puts parsed
74
79
 
75
80
  ### 1.1 Header
76
81
 
82
+ Parsing the following markdown headers:
83
+
77
84
  ```markdown
78
85
  TTY::Markdown
79
86
  =============
@@ -85,15 +92,9 @@ TTY::Markdown
85
92
  ### Nested list items
86
93
  ```
87
94
 
88
- and transforming it:
95
+ The terminal output looks like this:
89
96
 
90
- ```ruby
91
- parsed = TTY::Markdown.parse(markdown_string)
92
- ```
93
-
94
- `puts parsed` will output:
95
-
96
- ![Code highlight](https://cdn.rawgit.com/piotrmurach/tty-markdown/master/assets/headers.png)
97
+ ![Headers example](assets/headers.png)
97
98
 
98
99
  ### 1.2 List
99
100
 
@@ -107,29 +108,42 @@ Both numbered and unordered lists are supported. Given a markdown:
107
108
  - Item 5
108
109
  ```
109
110
 
110
- and transforming it:
111
+ The parsed output looks like this:
111
112
 
112
- ```ruby
113
- parsed = TTY::Markdown.parse(markdown_string)
113
+ ![Unordered list example](assets/list.png)
114
+
115
+ ### 1.3 Definition List
116
+
117
+ Given a definition list:
118
+
119
+ ```markdown
120
+ Item 1
121
+ : This is the description for Item 1
122
+
123
+ Item 2
124
+ : This is the description for Item 2
125
+ : This is another description for Item 2
114
126
  ```
115
127
 
116
- `puts parsed` will produce:
128
+ The parsed output looks like this:
117
129
 
118
- ![Code highlight](https://cdn.rawgit.com/piotrmurach/tty-markdown/master/assets/list.png)
130
+ ![Definition list example](assets/definition-list.png)
119
131
 
120
- ### 1.3 Link
132
+ ### 1.4 Link
121
133
 
122
- A mardown link:
134
+ A markdown link:
123
135
 
124
136
  ```markdown
125
- [I'm an inline-style link](https://www.google.com)
137
+ [An inline-style link](https://ttytoolkit.org)
138
+
139
+ [An inline-style link with title](https://ttytoolkit.org "TTY Toolkit Homepage")
126
140
  ```
127
141
 
128
- will be rendered with actual link content next to it:
142
+ The link text will be rendered with the link next to it:
129
143
 
130
- ![Code highlight](https://cdn.rawgit.com/piotrmurach/tty-markdown/master/assets/link.png)
144
+ ![Link example](assets/link.png)
131
145
 
132
- ### 1.4 Blockquote
146
+ ### 1.5 Blockquote
133
147
 
134
148
  Given a markdown quote:
135
149
 
@@ -139,19 +153,15 @@ Given a markdown quote:
139
153
  > *Oh*, you can put **Markdown** into a blockquote.
140
154
  ```
141
155
 
142
- and transforming it:
156
+ The rendered output looks like this:
143
157
 
144
- ```ruby
145
- parsed = TTY::Markdown.parse(markdown_string)
146
- ```
147
-
148
- `puts parsed` will output:
158
+ ![Blockquote example](assets/quote.png)
149
159
 
150
- ![Code highlight](https://cdn.rawgit.com/piotrmurach/tty-markdown/master/assets/quote.png)
160
+ ### 1.6 Code and Syntax Highlighting
151
161
 
152
- ### 1.5 Code and Syntax Highlighting
162
+ The parser can highlight syntax of many programming languages.
153
163
 
154
- The parser can highlight syntax of many programming languages. Given the markdown codeblock with language specification:
164
+ Given a markdown codeblock with a language specification:
155
165
 
156
166
  ````markdown
157
167
  ```ruby
@@ -163,17 +173,11 @@ end
163
173
  ```
164
174
  ````
165
175
 
166
- and converting this snippet:
167
-
168
- ```ruby
169
- parsed = TTY::Markdown.parse(code_snippet)
170
- ```
171
-
172
- `puts parsed` will produce:
176
+ The terminal output will look like this:
173
177
 
174
- ![Code highlight](https://cdn.rawgit.com/piotrmurach/tty-markdown/master/assets/syntax_highlight.png)
178
+ ![Code highlighting example](assets/codeblock.png)
175
179
 
176
- ### 1.6 Table
180
+ ### 1.7 Table
177
181
 
178
182
  You can transform tables which understand the markdown alignment.
179
183
 
@@ -187,17 +191,11 @@ For example, given the following table:
187
191
  | col 3 is | right-aligned | $1 |
188
192
  ```
189
193
 
190
- and transforming it:
194
+ Then the terminal output will look like this:
191
195
 
192
- ```ruby
193
- parsed = TTY::Markdown.parse(markdown_string)
194
- ```
195
-
196
- `puts parsed` will output:
197
-
198
- ![Code highlight](https://cdn.rawgit.com/piotrmurach/tty-markdown/master/assets/table.png)
196
+ ![Table example](assets/table.png)
199
197
 
200
- ### 1.7 Horizontal Rule
198
+ ### 1.8 Horizontal Rule
201
199
 
202
200
  You can specify a horizontal rule in markdown:
203
201
 
@@ -213,42 +211,66 @@ parsed = TTY::Markdown.parse(markdown_string)
213
211
 
214
212
  `puts parsed` will output:
215
213
 
216
- ![Code highlight](https://cdn.rawgit.com/piotrmurach/tty-markdown/master/assets/hr.png)
214
+ ![Horizontal rule example](assets/hr.png)
215
+
216
+ ### 1.9 Footnotes
217
+
218
+ You can create footnote references:
219
+
220
+ ```markdown
221
+ It is not down on any map[^foo]; true places[^bar] never are.
222
+
223
+ [^foo]: A diagrammatic representation of an area of land or sea.
224
+ [^bar]: A particular position, point, or area in space; a location.
225
+ ```
226
+
227
+ All footnotes will be displayed with a sequential number and rendered in the terminal like this:
228
+
229
+ ![Footnotes example](assets/footnotes.png)
217
230
 
218
231
  ## 2. Options
219
232
 
220
- ### 2.1 `:colors`
233
+ ### 2.1 `:mode`
221
234
 
222
- By default the `256` colors scheme is used to render code block elements. You can change that by specifying desired number of colors:
235
+ By default the `256` color scheme is used to render code block elements.
236
+
237
+ You can change this by specifying maximum number of colors to be `16` ANSI colors:
223
238
 
224
239
  ```ruby
225
- TTY::Markdown.pasre(markdown_string, colors: 16)
240
+ TTY::Markdown.parse(markdown_string, mode: 16)
226
241
  ```
227
242
 
228
- This feauture may be handy when working in terminals with limited color support. By default, **TTY::Markdown** detects your terminal color mode and adjusts output automatically.
243
+ This feature may be handy when working in terminals with limited color support.
244
+
245
+ By default, **TTY::Markdown** detects your terminal color mode and adjusts output automatically.
229
246
 
230
247
  ### 2.2 `:theme`
231
248
 
232
- A hash of styles that allows to customize specific elements of the markdown text. By default the following styles are used:
249
+ Use the `:theme` option to change specific markdown element styles.
250
+
251
+ For example, to override styles for the `link` and `list` elements do:
233
252
 
234
253
  ```ruby
235
- THEME = {
236
- em: :yellow,
237
- header: [:cyan, :bold],
238
- hr: :yellow,
239
- link: [:yellow, :underline],
240
- list: :yellow,
241
- strong: [:yellow, :bold],
242
- table: :yellow,
243
- quote: :yellow,
244
- }
254
+ TTY::Markdown.parse(markdown_string, theme: {link: :magenta, list: %i[magenta bold]})
245
255
  ```
246
256
 
247
- In order to provide new styles use `:theme` key:
257
+ Here's a complete list of element names with corresponding styles:
248
258
 
249
- ```ruby
250
- TTY::Markdown.parse(markdown_string, theme: { ... })
251
- ```
259
+ | Name | Style |
260
+ |------------|-------------------------|
261
+ | `:comment` | `:bright_black` |
262
+ | `:em` | `:yellow` |
263
+ | `:header` | `%i[cyan bold]` |
264
+ | `:hr` | `:yellow` |
265
+ | `:image` | `:bright_black` |
266
+ | `:link` | `%i[yellow underline]` |
267
+ | `:list` | `:yellow` |
268
+ | `:note` | `:yellow` |
269
+ | `:quote` | `:yellow` |
270
+ | `:strong` | `%i[yellow bold]` |
271
+ | `:table` | `:yellow` |
272
+
273
+ Read [pastel documentation](https://github.com/piotrmurach/pastel#3-supported-colors) for all supported styles.
252
274
 
253
275
  ### 2.3 `:width`
254
276
 
@@ -260,6 +282,80 @@ TTY::Markdown.parse(markdown_string, width: 80)
260
282
 
261
283
  By default the terminal screen width is used.
262
284
 
285
+ ### 2.4 `:symbols`
286
+
287
+ By default formatting will include various Unicode symbols. You can switch to an included ASCII set and/or override individually with the `:symbols` key:
288
+
289
+ ```ruby
290
+ TTY::Markdown.parse(markdown_string, symbols: :ascii)
291
+ TTY::Markdown.parse(markdown_string, symbols: {base: :ascii})
292
+ TTY::Markdown.parse(markdown_string, symbols: {override: {bullet: "x"}})
293
+ ```
294
+
295
+ Here's a complete list of symbol names with corresponding ASCII and Unicode characters:
296
+
297
+ | Name | ASCII | Unicode |
298
+ |------------------|-------|---------|
299
+ | `:arrow` | `->` | `»` |
300
+ | `:bar` | `\|` | `┃` |
301
+ | `:bottom_center` | `+` | `┴` |
302
+ | `:bottom_left` | `+` | `└` |
303
+ | `:bottom_right` | `+` | `┘` |
304
+ | `:bracket_left` | `[` | `[` |
305
+ | `:bracket_right` | `]` | `]` |
306
+ | `:bullet` | `*` | `●` |
307
+ | `:diamond` | `*` | `◈` |
308
+ | `:hash` | `#` | `#` |
309
+ | `:hellip` | `...` | `…` |
310
+ | `:laquo` | `<<` | `«` |
311
+ | `:laquo_space` | `<< ` | `« ` |
312
+ | `:ldquo` | `"` | `“` |
313
+ | `:lsquo` | `"` | `‘` |
314
+ | `:line` | `-` | `─` |
315
+ | `:mdash` | `-` | `—` |
316
+ | `:mid_center` | `+` | `┼` |
317
+ | `:mid_left` | `+` | `├` |
318
+ | `:mid_right` | `+` | `┤` |
319
+ | `:ndash` | `-` | `-` |
320
+ | `:paren_left` | `(` | `(` |
321
+ | `:paren_right` | `)` | `)` |
322
+ | `:pipe` | `\|` | `│` |
323
+ | `:raquo` | `>>` | `»` |
324
+ | `:raquo_space` | ` >>` | ` »` |
325
+ | `:rdquo` | `"` | `”` |
326
+ | `:rsquo` | `"` | `’` |
327
+ | `:top_center` | `+` | `┬` |
328
+ | `:top_left` | `+` | `┌` |
329
+ | `:top_right` | `+` | `┐` |
330
+
331
+ ### 2.5 `:indent`
332
+
333
+ By default any content apart from the main `h1` header is indented with `2` spaces. Use `:indent` to provide custom indent or no indent at all:
334
+
335
+ ```ruby
336
+ TTY::Markdown.parse(markdown_string, indent: 0)
337
+ ```
338
+
339
+ ### 2.6 `:color`
340
+
341
+ You can control when to apply coloring to various document elements.
342
+
343
+ Valid values are `:never`, `:always` or `:auto`. By default `:auto` is used which auto detects if coloring can be applied.
344
+
345
+ For example, to always color content regardless of terminal support do:
346
+
347
+ ```ruby
348
+ TTY::Markdown.parse(markdown_string, color: :always)
349
+ ```
350
+
351
+ ### 3. Command line tool
352
+
353
+ You can install [tty-markdown-cli](https://github.com/piotrmurach/tty-markdown-cli) to use `tty-markdown` executable in terminal:
354
+
355
+ ```bash
356
+ $ tty-markdown README.md
357
+ ```
358
+
263
359
  ## Development
264
360
 
265
361
  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.
@@ -268,7 +364,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
268
364
 
269
365
  ## Contributing
270
366
 
271
- Bug reports and pull requests are welcome on GitHub at https://github.com/piotrmurach/tty-markdown. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
367
+ Bug reports and pull requests are welcome on GitHub at https://github.com/piotrmurach/tty-markdown. 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/blob/master/CODE_OF_CONDUCT.md).
272
368
 
273
369
  ## License
274
370