![]() |
#16 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,635
Karma: 23190435
Join Date: Dec 2010
Device: Kindle PW2
|
@CalibUser: I've just tested the updated plugin with my Linux machine and appears to be working fine. (I only tested the line break fix.)
|
![]() |
![]() |
![]() |
#17 |
Connoisseur
![]() Posts: 81
Karma: 10
Join Date: Nov 2013
Device: Kobo Aura HD
|
The Fix for false line breaks doesn't work in greek language.
I use the following regex to fix the lines breaks. Code:
Find: ([\p{Greek},'–’“”][</ib>]*)</p>\s+<p>([<ib>]*[\p{Greek},'–’“”]) Replace:\1 \2 Code:
if allBreaks == 'Yes': CorrectText("Fixed false line breaks:", r'([a-z])</p>\s+<p[^>]*>([A-Z])', r'\1 \2') Code:
if allBreaks == 'Yes': CorrectText("Fixed false line breaks:", r'([\p{Greek}\,\'–’“”][</ib>]*)</p>\s+<p>([<ib>]*[\p{Greek},\'–’“”])', r'\1 \2') ![]() I don't know any python. Is my code ok? Thanks ![]() |
![]() |
![]() |
Advert | |
|
![]() |
#18 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 202
Karma: 62362
Join Date: Jul 2015
Device: Sony
|
@Doitsu: Thanks for testing the plugin
@gipsy: In your code: Code:
r'([\p{Greek}\,\'–’“”][</ib>]*)</p>\s+<p>([<ib>]*[\p{Greek},\'–’“”])' |
![]() |
![]() |
![]() |
#19 |
Connoisseur
![]() Posts: 81
Karma: 10
Join Date: Nov 2013
Device: Kobo Aura HD
|
You are right. But again they don't compine
![]() Yes is for greek characters. Code:
<p>ο Πυθέας ήπιε το υπόλοιπο</p> <p>γάλα από το κύπελλο, σκούπισε</p> <p>δυο σταγόνες στα χείλη του με την ανάστροφη του</p> <p>χεριού του και σηκώθηκε.</p> Code:
<p>ο Πυθέας ήπιε το υπόλοιπο γάλα από το κύπελλο, σκούπισε δυο σταγόνες στα χείλη του με την ανάστροφη του χεριού του και σηκώθηκε.</p> ![]() |
![]() |
![]() |
![]() |
#20 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,635
Karma: 23190435
Join Date: Dec 2010
Device: Kindle PW2
|
Sigil and Python use different Regex engines. Sigil uses PCRE and Python uses an older, less powerful version.
AFAIK, Python doesn't support the \p{Greek} syntax. I.e., Greek letters need to be explicitly expressed as Unicode ranges (0370–03FF). |
![]() |
![]() |
Advert | |
|
![]() |
#21 | |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Quote:
Code:
userProfile = (os.environ['USERPROFILE']) #Get path to user profile try: f = open(userProfile+'\\AppData\\Local\sigil-ebook\\sigil\\user_dictionaries\\WordDictionary.txt', 'r', encoding='utf-8') For that matter, it is highly environment-specific -- it would also break hard on a PortableApps.com install, for example. Is there any way in Sigil/the plugin container to access the value of the Sigil configuration folder? This would be a far, far better way of handling it. (If there isn't a way, then it would be a generally useful thing to have...) Asking the user to manually select the dictionary just to get around the issue of finding the configuration directory is overkill (and slightly onerous) -- although it could be useful if one has multiple dictionaries and wants to use a specific one, that is probably an edge case. EDIT: And of course the instructions already make it clear that that won't work. Last edited by eschwartz; 09-06-2015 at 12:24 AM. |
|
![]() |
![]() |
![]() |
#22 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,063
Karma: 5449552
Join Date: Nov 2009
Device: many
|
FWIW,
The next release of Sigil will include an interface to the hunspell spellchecker and will provide a list of paths to the hunspell dictionaries. If I can figure out how best to bundle sigil's version of gumbo for use by plugins, and if DiapDealer and I can fix some bugs, we should have a release out in 2 or 3 weeks. Kevin |
![]() |
![]() |
![]() |
#23 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,635
Karma: 23190435
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
@CalibUser: Python has a boatload of built-in functions for cross-platform file handling that make it really easy to implement cross-platform file support. Since the Sigil plugin root directory and the user_dictionary directory are sibling directories it's relatively easy to get the user_dictionary directory location. For example, you could use the following code to get the dictionary folder: Code:
import os, inspect def run(bk): # get plugin directory path plugin_path = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) print(plugin_path) # get rid of the last two directories tmp_path = plugin_path.split(os.path.sep)[:7] print(tmp_path) # add the dictionary path tmp_path.extend(['user_dictionaries', 'WordDictionary.txt']) # convert list back to file path dictionary_path = os.path.sep.join(tmp_path) print(dictionary_path) Windows: Code:
C:\Users\Doitsu\AppData\Local\sigil-ebook\sigil\plugins\test ['C:', 'Users', 'Doitsu', 'AppData', 'Local', 'sigil-ebook', 'sigil'] C:\Users\Doitsu\AppData\Local\sigil-ebook\sigil\user_dictionaries\WordDictionary.txt Code:
/home/doitsu/.local/share/sigil-ebook/sigil/plugins/test ['', 'home', 'doitsu', '.local', 'share', 'sigil-ebook', 'sigil'] /home/doitsu/.local/share/sigil-ebook/sigil/user_dictionaries/WordDictionary.txt Last edited by Doitsu; 09-06-2015 at 06:31 AM. |
|
![]() |
![]() |
![]() |
#24 | ||
Connoisseur
![]() Posts: 81
Karma: 10
Join Date: Nov 2013
Device: Kobo Aura HD
|
Quote:
I change it to Code:
if allBreaks == 'Yes': CorrectText("Fixed false line breaks:", r'(([\x{0370}-\x{03FF}\x{1F00}-\x{1FFF},\'–’“”][</ib>]*)</p>\s+<p>([<ib>]*[\x{0370}-\x{03FF}\x{1F00}-\x{1FFF},\'–’“”]))', r'\1 \2') ![]() Quote:
Last edited by gipsy; 09-06-2015 at 07:35 AM. |
||
![]() |
![]() |
![]() |
#25 |
Connoisseur
![]() Posts: 81
Karma: 10
Join Date: Nov 2013
Device: Kobo Aura HD
|
@CalibUser: Those are some fixes in greek language if you want to place them in your plygin. I try to find a solution and for some other things and i keep you posted
![]() Code:
#Greek line break fix if allBreaks == 'Yes': CorrectText("Fixed false line breaks:", r'(([\x{0370}-\x{03FF}\x{1F00}-\x{1FFF},\'–’“”][</ib>]*)</p>\s+<p>([<ib>]*[\x{0370}-\x{03FF}\x{1F00}-\x{1FFF},\'–’“”]))', r'\1 \2') return(0) Code:
#Fixes Έ when PDFd as 'Ε or "Ε CorrectText("Changed 'Ε,\"Ε to Έ", r'(\'Ε|\"Ε)', r'Έ') #Fixes Ύ when PDFd as 'Υ or "Υ CorrectText("Changed 'Υ,\"Υ to Ύ", r'(\'Υ|\"Υ)', r'Ύ') #Fixes Ί when PDFd as 'Ι or "Ι CorrectText("Changed 'Ι,\"Ι to Ί", r'(\'Ι|\"Ι)', r'Ί') #Fixes Ό when PDFd as 'Ο or "Ο CorrectText("Changed 'Ο,\"Ο to Ό", r'(\'Ο|\"Ο)', r'Ό') #Fixes Ά when PDFd as 'Α or "Α CorrectText("Changed 'Α,\"Α to Ά", r'(\'Α|\"Α)', r'Ά') #Fixes Ή when PDFd as 'Η or "Η CorrectText("Changed 'Η,\"Η to Ή", r'(\'Η|\"Η)', r'Ή') #Fixes Ώ when PDFd as 'Ω or "Ω CorrectText("Changed 'Ω,\"Ω to Ώ", r'(\'Ω|\"Ω)', r'Ώ') #Fixes ύ when PDFd as ΰ CorrectText("Changed ΰ to ύ", r'ΰ', r'ύ') Last edited by gipsy; 09-06-2015 at 11:25 AM. |
![]() |
![]() |
![]() |
#26 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 27,856
Karma: 198099188
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
![]() I would, however suggest something other than the relatively fragile method of converting a path to a list of strings and then using the [:7] slice to strip off the last two directories. If the depth of that path ever increases, it won't point to the sigil preferences directory anymore. To be clear: it's the [:7] slice I find fragile, not the list of strings conversion and eventual re-joining. I would suggest using [:-2] if you're going to split the path into a list of strings that later get rejoined. Or just use os.path.dirname twice without converting to a list of strings and rejoining. It's all a bit fragile I guess (even mine), considering that the plugin directory could conceivably change in relation to the Sigil preferences directory. Code:
import os, inspect # get plugin directory path plugin_path = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) print(plugin_path) # get rid of the last two directories tmp_path = os.path.dirname(os.path.dirname(plugin_path)) print(tmp_path) # add the dictionary path dictionary_path = os.path.join(tmp_path, 'user_dictionaries', 'WordDictionary.txt') print(dictionary_path) You could also determine the path of the current plugin script in the run method of a plugin by using: Code:
def run(bk): ppath = bk._w.plugin_dir ![]() Last edited by DiapDealer; 09-06-2015 at 09:25 AM. |
|
![]() |
![]() |
![]() |
#27 |
Connoisseur
![]() Posts: 81
Karma: 10
Join Date: Nov 2013
Device: Kobo Aura HD
|
Code:
#Greek line break fix if allBreaks == 'Yes': CorrectText("Fixed false line breaks:", r'([\u0370-\u03FF,\u1F00-\u1FFF,\'–’“”][</ib>]*)</p>\s+<p[^>]*>([<ib>]*[\u0370-\u03FF,\u1F00-\u1FFF,\'–’“”])', r'\1 \2') return(0) |
![]() |
![]() |
![]() |
#28 | ||
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Quote:
![]() Quote:
![]() (I guess it really depends on the app. I know they prefer if at all possible to not do that, it reduces the "portability" angle by potentially leaving unwanted cruft on the host computer.) ![]() (And it uses the deprecated-since-5.4 DataLocation, rather than AppDataLocation on Windows and AppConfigLocation on unix -- did Qt have to split it? ![]() |
||
![]() |
![]() |
![]() |
#29 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 27,856
Karma: 198099188
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
And there's just no "real" pressing need to convert and potentially lose user-settings/plugins in an upgrade (or create a one-time script to copy stuff to the new location). Maybe someday it will change, but it's just not high on the list of priorities at the moment. |
|
![]() |
![]() |
![]() |
#30 | |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Quote:
![]() Whether either is *necessary*, I won't venture to say. I agree once it's been used you shouldn't break everyone's settings just to conform to more "proper" standards. |
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Tidying Up My Kindle | selectortone | Calibre | 2 | 07-17-2013 10:35 AM |
developping a Plugin for Presentation files | abdlink | Plugins | 4 | 04-15-2013 11:27 AM |
Plugin to fix fb2 files | oviksna | Plugins | 3 | 01-28-2013 08:53 AM |
Tidying Up My Library | JayLaFunk | Library Management | 2 | 09-20-2011 09:12 AM |
Calibre 0.7.50 can't see plugin files | mb_webguy | Calibre | 5 | 04-29-2011 03:41 AM |