diff options
author | Arun SAG <sagarun@gmail.com> | 2011-09-18 17:23:16 +0530 |
---|---|---|
committer | Arun SAG <sagarun@gmail.com> | 2011-09-18 17:23:16 +0530 |
commit | 015a46ddf251032155cec161fed8300d15c6537f (patch) | |
tree | 875d105db2f772a3345eade913e91632ea5babae | |
parent | 1980d43ecfb7f30f2904eb924319d5c6aff0e4ac (diff) | |
download | askbot-015a46ddf251032155cec161fed8300d15c6537f.tar.gz askbot-015a46ddf251032155cec161fed8300d15c6537f.tar.bz2 askbot-015a46ddf251032155cec161fed8300d15c6537f.zip |
Autolinking urls based on regex now works
- Fix settings name for readbility
- Make utils/markup.py process autlinks
-rw-r--r-- | askbot/conf/markup.py | 6 | ||||
-rw-r--r-- | askbot/utils/markup.py | 5 |
2 files changed, 8 insertions, 3 deletions
diff --git a/askbot/conf/markup.py b/askbot/conf/markup.py index 9eeb3149..f7e92bd4 100644 --- a/askbot/conf/markup.py +++ b/askbot/conf/markup.py @@ -75,7 +75,7 @@ settings.register( settings.register( BooleanValue( AUTOLINK, - 'ENABLE_AUTO_LINK', + 'ENABLE_AUTO_LINKING', description=_('Enable autolinking a specifc pattern'), help_text=_( 'If you enable this feature, ' @@ -91,7 +91,7 @@ settings.register( settings.register( StringValue( AUTOLINK, - 'Pattern', + 'PATTERN', description=_('Regex to detect the pattern'), help_text=_( 'Enter a valid regular expression to' @@ -106,7 +106,7 @@ settings.register( settings.register( StringValue( AUTOLINK, - 'AutoLinkURL', + 'AUTO_LINK_URL', description=_('URL for autolinking'), help_text=_( 'Let us assume that to detect a pattern #rhbz 637402' diff --git a/askbot/utils/markup.py b/askbot/utils/markup.py index acb8d03d..ef67b315 100644 --- a/askbot/utils/markup.py +++ b/askbot/utils/markup.py @@ -10,6 +10,7 @@ LINK_PATTERNS = [ (URL_RE, r'\1'), ] + def get_parser(): extras = ['link-patterns', 'video'] if askbot_settings.ENABLE_MATHJAX or \ @@ -22,6 +23,10 @@ def get_parser(): #pip install -e git+git://github.com/andryuha/python-markdown2.git extras.append('video') + if askbot_settings.ENABLE_AUTO_LINKING: + LINK_PATTERNS.append((re.compile(askbot_settings.PATTERN),askbot_settings.AUTO_LINK_URL)) + + return Markdown( html4tags=True, extras=extras, |