justinvh / Markdown-LaTeX

This Markdown extension adds inline LaTeX support without the need for external images.
Other
127 stars 15 forks source link

render the png as transparent background? #6

Closed 404pnf closed 12 years ago

404pnf commented 12 years ago

This module rocks! And the solution is so simple (in regard to what user need to do) that at first I didn't get it because I didn't believe this could be my solution. :) How I was wrong!

After playing around with the module for a few days, I do have a question.

I added

  -bg Transparent

to the dvipng cmd options in line 108 where it used to be

   # Extract the image
    cmd = "dvipng -q -bg -T tight -x 1200 -z 9 \
    %s -o %s" % (dvi, png)

hoping to get what I want.

It didn't work.

How to get a math png with transparent background. The current background is white.

I want to do this because the final output is html and white background doesn't play well with some page background.

Thank you!

justinvh commented 12 years ago

Output images now default to transparent backgrounds. You can run the tests. I have tested this under dvipng 1.14.

404pnf commented 12 years ago

to provide more infomation

my dvipng version

dvipng installed through apt

dvipng --version This is dvipng 1.14 Copyright 2002-2010 Jan-Ake Larsson dvipng 1.14 kpathsea version 5.0.0 Compiled with Freetype 2.4.4 Using libft 2.4.8 Copyright (C) 2002-2010 Jan-Ake Larsson. There is NO warranty. You may redistribute this software under the terms of the GNU Lesser General Public License version 3, see the COPYING file in the dvipng distribution or http://www.gnu.org/licenses/.

my OS

Ubuntu 12.04.1 LTS

run test

  1. clone the repo
  2. run markdown_py -x latex math.markdown > math.html
  3. check png, they are transparent
  4. add my equations, never transparent.
  5. find out only your original equation are transparent
  6. expirement 30 mins and couldn't get a clue
  7. find a latex.cache file in test folder
  8. rm latex.cache
  9. re-run math.markdown
  10. pngs are not transparent

try that agan

  1. clone the repo in another dir
  2. make sure there is not latex.cache file, there isn't this time
  3. render math.markdown
  4. pngs are not transparent
justinvh commented 12 years ago

Can you upload that actual generated data somewhere?

justinvh commented 12 years ago

Also, verify that your -x is using the local latex.py and now your site-packages version (if it exists)

404pnf commented 12 years ago

Sorry, I didn't put the latest version in the markdown extension folder.

I am stupid!

The new version already has the -bg Transparent options. Thank you!

Sorry for taking up your time!

Close issue.