Changeset 6592f56 in sasmodels for sasmodels/rst2html.py
- Timestamp:
- Sep 11, 2016 11:37:18 PM (8 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- b217c71
- Parents:
- 7b68dc5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/rst2html.py
r40a87fa r6592f56 10 10 from contextlib import contextmanager 11 11 12 # CRUFT: locale.getlocale() fails on some versions of OS X 13 # See https://bugs.python.org/issue18378 14 import locale 15 if hasattr(locale, '_parse_localename'): 16 try: 17 locale._parse_localename('UTF-8') 18 except ValueError: 19 _old_parse_localename = locale._parse_localename 20 def _parse_localename(localename): 21 code = locale.normalize(localename) 22 if code == 'UTF-8': 23 return None, code 24 else: 25 return _old_parse_localename(localename) 26 locale._parse_localename = _parse_localename 27 12 28 from docutils.core import publish_parts 13 29 from docutils.writers.html4css1 import HTMLTranslator 14 30 from docutils.nodes import SkipNode 15 31 32 def wxview(html, url="", size=(850, 540)): 33 import wx 34 from wx.html2 import WebView 35 frame = wx.Frame(None, -1, size=size) 36 view = WebView.New(frame) 37 view.SetPage(html, url) 38 frame.Show() 39 return frame 16 40 17 def rst2html(rst, part="whole", math_output="html"): 41 def view_rst(filename): 42 from os.path import expanduser 43 with open(expanduser(filename)) as fid: 44 rst = fid.read() 45 html = rst2html(rst) 46 wxview(html) 47 48 def rst2html(rst, part="whole", math_output="mathjax"): 18 49 r""" 19 50 Convert restructured text into simple html. … … 44 75 else: 45 76 settings = {"math-output": math_output} 77 78 # TODO: support stylesheets 79 #html_root = "/full/path/to/_static/" 80 #sheets = [html_root+s for s in ["basic.css","classic.css"]] 81 #settings["embed_styesheet"] = True 82 #settings["stylesheet_path"] = sheets 46 83 47 84 # math2html and mathml do not support \frac12
Note: See TracChangeset
for help on using the changeset viewer.