martile 0.6.26 → 0.6.27

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.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/martile.rb +48 -72
  5. metadata +13 -13
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e1fc866dc1787640892b6290a820baeee0032ad7
4
- data.tar.gz: 85e2c547c024d0d05da4509db044093dad7a89e9
3
+ metadata.gz: c82e54f50f94ae7be44ab6449e2c5defe0801d24
4
+ data.tar.gz: 9093f1e4ab36350febe6fd62cf249c6b8dd9e87d
5
5
  SHA512:
6
- metadata.gz: 992ea2f9876d3eaa1070bde429f5a9afcdd814e39fe1ad81c3f1c6a3bbff590938bf7afc09f02cf7c6f7e16fd1867060a7113adbbb85c61401d36e810dab0ed4
7
- data.tar.gz: b48a7b08cc9b9357912dae4406fc30b040b9579b3f7f2dc2c230791fc3e9c739f490168bed1c37fcc58f4475effb0b7c02823da15a1ff56e5177f4b94bbc2e7e
6
+ metadata.gz: ea92efaaf95d6ada71633ac5fca9914c4748c595f0ed82a756f3696eca58cbcc6869e60c1e892bf320e8149c3085ab298f57fae39378b9738144d3dcf4d5f86e
7
+ data.tar.gz: ee95038e83e1c8d2bbd22ce20782144d35e4a6093156fffe3f24f708ccbb4d44f9d0b615ea74b8857c6ee025d2ce4cf099192a4cb9f91e016f9683a15967332c
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/martile.rb CHANGED
@@ -9,6 +9,9 @@ require 'rdiscount'
9
9
  require 'kvx'
10
10
 
11
11
 
12
+ # feature: 22-May-2016 Introduced the __DATA__ section which appears at
13
+ # the end of the document to reference 1 or more raw
14
+ # Dynarex documents
12
15
  # improvement: 9-Mar-2016 Method dynarex_to_markdown now uses the !d[]()
13
16
  # syntax instead of -[]
14
17
  # bug fix: 29-Feb-2016 Arbitrary URLs will no longer automatically
@@ -54,78 +57,23 @@ require 'kvx'
54
57
  # bug fix: The inner Martile call within a Section now
55
58
  # ignores domain labels to avoid duplication of URL scanning.
56
59
  # feature: 29-Mar-2015: Borrowed the strikethru feature from Mtlite
57
- # bug fix: 28-Mar-2015: Fixes a bug introduced on the 20-Mar-2015 relating to
58
- # Markdown lists not being converted to HTML
59
- # see http://www.jamesrobertson.eu/bugtracker/2015/mar/28/markdown-lists-are-not-converted-to-html.html
60
- # improvement: A space is now appended to the unicode checkbox to
61
- # separate it from the text
62
- # feature: 21-Mar-2015: URLS are now given labels e.g.
63
- # [news](http://news.bbc.co.uk)<span class='domain'>[bbc.co.uk]</span>
64
- # bug fix: 20-Mar-2015: HTML and XML elements should not be filtered out of
65
- # the section() method
66
- # feature: Added the unicode checkbox feature from the Mtlite gem
67
- # bug fix: 14-Mar-2015: A section can now be
68
- # written without an error occurring
69
- # bug fix: 11-Mar-2015: Escapes angle brackets within a code block *before*
70
- # the string is passed to Rexle
71
- # bug fix: A new line character is now added after the creation
72
- # of the code block tags
73
- # bug fix: 01-Mar-2015: code_block_to_html() now only searches strings which
74
- # are outside of angle brackets
75
- # bug fix: 10-Dec-2014: Generation of pre tags using // can now only happen
76
- # when the // appears at the beginning of the line
77
- # feature: 30-Oct-2014: A section can now be between a set of equal signs at
78
- # the beginning of the line
79
- # e.g.
80
- # =
81
- # inside a section
82
- # =
83
- # bug fix: 07-Oct-2014: Smartlink tested for new cases
84
- # feature: 27-Sep-2014: 1. A smartlink can now be used
85
- # e.g. ?link http://someurl?
86
- # 2. pre tags can now be created from 2 pairs of slash
87
- # tags, before and after the pre tag content e.g.
88
- # //
89
- # testing
90
- # //
91
- # feature: 24-Sep-2014: A kind of markdown list can now be created inside
92
- # of <ol> or <ul> tags
93
- # bug fix: 16-Apr-2014: Words containing an underscore should no longer be
94
- # transformed to an underline tag
95
- # bug fix: 03-Apr-2014: XML or HTML elements should now be filtered out
96
- # of any transformations.
97
- # feature: 31-Mar-2014: Added an _underline_ feature.
98
- # bug fix: 01-Mar-2014: A Dynarex_to_table statement between 2 HTML blocks
99
- # is now handled properly.
100
- # bug fix: 01-Mar-2014: Multiple pre tags within a string can now be handled
101
- # feature: 12-Oct-2013: escaped the non-code content of <pre> blocks
102
- # feature: 04-Oct-2013: angle brackets within <pre><code> blocks are
103
- # escaped automatically
104
- # feature: 03-Oct-2013: HTML tags now handled
105
- # bug fix: 25-Sep-2013: removed the new line statement from the join command.
106
- # headings etc. should no longer be split with a new line
107
- # feature: 12-Aug-2013: unordered_list supported
108
- # feature: 31-Mar-2013: markdown inside a martile ordered list
109
- # is now converted to HTML
110
- # bug fix: 02-Nov-2012: within dynarex_to_markdown URLs containing a
111
- # dash now work
112
- # bug fix: 20-Sep-2012: in ordered_list_to_html it now cuts off from
113
- # parsing headings
114
- # bug fix: 04-Aug-2012; replaced \s with a space in regex patterns
115
- # modified: 28-Mar-2012; Added dynarex_to_markdown
116
- # modified: 28-Aug-2011; Added escaping of HTML within a code block
60
+
117
61
 
