Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: getnikola/nikola
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c8a5ffd762dc
Choose a base ref
...
head repository: getnikola/nikola
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b37e435cd027
Choose a head ref
  • 3 commits
  • 3 files changed
  • 2 contributors

Commits on Apr 19, 2017

  1. Fix misplaced flags argument in re.sub() calls

    The 4th argument of re.sub() is maximum number of substitutions,
    not flags.
    jwilk committed Apr 19, 2017
    Copy the full SHA
    225e73a View commit details
  2. Compile _slugify_*_re with re.UNICODE flag

    Regular expression flags cannot be passed in the sub() method.
    They have to bet set at compile time.
    jwilk committed Apr 19, 2017
    Copy the full SHA
    903ec5e View commit details

Commits on Apr 20, 2017

  1. Merge pull request #2730 from jwilk/re.sub

    Fix misplaced regexp flags arguments
    Kwpolska authored Apr 20, 2017
    Copy the full SHA
    b37e435 View commit details
Showing with 6 additions and 6 deletions.
  1. +1 −1 nikola/plugins/command/auto/__init__.py
  2. +1 −1 nikola/plugins/command/serve.py
  3. +4 −4 nikola/utils.py
2 changes: 1 addition & 1 deletion nikola/plugins/command/auto/__init__.py
Original file line number Diff line number Diff line change
@@ -341,7 +341,7 @@ def inject_js(self, data):

def remove_base_tag(self, data):
"""Comment out any <base> to allow local resolution of relative URLs."""
data = re.sub(r'<base\s([^>]*)>', '<!--base \g<1>-->', data, re.IGNORECASE)
data = re.sub(r'<base\s([^>]*)>', '<!--base \g<1>-->', data, flags=re.IGNORECASE)
return data


2 changes: 1 addition & 1 deletion nikola/plugins/command/serve.py
Original file line number Diff line number Diff line change
@@ -253,7 +253,7 @@ def send_head(self):
# Comment out any <base> to allow local resolution of relative URLs.
data = f.read().decode('utf8')
f.close()
data = re.sub(r'<base\s([^>]*)>', '<!--base \g<1>-->', data, re.IGNORECASE)
data = re.sub(r'<base\s([^>]*)>', '<!--base \g<1>-->', data, flags=re.IGNORECASE)
data = data.encode('utf8')
f = StringIO()
f.write(data)
8 changes: 4 additions & 4 deletions nikola/utils.py
Original file line number Diff line number Diff line change
@@ -768,8 +768,8 @@ def remove_file(source):
# slugify is adopted from
# http://code.activestate.com/recipes/
# 577257-slugify-make-a-string-usable-in-a-url-or-filename/
_slugify_strip_re = re.compile(r'[^+\w\s-]')
_slugify_hyphenate_re = re.compile(r'[-\s]+')
_slugify_strip_re = re.compile(r'[^+\w\s-]', re.UNICODE)
_slugify_hyphenate_re = re.compile(r'[-\s]+', re.UNICODE)


def slugify(value, lang=None, force=False):
@@ -794,8 +794,8 @@ def slugify(value, lang=None, force=False):
# This is the standard state of slugify, which actually does some work.
# It is the preferred style, especially for Western languages.
value = unicode_str(unidecode(value))
value = _slugify_strip_re.sub('', value, re.UNICODE).strip().lower()
return _slugify_hyphenate_re.sub('-', value, re.UNICODE)
value = _slugify_strip_re.sub('', value).strip().lower()
return _slugify_hyphenate_re.sub('-', value)
else:
# This is the “disarmed” state of slugify, which lets the user
# have any character they please (be it regular ASCII with spaces,