word-to-markdown 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nokogiri/xml/element.rb +3 -1
- data/lib/word-to-markdown.rb +28 -18
- data/lib/word-to-markdown/document.rb +1 -1
- data/lib/word-to-markdown/version.rb +1 -1
- metadata +12 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8826b727f290781e7713325662d056482018d730
|
4
|
+
data.tar.gz: 8692363359366aac70359bf251ccba409f80bba7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8db1e766ad6bfc341de71a4fc82d14f8a3d109005f2bda9d779af2bd7b0f722d160cf873bff98cf56f9fa7929ab9282e945d249fc220fa56beafe46bd962cf9c
|
7
|
+
data.tar.gz: fd84315c249e983a6bdf073a8573d2fbca82886ed05da15b8325ceca4f655b3181cee6ee20cf888c933a4b10794a5c5145ad86a8f9ebf8f9550163de9ce284da
|
data/lib/nokogiri/xml/element.rb
CHANGED
@@ -2,12 +2,14 @@ module Nokogiri
|
|
2
2
|
module XML
|
3
3
|
class Element
|
4
4
|
|
5
|
+
DEFAULT_FONT_SIZE = 12.to_f
|
6
|
+
|
5
7
|
# The node's font size
|
6
8
|
# Used for guessing heading sizes
|
7
9
|
#
|
8
10
|
# Returns a float with the font-size
|
9
11
|
def font_size
|
10
|
-
styles['font-size']
|
12
|
+
styles['font-size'] ? styles['font-size'].to_f : DEFAULT_FONT_SIZE
|
11
13
|
end
|
12
14
|
|
13
15
|
def bold?
|
data/lib/word-to-markdown.rb
CHANGED
@@ -4,6 +4,8 @@ require 'premailer'
|
|
4
4
|
require 'nokogiri'
|
5
5
|
require 'nokogiri-styles'
|
6
6
|
require 'tmpdir'
|
7
|
+
require 'rbconfig'
|
8
|
+
require 'open3'
|
7
9
|
require_relative 'word-to-markdown/version'
|
8
10
|
require_relative 'word-to-markdown/document'
|
9
11
|
require_relative 'word-to-markdown/converter'
|
@@ -29,34 +31,42 @@ class WordToMarkdown
|
|
29
31
|
converter.convert!
|
30
32
|
end
|
31
33
|
|
32
|
-
# source: https://
|
33
|
-
def self.
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
# source: https://stackoverflow.com/questions/11784109/detecting-operating-systems-in-ruby
|
35
|
+
def self.os
|
36
|
+
@os ||= (
|
37
|
+
host_os = RbConfig::CONFIG['host_os']
|
38
|
+
case host_os
|
39
|
+
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
40
|
+
:windows
|
41
|
+
when /darwin|mac os/
|
42
|
+
:macosx
|
43
|
+
when /linux/
|
44
|
+
:linux
|
45
|
+
when /solaris|bsd/
|
46
|
+
:unix
|
47
|
+
else
|
48
|
+
raise Error::WebDriverError, "unknown os: #{host_os.inspect}"
|
40
49
|
end
|
41
|
-
|
42
|
-
return nil
|
50
|
+
)
|
43
51
|
end
|
44
52
|
|
45
53
|
def self.soffice_path
|
46
|
-
|
54
|
+
case os
|
55
|
+
when :macosx
|
47
56
|
%w[~/Applications /Applications]
|
48
|
-
.map { |f| File.join(f, "/LibreOffice.app/Contents/MacOS/soffice") }
|
49
|
-
.find { |f| File.file?(f) }
|
57
|
+
.map { |f| File.expand_path(File.join(f, "/LibreOffice.app/Contents/MacOS/soffice")) }
|
58
|
+
.find { |f| File.file?(f) }
|
59
|
+
when :windows
|
60
|
+
'C:\Program Files (x86)\LibreOffice 4\program\soffice.exe'
|
50
61
|
else
|
51
|
-
|
52
|
-
soffice_path ||= which("soffice.bin")
|
53
|
-
soffice_path ||= "soffice"
|
62
|
+
"soffice"
|
54
63
|
end
|
55
64
|
end
|
56
65
|
|
57
|
-
# Ideally this would be done via open3, but Travis CI can't seen to find soffice when we do
|
58
66
|
def self.run_command(*args)
|
59
|
-
|
67
|
+
output, status = Open3.capture2e(soffice_path, *args)
|
68
|
+
raise "Command `#{soffice_path} #{args.join(" ")}` failed: #{output}" if status != 0
|
69
|
+
output
|
60
70
|
end
|
61
71
|
|
62
72
|
def self.soffice_version
|
@@ -85,7 +85,7 @@ class WordToMarkdown
|
|
85
85
|
|
86
86
|
def raw_html
|
87
87
|
@raw_html ||= begin
|
88
|
-
WordToMarkdown::run_command '--headless', '--convert-to', 'html',
|
88
|
+
WordToMarkdown::run_command '--headless', '--convert-to', 'html', path, '--outdir', tmpdir
|
89
89
|
html = File.read dest_path
|
90
90
|
File.delete dest_path
|
91
91
|
html
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: word-to-markdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Balter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: reverse_markdown
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: descriptive_statistics
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2.5'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '2.5'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: premailer
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '10.
|
75
|
+
version: '10.4'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '10.
|
82
|
+
version: '10.4'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: shoulda
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,20 +94,6 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '3.5'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rdoc
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '4.1'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '4.1'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
98
|
name: bundler
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,28 +114,28 @@ dependencies:
|
|
128
114
|
requirements:
|
129
115
|
- - "~>"
|
130
116
|
- !ruby/object:Gem::Version
|
131
|
-
version: '0.
|
117
|
+
version: '0.10'
|
132
118
|
type: :development
|
133
119
|
prerelease: false
|
134
120
|
version_requirements: !ruby/object:Gem::Requirement
|
135
121
|
requirements:
|
136
122
|
- - "~>"
|
137
123
|
- !ruby/object:Gem::Version
|
138
|
-
version: '0.
|
124
|
+
version: '0.10'
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: mocha
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
142
128
|
requirements:
|
143
129
|
- - "~>"
|
144
130
|
- !ruby/object:Gem::Version
|
145
|
-
version: '1.
|
131
|
+
version: '1.1'
|
146
132
|
type: :development
|
147
133
|
prerelease: false
|
148
134
|
version_requirements: !ruby/object:Gem::Requirement
|
149
135
|
requirements:
|
150
136
|
- - "~>"
|
151
137
|
- !ruby/object:Gem::Version
|
152
|
-
version: '1.
|
138
|
+
version: '1.1'
|
153
139
|
- !ruby/object:Gem::Dependency
|
154
140
|
name: minitest
|
155
141
|
requirement: !ruby/object:Gem::Requirement
|