Repository: getpelican/pelican

Issue:
Internal content link doesn't work on video.poster
I'm using pelican 3.3.0, with python 2.7.5.

The [internal content link](http://docs.getpelican.com/en/3.3.0/getting_started.html#linking-to-internal-content) feature is very useful that I don't need to determine where attachment files will be placed after site generation. But recently I find that this feature has no effect on poster property of a video tag.

For example, I wrote this in my post.md:

``` html
<video controls poster="{filename}/images/2011/07/poster.jpg">
  <source src="{filename}/assets/2011/07/video.mp4" type="video/mp4">
</video>
```

After generation, I got this html code in my page:

``` html
<video controls poster="{filename}/images/2011/07/poster.jpg">
  <source src="/assets/2011/07/video.mp4" type="video/mp4">
</video>
```

As you can see, the `{filename}` still there, it should be replace to an empty string in this case.



Discussion:
The internal content linking feature was meant for... linking.  ;^)  So indeed, the use case you described is outside the scope of what was originally envisioned.

That said, I can certainly understand what you're trying to do here and why a more general-purpose function would benefit alternative use cases (e.g., poster frames).

Contributions to that effect would be welcome. Is this something you would like to work on?

Thanks @justinmayer for the explanation. I'm not sure whether I could contribute to this, i'm just a newbie to Pelican :) I'd like to have a try, if i have time.


Resolving patch:
diff --git a/pelican/contents.py b/pelican/contents.py
--- a/pelican/contents.py
+++ b/pelican/contents.py
@@ -189,8 +189,8 @@ def _update_content(self, content, siteurl):
 
         instrasite_link_regex = self.settings['INTRASITE_LINK_REGEX']
         regex = r"""
-            (?P<markup><\s*[^\>]*  # match tag with src and href attr
-                (?:href|src)\s*=)
+            (?P<markup><\s*[^\>]*  # match tag with all url-value attributes
+                (?:href|src|poster|data|cite|formaction|action)\s*=)
 
             (?P<quote>["\'])      # require value to be quoted
             (?P<path>{0}(?P<value>.*?))  # the url value


Test patch:
diff --git a/pelican/tests/test_contents.py b/pelican/tests/test_contents.py
--- a/pelican/tests/test_contents.py
+++ b/pelican/tests/test_contents.py
@@ -268,6 +268,61 @@ def test_intrasite_link(self):
             '?utm_whatever=234&highlight=word#section-2">link</a>'
         )
 
+    def test_intrasite_link_more(self):
+        # type does not take unicode in PY2 and bytes in PY3, which in
+        # combination with unicode literals leads to following insane line:
+        cls_name = '_DummyAsset' if six.PY3 else b'_DummyAsset'
+
+        args = self.page_kwargs.copy()
+        args['settings'] = get_settings()
+        args['source_path'] = 'content'
+        args['context']['filenames'] = {
+            'images/poster.jpg': type(cls_name, (object,), {'url': 'images/poster.jpg'}),
+            'assets/video.mp4': type(cls_name, (object,), {'url': 'assets/video.mp4'}),
+            'images/graph.svg': type(cls_name, (object,), {'url': 'images/graph.svg'}),
+            'reference.rst': type(cls_name, (object,), {'url': 'reference.html'}),
+        }
+
+        # video.poster
+        args['content'] = (
+            'There is a video with poster '
+            '<video controls poster="{filename}/images/poster.jpg">'
+            '<source src="|filename|/assets/video.mp4" type="video/mp4">'
+            '</video>'
+        )
+        content = Page(**args).get_content('http://notmyidea.org')
+        self.assertEqual(
+            content,
+            'There is a video with poster '
+            '<video controls poster="http://notmyidea.org/images/poster.jpg">'
+            '<source src="http://notmyidea.org/assets/video.mp4" type="video/mp4">'
+            '</video>'
+        )
+
+        # object.data
+        args['content'] = (
+            'There is a svg object '
+            '<object data="{filename}/images/graph.svg" type="image/svg+xml"></object>'
+        )
+        content = Page(**args).get_content('http://notmyidea.org')
+        self.assertEqual(
+            content,
+            'There is a svg object '
+            '<object data="http://notmyidea.org/images/graph.svg" type="image/svg+xml"></object>'
+        )
+
+        # blockquote.cite
+        args['content'] = (
+            'There is a blockquote with cite attribute '
+            '<blockquote cite="{filename}reference.rst">blah blah</blockquote>'
+        )
+        content = Page(**args).get_content('http://notmyidea.org')
+        self.assertEqual(
+            content,
+            'There is a blockquote with cite attribute '
+            '<blockquote cite="http://notmyidea.org/reference.html">blah blah</blockquote>'
+        )
+
 
 class TestArticle(TestPage):
     def test_template(self):