opened
shimizukawa
username_0
In order to easily test the new mathjax extension (https://bitbucket.org/kevindunn/sphinx-extension-mathjax/src/tip/mathjax.py and see discussion at http://groups.google.com/group/sphinx-dev/browse_thread/thread/164db6fd920f3501/) on Windows with local files, I initially tried the following in my conf.py file:
    
      mathjax_path = '/MathJax/MathJax.js'
    
but wasn't able to figure out where that directory is on Windows? Putting it directly in the C:\ folder didn't work.

I finally had to specify the following:
    
      mathjax_path = 'file:///C:/MathJax/MathJax.js'
    
However, this doesn't work with Sphinx 1.0.3 unless I change add_javascript() in sphinx/application.py from:
    
        def add_javascript(self, filename):
            from sphinx.builders.html import StandaloneHTMLBuilder
            StandaloneHTMLBuilder.script_files.append(
                posixpath.join('_static', filename))
    
to:
    
        def add_javascript(self, filename):
            from sphinx.builders.html import StandaloneHTMLBuilder
            if filename.startswith('file://'):
                StandaloneHTMLBuilder.script_files.append(filename)
            else:
                StandaloneHTMLBuilder.script_files.append(
                    posixpath.join('_static', filename))
    
Looking at basic/layout.html I see:
    
        {&#37;- for scriptfile in script_files &#37;}
        <script type="text/javascript" src="{{ pathto(scriptfile, 1) }}"></script>
        {&#37;- endfor &#37;}
    
And by looking at pathto() in sphinx\builders\html.py:
    
        def pathto(otheruri, resource=False,
                   baseuri=self.get_target_uri(pagename)):
            if not resource:
                otheruri = self.get_target_uri(otheruri)
            uri = relative_uri(baseuri, otheruri) or '#'
            return uri
    
I see I also need to change relative_uri in sphinx\util\osutil.py from:
    
        def relative_uri(base, to):
            """Return a relative URL from ``base`` to ``to``."""
            if to.startswith(SEP):
                return to
    
to:
    
        def relative_uri(base, to):
            """Return a relative URL from ``base`` to ``to``."""
            if to.startswith(SEP) or to.startswith("file://"):
                return to
    
I have a feeling that bad things would also happen if you tried to temporarily use mathjax from some other host while testing local files; i.e. the following probably also won't work?:
    
      mathjax_path = 'http://www.someotherhost.org/MathJax/MathJax.js'
    

----------------------------------------
- Bitbucket: https://bitbucket.org/birkenfeld/sphinx/issue/513
- Originally reported by: [tpowers](https://bitbucket.org/tpowers)
- Originally created at: 2010-08-25T08:55:15.598
add_javascript() & relative_uri() don't support local file url syntax in Sphinx 1.0.3
issue
closed
shimizukawa
username_0
issue
created
shimizukawa
username_0
_From Georg Brandl on 2010-08-25 10:30:10+00:00_

Should be fixed in \<\<cset 7e5ff71c40495c62e0c1c27a173139a4d281292c\>\>. Thanks for reoprting!
comment
created
shimizukawa
username_0
_From Georg Brandl on 2011-09-22 10:14:45+00:00_

Removing milestone: 1.0 (automated comment)
comment