Skip to content

Commit

Permalink
Generate valid markup.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnando committed Mar 15, 2015
1 parent 25ce27b commit c96eafa
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/kitabu/exporter/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def format(file)
#
def parse_layout(html)
toc = TOC::HTML.generate(html)
content = Footnotes::HTML.process(toc.content).html.css('html').first.inner_html
content = Footnotes::HTML.process(toc.content).html.css('body').first.inner_html

locals = config.merge({
content: content,
Expand Down
2 changes: 1 addition & 1 deletion lib/kitabu/toc/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def self.normalize(content)
tag.set_attribute("id", permalink)
end

html.css("body").to_xhtml.gsub(/<body>(.*?)<\/body>/m, "\\1")
html.css("body").first.inner_html
end

# Traverse every title normalizing its content as a permalink.
Expand Down
10 changes: 10 additions & 0 deletions spec/kitabu/exporter/html_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
let(:html) { File.read(file) }
before { format.export }

it "generates valid markup", osx: RUBY_PLATFORM.include?('darwin') do
`./vendor/bin/tidy5_osx '#{file}' 2>&1 > /dev/null`
expect($?.exitstatus).to eq(0)
end

it "generates valid markup", linux: RUBY_PLATFORM.include?('linux') do
`./vendor/bin/tidy5_linux '#{file}' 2>&1 > /dev/null`
expect($?.exitstatus).to eq(0)
end

it "keeps html file around" do
expect(file).to be_file
end
Expand Down
8 changes: 7 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ def bundle_install
config.include(SpecHelper)
config.include(Matchers)

config.filter_run_excluding html2text: false, kindlegen: false, prince: false
config.filter_run_excluding(
html2text: false,
kindlegen: false,
prince: false,
osx: false,
linux: false
)

cleaner = proc do
[TMPDIR].each do |i|
Expand Down
Binary file added vendor/bin/tidy5_linux
Binary file not shown.
Binary file added vendor/bin/tidy5_osx
Binary file not shown.

0 comments on commit c96eafa

Please sign in to comment.