h1

Overview of wplatex

January 30, 2010

Man, we are getting a lot of snow today. I guess that means I’ll stay inside and describe how to use the wplatex package that I put together.

Okay, so like I said in the last post, you should be able to install the package using the standard way for Python packages. Unzip it into whatever directory you like, then do a

 
    sudo python setup.py install
   

Next, copy the wpblogentry.cls document class definition file into your Latex path. This is usually something like /usr/share/texmf/.... Basically do whatever you have to on your system to make latex find the definition.

At this point, you should be able to make a Latex blog entry by doing something like this:

 
    \documentclass{wpblogentry}

    \title{A Latex Blog Entry}
    \tags{tag1, tag2}
    \category{latex}

    \begin{document}

      Your blog entry

    \end{document}
   

The package will install a script called wplpost on your system, so when you have got your blog entry looking like you want it, you’ll want to run this script to render it and upload it to wordpress. The script will prompt you for a username and password, but you can also specify them on the command line using the -u and -p options respectively. You also need to specify where to upload the post to. You can do this two different ways, using either the -b or -x options. If you do -b blogname, then the script will guess that it can access your blog’s xmlrpc.php file at

http://blogname.wordpress.com/xmlrpc.php

If this is not the correct location, you can specify the url directly using the -x option. As an example, I would upload this blog entry by doing

 
    wplpost -u ericfinster -b curiousreasoning wplatex.tex
   

Note that this form will automatically publish the post as well. If you would like to upload the post as a draft only, you can specify -d and you should then be able to go in and preview it on WordPress before you actually publish the result.

I think this much should be functional right now. I’m going to try to get the listings package working so that I can write source code in my entries. When I’m done, I’ll write a post about how to extend wplatex’s renderer so that you can add customizations if you like. Cheers everyone.

About these ads

13 comments

  1. It worked! Though the first time I tried it, I didn’t pass my username as an option, and it gave me a NameError, saying that my username was not defined.

    I also figured out along the way that you need to install both wordpresslib and plastex. I hadn’t done either of those yet, evidently.


    • For me, it works to post, but some math symbols do not come up correctly. However plastex works well in the same document. Please see http://rvfmath.wordpress.com/2010/01/31/latex-blog-entry-with-math/ for the result of the following simple file: (test.tex)

      \documentclass{wpblogentry}

      \title{Latex Blog Entry With Math}
      \tags{tag1, tag2}
      \category{latex}

      \begin{document}

      $\Delta$ $\alpha$ $\beta$ $\gamma$ $\delta$ $\sigma$ $a_{1}$ $\subseteq$.

      \begin{equation}
      x+y=5
      \end{equation}

      \end{document}

      and the output of wplatex:

      rafael@rafael-laptop:~/TeXfiles/wordpress$ wplpost -u rvf0068 -b rvfmath test.tex
      ( /usr/local/lib/python2.6/dist-packages/wplatex/wpblogentry.pyc )…….Wordpress Password:

      WARNING: Using default renderer for Delta
      WARNING: Using default renderer for alpha
      WARNING: Using default renderer for beta
      WARNING: Using default renderer for gamma
      WARNING: Using default renderer for delta
      WARNING: Using default renderer for sigma
      WARNING: Using default renderer for subseteq
      WARNING: Using default renderer for equation
      rafael@rafael-laptop:~/TeXfiles/wordpress$


      • Thanks for experimenting with some of these things. Right now, there are not too many environments implemented by the renderer. I added the equation environment, but it basically does the same as displaymath right now (no numbering till I get to that . . .)

        The thing with the greek letters is fixed though. That was a bug. Try new version and see if it works better.


  2. Yes, thanks! It works now. And also the inclusion of source code, though I think I would post more LaTeX code (which of course it is only one trivial edit away).

    Now I would be very happy if theorems and inclusions of tikzpictures worked… will try but first I have to feel comfortable with Python.


  3. [...] times. Also good times: writing this post in emacs, and using Eric Finster’s wplatex python package to post it. Well, once I got plastex working in my Ubuntu install. Something strange [...]


  4. [...] (LaTeX2WP.sty). For more information, look the following posts at the Curious Reasoning blog: 1 – 2 – [...]


  5. What packages does wplatex depend on? I have trouble installing it.


  6. Cool stuff! But I have a problem. I have tried a number of things but can’t seem to get wpblogentry to load, which I am guessing is the .py based on this error output
    =============
    ERROR: Could not load package “wpblogentry”: name ‘Command’ is not defined
    ..
    WARNING: unrecognized command/environment: tags
    WARNING: unrecognized command/environment: category
    ….Traceback (most recent call last):
    File “/usr/bin/wplpost”, line 115, in
    sys.exit(main())
    File “/usr/bin/wplpost”, line 110, in main
    idPost = wp.newPost(post, not options.draft)
    File “/usr/lib/python2.6/site-packages/wplatex/wp.py”, line 91, in newPost
    post.render()
    File “/usr/lib/python2.6/site-packages/wplatex/wp.py”, line 59, in render
    self.tags = self._document.userdata['tags'].textContent.encode(‘utf-8′)
    KeyError: ‘tags’
    ============

    I’ve tried a number of things, am gonna do a fresh install, but does anyone have some advice?


  7. I had posted a question about an error message while trying to get wplatex running. I don’t see it, but here is the update:

    I have since installed on my ArchLinux and everything works fine (though, for some reason, having “^” in my password was a problem).

    The original problems were on Fedora 12 and it looked like wpblogentry.py was not being read… the main error being that is would not load, and so things like \tag{} and \category{} were not being defined.


  8. Thanks for creating this tool.I have a problem, I get this error when trying to post:

    File “/Library/Python/2.5/site-packages/wplatex/renderer.py”, line 120, in default
    if len(node.nodeName) == 1 and node.nodeName not in string.letters:
    NameError: global name ‘string’ is not defined

    It is due to my using \, for generating a space in the latex code. Could you please help? Thanks a lot.


    • I solved this by adding the line

      import string

      at the beginning of the renderer.py. It seems that string is not automatically available in the current python2 release…


  9. I made a PKGBUILD of your package, which makes it a one line to install wplatex onto Arch Linux. I hope that this is okay!

    I wonder how large is the intersection of Arch users and math WP bloggers, but I know it’s non-empty :) .



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: