Changeset b32dafd in sasmodels for sasmodels/rst2html.py


Ignore:
Timestamp:
Aug 5, 2016 3:59:13 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
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
Message:

lint

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/rst2html.py

    r7722b4a rb32dafd  
    1 """ 
     1r""" 
    22Convert a restructured text document to html. 
    33 
    44Inline math markup can uses the *math* directive, or it can use latex 
    5 style *\$expression\$*.  Math can be rendered using simple html and  
     5style *\$expression\$*.  Math can be rendered using simple html and 
    66unicode, or with mathjax. 
    77""" 
     
    4141    # others don't work properly with math_output! 
    4242    if math_output == "mathjax": 
    43         settings = { "math_output": math_output } 
     43        settings = {"math_output": math_output} 
    4444    else: 
    45         settings = { "math-output": math_output } 
     45        settings = {"math-output": math_output} 
    4646 
    4747    # math2html and mathml do not support \frac12 
     
    8989    Convert dollar signs to inline math markup in rst. 
    9090    """ 
    91     content = _dollar.sub(r":math:`\1`",content) 
     91    content = _dollar.sub(r":math:`\1`", content) 
    9292    content = _notdollar.sub("$", content) 
    9393    return content 
     
    9595 
    9696def 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" 
    116119 
    117120if __name__ == "__main__": 
Note: See TracChangeset for help on using the changeset viewer.