{"id":582,"date":"2009-03-19T14:54:15","date_gmt":"2009-03-19T18:54:15","guid":{"rendered":"http:\/\/michaelnielsen.org\/blog\/?p=582"},"modified":"2009-03-19T18:41:27","modified_gmt":"2009-03-19T22:41:27","slug":"wiki_texpy","status":"publish","type":"post","link":"https:\/\/michaelnielsen.org\/blog\/wiki_texpy\/","title":{"rendered":"wiki_tex.py"},"content":{"rendered":"<p>I&#8217;ve written a simple python script called wiki_tex.py to help convert LaTeX to the wiki-tex used on MediaWikis like the <a href=\"http:\/\/michaelnielsen.org\/polymath1\">Polymath1 wiki<\/a>, and <a href=\"http:\/\/en.wikipedia.org\/wiki\/Main_Page\">Wikipedia<\/a>.  It&#8217;s a stripped-down port of a similar script I use to put LaTeX on my blog &#8211; the original script is heavily customized, which is why I haven&#8217;t made it generally available.  <\/p>\n<p>A zipped version of the script can be downloaded <a href=\"http:\/\/github.com\/mnielsen\/wiki_tex\/zipball\/master\">here<\/a>.<\/p>\n<p>To use the script, put a copy of the script in the directory you&#8217;re writing LaTeX in.  You also need to make sure Python is installed on your machine.  Mac and most Linuxes have it pre-installed.  Windows doesn&#8217;t, but you can get a one-click installer at the <a href=\"http:\/\/www.python.org\/\">python site<\/a>.  I wrote the script under Python 2.5, but would be surprised if it doesn&#8217;t work under Python 2.x.  I don&#8217;t know how it runs under the recently released Python 3.<\/p>\n<p>To run the script, you need a command line prompt, and to have the directory set to be whatever directory you&#8217;re writing LaTeX in.  Once in the right directory, just run:<\/p>\n<p>python wiki_tex.py filename<\/p>\n<p>where filename.tex is the file you&#8217;re texing. Note the omission of the .tex suffix is intentional.  The script will extract everything between \\begin{document} and \\end{document}, convert to wiki-tex, and output a file filename0.wiki which you can cut and paste into the MediaWiki.<\/p>\n<p>As a convenience, if you put lines of the form &#8220;%#break&#8221; into the file (these are comments, so LaTeX ignores them) then the script breaks up the resulting output into multiple files, filename0.wiki, filename1.wiki, and so on.  This is useful for compiling smaller snippets of LaTeX into wiki-tex.<\/p>\n<p>The script is very basic.  There&#8217;s many conversions it won&#8217;t handle, but there&#8217;s quite a bit of basic stuff that it copes with just fine. I&#8217;d suggest starting with some small examples, and gradually working up in complexity.  <\/p>\n<p>The script is also not very battle-tested.  It&#8217;s undergone a little testing, but this is well and truly alpha software.  Let me know in comments if you find bugs, and I&#8217;ll try to fix them. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve written a simple python script called wiki_tex.py to help convert LaTeX to the wiki-tex used on MediaWikis like the Polymath1 wiki, and Wikipedia. It&#8217;s a stripped-down port of a similar script I use to put LaTeX on my blog &#8211; the original script is heavily customized, which is why I haven&#8217;t made it generally&hellip; <a class=\"more-link\" href=\"https:\/\/michaelnielsen.org\/blog\/wiki_texpy\/\">Continue reading <span class=\"screen-reader-text\">wiki_tex.py<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[62],"tags":[],"class_list":["post-582","post","type-post","status-publish","format-standard","hentry","category-polymath1","entry"],"_links":{"self":[{"href":"https:\/\/michaelnielsen.org\/blog\/wp-json\/wp\/v2\/posts\/582","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michaelnielsen.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michaelnielsen.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michaelnielsen.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/michaelnielsen.org\/blog\/wp-json\/wp\/v2\/comments?post=582"}],"version-history":[{"count":0,"href":"https:\/\/michaelnielsen.org\/blog\/wp-json\/wp\/v2\/posts\/582\/revisions"}],"wp:attachment":[{"href":"https:\/\/michaelnielsen.org\/blog\/wp-json\/wp\/v2\/media?parent=582"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michaelnielsen.org\/blog\/wp-json\/wp\/v2\/categories?post=582"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michaelnielsen.org\/blog\/wp-json\/wp\/v2\/tags?post=582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}