hplgit / doconce

Lightweight markup language - document once, include anywhere
http://hplgit.github.io/doconce/doc/web/index.html
Other
311 stars 60 forks source link

Unable to run *.do.txt containing Exercise Section #46

Closed sakhan007 closed 8 years ago

sakhan007 commented 9 years ago

Here is my source file: http://pastebin.com/QBTKKp59 Would you please help me in getting rid of the following error?

$ doconce format html main.do.txt --list_of_exercises=toc
 translating doconce text in main.do.txt to html
 Traceback (most recent call last):
  File "/home/sohail/anaconda/envs/doc27/bin/doconce", line 1177, in <module>
  main()
  File "/home/sohail/anaconda/envs/doc27/bin/doconce", line 1167, in main
eval(command + '()')
  File "<string>", line 1, in <module>
  File "/home/sohail/anaconda/envs/doc27/bin/doconce", line 92, in format
doconce.doconce.format_driver()
  File "/home/sohail/anaconda/envs/doc27/lib/python2.7/site-packages/doconce/doconce.py", line 4278, in format_driver
out_filename = file2file(filename_preprocessed, format, basename)
  File "/home/sohail/anaconda/envs/doc27/lib/python2.7/site-packages/doconce/doconce.py", line 3247, in file2file
  filestr = doconce2format(filestr, format)
  File "/home/sohail/anaconda/envs/doc27/lib/python2.7/site-packages/doconce/doconce.py", line 3575, in doconce2format
filestr = exercises(filestr, format, code_blocks, tex_blocks)
 File "/home/sohail/anaconda/envs/doc27/lib/python2.7/site-packages/doconce/doconce.py", line 1434, in exercises
formatted_exercise, formatted_solution = EXERCISE[format](exer)
 File "/home/sohail/anaconda/envs/doc27/lib/python2.7/site-packages/doconce/html.py", line 1737, in html_exercise
hint_header='__Hint.__')
 File "/home/sohail/anaconda/envs/doc27/lib/python2.7/site-packages/doconce/common.py", line 792, in doconce_exercise_output
ssol += answer_header + '\n' + exer['answer'] + '\n'
UnboundLocalError: local variable 'ssol' referenced before assignment
hplgit commented 9 years ago

Your example runs fine with the current version of doconce. Looking at the ssol += construction in the line that aborts the program, I realize that this must be an old doconce installation.

sakhan007 commented 9 years ago

I am using doconce under anaconda, please request Johannes to upload the updates.

hplgit commented 9 years ago

I strongly recommend to clone doconce directly from github and not rely on the conda package which will always be behind. As long as you have anaconda doconce with all its dependencies, just do git clone https://github.com/hplgit/doconce.git to make the doconce directory. Then update by

cd doconce
git pull origin master
sudo python setup.py install
sakhan007 commented 9 years ago

Is using sudo necessary in this case?? The problem is that though which python returns /home/sohail/anaconda/envs/doc27/bin/python but sudo which python returns /usr/bin and if I use sudo python setup.py install, the python at /usr/bin would be used to do the installation, and this python has no access to all the dependencies installed by the annaconda's doconce.

hplgit commented 9 years ago

You are absolutely correct: If you have a local private Anaconda installation, as you have, you should not use the system-wise python that sudo calls. Hope it works now.

sakhan007 commented 9 years ago

Yes its working now. Thank you!!! One question though. I couldn't figure out the use of statements like file=answers.pdf, solution=solution.do.txt in my main.do.txt under =====Exercise: ...=====, as it appears that there are no commands like extract_solutions, extract_answers

hplgit commented 9 years ago

Not sure what you mean... file=... is used to specify a filename for the exercise. solution=... just leads to a comment (for now, it was intended as a link, but we use !bsol, !esol instead, perhaps with including text snippets from a solution file via # #include "solution.do.txt" fromto: start@stop).