<commit_before>require 'tempfile'
require File.join(File.dirname(__FILE__), '..', 'html', 'html.rb')

# Depends on HTMLDOC utility (http://www.easysw.com/htmldoc/)
module Markout

  class Pdf < Formatter

    def export
      `cat "#{tempfile.path}" | /opt/local/bin/htmldoc -t pdf \
          --bodyfont "Helvetica" --headfootfont "Helvetica" \
          --no-compression --color --embedfonts \
          --header "" --footer .1. --links --no-title \
          --toctitle "" --tocheader "..." --tocfooter "..." \
          -`
    end

    private

    def tempfile
      tempfile = Tempfile.new(File.basename(@document.path) + '.html')
      tempfile << Markout::Html.new(@document).export
    end

  end

end<commit_msg>FIXed handling of accented characters for the PDF output (gsub lifted from TextMate's Markdown bundle, cannot find who to credit)<commit_after>$KCODE = 'UTF-8'

require 'tempfile'
require File.join(File.dirname(__FILE__), '..', 'html', 'html.rb')

# Depends on HTMLDOC utility (http://www.easysw.com/htmldoc/)
module Markout

  class Pdf < Formatter

    def export
      `cat "#{tempfile.path}" | /opt/local/bin/htmldoc -t pdf \
          --bodyfont "Helvetica" --headfootfont "Helvetica" \
          --no-compression --color --embedfonts \
          --header "" --footer .1. --links --no-title \
          --toctitle "" --tocheader "..." --tocfooter "..." \
          -`
    end

    private

    def tempfile
      tempfile = Tempfile.new(File.basename(@document.path) + '.html')
      content  = Markout::Html.new(@document).export
      tempfile << content.gsub(/[^\x00-\x7F]/) { |ch| "&##{ch.unpack("U")[0]};" } # From the Textmate Markdown bundle
    end

  end

end
{'fraction_non_alphanumeric': 0.168141592920354, 'fraction_numerical': 0.004129793510324484, 'mean_word_length': 2.338582677165354, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4772512', 'n_tokens_mistral': 582, 'n_tokens_neox': 553, 'n_words': 130}