mindmap_mfm 0.1.0 → 0.2.0

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
  SHA1:
3
- metadata.gz: 41f9a4080ea18c59b5d162ed13466a1a03250bac
4
- data.tar.gz: 827af4e95d2477a883356f9c333badf0867cc734
3
+ metadata.gz: 6f0a51a746d7fdb6a78c7c47a5b63ece78eda9a4
4
+ data.tar.gz: 75f2ff0b85d66aafad44e4977fb015038f7a7053
5
5
  SHA512:
6
- metadata.gz: cb6c33079449532da9b97f592ffbed7e26aadef75dd291f7496fe4e7cb6b9ce88b204b92314f5308c8079972a864713a56e461faadb325cc649261e072cd756b
7
- data.tar.gz: 7b93e766c3e808efbb450ae9618677dd6ba5aa5c5c4cb1b7b6049d1a89230439acc236976857b50295fe24a86b7a926b7d880e241b8c3d30b46fbb991aa9bbc8
6
+ metadata.gz: a136db1f82b2063a65f2031976ece3505248dd740d291c54baf13cecde64598f6419582d02989a200f0357922e3582b6b1c3962239a591a84074ece554a79d5c
7
+ data.tar.gz: c0b2188207f7516c574f0677618b6b8eb0fae05dd798b276077bd03256ca81cf3111e8ceb5eb9f97101f302826b04fed6f10240557c51a5a6c517a88a970a70f
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/mindmap_mfm.rb CHANGED
@@ -6,6 +6,7 @@
6
6
  require 'martile'
7
7
  require 'kramdown'
8
8
  require 'mindmapdoc'
9
+ require 'html-to-css'
9
10
 
10
11
 
11
12
  class MindmapMFM
@@ -13,11 +14,31 @@ class MindmapMFM
13
14
  def initialize(s)
14
15
 
15
16
  @rawdoc = build_rawdoc(s)
17
+ @html = Kramdown::Document.new(@rawdoc).to_html
16
18
 
19
+ end
20
+
21
+ # Returns an HTML-to-CSS object
22
+ #
23
+ def to_htc()
24
+ HtmlToCss.new(@html)
17
25
  end
18
26
 
19
- def to_html()
20
- Kramdown::Document.new(@rawdoc).to_html
27
+ def to_html(cssfile: nil)
28
+
29
+ html = if cssfile then
30
+
31
+ doc = Rexle.new(@html)
32
+ link = Rexle::Element.new('link')
33
+ link.attributes.merge!(rel: 'stylesheet', href: cssfile)
34
+ doc.root.element('head/style').insert_after(link)
35
+ doc.xml(declaration: 'none')
36
+
37
+ else
38
+ @html
39
+ end
40
+
41
+ "<!DOCTYPE html>\n" + html
21
42
  end
22
43
 
23
44
  private
@@ -35,7 +56,7 @@ head =<<EOF
35
56
  g.node {fill: #311}
36
57
  a {fill: #114; }
37
58
  svg g a:hover {background-color: #3ac; }
38
- #doc {float: right; width: 50%; overflow-y: auto; height: 90%}
59
+ svg + div {float: right; width: 50%; overflow-y: auto; height: 70vh}
39
60
  </style>
40
61
  </head>
41
62
  EOF
@@ -44,15 +65,23 @@ EOF
44
65
  a = s.split(/(?=__DATA__)/,2)
45
66
  a2 = a.first.split(/(?=!s)/,2)
46
67
  svg = a2[1].lines.first
47
- div = a2[1].lines[1..-1]
68
+ txtdoc = a2[1].lines[1..-1].join
48
69
 
70
+ divdoc = if txtdoc[0] != '<' then
71
+ actual_txtdoc, below_txtdoc = txtdoc.split(/-{10,}/,2)
72
+ '<div markdown="1">' + actual_txtdoc \
73
+ + "</div>\n<div style='clear: both'/>\n" + below_txtdoc
74
+ else
75
+ txtdoc
76
+ end
77
+
49
78
  html = [
50
79
  "<html>\n",
51
80
  head,
52
81
  "\n <body markdown='1'>\n\n",
53
82
  a2[0],
54
83
  svg,
55
- "<div markdown='1' id='doc'>\n\n", div, "</div>\n</body>\n</html>\n\n",
84
+ "\n\n", divdoc, "\n</body>\n</html>\n\n",
56
85
  a.last
57
86
  ].join
58
87
 
@@ -61,4 +90,3 @@ EOF
61
90
  end
62
91
 
63
92
  end
64
-
data.tar.gz.sig CHANGED
Binary file
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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -30,7 +30,7 @@ cert_chain:
30
30
  psX3wHSCzaVBci2BgFjWgkcfzQhHUZuwhmzOTmIpIiSDkL5n+E0dmvu2ykk4C7WL
31
31
  uQk=
32
32
  -----END CERTIFICATE-----
33
- date: 2018-02-08 00:00:00.000000000 Z
33
+ date: 2018-02-09 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: martile
@@ -92,6 +92,26 @@ dependencies:
92
92
  - - ">="
93
93
  - !ruby/object:Gem::Version
94
94
  version: 1.16.2
95
+ - !ruby/object:Gem::Dependency
96
+ name: html-to-css
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '0.1'
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: 0.1.8
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '0.1'
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: 0.1.8
95
115
  description:
96
116
  email: james@jamesrobertson.eu
97
117
  executables: []
metadata.gz.sig CHANGED
Binary file