mobi ebook remove the extra space

  Chinese New Year holiday, or at home reading a book at home, and found that some e-books online finishing is not good, there is a lot of use of spaces, very affect the reading efficiency, we intended to see if you can solve it. Step is also very simple, first download a caliber, this severe kindle users know, then we need to convert mobi to epub format, which can be edited, caliber has a built-caliber editor such editor, open just fine .

We can see the red box in a lot of space, and these spaces so that we do not need, at this time we need regular expressions. We note that some parts of the space is actually useful, such as grammar css, for example, between the above p and class.

 

Then we click on the search and replace in the search editor, and then enter the following regular expression:

[^a-zA-Z=""><0-9]\s[^a-zA-Z=""><0-9]

While the following mode into the regular expression functions.

We click on the Create / Edit, then build its own replacement function, the code of python function of the students should be very clear.

def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):
    return match.group()[0] + match.group()[-1]

Function can be said to be at a glance.

Overall, positioned by the regular expression to spare space, the regular expression, taking into account some special formatting characters, it requires a space left and right side can not be numbers and letters; followed by replacement function, the regular expression type mating end to end to a portion of the contents as an alternative.

 

Call it a day, reading to go.

 

 

发布了205 篇原创文章 · 获赞 236 · 访问量 98万+

Guess you like

Origin blog.csdn.net/qtlyx/article/details/104078480