Changeset b32dafd in sasmodels for sasmodels/rst2html.py
- Timestamp:
- Aug 5, 2016 3:59:13 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:
- 99f446a
- Parents:
- 7722b4a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/rst2html.py
r7722b4a rb32dafd 1 """1 r""" 2 2 Convert a restructured text document to html. 3 3 4 4 Inline math markup can uses the *math* directive, or it can use latex 5 style *\$expression\$*. Math can be rendered using simple html and 5 style *\$expression\$*. Math can be rendered using simple html and 6 6 unicode, or with mathjax. 7 7 """ … … 41 41 # others don't work properly with math_output! 42 42 if math_output == "mathjax": 43 settings = { "math_output": math_output}43 settings = {"math_output": math_output} 44 44 else: 45 settings = { "math-output": math_output}45 settings = {"math-output": math_output} 46 46 47 47 # math2html and mathml do not support \frac12 … … 89 89 Convert dollar signs to inline math markup in rst. 90 90 """ 91 content = _dollar.sub(r":math:`\1`", content)91 content = _dollar.sub(r":math:`\1`", content) 92 92 content = _notdollar.sub("$", content) 93 93 return content … … 95 95 96 96 def test_dollar(): 97 assert replace_dollar(u"no dollar")==u"no dollar" 98 assert replace_dollar(u"$only$")==u":math:`only`" 99 assert replace_dollar(u"$first$ is good")==u":math:`first` is good" 100 assert replace_dollar(u"so is $last$")==u"so is :math:`last`" 101 assert replace_dollar(u"and $mid$ too")==u"and :math:`mid` too" 102 assert replace_dollar(u"$first$, $mid$, $last$")==u":math:`first`, :math:`mid`, :math:`last`" 103 assert replace_dollar(u"dollar\$ escape")==u"dollar$ escape" 104 assert replace_dollar(u"dollar \$escape\$ too")==u"dollar $escape$ too" 105 assert replace_dollar(u"spaces $in the$ math")==u"spaces :math:`in the` math" 106 assert replace_dollar(u"emb\ $ed$\ ed")==u"emb\ :math:`ed`\ ed" 107 assert replace_dollar(u"$first$a")==u"$first$a" 108 assert replace_dollar(u"a$last$")==u"a$last$" 109 assert replace_dollar(u"$37")==u"$37" 110 assert replace_dollar(u"($37)")==u"($37)" 111 assert replace_dollar(u"$37 - $43")==u"$37 - $43" 112 assert replace_dollar(u"($37, $38)")==u"($37, $38)" 113 assert replace_dollar(u"a $mid$dle a")==u"a $mid$dle a" 114 assert replace_dollar(u"a ($in parens$) a")==u"a (:math:`in parens`) a" 115 assert replace_dollar(u"a (again $in parens$) a")==u"a (again :math:`in parens`) a" 97 """ 98 Test substitution of dollar signs with equivalent RST math markup 99 """ 100 assert replace_dollar(u"no dollar") == u"no dollar" 101 assert replace_dollar(u"$only$") == u":math:`only`" 102 assert replace_dollar(u"$first$ is good") == u":math:`first` is good" 103 assert replace_dollar(u"so is $last$") == u"so is :math:`last`" 104 assert replace_dollar(u"and $mid$ too") == u"and :math:`mid` too" 105 assert replace_dollar(u"$first$, $mid$, $last$") == u":math:`first`, :math:`mid`, :math:`last`" 106 assert replace_dollar(ur"dollar\$ escape") == u"dollar$ escape" 107 assert replace_dollar(ur"dollar \$escape\$ too") == u"dollar $escape$ too" 108 assert replace_dollar(u"spaces $in the$ math") == u"spaces :math:`in the` math" 109 assert replace_dollar(u"emb\ $ed$\ ed") == ur"emb\ :math:`ed`\ ed" 110 assert replace_dollar(u"$first$a") == u"$first$a" 111 assert replace_dollar(u"a$last$") == u"a$last$" 112 assert replace_dollar(u"$37") == u"$37" 113 assert replace_dollar(u"($37)") == u"($37)" 114 assert replace_dollar(u"$37 - $43") == u"$37 - $43" 115 assert replace_dollar(u"($37, $38)") == u"($37, $38)" 116 assert replace_dollar(u"a $mid$dle a") == u"a $mid$dle a" 117 assert replace_dollar(u"a ($in parens$) a") == u"a (:math:`in parens`) a" 118 assert replace_dollar(u"a (again $in parens$) a") == u"a (again :math:`in parens`) a" 116 119 117 120 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.