Changeset 678 for latexformulamacro
- Timestamp:
- 04/21/06 00:33:50 (3 years ago)
- Files:
-
- latexformulamacro/0.9/formula.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
latexformulamacro/0.9/formula.py
r677 r678 10 10 * replaced every Tab by spaces 11 11 * make tmp dir creation recursive 12 2005-10-21: Ken McIvor <mcivor@iit.edu>: 13 * Updated to support trac 0.9b2. 14 * Improved the error messages for missing configuration elements. 12 15 2005-10-03: 13 16 * make image format selectable via 'image_format' configuration option … … 112 115 tmpdir = env.config.get('latex', 'temp_dir') 113 116 114 fleqnIndent = env.config.get('latex', 'fleqn_indent') 115 latexPath = env.config.get('latex', 'latex_path') 116 dvipsPath = env.config.get('latex', 'dvips_path') 117 convertPath = env.config.get('latex', 'convert_path') 118 texMag = env.config.get('latex', 'text_mag') 119 imageFormat = env.config.get('latex', 'image_format') 117 cfg = env.config 118 fleqnIndent = cfg.get('latex', 'fleqn_indent', '5%') 119 latexPath = cfg.get('latex', 'latex_path', 'latex') 120 dvipsPath = cfg.get('latex', 'dvips_path', 'dvips') 121 convertPath = cfg.get('latex', 'convert_path', 'convert') 122 texMag = cfg.get('latex', 'text_mag', 1000) 123 imageFormat = cfg.get('latex', 'image_format', 'png') 120 124 121 125 imagePath = os.path.normpath(os.path.join(env.get_htdocs_dir(), "formulas")) … … 126 130 return "<b>Error: unable to create image directory</b><br>" 127 131 132 def make_cfg_error(element): 133 msg = """\ 134 <div class="system-message"> 135 <strong>Error: the <code>formula</code> macro requires the 136 setting <code>%s</code> in the configuration section 137 <code>latex</code> 138 </strong> 139 </div> 140 """ 141 return msg % element 142 128 143 if not tmpdir: 129 return "<b>Error: missing configuration 'tmpdir' setting in 'latex' macro</b><br>" 130 131 # set defaults 132 if not fleqnIndent: 133 fleqnIndent = '5%' 134 if not latexPath: 135 latexPath = 'latex' 136 if not dvipsPath: 137 dvipsPath = 'dvips' 138 if not convertPath: 139 convertPath = 'convert' 140 if not texMag: 141 texMag = 1000 # I'm told this is latex's default value 142 if not imageFormat: 143 imageFormat = 'png' 144 return make_cfg_error('temp_dir') 145 if not imagePath: 146 return make_cfg_error('image_path') 144 147 145 148 path = tmpdir … … 236 239 # arguments start with "#" on the beginning of a line 237 240 def execute(hdf, text, env): 241 cfg = env.config 242 238 243 # TODO: unescape all html escape codes 239 240 244 text = text.replace("&", "&") 241 245 … … 244 248 mathMode = 1 # default to using display-math mode for LaTeX processing 245 249 displayMode = 0 # default to generating inline formula 246 fleqnMode = env.config.get('latex', 'fleqn')250 fleqnMode = cfg.get('latex', 'fleqn') 247 251 centerImage = 0 248 252 indentImage = 0
