Image paths can now be absolute (like `/images/foo.png`).

They are treated as relative to the top source directory.
This commit is contained in:
Georg Brandl
2009-02-14 15:29:18 +01:00
parent 364d38fd74
commit 06b32a712f
4 changed files with 13 additions and 3 deletions

View File

@@ -37,6 +37,9 @@ New features added
the directive -- this allows you to define your document
structure, but place the links yourself.
- Image paths can now be absolute (like ``/images/foo.png``).
They are treated as relative to the top source directory.
- #52: There is now a ``hlist`` directive, creating a compact
list by placing distributing items into multiple columns.
@@ -49,8 +52,8 @@ New features added
- #23: Added a ``classmethod`` directive along with ``method``
and ``staticmethod``.
- Added a ``toctree`` variable to the templates, and the ability to
include external links in toctrees.
- Added a ``toctree`` callable to the templates, and the ability
to include external links in toctrees.
* Configuration:

View File

@@ -647,7 +647,11 @@ class BuildEnvironment:
candidates['?'] = imguri
continue
# imgpath is the image path *from srcdir*
imgpath = path.normpath(path.join(docdir, imguri))
if imguri.startswith('/') or imguri.startswith(os.sep):
# absolute path (= relative to srcdir)
imgpath = path.normpath(imguri[1:])
else:
imgpath = path.normpath(path.join(docdir, imguri))
# set imgpath as default URI
node['uri'] = imgpath
if imgpath.endswith(os.extsep + '*'):

View File

@@ -2,3 +2,5 @@ Image including source in subdir
================================
.. image:: img.*
.. image:: /rimg.png

View File

@@ -61,6 +61,7 @@ HTML_XPATH = {
},
'subdir/images.html': {
".//img[@src='../_images/img1.png']": '',
".//img[@src='../_images/rimg.png']": '',
},
'includes.html': {
".//pre": u'Max Strauß',