From bed1c99d640613179fd9098f30234bc35e2c25e5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Boulogne?= Date: Sat, 4 May 2013 20:56:08 +0200 Subject: [PATCH] add sources --- jsmath.tmpl | 205 +++++++++++++++++++++++++++++++++++++++++++++ latexmathml.tmpl | 206 +++++++++++++++++++++++++++++++++++++++++++++ mathjax.tmpl | 205 +++++++++++++++++++++++++++++++++++++++++++++ mathml.js | 70 ++++++++++++++++ mathml.tmpl | 197 +++++++++++++++++++++++++++++++++++++++++++ pandoc.pm | 212 +++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 1095 insertions(+) create mode 100644 jsmath.tmpl create mode 100644 latexmathml.tmpl create mode 100644 mathjax.tmpl create mode 100644 mathml.js create mode 100644 mathml.tmpl create mode 100755 pandoc.pm diff --git a/jsmath.tmpl b/jsmath.tmpl new file mode 100644 index 0000000..bea7083 --- /dev/null +++ b/jsmath.tmpl @@ -0,0 +1,205 @@ + + + + + + + + + + + + +<TMPL_VAR TITLE> + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +
+ +
+ +
+ + + +
+ + + + +
Comments on this page are closed.
+
+
+
+
+ + + +
+ + + + + + + +
+ +License: +
+
+ +
+Last edited + +
+ + + + + +
+ +
+ + + diff --git a/latexmathml.tmpl b/latexmathml.tmpl new file mode 100644 index 0000000..9daa2c6 --- /dev/null +++ b/latexmathml.tmpl @@ -0,0 +1,206 @@ + + + + + + + + + + + + +<TMPL_VAR TITLE> + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +
+ +
+ +
+ + + +
+ + + + +
Comments on this page are closed.
+
+
+
+
+ + + +
+ + + + + + + +
+ +License: +
+
+ +
+Last edited + +
+ + + + + +
+ +
+ + + diff --git a/mathjax.tmpl b/mathjax.tmpl new file mode 100644 index 0000000..6f19a60 --- /dev/null +++ b/mathjax.tmpl @@ -0,0 +1,205 @@ + + + + + + + + + + + + +<TMPL_VAR TITLE> + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +
+ +
+ +
+ + + +
+ + + + +
Comments on this page are closed.
+
+
+
+
+ + + +
+ + + + + + + +
+ +License: +
+
+ +
+Last edited + +
+ + + + + +
+ +
+ + + diff --git a/mathml.js b/mathml.js new file mode 100644 index 0000000..a72c2e5 --- /dev/null +++ b/mathml.js @@ -0,0 +1,70 @@ +/* +March 19, 2004 MathHTML (c) Peter Jipsen http://www.chapman.edu/~jipsen +Released under the GNU General Public License version 2 or later. +See the GNU General Public License (at http://www.gnu.org/copyleft/gpl.html) +for more details. +*/ + +function convertMath(node) {// for Gecko + if (node.nodeType==1) { + var newnode = + document.createElementNS("http://www.w3.org/1998/Math/MathML", + node.nodeName.toLowerCase()); + for(var i=0; i < node.attributes.length; i++) + newnode.setAttribute(node.attributes[i].nodeName, + node.attributes[i].nodeValue); + for (var i=0; i"); + document.write(""); +} +if(typeof window.addEventListener != 'undefined'){ + window.addEventListener('load', convert, false); +} +if(typeof window.attachEvent != 'undefined') { + window.attachEvent('onload', convert); +} diff --git a/mathml.tmpl b/mathml.tmpl new file mode 100644 index 0000000..cca833d --- /dev/null +++ b/mathml.tmpl @@ -0,0 +1,197 @@ + + + + + + + + + + + + +<TMPL_VAR TITLE> + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + +
+ +
+ +
+ + + +
+ + + + +
Comments on this page are closed.
+
+
+
+
+ + + +
+ + + + + + + +
+ +License: +
+
+ +
+Last edited + +
+ + + + + +
+ +
+ + + diff --git a/pandoc.pm b/pandoc.pm new file mode 100755 index 0000000..ec3706d --- /dev/null +++ b/pandoc.pm @@ -0,0 +1,212 @@ +#!/usr/bin/env perl + +package IkiWiki::Plugin::pandoc; + +use warnings; +use strict; +use IkiWiki; +use FileHandle; +use IPC::Open2; + +sub import { + my $markdown_ext = $config{pandoc_markdown_ext} || "mdwn"; + + hook(type => "getsetup", id => "pandoc", call => \&getsetup); + hook(type => "htmlize", id => $markdown_ext, + # longname => "Pandoc Markdown", + call => sub { htmlize("markdown", @_) }); + if ($config{pandoc_latex}) { + hook(type => "htmlize", id => "tex", + call => sub { htmlize("latex", @_) }); + } + if ($config{pandoc_rst}) { + hook(type => "htmlize", id => "rst", + call => sub { htmlize("rst", @_) }); + } +} + + +sub getsetup () { + return + plugin => { + safe => 1, + rebuild => 1, + }, + pandoc_command => { + type => "string", + example => "/usr/local/bin/pandoc", + description => "Path to pandoc executable", + safe => 0, + rebuild => 0, + }, + pandoc_markdown_ext => { + type => "string", + example => "mdwn", + description => "File extension for Markdown files", + safe => 1, + rebuild => 1, + }, + pandoc_latex => { + type => "boolean", + example => 0, + description => "Enable Pandoc processing of LaTeX documents", + safe => 0, + rebuild => 1, + }, + pandoc_rst => { + type => "boolean", + example => 0, + description => "Enable Pandoc processing of reStructuredText documents", + safe => 0, + rebuild => 1, + }, + pandoc_smart => { + type => "boolean", + example => 1, + description => "Use smart quotes, dashes, and ellipses", + safe => 1, + rebuild => 1, + }, + pandoc_obfuscate => { + type => "boolean", + example => 1, + description => "Obfuscate emails", + safe => 1, + rebuild => 1, + }, + pandoc_html5 => { + type => "boolean", + example => 0, + description => "Generate HTML5", + safe => 1, + rebuild => 1, + }, + pandoc_ascii => { + type => "boolean", + example => 0, + description => "Generate ASCII instead of UTF8", + safe => 1, + rebuild => 1, + }, + pandoc_numsect => { + type => "boolean", + example => 0, + description => "Number sections", + safe => 1, + rebuild => 1, + }, + pandoc_sectdiv => { + type => "boolean", + example => 0, + description => "Attach IDs to section DIVs instead of Headers", + safe => 1, + rebuild => 1, + }, + pandoc_codeclasses => { + type => "string", + example => "", + description => "Classes to use for indented code blocks", + safe => 1, + rebuild => 1, + }, + pandoc_math => { + type => "string", + example => "unicode", + description => "Process TeX math using", + safe => 0, + rebuild => 1, + }, +} + + +sub htmlize ($@) { + my $format = shift; + my %params = @_; + my $page = $params{page}; + + local(*PANDOC_IN, *PANDOC_OUT); + my @args; + + my $command = $config{pandoc_command} || "/usr/local/bin/pandoc"; + + if ($config{pandoc_smart}) { + push @args, '--smart'; + }; + + if ($config{pandoc_obfuscate}) { + push @args, '--email-obfuscation=references'; + } else { + push @args, '--email-obfuscation=none'; + }; + + if ($config{pandoc_html5}) { + push @args, '--html5'; + }; + + if ($config{pandoc_ascii}) { + push @args, '--ascii'; + }; + + if ($config{pandoc_numsect}) { + push @args, '--number-sections'; + }; + + if ($config{pandoc_sectdiv}) { + push @args, '--section-divs'; + }; + + if ($config{pandoc_codeclasses} && ($config{pandoc_codeclasses} ne "")) { + push @args, '--indented-code-classes=' . $config{pandoc_codeclasses}; + }; + + + for ($config{pandoc_math}) { + if (/^mathjax$/) { + push @args, '--mathjax=/dev/null'; + } + elsif (/^jsmath$/) { + push @args, '--jsmath'; + } + elsif (/^latexmathml$/) { + push @args, '--latexmathml'; + } + elsif (/^mimetex$/) { + push @args, '--mimetex'; + } + elsif (/^mathtex$/) { + push @args, '--mimetex=/cgi-bin/mathtex.cgi'; + } + elsif (/^google$/) { + push @args, '--webtex'; + } + elsif (/^mathml$/) { + push @args, '--mathml'; + } + else { } + } + + # $ENV{"LC_ALL"} = "en_US.UTF-8"; + my $pid = open2(*PANDOC_IN, *PANDOC_OUT, $command, + '-f', $format, + '-t', 'html', + @args); + + error("Unable to open $command") unless $pid; + + # Workaround for perl bug (#376329) + require Encode; + my $content = Encode::encode_utf8($params{content}); + + print PANDOC_OUT $content; + close PANDOC_OUT; + + my @html = ; + close PANDOC_IN; + + waitpid $pid, 0; + + $content = Encode::decode_utf8(join('', @html)); + return $content; +} + +1 -- 2.39.2