Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Conversion

Notices

Reply
 
Thread Tools Search this Thread
Old 05-19-2022, 08:12 AM   #1
evilone
Junior Member
evilone began at the beginning.
 
Posts: 7
Karma: 10
Join Date: May 2022
Device: kindle kwp4
Question question:regex of bionic reading

I want to modify the ebook to bionic reading using CSS styles, but I can't write the regex.

Code:
p{    
font-weight: bolder; 
}
I write excel
Code:
=ROUNDDOWN(LEN(A1)/2,0)
Code:
Sub bold()
For i = 1 To [a65536].End(xlUp).Row
   Cells(i, 1).Characters(1, 5).Font.bold = True
Next
End Sub
Bold the first half of a single word.

pls help me Finish that Additional CSS
evilone is offline   Reply With Quote
Old 05-19-2022, 10:06 AM   #2
PeterT
Grand Sorcerer
PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.
 
PeterT's Avatar
 
Posts: 12,167
Karma: 73448616
Join Date: Nov 2007
Location: Toronto
Device: Nexus 7, Clara, Touch, Tolino EPOS
If people want some background on this see https://www.mobileread.com/forums/sh...d.php?t=346904

Sent from my Pixel 4a using Tapatalk
PeterT is offline   Reply With Quote
Advert
Old 05-19-2022, 11:12 PM   #3
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
As mentioned in the other thread, you could do it using a regex function in the editor. A quick and dirty one would be:

Code:
import math
def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):
    boldlen = math.ceil(len(match[0])/2)
    boldedword = '<b>' + match[0][:boldlen] + '</b>' + match[0][boldlen:]
    return boldedword
With the search as "\b\w+\b", it will make the changes. But, it does not distinguish between words in the text and tags. And doesn't handle if you have already made the changes.
davidfor is offline   Reply With Quote
Old 05-20-2022, 01:05 AM   #4
evilone
Junior Member
evilone began at the beginning.
 
Posts: 7
Karma: 10
Join Date: May 2022
Device: kindle kwp4
Quote:
Originally Posted by davidfor View Post
As mentioned in the other thread, you could do it using a regex function in the editor. A quick and dirty one would be:

Code:
import math
def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):
    boldlen = math.ceil(len(match[0])/2)
    boldedword = '<b>' + match[0][:boldlen] + '</b>' + match[0][boldlen:]
    return boldedword
With the search as "\b\w+\b", it will make the changes. But, it does not distinguish between words in the text and tags. And doesn't handle if you have already made the changes.
I am sorry about that code can't run in my cailbre additional CSS, I don't have program konwlege,think your reply,Can you give me some more code to make sure the additional CSS works on cailbre
evilone is offline   Reply With Quote
Old 05-20-2022, 01:08 AM   #5
evilone
Junior Member
evilone began at the beginning.
 
Posts: 7
Karma: 10
Join Date: May 2022
Device: kindle kwp4
Quote:
Originally Posted by davidfor View Post
As mentioned in the other thread, you could do it using a regex function in the editor. A quick and dirty one would be:

Code:
import math
def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):
    boldlen = math.ceil(len(match[0])/2)
    boldedword = '<b>' + match[0][:boldlen] + '</b>' + match[0][boldlen:]
    return boldedword
With the search as "\b\w+\b", it will make the changes. But, it does not distinguish between words in the text and tags. And doesn't handle if you have already made the changes.
Code:
p{    
font-weight: bolder; 
}
this is bolder all of text code in cailbre ,pls give me more help :谢谢:
evilone is offline   Reply With Quote
Advert
Old 05-20-2022, 03:20 AM   #6
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by evilone View Post
I am sorry about that code can't run in my cailbre additional CSS, I don't have program konwlege,think your reply,Can you give me some more code to make sure the additional CSS works on cailbre
No it can't be done that way.

Quote:
Originally Posted by evilone View Post
Code:
p{    
font-weight: bolder; 
}
this is bolder all of text code in cailbre ,pls give me more help :谢谢:
But, that won't work. What that will do is change all test in a paragraph to "bolder". That isn't what the Bionic Reading is doing. It is making parts of each word, or some words bolder. Which is what my code is doing. I doubt there is a way to do this via just CSS. You will need to wrap the parts of the word that need to be different in a tag to change its style.

