mdless 2.0.2 → 2.0.3

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: 8cc069a55f00ad3b4165a8001caac96382742d1cb653ceb20b45402a76d2ec22
4
- data.tar.gz: 1e9749a769176d7c9513c61d5edf51332525282e4067a4b63612028d05f89a3d
3
+ metadata.gz: 5d7335d03b6ff9a4cd2453de9ecaf5eec3a60fe6dc10d2950cd7b33b298c2852
4
+ data.tar.gz: b83ff9e51541d1baebb07a747a369e5a90bc073fc590ff5620fa33a320ebb888
5
5
  SHA512:
6
- metadata.gz: ee64552eeb8c46715bcda2a3ce812affc8988837deacbc70fd856c426fc280108b561f5c2c005c2354cf02e1f09821441df8f0a1331bbf31c5c59e3991f73a70
7
- data.tar.gz: 409a8507a1e6419aa2e408872a16a68af8e53e0d5b23594c0cec3175259d35b63474dd39428de78654a7b249cc914f23c03926768210e239de39bf6a8b1a6d06
6
+ metadata.gz: 20e2aa0e4c82a944fa07cdeed22ea77205387dac18b2393dbd2550620ead1bd1e8b3a9bc2ef130596c273325fa2913f8a0226154988df5cf4452cc004a73b067
7
+ data.tar.gz: '053559f22fd9d96a802f0a4bb98f40512b37591715e977d1994e00a86698901dc39053f0ffb2ebe0ea455ec930feab1004548f139ed87e0be4511bc64696d5b1'
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) if using iTerm2 2.9+
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 imgcat and iTerm2, default NONE)
61
- -I, --all-images Include local and remote images in output (requires imgcat and iTerm2)
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 Output only a headline-based section of the input (numeric from --list)
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
 
@@ -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 @headers && !@headers.empty?
499
- @headers = []
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
- @headers << [
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
- @headers
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)^\w.+:\s+\S+/
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
- @headers = get_headers(input)
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 == @headers[sect - 1][1].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)
@@ -1,3 +1,3 @@
1
1
  module CLIMarkdown
2
- VERSION = '2.0.2'
2
+ VERSION = '2.0.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mdless
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra