markdown_to_word 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.travis.yml +18 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +20 -0
  6. data/README.md +49 -0
  7. data/Rakefile +8 -0
  8. data/bin/m2w +14 -0
  9. data/lib/markdown_to_word.rb +18 -0
  10. data/lib/markdown_to_word/default.docx +0 -0
  11. data/lib/markdown_to_word/document.rb +35 -0
  12. data/lib/markdown_to_word/template/[Content_Types].xml +16 -0
  13. data/lib/markdown_to_word/template/_rels/.rels +7 -0
  14. data/lib/markdown_to_word/template/docProps/app.xml +2 -0
  15. data/lib/markdown_to_word/template/docProps/core.xml +2 -0
  16. data/lib/markdown_to_word/template/docProps/thumbnail.jpeg +0 -0
  17. data/lib/markdown_to_word/template/word/_rels/document.xml.rels +10 -0
  18. data/lib/markdown_to_word/template/word/document.xml +127 -0
  19. data/lib/markdown_to_word/template/word/fontTable.xml +64 -0
  20. data/lib/markdown_to_word/template/word/numbering.xml +229 -0
  21. data/lib/markdown_to_word/template/word/settings.xml +63 -0
  22. data/lib/markdown_to_word/template/word/styles.xml +504 -0
  23. data/lib/markdown_to_word/template/word/stylesWithEffects.xml +504 -0
  24. data/lib/markdown_to_word/template/word/theme/theme1.xml +318 -0
  25. data/lib/markdown_to_word/template/word/webSettings.xml +5 -0
  26. data/lib/markdown_to_word/version.rb +3 -0
  27. data/markdown_to_word.gemspec +29 -0
  28. data/script/bootstrap +3 -0
  29. data/script/build-template +19 -0
  30. data/script/cibuild +9 -0
  31. data/script/console +3 -0
  32. data/spec/fixtures/ol.md +4 -0
  33. data/spec/fixtures/ul.md +4 -0
  34. data/spec/markdown_to_word_bin_spec.rb +18 -0
  35. data/spec/markdown_to_word_conversion_spec.rb +21 -0
  36. data/spec/markdown_to_word_document_spec.rb +32 -0
  37. data/spec/markdown_to_word_spec.rb +15 -0
  38. data/spec/spec_helper.rb +25 -0
  39. metadata +201 -0
@@ -0,0 +1,32 @@
1
+ require "spec_helper"
2
+
3
+ describe MarkdownToWord::Document do
4
+
5
+ subject do
6
+ MarkdownToWord::Document.new("# Test")
7
+ end
8
+
9
+ it "stores the markdown" do
10
+ expect(subject.markdown).to eql("# Test")
11
+ end
12
+
13
+ it "converts the html" do
14
+ expect(subject.send(:raw_html)).to eql("<h1>Test</h1>")
15
+ end
16
+
17
+ it "makes it a valid HTML document" do
18
+ expect(subject.html).to match(/<html><body><h1>Test<\/h1><\/body><\/html>/)
19
+ end
20
+
21
+ it "converts the file" do
22
+ as_markdown(subject.contents) { |md| expect(md).to eql("# Test") }
23
+ end
24
+
25
+ it "strips YAML front matter" do
26
+ doc = MarkdownToWord::Document.new("---\nfoo: bar\n---\n# Test")
27
+ expect(doc.markdown).to eql("# Test")
28
+
29
+ MarkdownToWord::Document.new("---\nfoo: bar\n---\n\n# Test")
30
+ expect(doc.markdown).to eql("# Test")
31
+ end
32
+ end
@@ -0,0 +1,15 @@
1
+ require "spec_helper"
2
+
3
+ describe MarkdownToWord do
4
+ it "converts the file" do
5
+ content = subject.convert("# Test").contents
6
+ as_markdown(content) { |md| expect(md).to eql("# Test") }
7
+ end
8
+
9
+ it "returns the default template" do
10
+ template_dir = MarkdownToWord.default_templates_path
11
+ expect(template_dir).to eql(File.expand_path("../lib/markdown_to_word", File.dirname(__FILE__)))
12
+ template = File.expand_path("default.docx", template_dir)
13
+ expect(File.exists?(template)).to eql(true)
14
+ end
15
+ end
@@ -0,0 +1,25 @@
1
+ require "bundler/setup"
2
+ require 'word-to-markdown'
3
+ require 'open3'
4
+ require_relative "../lib/markdown_to_word"
5
+
6
+ def fixture_path(fixture)
7
+ File.expand_path "./fixtures/#{fixture}.md", File.dirname(__FILE__)
8
+ end
9
+
10
+ def fixture(fixture)
11
+ path = fixture_path(fixture)
12
+ File.open(path).read
13
+ end
14
+
15
+ def as_markdown(contents, &block)
16
+ Tempfile.open(["MarkdownToWord", ".docx"]) do |file|
17
+ File.write(file, contents)
18
+ md = WordToMarkdown.new(file).to_s
19
+ yield(md)
20
+ end
21
+ end
22
+
23
+ def as_docx(md, &block)
24
+ yield(MarkdownToWord.convert(md).contents)
25
+ end
metadata ADDED
@@ -0,0 +1,201 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: markdown_to_word
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.5
5
+ platform: ruby
6
+ authors:
7
+ - Ben Balter
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: htmltoword
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: html-pipeline
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: github-markdown
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.6'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.10'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.10'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.4'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.4'
111
+ - !ruby/object:Gem::Dependency
112
+ name: word-to-markdown
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.1'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.1'
125
+ description:
126
+ email:
127
+ - ben.balter@github.com
128
+ executables:
129
+ - m2w
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".gitignore"
134
+ - ".travis.yml"
135
+ - Gemfile
136
+ - LICENSE
137
+ - README.md
138
+ - Rakefile
139
+ - bin/m2w
140
+ - lib/markdown_to_word.rb
141
+ - lib/markdown_to_word/default.docx
142
+ - lib/markdown_to_word/document.rb
143
+ - lib/markdown_to_word/template/[Content_Types].xml
144
+ - lib/markdown_to_word/template/_rels/.rels
145
+ - lib/markdown_to_word/template/docProps/app.xml
146
+ - lib/markdown_to_word/template/docProps/core.xml
147
+ - lib/markdown_to_word/template/docProps/thumbnail.jpeg
148
+ - lib/markdown_to_word/template/word/_rels/document.xml.rels
149
+ - lib/markdown_to_word/template/word/document.xml
150
+ - lib/markdown_to_word/template/word/fontTable.xml
151
+ - lib/markdown_to_word/template/word/numbering.xml
152
+ - lib/markdown_to_word/template/word/settings.xml
153
+ - lib/markdown_to_word/template/word/styles.xml
154
+ - lib/markdown_to_word/template/word/stylesWithEffects.xml
155
+ - lib/markdown_to_word/template/word/theme/theme1.xml
156
+ - lib/markdown_to_word/template/word/webSettings.xml
157
+ - lib/markdown_to_word/version.rb
158
+ - markdown_to_word.gemspec
159
+ - script/bootstrap
160
+ - script/build-template
161
+ - script/cibuild
162
+ - script/console
163
+ - spec/fixtures/ol.md
164
+ - spec/fixtures/ul.md
165
+ - spec/markdown_to_word_bin_spec.rb
166
+ - spec/markdown_to_word_conversion_spec.rb
167
+ - spec/markdown_to_word_document_spec.rb
168
+ - spec/markdown_to_word_spec.rb
169
+ - spec/spec_helper.rb
170
+ homepage: https://github.com/benbalter/markdown_to_word
171
+ licenses:
172
+ - MIT
173
+ metadata: {}
174
+ post_install_message:
175
+ rdoc_options: []
176
+ require_paths:
177
+ - lib
178
+ required_ruby_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ required_rubygems_version: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ requirements: []
189
+ rubyforge_project:
190
+ rubygems_version: 2.5.1
191
+ signing_key:
192
+ specification_version: 4
193
+ summary: Converts GitHub-flavored Markdown to a Word document
194
+ test_files:
195
+ - spec/fixtures/ol.md
196
+ - spec/fixtures/ul.md
197
+ - spec/markdown_to_word_bin_spec.rb
198
+ - spec/markdown_to_word_conversion_spec.rb
199
+ - spec/markdown_to_word_document_spec.rb
200
+ - spec/markdown_to_word_spec.rb
201
+ - spec/spec_helper.rb