]> git.phdru.name Git - phdru.name/cgi-bin/blog-ru/search-tags.git/blobdiff - tags.py
Version 0.8: Python 3
[phdru.name/cgi-bin/blog-ru/search-tags.git] / tags.py
diff --git a/tags.py b/tags.py
index a4ae88b15ce64e980f95c1577c491dcbdd8d0453..92a37060cc32c81f3bddb7838795cc683e8548e4 100644 (file)
--- a/tags.py
+++ b/tags.py
@@ -22,13 +22,13 @@ _new_dict = {}
 for (year, month, day), posts in blog_dict.items():
     _new_dict[year, month, day] = _posts = []
     for _file, _title, _lead, _tags in posts:
-        tags_lower = [tag.lower() for tag in _tags]
+        tags_lower = [tag.lower().replace(' ', '_') for tag in _tags]
         _posts.append((_file, _title, _lead, _tags, tags_lower))
 blog_dict = _new_dict
 
 
 def real_tag(tag):
-    ltag = tag.lower()
+    ltag = tag.lower().replace(' ', '_')
     for posts in blog_dict.values():
         for _file, _title, _lead, _tags, _tags_lower in posts:
             try:
@@ -36,7 +36,7 @@ def real_tag(tag):
             except ValueError:
                 continue
             else:
-                return _tags[ix]
+                return _tags[ix].replace(' ', '_')
 
 
 def _test_post(post, tree):
@@ -49,7 +49,7 @@ def _test_post(post, tree):
     if op == 'NAME':
         tag = tree[1]
         assert isinstance(tag, str)
-        return tag.lower() in post[4]
+        return tag.lower().replace(' ', '_') in post[4]
     elif op in ('AND', 'OR'):
         value1 = _test_post(post, tree[1])
         value2 = _test_post(post, tree[2])