mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Add INTRASITE_LINK_REGEX to configuration that user can modify
This INTRASITE_LINK_REGEX is a string. It should have the capturing group name which is `what`. This change was made after discussions with @ametaireau and @justinmayer. 1. https://github.com/getpelican/pelican/pull/1067 1. https://github.com/getpelican/pelican/pull/1071 Updates getpelican/pelican#1061
This commit is contained in:
parent
bddf0faa9c
commit
48fa70c6a6
2 changed files with 6 additions and 3 deletions
|
|
@ -182,13 +182,15 @@ class Content(object):
|
||||||
if not content:
|
if not content:
|
||||||
return content
|
return content
|
||||||
|
|
||||||
hrefs = re.compile(r"""
|
instrasite_link_regex = self.settings['INTRASITE_LINK_REGEX']
|
||||||
|
regex = r"""
|
||||||
(?P<markup><\s*[^\>]* # match tag with src and href attr
|
(?P<markup><\s*[^\>]* # match tag with src and href attr
|
||||||
(?:href|src)\s*=)
|
(?:href|src)\s*=)
|
||||||
|
|
||||||
(?P<quote>["\']) # require value to be quoted
|
(?P<quote>["\']) # require value to be quoted
|
||||||
(?P<path>[|{](?P<what>.*?)[|}](?P<value>.*?)) # the url value
|
(?P<path>{0}(?P<value>.*?)) # the url value
|
||||||
\2""", re.X)
|
\2""".format(instrasite_link_regex)
|
||||||
|
hrefs = re.compile(regex, re.X)
|
||||||
|
|
||||||
def replacer(m):
|
def replacer(m):
|
||||||
what = m.group('what')
|
what = m.group('what')
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,7 @@ DEFAULT_CONFIG = {
|
||||||
'TEMPLATE_PAGES': {},
|
'TEMPLATE_PAGES': {},
|
||||||
'IGNORE_FILES': ['.#*'],
|
'IGNORE_FILES': ['.#*'],
|
||||||
'SLUG_SUBSTITUTIONS': (),
|
'SLUG_SUBSTITUTIONS': (),
|
||||||
|
'INTRASITE_LINK_REGEX': '[{|](?P<what>.*?)[|}]',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue