git.iko.soy/typeable/pandoc
on master help sign in
Added html2x demo to the website.

git-svn-id: https://pandoc.googlecode.com/svn/trunk@1017 788f1e2b-df1e-0410-8736-df70ead52e1b

commitb5819b8ed6b107a089f55e636c78cac7166ea36d authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSat 15 Sep 2007, 01:53 (19 years ago) parentd5b7257
4 files changed+89−2
web/Makefile+2−2 web/demos+3 web/html2x.pl+34 web/html2x.txt+50
web/Makefile+2−2
@@ -1,4 +1,4 @@
1−ALL := index.html README.html INSTALL.html examples.html pandoc1.html markdown2pdf1.html html2markdown1.html hsmarkdown1.html
1+ALL := index.html README.html INSTALL.html examples.html pandoc1.html markdown2pdf1.html html2markdown1.html hsmarkdown1.html html2x.html
22PANDOC_PATH ?= $(dir $(shell which pandoc))
33MAKEPAGE = $(PANDOC_PATH)/pandoc -s -S -c pandoc.css -A footer.html
44all : $(ALL)
@@ -34,4 +34,4 @@ INSTALL.html : INSTALL
3434 $(MAKEPAGE) $< > $@
3535
3636upload :
37− sitecopy --update macfarlane
37+ make -C .. upload
web/demos+3
@@ -72,3 +72,6 @@ click on the name of the output file:
727215. A simple wiki program using [HAppS](http://happs.org) and pandoc:
7373 [pandocwiki](http://pandocwiki.googlecode.com/svn/trunk/)
7474
75+16. A web application that converts web pages to any of eight different
76+ formats: [html2x](html2x.html).
77+
web/html2x.plnew file+34
@@ -0,0 +1,34 @@
1+#!/usr/bin/env perl
2+use CGI qw/:standard/;
3+use CGI::Carp 'fatalsToBrowser';
4+
5+$CGI::POST_MAX=1024 * 100; # max 100K posts
6+$CGI::DISABLE_UPLOADS = 1; # no uploads
7+
8+if (param('url') && param('format')) {
9+ $options = '--standalone --reference-links';
10+ $url = param('url');
11+ $format = param('format') || 'markdown';
12+ if ($format =~ '^markdown$') {
13+ $options .= ' --strict';
14+ }
15+ if ($format =~ '^markdown\+$') {
16+ $format = 'markdown';
17+ }
18+ $output = `wget -O- $url | tidy -asxhtml -utf8 | pandoc -r html -w $format $options`;
19+ if ($format =~ "rtf") {
20+ $type = "application/rtf"
21+ } else {
22+ $type = "text/plain"
23+ };
24+ print header(-charset=>"utf8",-type=>"$type"),
25+ $output;
26+} else {
27+ print start_html(-title=>"html2x"),
28+ h1("Usage"),
29+ p("You have tried to call html2x.pl without the proper parameters."),
30+ p("Please use <a href=\"/pandoc/html2x.html\">this form</a>."),
31+ end_html();
32+}
33+
34+
web/html2x.txtnew file+50
@@ -0,0 +1,50 @@
1+% html2x
2+
3+This form uses [pandoc] to convert a web page to markdown,
4+reStructuredText, DocBook XML, LaTeX, RTF, or a unix man page.
5+
6+<form action="/pandoc/html2x.pl" method="get">
7+<p>
8+<label for="url">URL:</label>
9+<input type="text" size="60" name="url" />
10+</p>
11+<p>
12+<label for="format">Format:</label><br/>
13+<input type="radio" name="format" value="markdown" checked="checked" />Markdown<br/>
14+<input type="radio" name="format" value="markdown+" />Markdown with
15+<a href="/pandoc/README.html#pandocs-markdown-vs-standard-markdown">pandoc extensions</a><br/>
16+<input type="radio" name="format" value="rst" />reStructuredText<br/>
17+<input type="radio" name="format" value="docbook" />DocBook XML<br/>
18+<input type="radio" name="format" value="latex" />LaTeX<br/>
19+<input type="radio" name="format" value="context" />ConTeXt<br/>
20+<input type="radio" name="format" value="rtf" />Rich Text Format (RTF)<br/>
21+<input type="radio" name="format" value="man" />Groff man page
22+</p>
23+<input type="submit" value="Convert" /><br/>
24+</form>
25+
26+Javascript bookmarklets (right-click and add bookmark):
27+
28+- [2markdown]
29+- [2markdown+]
30+- [2rst]
31+- [2docbook]
32+- [2LaTeX]
33+- [2ConTeXt]
34+- [2RTF]
35+- [2man]
36+
37+(Inspired by [the Asciinator].)
38+
39+[2markdown]: javascript:location.href='http://johnmacfarlane.net/pandoc/html2x.pl?format=markdown&url='+document.location.href;
40+[2markdown+]: javascript:location.href='http://johnmacfarlane.net/pandoc/html2x.pl?format=markdown+&url='+document.location.href;
41+[2rst]: javascript:location.href='http://johnmacfarlane.net/pandoc/html2x.pl?format=rst&url='+document.location.href;
42+[2docbook]: javascript:location.href='http://johnmacfarlane.net/pandoc/html2x.pl?format=docbook&url='+document.location.href;
43+[2LaTeX]: javascript:location.href='http://johnmacfarlane.net/pandoc/html2x.pl?format=latex&url='+document.location.href;
44+[2ConTeXt]: javascript:location.href='http://johnmacfarlane.net/pandoc/html2x.pl?format=context&url='+document.location.href;
45+[2RTF]: javascript:location.href='http://johnmacfarlane.net/pandoc/html2x.pl?format=rtf&url='+document.location.href;
46+[2man]: javascript:location.href='http://johnmacfarlane.net/pandoc/html2x.pl?format=man&url='+document.location.href;
47+
48+[pandoc]: /pandoc/
49+[the Asciinator]: http://www.aaronsw.com/2002/html2text/
50+