Merge pull request #2288 from charlesfleche/fix-metadata-intrasite-links-squashed

Fix intrasite links for non-'summary' metadata

Metadata like `MyArticleBanner: ![alt text]({attach}banner.jpg)` would be properly parsed (as defined in `FORMATTED_FIELDS`), but the intrasite links would not be processed.

Only the summary gets its intrasite links processed, has its value is either generated from the content (calling self._update_content at some point) or self._update_content is explicitly called if summary is passed as metadata.

This PR expands the paths as soon as possible in (`Content.__init__`) for metadata defined in `FORMATTED_FIELDS`.
This commit is contained in:
Justin Mayer 2018-02-09 11:41:30 -08:00 committed by GitHub
commit 2d24d6b997
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 10 deletions

View file

@ -319,17 +319,21 @@ class TestPage(LoggedTestCase):
)
# also test for summary in metadata
args['metadata']['summary'] = (
parsed = (
'A simple summary test, with a '
'<a href="|filename|article.rst">link</a>'
)
args['context']['localsiteurl'] = 'http://notmyidea.org'
p = Page(**args)
self.assertEqual(
p.summary,
linked = (
'A simple summary test, with a '
'<a href="http://notmyidea.org/article.html">link</a>'
)
args['settings']['FORMATTED_FIELDS'] = ['summary', 'custom']
args['metadata']['summary'] = parsed
args['metadata']['custom'] = parsed
args['context']['localsiteurl'] = 'http://notmyidea.org'
p = Page(**args)
self.assertEqual(p.summary, linked)
self.assertEqual(p.custom, linked)
def test_intrasite_link_more(self):
# type does not take unicode in PY2 and bytes in PY3, which in