As to my code, that is used in the calibre editor. It would allow you to change one book at a time to see if it works for you. It is a regex function that is used as part of the search and replace. With it, you do a search using the regex specified, and the function doe the replace side of. I would suggest you look at the help for the editor to see how to use it. If you still have problems after that, then ask questions.

And my code is just a sample. It is what I thought of when I saw the page that is referred to above. It is an simplistic implementation that would only be good to get an idea of whether the Bionic Reading would work for you. Which I only did as a I was curious about whether I could. And I see lots of problems that I have no interest in solving as I don't have an interest in reading in that way.

If this was to be done "properly" it would probably need to be in a plugin. And, as the Bionic Reading clearly states, there are Patents around it, so it should be licensed to use their API. Maybe someone will be interested in doing that.
davidfor is offline   Reply With Quote
Old 05-20-2022, 04:47 AM   #7
evilone
Junior Member
evilone began at the beginning.
 
Posts: 7
Karma: 10
Join Date: May 2022
Device: kindle kwp4
Quote:
Originally Posted by davidfor View Post
No it can't be done that way.



But, that won't work. What that will do is change all test in a paragraph to "bolder". That isn't what the Bionic Reading is doing. It is making parts of each word, or some words bolder. Which is what my code is doing. I doubt there is a way to do this via just CSS. You will need to wrap the parts of the word that need to be different in a tag to change its style.

As to my code, that is used in the calibre editor. It would allow you to change one book at a time to see if it works for you. It is a regex function that is used as part of the search and replace. With it, you do a search using the regex specified, and the function doe the replace side of. I would suggest you look at the help for the editor to see how to use it. If you still have problems after that, then ask questions.

And my code is just a sample. It is what I thought of when I saw the page that is referred to above. It is an simplistic implementation that would only be good to get an idea of whether the Bionic Reading would work for you. Which I only did as a I was curious about whether I could. And I see lots of problems that I have no interest in solving as I don't have an interest in reading in that way.

If this was to be done "properly" it would probably need to be in a plugin. And, as the Bionic Reading clearly states, there are Patents around it, so it should be licensed to use their API. Maybe someone will be interested in doing that.
thank you for you reply,that question,This problem is 80% complete,Next, we only need a correct regular expression, and we can do it all.thanks!
evilone is offline   Reply With Quote
Old 05-21-2022, 06:46 AM   #8
evilone
Junior Member
evilone began at the beginning.
 
Posts: 7
Karma: 10
Join Date: May 2022
Device: kindle kwp4
Quote:
Originally Posted by davidfor View Post
No it can't be done that way.



But, that won't work. What that will do is change all test in a paragraph to "bolder". That isn't what the Bionic Reading is doing. It is making parts of each word, or some words bolder. Which is what my code is doing. I doubt there is a way to do this via just CSS. You will need to wrap the parts of the word that need to be different in a tag to change its style.

As to my code, that is used in the calibre editor. It would allow you to change one book at a time to see if it works for you. It is a regex function that is used as part of the search and replace. With it, you do a search using the regex specified, and the function doe the replace side of. I would suggest you look at the help for the editor to see how to use it. If you still have problems after that, then ask questions.

And my code is just a sample. It is what I thought of when I saw the page that is referred to above. It is an simplistic implementation that would only be good to get an idea of whether the Bionic Reading would work for you. Which I only did as a I was curious about whether I could. And I see lots of problems that I have no interest in solving as I don't have an interest in reading in that way.

If this was to be done "properly" it would probably need to be in a plugin. And, as the Bionic Reading clearly states, there are Patents around it, so it should be licensed to use their API. Maybe someone will be interested in doing that.
I find new regex,
Code:
>[^<]+<
,maybe fix
Code:
\b(\w+)\b
we can achieve our purpose
evilone is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bionic Reading implementation on Kobo? jeff47 Kobo Developer's Corner 28 06-03-2022 09:54 AM
pdf regex question - regex that wraps to a new line flyash Conversion 1 09-05-2021 09:00 AM
Regex question theaccountant Library Management 0 11-07-2016 02:29 PM
Regex help on reading Metadata from file name. JohnnyBook Library Management 11 03-05-2015 07:35 PM
RegEx question (again) phossler Sigil 12 01-20-2013 02:37 PM


All times are GMT -4. The time now is 05:39 PM.


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