118
62
  class Martile
119
63
 
120
- attr_reader :to_s
64
+ attr_reader :to_s, :data_source
121
65
 
122
66
  def initialize(raw_s, ignore_domainlabel: nil)
123
67
 
68
+ @data_source = {}
69
+
124
70
  @ignore_domainlabel = ignore_domainlabel
125
71
 
126
- s = slashpre raw_s
72
+ s0 = raw_s =~ /^__DATA__$/ ? parse__data__(raw_s) : raw_s
73
+
74
+ s1 = slashpre s0
127
75
  #puts 's : ' + s.inspect
128
- s2 = code_block_to_html(s.strip + "\n")
76
+ s2 = code_block_to_html(s1.strip + "\n")
129
77
 
130
78
  #puts 's2 : ' + s2.inspect
131
79
  #s3 = apply_filter(s2, %w(ol ul)) {|x| explicit_list_to_html x }
@@ -145,11 +93,11 @@ class Martile
145
93
  s8 = apply_filter(s7) {|x| underline x }
146
94
  #puts 's8: ' + s8.inspect
147
95
  s9 = apply_filter(s8) {|x| section x }
148
- puts 's9: ' + s9.inspect
96
+ #puts 's9: ' + s9.inspect
149
97
 
150
98
  s10 = apply_filter(s9) {|x| smartlink x }
151
99
 
152
- puts 's10: ' + s10.inspect
100
+ #puts 's10: ' + s10.inspect
153
101
 
154
102
  #s11 = section s9
155
103
  #puts 's11 : ' + s11.inspect
@@ -162,10 +110,10 @@ class Martile
162
110
  s15 = apply_filter(s14){|x| kvx_to_dl x}
163
111
  #puts 's15 : ' + s15.inspect
164
112
  s16 = apply_filter(s15){|x| list_item_to_hyperlink x}
165
- puts 's16 : ' + s16.inspect
113
+ #puts 's16 : ' + s16.inspect
166
114
  s17 = apply_filter(s16) {|x| mtlite_utils x }
167
115
 
168
- puts 's17 : ' + s17.inspect
116
+ #puts 's17 : ' + s17.inspect
169
117
 
170
118
  @to_s = s17
171
119
  end
@@ -245,12 +193,17 @@ class Martile
245
193
  end
246
194
 
247
195
  def dynarex_to_markdown(s)
248
-
249
- s.gsub(/!d\[\]\(((https?:\/\/)?[\w\/\.\-]+)\)(\{[^\}]+\})?/) do |match|
196
+
197
+ s.gsub(/!d\[\]\(((#\w+|https?:\/\/)?[\w\/\.\-]+)\)(\{[^\}]+\})?/) do |match|
250
198
 
251
199
  source = ($1)
252
200
  raw_select = ($3)
253
- dx = Dynarex.new(source)
201
+
202
+ dx = if source =~ /^http/ then
203
+ Dynarex.new(source)
204
+ else
205
+ @data_source[source[/\w+/]]
206
+ end
254
207
 
255
208
  if dx.fields.length > 1 then
256
209
  dx_render_table(dx, raw_select)
@@ -472,7 +425,30 @@ class Martile
472
425
 
473
426
  def unordered_list_to_html(s)
474
427
  list_to_html s, '\*'
475
- end
428
+ end
429
+
430
+ def parse__data__(s)
431
+
432
+ a = s.split(/^__DATA__$/,2)
433
+
434
+ data = a[-1]
435
+
436
+ data.split(/(?=<\?)/).each do |x|
437
+
438
+ s2 = x.strip
439
+ next if s2.empty?
440
+
441
+ puts 's2: ' + s2.inspect
442
+ id = s2.lines.first[/id=["']([^"']+)/,1]
443
+ dx = Dynarex.new
444
+ dx.import s2
445
+
446
+ @data_source[id] = dx
447
+ end
448
+
449
+ a[0..-2].join
450
+
451
+ end
476
452
 
477
453
  def table_to_html(s)
478
454
 
@@ -599,4 +575,4 @@ class Martile
599
575
  s.gsub(/\B(\* +)([^\n]+)\s+(https?:\/\/.*)/,'\1[\2](\3)')
600
576
 
601
577
  end
602
- end
578
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: martile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.26
4
+ version: 0.6.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  fHJRwdYS8tvLYH9UFytJxDKjlovBuFUsfKP0FJlZGQGJM5JiIj5LWelTGJtJD8hI
32
32
  2jPlwrOtiqZt2A==
33
33
  -----END CERTIFICATE-----
34
- date: 2016-03-09 00:00:00.000000000 Z
34
+ date: 2016-05-22 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rdiscount
@@ -39,40 +39,40 @@ dependencies:
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: '2.1'
42
+ version: '2.2'
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- version: 2.1.8
45
+ version: 2.2.0.1
46
46
  type: :runtime
47
47
  prerelease: false
48
48
  version_requirements: !ruby/object:Gem::Requirement
49
49
  requirements:
50
50
  - - "~>"
51
51
  - !ruby/object:Gem::Version
52
- version: '2.1'
52
+ version: '2.2'
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: 2.1.8
55
+ version: 2.2.0.1
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: dynarex
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '1.5'
62
+ version: '1.7'
63
63
  - - ">="
64
64
  - !ruby/object:Gem::Version
65
- version: 1.5.26
65
+ version: 1.7.4
66
66
  type: :runtime
67
67
  prerelease: false
68
68
  version_requirements: !ruby/object:Gem::Requirement
69
69
  requirements:
70
70
  - - "~>"
71
71
  - !ruby/object:Gem::Version
72
- version: '1.5'
72
+ version: '1.7'
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 1.5.26
75
+ version: 1.7.4
76
76
  - !ruby/object:Gem::Dependency
77
77
  name: kvx
78
78
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +82,7 @@ dependencies:
82
82
  version: '0.5'
83
83
  - - ">="
84
84
  - !ruby/object:Gem::Version
85
- version: 0.5.8
85
+ version: 0.5.11
86
86
  type: :runtime
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -92,7 +92,7 @@ dependencies:
92
92
  version: '0.5'
93
93
  - - ">="
94
94
  - !ruby/object:Gem::Version
95
- version: 0.5.8
95
+ version: 0.5.11
96
96
  description:
97
97
  email: james@r0bertson.co.uk
98
98
  executables: []
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  requirements: []
122
122
  rubyforge_project:
123
- rubygems_version: 2.4.8
123
+ rubygems_version: 2.5.1
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: A flavour of Markdown which converts a Martile string to html
metadata.gz.sig CHANGED
Binary file