Permalink
Browse files

Make relative file references work when rst is not in current dir.

For example, this content in ``foo/bar.rst``::

	.. python::
	   :filename: quux.py

would have looked for ``quux.py``, not ``foo/quux.py``.
  • Loading branch information...
1 parent cc333dd commit 496e7052dcb6f80ad18af4e12f1e2b62795f5d09 @tv42 committed Jun 30, 2008
Showing with 5 additions and 2 deletions.
  1. +3 −1 atomat/commands/import_.py
  2. +2 −1 atomat/rst2entry.py
@@ -33,7 +33,8 @@ def readEntries(path, feedId):
if (not badFilename(f)
and f.endswith('.rst'))]
for filename in files:
- f = file(os.path.join(path, dirname, filename))
+ p = os.path.join(path, dirname, filename)
+ f = file(p)
s = f.read()
f.close()
@@ -51,6 +52,7 @@ def readEntries(path, feedId):
x = rst2entry.convertString(
s,
+ filename=p,
id=id_,
link=sets.Set([link]))
yield x
View
@@ -60,10 +60,11 @@ def comment(name, arguments, options, content, lineno,
rst.directives.register_directive('comment', comment)
-def convertString(rst, **kw):
+def convertString(rst, filename=None, **kw):
"""Convert reStructuredText to iatom.IEntry."""
html = publish_string(source=rst,
+ source_path=filename,
writer_name='html',
settings_overrides={'input_encoding': 'utf-8',
'output_encoding': 'utf-8',

0 comments on commit 496e705

Please sign in to comment.