File: print.rb

package info (click to toggle)
ruby-wikicloth 0.8.1%2Bdfsg-4.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 588 kB
  • sloc: ruby: 2,548; makefile: 14
file content (23 lines) | stat: -rw-r--r-- 604 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require File.join(File.dirname(__FILE__),'../init.rb')
if ARGV[0] && File.exists?(ARGV[0])
  data = File.read(ARGV[0])
else
  data = "[[ this ]] is a [[ link ]] and another [http://www.google.com Google] but they should be disabled"
end

# Disables all links in the document for printing
class PrettyPrint < WikiCloth::Parser

  external_link do |url,text|
    text.nil? ? url : "#{text} (#{url})"
  end

  link_for do |page,text|
    text.nil? ? page : text
  end

end

# load file into custom parser and render without 
# section edit links
puts PrettyPrint.new(:data => data).to_html(:noedit => true)