]> sipb.mit.edu Git - ikiwiki.git/commitdiff
willu's teximg changes
authorJoey Hess <joey@kodama.kitenet.net>
Sun, 24 Aug 2008 19:21:51 +0000 (15:21 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Sun, 24 Aug 2008 19:21:51 +0000 (15:21 -0400)
* teximg: The prefix is configurable, and has changed to not include the
  nonstandard mhchem by default. (willu)
* teximg: dvipng is used if available to render images. Its output is
  antialiased and better than dvips. If not available, the old dvips+convert
  chain will be used. (willu)
* Drop suggests on texlive-science, add suggests on dvipng.

IkiWiki/Plugin/teximg.pm
debian/NEWS
debian/changelog
debian/control
doc/plugins/teximg.mdwn
doc/todo/Move_teximg_latex_preamble_to_config_file.mdwn
po/ikiwiki.pot

index 369c1088203cb2ec86e397bd46e9a98e1a4e544d..661d97b1f4fc04b86421f41baa36cd05ce021a8b 100644 (file)
@@ -10,6 +10,17 @@ use File::Temp qw(tempdir);
 use HTML::Entities;
 use IkiWiki 2.00;
 
 use HTML::Entities;
 use IkiWiki 2.00;
 
+my $default_prefix = <<EOPREFIX;
+\\documentclass{article}
+\\usepackage{amsmath}
+\\usepackage{amsfonts}
+\\usepackage{amssymb}
+\\pagestyle{empty}
+\\begin{document}
+EOPREFIX
+
+my $default_postfix = '\\end{document}';
+
 sub import { #{{{
        hook(type => "getsetup", id => "teximg", call => \&getsetup);
        hook(type => "preprocess", id => "teximg", call => \&preprocess);
 sub import { #{{{
        hook(type => "getsetup", id => "teximg", call => \&getsetup);
        hook(type => "preprocess", id => "teximg", call => \&preprocess);
@@ -21,6 +32,26 @@ sub getsetup () { #{{{
                        safe => 1,
                        rebuild => undef,
                },
                        safe => 1,
                        rebuild => undef,
                },
+               teximg_dvipng => {
+                       type => "boolean",
+                       description => "Should teximg use dvipng to render, or dvips and convert?",
+                       safe => 0,
+                       rebuild => undef,
+               },
+               teximg_prefix => {
+                       type => "string",
+                       example => $default_prefix,
+                       description => "LaTeX prefix for teximg plugin",
+                       safe => 0, # Not sure how secure LaTeX is...
+                       rebuild => 1,
+               },
+               teximg_postfix => {
+                       type => "string",
+                       example => $default_postfix,
+                       description => "LaTeX postfix for teximg plugin",
+                       safe => 0, # Not sure how secure LaTeX is...
+                       rebuild => 1,
+               },
 } #}}}
 
 sub preprocess (@) { #{{{
 } #}}}
 
 sub preprocess (@) { #{{{
@@ -105,25 +136,34 @@ sub gen_image ($$$$) { #{{{
        my $digest = shift;
        my $imagedir = shift;
 
        my $digest = shift;
        my $imagedir = shift;
 
-       #TODO This should move into the setup file.
-       my $tex = '\documentclass['.$height.'pt]{scrartcl}';
-       $tex .= '\usepackage[version=3]{mhchem}';
-       $tex .= '\usepackage{amsmath}';
-       $tex .= '\usepackage{amsfonts}';
-       $tex .= '\usepackage{amssymb}';
-       $tex .= '\pagestyle{empty}';
-       $tex .= '\begin{document}';
+       if (!defined $config{teximg_prefix}) {
+               $config{teximg_prefix} = $default_prefix;
+       }
+       if (!defined $config{teximg_postfix}) {
+               $config{teximg_postfix} = $default_postfix;
+       }
+       if (!defined $config{teximg_dvipng}) {
+               $config{teximg_dvipng} = length `which dvipng 2>/dev/null`;
+       }
+       
+       my $tex = $config{teximg_prefix};
        $tex .= '$$'.$code.'$$';
        $tex .= '$$'.$code.'$$';
-       $tex .= '\end{document}';
+       $tex .= $config{teximg_postfix};
+       $tex =~ s!\\documentclass{article}!\\documentclass[${height}pt]{article}!g;
+       $tex =~ s!\\documentclass{scrartcl}!\\documentclass[${height}pt]{scrartcl}!g;
 
        my $tmp = eval { create_tmp_dir($digest) };
        if (! $@ &&
            writefile("$digest.tex", $tmp, $tex) &&
            system("cd $tmp; latex --interaction=nonstopmode $tmp/$digest.tex > /dev/null") == 0 &&
 
        my $tmp = eval { create_tmp_dir($digest) };
        if (! $@ &&
            writefile("$digest.tex", $tmp, $tex) &&
            system("cd $tmp; latex --interaction=nonstopmode $tmp/$digest.tex > /dev/null") == 0 &&
-           system("dvips -E $tmp/$digest.dvi -o $tmp/$digest.ps 2> $tmp/$digest.log") == 0 &&
            # ensure destination directory exists
            writefile("$imagedir/$digest.png", $config{destdir}, "") &&
            # ensure destination directory exists
            writefile("$imagedir/$digest.png", $config{destdir}, "") &&
-           system("convert -density 120  -trim -transparent \"#FFFFFF\" $tmp/$digest.ps $config{destdir}/$imagedir/$digest.png > $tmp/$digest.log") == 0) {
+           (($config{teximg_dvipng} &&
+               system("dvipng -D 120 -bg Transparent -T tight -o $config{destdir}/$imagedir/$digest.png $tmp/$digest.dvi > $tmp/$digest.log") == 0
+           ) || (!$config{teximg_dvipng} &&
+               system("dvips -E $tmp/$digest.dvi -o $tmp/$digest.ps 2> $tmp/$digest.log") == 0 &&
+               system("convert -density 120  -trim -transparent \"#FFFFFF\" $tmp/$digest.ps $config{destdir}/$imagedir/$digest.png > $tmp/$digest.log") == 0
+           ))) {
                return 1;
        }
        else {
                return 1;
        }
        else {
index e0c9b77eb64119ede76bff3e50a9637774d398bc..a7a145d9bce7ee3a1bf307d73d2473ad862631f3 100644 (file)
@@ -1,3 +1,27 @@
+ikiwiki (2.62) unstable; urgency=low
+
+  TexImg standard preamble changed
+
+  The teximg plugin now has a configurable LaTeX preamble.
+  As part of this change the `mchem` LaTeX package has been removed from
+  the default LaTeX preamble as it wasn't included in many TeX installations.
+
+  The previous behaviour can be restored by adding the following to your
+  ikiwiki setup:
+
+        teximg_prefix => '\documentclass{scrartcl}
+                \usepackage[version=3]{mhchem}
+                \usepackage{amsmath}
+                \usepackage{amsfonts}
+                \usepackage{amssymb}
+                \pagestyle{empty}
+                \begin{document}',
+
+  In addition, the rendering mechanism has been changed to use `dvipng` by
+  default, if available.
+
+ -- Joey Hess <joeyh@debian.org>  Sun, 24 Aug 2008 15:00:40 -0400
+
 ikiwiki (2.60) unstable; urgency=low
 
   Admin preferences are moving from the web interface to the setup file.
 ikiwiki (2.60) unstable; urgency=low
 
   Admin preferences are moving from the web interface to the setup file.
index 460ddc27fa43f0a8e26c3f8b4201ffa0d9de8df6..5e537a9db79c9940ff0e15f9ce3a174b5d573c1d 100644 (file)
@@ -7,6 +7,12 @@ ikiwiki (2.62) UNRELEASED; urgency=low
   * ikiwiki-makerepo: Added support for monotone. (Thomas Keller)
   * map: The fix for #449285 was buggy and broke display of parents in certian
     circumstances.
   * ikiwiki-makerepo: Added support for monotone. (Thomas Keller)
   * map: The fix for #449285 was buggy and broke display of parents in certian
     circumstances.
+  * teximg: The prefix is configurable, and has changed to not include the
+    nonstandard mhchem by default. (willu)
+  * teximg: dvipng is used if available to render images. Its output is
+    antialiased and better than dvips. If not available, the old dvips+convert
+    chain will be used. (willu)
+  * Drop suggests on texlive-science, add suggests on dvipng.
 
  -- Joey Hess <joeyh@debian.org>  Thu, 21 Aug 2008 16:20:58 -0400
 
 
  -- Joey Hess <joeyh@debian.org>  Thu, 21 Aug 2008 16:20:58 -0400
 
index 72aa12ab8cd22b07a21575e89d65253b9ae0937d..b900052dcd4fba7dc7610c8112ded0230967d125 100644 (file)
@@ -14,7 +14,7 @@ Package: ikiwiki
 Architecture: all
 Depends: ${perl:Depends}, markdown | libtext-markdown-perl, libhtml-scrubber-perl, libhtml-template-perl, libhtml-parser-perl, liburi-perl
 Recommends: gcc | c-compiler, libc6-dev | libc-dev, subversion | git-core (>= 1:1.5.0) | tla | bzr (>= 0.91) | mercurial | monotone (>= 0.38), libxml-simple-perl, libnet-openid-consumer-perl, liblwpx-paranoidagent-perl, libtimedate-perl, libcgi-formbuilder-perl (>= 3.05), libcgi-session-perl (>= 4.14-1), libmail-sendmail-perl, libauthen-passphrase-perl
 Architecture: all
 Depends: ${perl:Depends}, markdown | libtext-markdown-perl, libhtml-scrubber-perl, libhtml-template-perl, libhtml-parser-perl, liburi-perl
 Recommends: gcc | c-compiler, libc6-dev | libc-dev, subversion | git-core (>= 1:1.5.0) | tla | bzr (>= 0.91) | mercurial | monotone (>= 0.38), libxml-simple-perl, libnet-openid-consumer-perl, liblwpx-paranoidagent-perl, libtimedate-perl, libcgi-formbuilder-perl (>= 3.05), libcgi-session-perl (>= 4.14-1), libmail-sendmail-perl, libauthen-passphrase-perl
-Suggests: viewvc | gitweb | viewcvs, libsearch-xapian-perl, xapian-omega (>= 1.0.5), librpc-xml-perl, libtext-wikiformat-perl, python, python-docutils, polygen, tidy, libxml-feed-perl, libmailtools-perl, perlmagick, libfile-mimeinfo-perl, libcrypt-ssleay-perl, liblocale-gettext-perl (>= 1.05-1), libtext-typography-perl, libtext-csv-perl, libdigest-sha1-perl, graphviz, libnet-amazon-s3-perl, sparkline-php, texlive, texlive-science
+Suggests: viewvc | gitweb | viewcvs, libsearch-xapian-perl, xapian-omega (>= 1.0.5), librpc-xml-perl, libtext-wikiformat-perl, python, python-docutils, polygen, tidy, libxml-feed-perl, libmailtools-perl, perlmagick, libfile-mimeinfo-perl, libcrypt-ssleay-perl, liblocale-gettext-perl (>= 1.05-1), libtext-typography-perl, libtext-csv-perl, libdigest-sha1-perl, graphviz, libnet-amazon-s3-perl, sparkline-php, texlive, dvipng
 Conflicts: ikiwiki-plugin-table
 Replaces: ikiwiki-plugin-table
 Provides: ikiwiki-plugin-table
 Conflicts: ikiwiki-plugin-table
 Replaces: ikiwiki-plugin-table
 Provides: ikiwiki-plugin-table
index 1908cfb79740f71e0d31392a1b13c3ae23f226e2..07ebb6d997a958748136cdb9be348ce9c58b5078 100644 (file)
@@ -27,3 +27,11 @@ To add an alt text to the image, use alt="text":
        \[[!teximg code="\frac{1}{2}" alt="1/2"]]
 
 See [this site](http://www.der-winnie.de/opensource/gsoc2007) for rendered images.
        \[[!teximg code="\frac{1}{2}" alt="1/2"]]
 
 See [this site](http://www.der-winnie.de/opensource/gsoc2007) for rendered images.
+
+## configuration
+
+There are several configuration directives that can be used in the setup
+file. `teximg_prefix` can be set to change the LaTeX preamble, and
+`teximg_postfix` to change the LaTeX postfix. The `teximg_dvipng` setting
+can be set to 0 to disable use of `dvipng`, and instead force use of `dvips`
+and `convert`.
index 2d5415c09059e96efa9bbfbb75bc8d02619df45a..d94d24ee4d81f5ae0442d3066772a161cff8eca9 100644 (file)
@@ -152,3 +152,5 @@ Happy TeXing.
                return 1;
        }
        else {
                return 1;
        }
        else {
+
+[[done]]
index 99a18be37430b9d1e551cc79ef035b1fb7dc0b16..60ee59737161c968d9cc401dce6dd4562d554d6a 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-08-21 22:49-0400\n"
+"POT-Creation-Date: 2008-08-24 15:06-0400\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -695,15 +695,15 @@ msgstr ""
 msgid "failed to process:"
 msgstr ""
 
 msgid "failed to process:"
 msgstr ""
 
-#: ../IkiWiki/Plugin/teximg.pm:39
+#: ../IkiWiki/Plugin/teximg.pm:70
 msgid "missing tex code"
 msgstr ""
 
 msgid "missing tex code"
 msgstr ""
 
-#: ../IkiWiki/Plugin/teximg.pm:46
+#: ../IkiWiki/Plugin/teximg.pm:77
 msgid "code includes disallowed latex commands"
 msgstr ""
 
 msgid "code includes disallowed latex commands"
 msgstr ""
 
-#: ../IkiWiki/Plugin/teximg.pm:97
+#: ../IkiWiki/Plugin/teximg.pm:128
 msgid "failed to generate image from code"
 msgstr ""
 
 msgid "failed to generate image from code"
 msgstr ""
 
@@ -800,6 +800,19 @@ msgstr ""
 msgid "cannot read %s: %s"
 msgstr ""
 
 msgid "cannot read %s: %s"
 msgstr ""
 
+#: ../IkiWiki/Setup/Automator.pm:33
+msgid "you must enter a wikiname (that contains alphanumerics)"
+msgstr ""
+
+#: ../IkiWiki/Setup/Automator.pm:67
+#, perl-format
+msgid "unsupported revision control system %s"
+msgstr ""
+
+#: ../IkiWiki/Setup/Automator.pm:83
+msgid "failed to set up the repository with ikiwiki-makerepo"
+msgstr ""
+
 #: ../IkiWiki/Wrapper.pm:16
 #, perl-format
 msgid "%s doesn't seem to be executable"
 #: ../IkiWiki/Wrapper.pm:16
 #, perl-format
 msgid "%s doesn't seem to be executable"