mdless 2.0.2 → 2.0.4
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/README.md +18 -11
- data/lib/mdless/console.rb +9 -8
- data/lib/mdless/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e50c4e915aa31ffff9b159763d18828ffb1f639588773b45a3aa7528a897cf3
|
4
|
+
data.tar.gz: b6de738b4cd1f6fd6aa208d4a6607354faa143a5a7f2943147f2a244ba9204b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7df9141901628641895a5d3ac76d37c5af99c30cc94f8fd7e2a1e506b62e9da48267c8173418de66fe139456b120e3b082437d497eb32609a2e4105b1bfa969e
|
7
|
+
data.tar.gz: eabe40a67402c2a9db8488f74b33b7d48295190e6788690375f71a121b934a6659b10e3c8d8e05c5ae9b1de0aa791ea5d405cf85340c913d317e2d3f50fb7392
|
data/README.md
CHANGED
@@ -16,10 +16,8 @@ I often use iTerm2 in visor mode, so `qlmanage -p` is annoying. I still wanted a
|
|
16
16
|
- Colorize Markdown syntax for most elements
|
17
17
|
- Normalize spacing and link formatting
|
18
18
|
- Display footnotes after each paragraph
|
19
|
-
- Inline image display (local, optionally remote)
|
19
|
+
- Inline image display (local, optionally remote) (with compatible tools like imgcat or chafa)
|
20
20
|
- Syntax highlighting when [Pygments](http://pygments.org/) is installed
|
21
|
-
- Only fenced code with a language defined (e.g. `python`) will be highlighted
|
22
|
-
- Languages can also be determined by hashbang in the code block
|
23
21
|
- List headlines in document
|
24
22
|
- Display single section of the document based on headlines
|
25
23
|
- Customizable colors
|
@@ -29,6 +27,8 @@ I often use iTerm2 in visor mode, so `qlmanage -p` is annoying. I still wanted a
|
|
29
27
|
|
30
28
|
gem install mdless
|
31
29
|
|
30
|
+
If you run into errors, try `gem install --user-install mdless`, or `sudo gem install mdless` (in that order).
|
31
|
+
|
32
32
|
### Dependencies
|
33
33
|
|
34
34
|
Some OSs are missing `tput`, which is necessary for mdless.
|
@@ -37,16 +37,17 @@ Some OSs are missing `tput`, which is necessary for mdless.
|
|
37
37
|
apt install ruby ncurses-utils
|
38
38
|
gem install mdless
|
39
39
|
|
40
|
+
To render images, you need `imgcat` or `chafa` installed (`brew install chafa`).
|
41
|
+
|
42
|
+
For syntax highlighting, the `pygmentize` command must be available, part of the [Pygments](http://pygments.org/) package (`brew install pygments`).
|
43
|
+
|
40
44
|
## Usage
|
41
45
|
|
42
46
|
`mdless [options] path` or `cat [path] | mdless`
|
43
47
|
|
44
48
|
The pager used is determined by system configuration in this order of preference:
|
45
49
|
|
46
|
-
* `$GIT_PAGER`
|
47
50
|
* `$PAGER`
|
48
|
-
* `git config --get-all core.pager`
|
49
|
-
* `bat`
|
50
51
|
* `less`
|
51
52
|
* `more`
|
52
53
|
* `cat`
|
@@ -55,18 +56,24 @@ The pager used is determined by system configuration in this order of preference
|
|
55
56
|
### Options
|
56
57
|
|
57
58
|
-c, --[no-]color Colorize output (default on)
|
58
|
-
-d, --debug LEVEL Level of debug messages to output
|
59
|
+
-d, --debug LEVEL Level of debug messages to output (1-4, 4 to see all messages)
|
59
60
|
-h, --help Display this screen
|
60
|
-
-i, --images=TYPE Include [local|remote (both)] images in output (requires
|
61
|
-
-I, --all-images Include local and remote images in output (requires imgcat
|
61
|
+
-i, --images=TYPE Include [local|remote (both)] images in output (requires chafa or imgcat, default NONE).
|
62
|
+
-I, --all-images Include local and remote images in output (requires imgcat or chafa)
|
63
|
+
--syntax Syntax highlight code blocks
|
62
64
|
--links=FORMAT Link style ([inline, reference], default inline) [NOT CURRENTLY IMPLEMENTED]
|
63
65
|
-l, --list List headers in document and exit
|
64
66
|
-p, --[no-]pager Formatted output to pager (default on)
|
65
67
|
-P Disable pager (same as --no-pager)
|
66
|
-
-s, --section=NUMBER
|
68
|
+
-s, --section=NUMBER[,NUMBER] Output only a headline-based section of the input (numeric from --list)
|
67
69
|
-t, --theme=THEME_NAME Specify an alternate color theme to load
|
68
70
|
-v, --version Display version number
|
69
|
-
-w, --width=COLUMNS Column width to format for (default terminal width)
|
71
|
+
-w, --width=COLUMNS Column width to format for (default: terminal width)
|
72
|
+
--[no-]inline_footnotes Display footnotes immediately after the paragraph that references them
|
73
|
+
|
74
|
+
## Configuration
|
75
|
+
|
76
|
+
The first time mdless is run, a config file will be written to `~/.config/mdless/config.yml`, based on the command line options used on the first run. Update that file to make any options permanent (config options will always be overridden by command line flags).
|
70
77
|
|
71
78
|
## Customization
|
72
79
|
|
data/lib/mdless/console.rb
CHANGED
@@ -8,6 +8,7 @@ module Redcarpet
|
|
8
8
|
@@listitemid = 0
|
9
9
|
@@listid = 0
|
10
10
|
@@footnotes = []
|
11
|
+
@@headers = []
|
11
12
|
|
12
13
|
def xc
|
13
14
|
x + color('text')
|
@@ -491,12 +492,12 @@ module Redcarpet
|
|
491
492
|
indent -= outdent
|
492
493
|
"#{' ' * indent}#{l}"
|
493
494
|
end.join("\n"), indent)
|
494
|
-
end
|
495
|
+
end + "\n"
|
495
496
|
end
|
496
497
|
|
497
498
|
def get_headers(input)
|
498
|
-
unless
|
499
|
-
|
499
|
+
unless @@headers && !@@headers.empty?
|
500
|
+
@@headers = []
|
500
501
|
headers = input.scan(/^((?!#!)(\#{1,6})\s*([^#]+?)(?: #+)?\s*|(\S.+)\n([=-]+))$/i)
|
501
502
|
|
502
503
|
headers.each do |h|
|
@@ -512,7 +513,7 @@ module Redcarpet
|
|
512
513
|
hlevel = h[1].length
|
513
514
|
title = h[2]
|
514
515
|
end
|
515
|
-
|
516
|
+
@@headers << [
|
516
517
|
'#' * hlevel,
|
517
518
|
title,
|
518
519
|
h[0]
|
@@ -520,7 +521,7 @@ module Redcarpet
|
|
520
521
|
end
|
521
522
|
end
|
522
523
|
|
523
|
-
|
524
|
+
@@headers
|
524
525
|
end
|
525
526
|
|
526
527
|
def preprocess(input)
|
@@ -545,7 +546,7 @@ module Redcarpet
|
|
545
546
|
end
|
546
547
|
end
|
547
548
|
|
548
|
-
if !in_yaml && input.gsub(/\n/, ' ') =~ /(?i-m)
|
549
|
+
if !in_yaml && input.gsub(/\n/, ' ') =~ /(?i-m)^[\w ]+:\s+\S+/
|
549
550
|
@log.info('Found MMD Headers')
|
550
551
|
input.sub!(/(?i-m)^([\S ]+:[\s\S]*?)+(?=\n\n)/) do |mmd|
|
551
552
|
mmd.split(/\n/).map do |line|
|
@@ -562,7 +563,7 @@ module Redcarpet
|
|
562
563
|
input.gsub!(/^([^\n]+)\n={3,}\s*$/m, "# \\1\n")
|
563
564
|
input.gsub!(/^([^\n]+?)\n-{3,}\s*$/m, "## \\1\n")
|
564
565
|
|
565
|
-
|
566
|
+
@@headers = get_headers(input)
|
566
567
|
|
567
568
|
if @options[:section]
|
568
569
|
new_content = []
|
@@ -581,7 +582,7 @@ module Redcarpet
|
|
581
582
|
in_section = false
|
582
583
|
break
|
583
584
|
end
|
584
|
-
elsif title.downcase ==
|
585
|
+
elsif title.downcase == @@headers[sect - 1][1].downcase
|
585
586
|
in_section = true
|
586
587
|
top_level = level + 1
|
587
588
|
new_content.push(graf)
|
data/lib/mdless/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mdless
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Terpstra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redcarpet
|