mdless 1.0.7 → 1.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b79330028da2d98251af174cfb9f0ae60294efa6e24de4cff88d245c351340f3
4
- data.tar.gz: 22c669286e9486f739badc7e74819e1989fb00fc1f415c9e3fd371e60b1a6026
3
+ metadata.gz: 80c514e484cba1a3688a1bd9f12255b6e8ac6807ff21bb1880af2147257dc05a
4
+ data.tar.gz: dd9f135de513cc0b3b28a499d1dd043d48bdb177c48f69bd1133fc56c9b185fb
5
5
  SHA512:
6
- metadata.gz: 719d4170904c7fd9bc21e5cc4f19ca1a9f5a197d891e211bb29bfd1eecb94cf7d1b9af22943dc253bae4a2ffa0baa91233aae84005752bc5b5f1660ff539dcfa
7
- data.tar.gz: e69bbfb47daf84166fe3cf930601a5fbbaedbd57453c9361547c3b1c6c9cdfb170b4c4a641793a497f23547a3781097e47100a3a8272a8820f4faeb6d4f4de8a
6
+ metadata.gz: de96d5743f91a562b0f758baf5a80de41040506f33b0363303d1e12ed3e84c43a5b0c932f422823360fa470c73747cffccad318770363558142eabd3662f1d6a
7
+ data.tar.gz: f52073c74448d6613c46fc7bb314024d5205d337957bcc2cf2541b49b6cf2c47338c64b19a81a8babb9fecaaaccd3c1f90a8c37e695b23ec4b456679cf889c2f
data/README.md CHANGED
@@ -21,6 +21,7 @@ I often use iTerm2 in visor mode, so `qlmanage -p` is annoying. I still wanted a
21
21
  - List headlines in document
22
22
  - Display single section of the document based on headlines
23
23
  - Customizable colors
24
+ - Add iTerm marks for h1-3 navigation when pager is disabled
24
25
 
25
26
  ## Installation
26
27
 
@@ -269,11 +269,15 @@ module CLIMarkdown
269
269
  first = true
270
270
  input.split(/\n/).map{|line|
271
271
  if first
272
- first = false
273
- line.gsub!(/\|/, "#{color('table border')}|#{color('table header')}")
274
- elsif line.strip =~ /^[|:\- ]+$/
272
+ if line =~ /^\+-+/
273
+ line.gsub!(/^/, color('table border'))
274
+ else
275
+ first = false
276
+ line.gsub!(/\|/, "#{color('table border')}|#{color('table header')}")
277
+ end
278
+ elsif line.strip =~ /^[|:\- +]+$/
275
279
  line.gsub!(/^(.*)$/, "#{color('table border')}\\1#{color('table color')}")
276
- line.gsub!(/([:\-]+)/,"#{color('table divider')}\\1#{color('table border')}")
280
+ line.gsub!(/([:\-+]+)/,"#{color('table divider')}\\1#{color('table border')}")
277
281
  else
278
282
  line.gsub!(/\|/, "#{color('table border')}|#{color('table color')}")
279
283
  end
@@ -1,6 +1,8 @@
1
1
  module CLIMarkdown
2
2
  class MDTableCleanup
3
3
 
4
+ PAD_CHAR = '⎕'
5
+
4
6
  def initialize(input)
5
7
  @string = input
6
8
  @format_row = []
@@ -25,10 +27,11 @@ module CLIMarkdown
25
27
  end
26
28
 
27
29
  format.each_with_index {|cell, i|
30
+ cell.strip!
28
31
  f = 'left'
29
32
  if cell =~ /^:.*?:$/
30
33
  f = 'center'
31
- elsif cell =~ /:$/
34
+ elsif cell =~ /[^:]+:$/
32
35
  f = 'right'
33
36
  else
34
37
  f = 'just'
@@ -81,13 +84,13 @@ module CLIMarkdown
81
84
  def pad(string,type,length)
82
85
  string.strip!
83
86
  if type == 'center'
84
- string.center(length, ' ')
87
+ string.center(length, PAD_CHAR)
85
88
  elsif type == 'right'
86
- string.rjust(length, ' ')
89
+ string.rjust(length, PAD_CHAR)
87
90
  elsif type == 'left'
88
- string.ljust(length, ' ')
91
+ string.ljust(length, PAD_CHAR)
89
92
  else
90
- string.ljust(length, ' ')
93
+ string.ljust(length, PAD_CHAR)
91
94
  end
92
95
  end
93
96
 
@@ -114,6 +117,14 @@ module CLIMarkdown
114
117
  "|#{output.join('|')}|"
115
118
  end
116
119
 
120
+ def table_border
121
+ output = []
122
+ @format_row.each_with_index do |column, i|
123
+ output.push separator(column_width(i), column)
124
+ end
125
+ "+#{output.join('+').gsub(/:/,'-')}+"
126
+ end
127
+
117
128
  def to_md
118
129
  output = []
119
130
  t = table.clone
@@ -123,7 +134,12 @@ module CLIMarkdown
123
134
  output.push("| #{row.join(' | ').lstrip} |")
124
135
  end
125
136
  output.insert(1, header_separator_row)
126
- output.join("\n")
137
+ output.insert(0, table_border)
138
+ output.push(table_border)
139
+
140
+ output.join("\n").gsub(/((?<=\| )#{PAD_CHAR}+|#{PAD_CHAR}+(?= \|))/) {|m|
141
+ " "*m.length
142
+ }
127
143
  end
128
144
  end
129
145
  end
@@ -1,3 +1,3 @@
1
1
  module CLIMarkdown
2
- VERSION = '1.0.7'
2
+ VERSION = '1.0.8'
3
3
  end
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: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-20 00:00:00.000000000 Z
11
+ date: 2019-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake