mindmap_mfm 0.3.0 → 0.3.1

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: 98240ecc59dc134545c3f7cdac85be48acc37d2126aa15b52a06b23d57259607
4
- data.tar.gz: a590a5230cfb55774b61a6edeff0cfc7fdf48bb6e5724c8cf510ad3ab70d4322
3
+ metadata.gz: eede1818ee15c3a120cfaa3d85c2db43b1f4de09192b65debad3a22da9a69d83
4
+ data.tar.gz: 358755625744b953a44c03dadeaf79b437ae33b67abb53b898b205c2c70050e3
5
5
  SHA512:
6
- metadata.gz: 3877c8dbf15bba9b1072666ac9b592cc5dcebcab7f61eaafb17db421191381f52a4e6b8dcc79b196ab464bc23ec3e197c10c6a57a8ddb21a305c9702d383b076
7
- data.tar.gz: 533aa3f21897dbf10ad8cc08c30e2e284f58cc2b264e442091de681bfe94529ca0e892210811ba8102fffb68cb09ca7f48c4188edb1c5a6abaa7a6e7df3fd59a
6
+ metadata.gz: 4dddacff708698f6a29ba4da399c632e3108513a05c7f108a710ab2b99cc6b52830c60ba43772128c73e987863acb759dfa5e2c21595614a0340996171a650ce
7
+ data.tar.gz: be5cfca2c5cdc558d928525f51ca06c8dd76c903138eb338311c90792fcd370c77f2944a7a915cac68e9f5b9bf0b311e8b28ee1228ec8b532816dfd1b442f341
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -12,12 +12,10 @@ require 'html-to-css'
12
12
  class MindmapMFM
13
13
  using ColouredText
14
14
 
15
- def initialize(s, debug: false)
16
-
17
- @debug = debug
18
- @rawdoc = build_rawdoc(s)
19
- @html = Kramdown::Document.new(@rawdoc).to_html
15
+ def initialize(s, cssfile: nil, debug: false, footer: '')
20
16
 
17
+ @s, @cssfile, @footer, @debug = s, cssfile, footer, debug
18
+ puts ('footer: ' + @footer.inspect).debug if debug
21
19
  end
22
20
 
23
21
  # Returns an HTML-to-CSS object
@@ -26,14 +24,23 @@ class MindmapMFM
26
24
  HtmlToCss.new(@html)
27
25
  end
28
26
 
29
- def to_html(cssfile: nil)
27
+ def to_html()
28
+
29
+ if @debug then
30
+ puts 'MindmapMFM | inside to_html()'.info
31
+ puts ('@s: ' + @s.inspect).debug
32
+ end
30
33
 
31
- html = if cssfile then
34
+ @rawdoc = build_rawdoc(@s)
35
+ @html = Kramdown::Document.new(
36
+ @rawdoc.gsub(/\b'\b/,"{::nomarkdown}'{:/}")).to_html
37
+
38
+ html = if @cssfile and @cssfile.length > 1 then
32
39
 
33
40
  doc = Rexle.new(@html)
34
41
  link = Rexle::Element.new('link')
35
- link.attributes.merge!(rel: 'stylesheet', href: cssfile)
36
- doc.root.element('head/style').insert_after(link)
42
+ link.attributes.merge!(rel: 'stylesheet', href: @cssfile)
43
+ doc.root.element('head').add(link)
37
44
  doc.xml(declaration: 'none')
38
45
 
39
46
  else
@@ -46,9 +53,9 @@ class MindmapMFM
46
53
  private
47
54
 
48
55
  def build_rawdoc(s)
49
-
50
- head =<<EOF
51
- <head>
56
+
57
+
58
+ css=<<EOF
52
59
  <style>
53
60
  h2 {background-color: #ee2;}
54
61
  svg {fill: #3ac;}
@@ -60,6 +67,11 @@ head =<<EOF
60
67
  svg g a:hover {background-color: #3ac; }
61
68
  svg + div {float: right; width: 50%; overflow-y: auto; height: 70vh}
62
69
  </style>
70
+ EOF
71
+
72
+ head =<<EOF
73
+ <head>
74
+ #{css unless @cssfile}
63
75
  </head>
64
76
  EOF
65
77
 
@@ -89,17 +101,24 @@ EOF
89
101
  else
90
102
  s
91
103
  end
104
+
92
105
  puts ('body: ' + body.inspect).debug if @debug
93
- html = [
94
- "<html>\n",
95
- head,
96
- "\n <body markdown='1'>\n\n",
97
- body, "\n</body>\n</html>\n\n"
98
- ]
99
- html << a.last if a.length > 1
100
106
 
101
- puts ('html: ' + html.inspect) if @debug
102
- Martile.new(html.join, debug: @debug).to_s
107
+
108
+ r = Martile.new(body, debug: false).to_s
109
+ puts ('r: ' + r.inspect).debug if @debug
110
+
111
+ html = [
112
+ "<html>\n",
113
+ head,
114
+ "\n <body markdown='1'>\n\n",
115
+ r,
116
+ "<div id='footer'>",@footer, "</div>",
117
+ "\n</body>\n</html>\n\n"
118
+ ]
119
+
120
+ html << a.last if a.length > 1
121
+ html.join
103
122
 
104
123
  end
105
124
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mindmap_mfm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  kt2QNYYgUi8zg4M1dWd577TMf7qbsXx3pUrE4deIsdMMFYf2/yN2/d47911IieWl
36
36
  LuePKi4Rlu2mLxsfnRgVS2D5
37
37
  -----END CERTIFICATE-----
38
- date: 2019-03-04 00:00:00.000000000 Z
38
+ date: 2019-03-06 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: martile
metadata.gz.sig CHANGED
Binary file