Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 09-10-2017, 05:48 AM   #1
Tanjamuse
Wizard
Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!
 
Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
Template Help in S&R

Hello.

Chaley kindly helped me with the following template for S&R and I fiddled a bit with it, because I needed both http and https.

When I tried with the following I got an invalid group reference.

Code:
Template: {#story_url:'re($, '(http(s?)://www.fanfiction.net/s/[0-9]*?/)', strcat('<p class="description"><a href="\1>',  field('title'), '</a></p>'))'}

Search for: .*

Replace with: \1

Destination Field: #story_url

The original story link could be either:

https://www.fanfiction.net/s/7950093/1/

or

http://www.fanfiction.net/s/1962402/1/

It varies if there's is s in the address but always the same with id-number and then the /1/ in the end.

I hope someone can help me.

Thanks in advance.

Last edited by Tanjamuse; 09-10-2017 at 06:24 AM.
Tanjamuse is offline   Reply With Quote
Old 09-10-2017, 06:32 AM   #2
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Try
Code:
{comment:'re($, '(https?://www.fanfiction.net/s/[^/]*/1/)', strcat('<p class="description"><a href="\1">',  field('title'), '</a></p>'))'}
as the template.

The four changes:
  • I moved the test for the 's' in https to where it belongs.
  • The original example you gave me had a /u/ in it. Now it has a /s/ in it. The pattern was changed to account for that.
  • Now that there is always a /1/ at the end of the URL, the capture for the id number can be simplified.
  • Add a missing " at the end of the URL
For those who come along later to offer improvements (I am sure there are many), she wants to convert a URL of the form
Code:
http://www.fanfiction.net/s/1962402/1/
to the form
Code:
<p class="description"><a href="http://www.fanfiction.net/s/1962402/1/">{title of book}</a></p>
chaley is offline   Reply With Quote
Advert
Old 09-10-2017, 06:37 AM   #3
Tanjamuse
Wizard
Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!
 
Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
Thanks Chaley.

It seems to work like a charm.
Tanjamuse is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Kindle newbie needs "template" HTML & CSS Rich_H Kindle Developer's Corner 12 09-10-2012 11:16 PM
Kindle Newbie needs "template" HTML & CSS Rich_H Workshop 4 09-10-2012 08:33 PM
PRS-500 Template & extended font support at Feedbooks (poll) Hadrien Sony Reader Dev Corner 9 05-12-2007 12:04 PM


All times are GMT -4. The time now is 04:50 AM.


MobileRead.com is a privately owned, operated and funded community.