mdless 2.0.14 → 2.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mdless/console.rb +39 -15
- data/lib/mdless/converter.rb +9 -1
- data/lib/mdless/taskpaper.rb +6 -4
- 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: 863102e504ba07c2ab9b018687d50053ca3395206666d1abffcf79997023db9e
|
4
|
+
data.tar.gz: bbba927ea37503308dac7356cb2d72e84e4cf53c5cf28f3f2b210c68b745cbf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92d0edc1d4722074e897981138c585a02fb9c287c8e8fc270885cc19b6274a2490bcd69b92c198c9876d4c4c1bf9b0ec0226c0e97660791fbfdf6c8e85f5592b
|
7
|
+
data.tar.gz: d738066449abc9ee9a8d0331b6ef64db675686cc53c9d0bbf3fa320a63a70c9f33312e0a6fe6c7055caffca7ba13deefcce10ee57f7e3fd7e291a8447e9674fd
|
data/lib/mdless/console.rb
CHANGED
@@ -601,8 +601,27 @@ module Redcarpet
|
|
601
601
|
def preprocess(input)
|
602
602
|
in_yaml = false
|
603
603
|
|
604
|
+
if @options[:taskpaper] == :auto
|
605
|
+
@options[:taskpaper] = if @file =~ /\.taskpaper/
|
606
|
+
@log.info('TaskPaper extension detected')
|
607
|
+
true
|
608
|
+
elsif CLIMarkdown::TaskPaper.is_taskpaper?(input)
|
609
|
+
@log.info('TaskPaper document detected')
|
610
|
+
true
|
611
|
+
else
|
612
|
+
false
|
613
|
+
end
|
614
|
+
end
|
615
|
+
|
604
616
|
input = color_meta(input)
|
605
617
|
|
618
|
+
if @options[:taskpaper]
|
619
|
+
input = CLIMarkdown::TaskPaper.highlight(input, @theme)
|
620
|
+
input = highlight_tags(input)
|
621
|
+
return input
|
622
|
+
end
|
623
|
+
|
624
|
+
|
606
625
|
## Replace setex headers with ATX
|
607
626
|
input.gsub!(/^([^\n]+)\n={2,}\s*$/m, "# \\1\n")
|
608
627
|
input.gsub!(/^([^\n]+?)\n-{2,}\s*$/m, "## \\1\n")
|
@@ -647,20 +666,6 @@ module Redcarpet
|
|
647
666
|
"#{color('dd term')}#{m['term']}#{xc}#{color('dd color')}#{color_dd_def(m['def'])}"
|
648
667
|
end
|
649
668
|
|
650
|
-
if @options[:taskpaper] == :auto
|
651
|
-
@options[:taskpaper] = if @file =~ /\.taskpaper/
|
652
|
-
@log.info('TaskPaper extension detected')
|
653
|
-
true
|
654
|
-
elsif CLIMarkdown::TaskPaper.is_taskpaper?(input)
|
655
|
-
@log.info('TaskPaper document detected')
|
656
|
-
true
|
657
|
-
else
|
658
|
-
false
|
659
|
-
end
|
660
|
-
end
|
661
|
-
|
662
|
-
input = CLIMarkdown::TaskPaper.highlight(input, @theme) if @options[:taskpaper]
|
663
|
-
|
664
669
|
input
|
665
670
|
end
|
666
671
|
|
@@ -833,7 +838,7 @@ module Redcarpet
|
|
833
838
|
def highlight_tags(input)
|
834
839
|
tag_color = color('at_tags tag')
|
835
840
|
value_color = color('at_tags value')
|
836
|
-
input.gsub(/(?<pre>\s|m)(?<tag>@[^ ("']+)(?:(?<lparen>\()(?<value>.*?)(?<rparen>\)))?/) do
|
841
|
+
input.gsub(/(?<pre>\s|m)(?<tag>@[^ \].?!,("']+)(?:(?<lparen>\()(?<value>.*?)(?<rparen>\)))?/) do
|
837
842
|
m = Regexp.last_match
|
838
843
|
last_color = m.pre_match.last_color_code
|
839
844
|
[
|
@@ -851,9 +856,28 @@ module Redcarpet
|
|
851
856
|
end
|
852
857
|
end
|
853
858
|
|
859
|
+
def highlight_wiki_links(input)
|
860
|
+
input.gsub(/\[\[(.*?)\]\]/) do
|
861
|
+
content = Regexp.last_match(1)
|
862
|
+
[
|
863
|
+
pre_element,
|
864
|
+
color('link brackets'),
|
865
|
+
'[[',
|
866
|
+
color('link text'),
|
867
|
+
content,
|
868
|
+
color('link brackets'),
|
869
|
+
']]',
|
870
|
+
xc,
|
871
|
+
post_element
|
872
|
+
].join
|
873
|
+
end
|
874
|
+
end
|
875
|
+
|
854
876
|
def postprocess(input)
|
855
877
|
input.scrub!
|
856
878
|
|
879
|
+
input = highlight_wiki_links(input) if @options[:wiki_links]
|
880
|
+
|
857
881
|
if @options[:inline_footnotes]
|
858
882
|
input = insert_footnotes(input)
|
859
883
|
else
|
data/lib/mdless/converter.rb
CHANGED
@@ -146,6 +146,11 @@ module CLIMarkdown
|
|
146
146
|
@options[:at_tags] = true
|
147
147
|
end
|
148
148
|
|
149
|
+
@options[:wiki_links] ||= false
|
150
|
+
opts.on('--[no-]wiki-links', 'Highlight [[wiki links]]') do |opt|
|
151
|
+
@options[:wiki_links] = opt
|
152
|
+
end
|
153
|
+
|
149
154
|
opts.on('-v', '--version', 'Display version number') do
|
150
155
|
puts version
|
151
156
|
exit
|
@@ -224,7 +229,10 @@ module CLIMarkdown
|
|
224
229
|
rescue StandardError
|
225
230
|
input = IO.read(file)
|
226
231
|
end
|
227
|
-
input
|
232
|
+
raise 'Nil input' if input.nil?
|
233
|
+
|
234
|
+
input.scrub!
|
235
|
+
input.gsub!(/\r?\n/, "\n")
|
228
236
|
if @options[:list]
|
229
237
|
puts list_headers(input)
|
230
238
|
Process.exit 0
|
data/lib/mdless/taskpaper.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
module CLIMarkdown
|
4
4
|
module TaskPaper
|
5
|
-
TASK_RX = /^(?<indent>(?: |\t)
|
6
|
-
PROJECT_RX = /^(?<indent>(?: |\t)
|
5
|
+
TASK_RX = /^(?<indent>(?: |\t)*?)(?<marker>-)(?<task>\s+\S.*?)$/
|
6
|
+
PROJECT_RX = /^(?<indent>(?: |\t)*?)(?<project>[^- \t].*?:)(?<tags> @\S+)*$/
|
7
7
|
NOTE_RX = /^(?<indent>(?: |\t)+)(?<note>(?<!- ).*?(?!:))$/
|
8
8
|
|
9
9
|
class << self
|
@@ -39,8 +39,10 @@ module CLIMarkdown
|
|
39
39
|
def is_taskpaper?(input)
|
40
40
|
projects = input.split(PROJECT_RX)
|
41
41
|
tasks = 0
|
42
|
-
projects.
|
43
|
-
|
42
|
+
if projects.count > 1
|
43
|
+
projects.each do |proj|
|
44
|
+
tasks += proj.scan(TASK_RX).count
|
45
|
+
end
|
44
46
|
end
|
45
47
|
|
46
48
|
tasks >= 6
|
data/lib/mdless/version.rb
CHANGED
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.
|
4
|
+
version: 2.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Terpstra
|
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
|
-
rubygems_version: 3.2.
|
117
|
+
rubygems_version: 3.2.16
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: A pager like less, but for Markdown files
|