Repository: getnikola/nikola

Issue:
Custom INDEX_READ_MORE_LINK not working
I am adding an additional class for the "Read more" links using

```
INDEX_READ_MORE_LINK = '<p class="more"><a class="label label-primary" href="{link}">{read_more}…</a></p>'
```

but it is not being applied to the output files. Using Nikola 7.6.0



Discussion:
Did you change the setting that already exists?

Yes, in conf.py.

```
$ grep INDEX_READ_MORE_LINK conf.py
# INDEX_READ_MORE_LINK = '<p class="more"><a href="{link}">{read_more}…</a></p>'
INDEX_READ_MORE_LINK = '<p class="more"><a class="label label-primary" href="{link}">{read_more}…</a></p>'
```

I’m afraid I cannot reproduce with an almost-clean demo site and Nikola from GitHub master.  Please:

(a) try rebuilding everything with `nikola build -a` (maybe there’s a caching issue?)
(b) post your conf.py file if that does not help

Works for me:

```
$ grep INDEX_READ_MORE_LINK conf.py
# INDEX_READ_MORE_LINK = '<p class="more"><a href="{link}">{read_more}…</a></p>'
INDEX_READ_MORE_LINK = '<p class="more"><a class="label label-primary" href="{link}">{read_more}…</a></p>'
```

Also, do you have an old `READ_MORE_LINK` setting? This could break things, though I’m pretty sure it wouldn’t…

`nikola build -a` didn't work.

Then I tried a new test site with a clean conf.py, but copied over my posts to the new site. Same result. I finally tracked down the problem to custom TEASER_END text. Without custom text, INDEX_READ_MORE_LINK works fine.

I use the following:

```
.. TEASER_END: Continue Reading...
```


Resolving patch:
diff --git a/nikola/post.py b/nikola/post.py
--- a/nikola/post.py
+++ b/nikola/post.py
@@ -593,19 +593,18 @@ def text(self, lang=None, teaser_only=False, strip_html=False, show_read_more_li
             if teaser != data:
                 if not strip_html and show_read_more_link:
                     if TEASER_REGEXP.search(data).groups()[-1]:
-                        teaser += '<p class="more"><a href="{0}">{1}</a></p>'.format(
-                            self.permalink(lang),
-                            TEASER_REGEXP.search(data).groups()[-1])
+                        teaser_text = TEASER_REGEXP.search(data).groups()[-1]
                     else:
-                        l = self.config['RSS_READ_MORE_LINK'](lang) if rss_read_more_link else self.config['INDEX_READ_MORE_LINK'](lang)
-                        teaser += l.format(
-                            link=self.permalink(lang, query=rss_links_append_query),
-                            read_more=self.messages[lang]["Read more"],
-                            min_remaining_read=self.messages[lang]["%d min remaining to read"] % (self.remaining_reading_time),
-                            reading_time=self.reading_time,
-                            remaining_reading_time=self.remaining_reading_time,
-                            paragraph_count=self.paragraph_count,
-                            remaining_paragraph_count=self.remaining_paragraph_count)
+                        teaser_text = self.messages[lang]["Read more"]
+                    l = self.config['RSS_READ_MORE_LINK'](lang) if rss_read_more_link else self.config['INDEX_READ_MORE_LINK'](lang)
+                    teaser += l.format(
+                        link=self.permalink(lang, query=rss_links_append_query),
+                        read_more=teaser_text,
+                        min_remaining_read=self.messages[lang]["%d min remaining to read"] % (self.remaining_reading_time),
+                        reading_time=self.reading_time,
+                        remaining_reading_time=self.remaining_reading_time,
+                        paragraph_count=self.paragraph_count,
+                        remaining_paragraph_count=self.remaining_paragraph_count)
                 # This closes all open tags and sanitizes the broken HTML
                 document = lxml.html.fromstring(teaser)
                 try:


Test patch: