Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a blog in the following website http://ecosdobigbang.com/ where I'll post material that is relevant to Physics students that speak portuguese (the target audience of this post are physics students in lusophone developing countries since they have a lot of difficulties in getting the material).

To this end I use the following python script that was coded by Luca Trevisan http://lucatrevisan.wordpress.com/latex-to-wordpress/download/ that allows one to write a LaTeX file that is converted into wordpress.com friendly html.

I never learned how to code in python but through trial and error I was able to make a few little modifications that made the final html output more to my liking.

Nevertheless there is one thing that I want to do that I've not able to do thus far. When the LaTeX file I'm able to use the portuguese class and all the commands that I use are natively translated into portuguese in the LaTeX file, but when I run the script the html output uses the english name for the theorem like environments.

After digging a lot on the web I've finally decided to quit and ask for help. What I want to be able to do is to modify the python script so that the following theorem environments have their portuguese name

Axiom -> Axiom
Theorem -> Teorema
Lemma -> Lema
etc...

It seems to me that the place where I need to change my code is in the following lines:

def convertbeginnamedthm(thname,thm) :
  global inthm

  count[T[thm]] +=1
  inthm = thm
  t = beginnamedthm.replace("_ThmType_",thm.capitalize())
  t = t.replace("_ThmNumb_",str(count[T[thm]]))
  t = t.replace("_ThmName_",thname)
  return(t)

def convertbeginthm(thm) :
  global inthm

  count[T[thm]] +=1
  inthm = thm
  t = beginthm.replace("_ThmType_",thm.capitalize())
  t = t.replace("_ThmNumb_",str(count[T[thm]]))
  return(t)

but no matter what I'm not able to have the final output that I want.

Sorry to bother you with such a question, but the problem truly defeats me.

share|improve this question

migrated from programmers.stackexchange.com Jun 19 at 19:28

This question came from our site for professional programmers interested in conceptual questions about software development.

1  
+1 for teaching me the word "lusophone". –  Robᵩ Jun 19 at 21:43
add comment

1 Answer 1

up vote 0 down vote accepted

A quick and dirty approach would be (tested with the example.tex provided with the python script) to add

t = t.replace("Theorem", "Teorema")
t = t.replace("Lemma", "Lema")

in the function convertbeginthm just before the return (t).

share|improve this answer
    
Jasper first off all thanks for you answer. Your suggestion worked just fine. I just have a small problem while trying to include characters like "ç", "ã" etc. that I get the following error message: "Non-ASCII character '\xc23' in file... but no encoding declared". How can I declare the encoding so that accented characters are supported? –  ateixeira82 Jun 19 at 21:47
    
legacy.python.org/dev/peps/pep-0263 this perhaps? –  Jasper Jun 19 at 22:03
    
Thanks again jasper! I've follwed your link and follwed the instructions. That is to say that i put the following lines of code at the beginning of the script: #!/usr/bin/python # -- coding: latin-1 -- Nevertheless, for the word "Definição" it prints "Definiçao". –  ateixeira82 Jun 19 at 22:16
    
then you must also make sure that your editor uses the same encoding to store the file. –  Jasper Jun 19 at 22:38
    
It worked!Thanks for your help –  ateixeira82 Jun 19 at 22:51
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.