This commit is contained in:
Talha Mansoor 2013-08-30 09:46:13 -07:00
commit e6f04a8978
4 changed files with 24 additions and 15 deletions

View file

@ -400,7 +400,7 @@ and images that may be sitting alongside the current post (instead of having
to determine where those resources will be placed after site generation).
To link to internal content (files in the ``content`` directory), use the
following syntax: ``|filename|path/to/file``::
following syntax: ``{filename}path/to/file``::
website/
@ -421,8 +421,8 @@ In this example, ``article1.rst`` could look like::
See below intra-site link examples in reStructuredText format.
`a link relative to content root <|filename|/cat/article2.rst>`_
`a link relative to current file <|filename|cat/article2.rst>`_
`a link relative to content root <{filename}/cat/article2.rst>`_
`a link relative to current file <{filename}cat/article2.rst>`_
and ``article2.md``::
@ -431,8 +431,8 @@ and ``article2.md``::
See below intra-site link examples in Markdown format.
[a link relative to content root](|filename|/article1.md)
[a link relative to current file](|filename|../article1.md)
[a link relative to content root]({filename}/article1.md)
[a link relative to current file]({filename}../article1.md)
Embedding non-article or non-page content is slightly different in that the
directories need to be specified in ``pelicanconf.py`` file. The ``images``
@ -447,7 +447,7 @@ manually::
And ``image-test.md`` would include::
![Alt Text](|filename|/images/han.jpg)
![Alt Text]({filename}/images/han.jpg)
Any content can be linked in this way. What happens is that the ``images``
directory gets copied to ``output/static/`` upon publishing. This is
@ -459,9 +459,15 @@ following to ``pelicanconf.py``::
And then the ``pdfs`` directory would also be copied to ``output/static/``.
You can also link to categories or tags, using the `|tag|tagname` and
`|category|foobar` syntax.
You can also link to categories or tags, using the `{tag}tagname` and
`{category}foobar` syntax.
For backward compatibility, Pelican also supports `|filename|an_article.rst`
or `|tag|tagname` or `|category|foobar`, i.e. the `filename`, `tag`
and `category` identifiers can be enclosed in bar `|` instead of braces `{}`.
Using `{}` ensures that the syntax will not collide with markdown extensions or
reST directives.
Importing an existing blog
--------------------------

View file

@ -156,9 +156,11 @@ Setting name (default value) What doe
<http://www.methods.co.nz/asciidoc/manpage.html>`_
`WITH_FUTURE_DATES` (``True``) If disabled, content with dates in the future will get a
default status of draft.
`INTRASITE_LINK_REGEX` (''[#]_) Regex to parse intra site links to files, images, category, tags etc
===================================================================== =====================================================================
.. [#] Default is the system locale.
.. [#] Default is ``'(?P<markup><\s*[^\>]*(?:href|src)\s*=) (?P<quote>["\'])(?P<path>[|{](?P<what>.*?)[|}] (?P<value>.*?))\2'``
URL settings

View file

@ -182,13 +182,7 @@ class Content(object):
if not content:
return content
hrefs = re.compile(r"""
(?P<markup><\s*[^\>]* # match tag with src and href attr
(?:href|src)\s*=)
(?P<quote>["\']) # require value to be quoted
(?P<path>\|(?P<what>.*?)\|(?P<value>.*?)) # the url value
\2""", re.X)
hrefs = re.compile(self.settings['INTRASITE_LINK_REGEX'], re.X)
def replacer(m):
what = m.group('what')

View file

@ -110,6 +110,13 @@ DEFAULT_CONFIG = {
'TEMPLATE_PAGES': {},
'IGNORE_FILES': ['.#*'],
'SLUG_SUBSTITUTIONS': (),
'INTRASITE_LINK_REGEX': r"""
(?P<markup><\s*[^\>]* # match tag with src and href attr
(?:href|src)\s*=)
(?P<quote>["\']) # require value to be quoted
(?P<path>[|{](?P<what>.*?)[|}](?P<value>.*?)) # the url value
\2""",
}