| 1 |
# SOME DESCRIPTIVE TITLE. |
| 2 |
# Copyright (C) Kovid Goyal |
| 3 |
# This file is distributed under the same license as the calibre package. |
| 4 |
# |
| 5 |
# Translators: |
| 6 |
msgid "" |
| 7 |
msgstr "" |
| 8 |
"Project-Id-Version: calibre\n" |
| 9 |
"Report-Msgid-Bugs-To: \n" |
| 10 |
"POT-Creation-Date: 2014-10-17 08:20+0530\n" |
| 11 |
"PO-Revision-Date: 2014-10-17 02:53+0000\n" |
| 12 |
"Last-Translator: Kovid Goyal <[email protected]>\n" |
| 13 |
"Language-Team: Slovenian (Slovenia) (http://www.transifex.com/projects/p/calibre/language/sl_SI/)\n" |
| 14 |
"MIME-Version: 1.0\n" |
| 15 |
"Content-Type: text/plain; charset=UTF-8\n" |
| 16 |
"Content-Transfer-Encoding: 8bit\n" |
| 17 |
"Language: sl_SI\n" |
| 18 |
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" |
| 19 |
|
| 20 |
# 928057a5e25147f49d9d68a4fa422133 |
| 21 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:4 |
| 22 |
msgid "All about using regular expressions in calibre" |
| 23 |
msgstr "" |
| 24 |
|
| 25 |
# f56932f2cb87406cacd25e2a3ff375b4 |
| 26 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:6 |
| 27 |
msgid "" |
| 28 |
"Regular expressions are features used in many places in calibre to perform " |
| 29 |
"sophisticated manipulation of ebook content and metadata. This tutorial is a" |
| 30 |
" gentle introduction to getting you started with using regular expressions " |
| 31 |
"in calibre." |
| 32 |
msgstr "" |
| 33 |
|
| 34 |
# 5276fc281ef54482b4df88e8d1cffb3c |
| 35 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:0 |
| 36 |
msgid "Contents" |
| 37 |
msgstr "" |
| 38 |
|
| 39 |
# d46f02e13d004eb9a5f28b5050673049 |
| 40 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:14 |
| 41 |
msgid "First, a word of warning and a word of courage" |
| 42 |
msgstr "" |
| 43 |
|
| 44 |
# 736cc1ba25f2489fa7217b4c5b30811e |
| 45 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:16 |
| 46 |
msgid "" |
| 47 |
"This is, inevitably, going to be somewhat technical- after all, regular " |
| 48 |
"expressions are a technical tool for doing technical stuff. I'm going to " |
| 49 |
"have to use some jargon and concepts that may seem complicated or " |
| 50 |
"convoluted. I'm going to try to explain those concepts as clearly as I can, " |
| 51 |
"but really can't do without using them at all. That being said, don't be " |
| 52 |
"discouraged by any jargon, as I've tried to explain everything new. And " |
| 53 |
"while regular expressions themselves may seem like an arcane, black magic " |
| 54 |
"(or, to be more prosaic, a random string of mumbo-jumbo letters and signs), " |
| 55 |
"I promise that they are not all that complicated. Even those who understand " |
| 56 |
"regular expressions really well have trouble reading the more complex ones, " |
| 57 |
"but writing them isn't as difficult- you construct the expression step by " |
| 58 |
"step. So, take a step and follow me into the rabbit hole." |
| 59 |
msgstr "" |
| 60 |
|
| 61 |
# 7a9f6b72f0e547888dece8f905c11110 |
| 62 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:19 |
| 63 |
msgid "Where in calibre can you use regular expressions?" |
| 64 |
msgstr "" |
| 65 |
|
| 66 |
# 2baa79a95c5e4ca4ac0580aa70888d09 |
| 67 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:21 |
| 68 |
msgid "" |
| 69 |
"There are a few places calibre uses regular expressions. There's the Search " |
| 70 |
"& Replace in conversion options, metadata detection from filenames in the " |
| 71 |
"import settings and Search & Replace when editing the metadata of books in " |
| 72 |
"bulk." |
| 73 |
msgstr "" |
| 74 |
|
| 75 |
# c39f98f496df420a921895aac6e6cc25 |
| 76 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:24 |
| 77 |
msgid "What on earth *is* a regular expression?" |
| 78 |
msgstr "" |
| 79 |
|
| 80 |
# 17b5bcf66dcf423983925bccf3b7ba94 |
| 81 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:26 |
| 82 |
msgid "" |
| 83 |
"A regular expression is a way to describe sets of strings. A single regular " |
| 84 |
"expression can *match* a number of different strings. This is what makes " |
| 85 |
"regular expression so powerful -- they are a concise way of describing a " |
| 86 |
"potentially large number of variations." |
| 87 |
msgstr "" |
| 88 |
|
| 89 |
# 85ba2f4adf634c2cb8bedf31c577817a |
| 90 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:28 |
| 91 |
msgid "" |
| 92 |
"I'm using string here in the sense it is used in programming languages: a " |
| 93 |
"string of one or more characters, characters including actual characters, " |
| 94 |
"numbers, punctuation and so-called whitespace (linebreaks, tabulators etc.)." |
| 95 |
" Please note that generally, uppercase and lowercase characters are not " |
| 96 |
"considered the same, thus \"a\" being a different character from \"A\" and " |
| 97 |
"so forth. In calibre, regular expressions are case insensitive in the search" |
| 98 |
" bar, but not in the conversion options. There's a way to make every regular" |
| 99 |
" expression case insensitive, but we'll discuss that later. It gets " |
| 100 |
"complicated because regular expressions allow for variations in the strings " |
| 101 |
"it matches, so one expression can match multiple strings, which is why " |
| 102 |
"people bother using them at all. More on that in a bit." |
| 103 |
msgstr "" |
| 104 |
|
| 105 |
# 102624f8335a4b6d94ed1791e3f3b2af |
| 106 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:31 |
| 107 |
msgid "Care to explain?" |
| 108 |
msgstr "" |
| 109 |
|
| 110 |
# 6282f2cac067461fb2ed663d0adad5bf |
| 111 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:33 |
| 112 |
msgid "" |
| 113 |
"Well, that's why we're here. First, this is the most important concept in " |
| 114 |
"regular expressions: *A string by itself is a regular expression that " |
| 115 |
"matches itself*. That is to say, if I wanted to match the string ``\"Hello, " |
| 116 |
"World!\"`` using a regular expression, the regular expression to use would " |
| 117 |
"be ``Hello, World!``. And yes, it really is that simple. You'll notice, " |
| 118 |
"though, that this *only* matches the exact string ``\"Hello, World!\"``, not" |
| 119 |
" e.g. ``\"Hello, wOrld!\"`` or ``\"hello, world!\"`` or any other such " |
| 120 |
"variation." |
| 121 |
msgstr "" |
| 122 |
|
| 123 |
# 0d78360a4b834b3ea381cfec4fa44694 |
| 124 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:36 |
| 125 |
msgid "That doesn't sound too bad. What's next?" |
| 126 |
msgstr "" |
| 127 |
|
| 128 |
# 5252286ca82246fa87601cd0e6f73afd |
| 129 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:38 |
| 130 |
msgid "" |
| 131 |
"Next is the beginning of the really good stuff. Remember where I said that " |
| 132 |
"regular expressions can match multiple strings? This is were it gets a " |
| 133 |
"little more complicated. Say, as a somewhat more practical exercise, the " |
| 134 |
"ebook you wanted to convert had a nasty footer counting the pages, like " |
| 135 |
"\"Page 5 of 423\". Obviously the page number would rise from 1 to 423, thus " |
| 136 |
"you'd have to match 423 different strings, right? Wrong, actually: regular " |
| 137 |
"expressions allow you to define sets of characters that are matched: To " |
| 138 |
"define a set, you put all the characters you want to be in the set into " |
| 139 |
"square brackets. So, for example, the set ``[abc]`` would match either the " |
| 140 |
"character \"a\", \"b\" or \"c\". *Sets will always only match one of the " |
| 141 |
"characters in the set*. They \"understand\" character ranges, that is, if " |
| 142 |
"you wanted to match all the lower case characters, you'd use the set " |
| 143 |
"``[a-z]`` for lower- and uppercase characters you'd use ``[a-zA-Z]`` and so " |
| 144 |
"on. Got the idea? So, obviously, using the expression ``Page [0-9] of 423`` " |
| 145 |
"you'd be able to match the first 9 pages, thus reducing the expressions " |
| 146 |
"needed to three: The second expression ``Page [0-9][0-9] of 423`` would " |
| 147 |
"match all two-digit page numbers, and I'm sure you can guess what the third " |
| 148 |
"expression would look like. Yes, go ahead. Write it down." |
| 149 |
msgstr "" |
| 150 |
|
| 151 |
# f9a1f8fd16434a659d55da29854484d6 |
| 152 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:41 |
| 153 |
msgid "Hey, neat! This is starting to make sense!" |
| 154 |
msgstr "" |
| 155 |
|
| 156 |
# a8ddc500e86e41f2b71887842da291cf |
| 157 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:43 |
| 158 |
msgid "" |
| 159 |
"I was hoping you'd say that. But brace yourself, now it gets even better! We" |
| 160 |
" just saw that using sets, we could match one of several characters at once." |
| 161 |
" But you can even repeat a character or set, reducing the number of " |
| 162 |
"expressions needed to handle the above page number example to one. Yes, ONE!" |
| 163 |
" Excited? You should be! It works like this: Some so-called special " |
| 164 |
"characters, \"+\", \"?\" and \"*\", *repeat the single element preceding " |
| 165 |
"them*. (Element means either a single character, a character set, an escape " |
| 166 |
"sequence or a group (we'll learn about those last two later)- in short, any " |
| 167 |
"single entity in a regular expression.) These characters are called " |
| 168 |
"wildcards or quantifiers. To be more precise, \"?\" matches *0 or 1* of the " |
| 169 |
"preceding element, \"*\" matches *0 or more* of the preceding element and " |
| 170 |
"\"+\" matches *1 or more* of the preceding element. A few examples: The " |
| 171 |
"expression ``a?`` would match either \"\" (which is the empty string, not " |
| 172 |
"strictly useful in this case) or \"a\", the expression ``a*`` would match " |
| 173 |
"\"\", \"a\", \"aa\" or any number of a's in a row, and, finally, the " |
| 174 |
"expression ``a+`` would match \"a\", \"aa\" or any number of a's in a row " |
| 175 |
"(Note: it wouldn't match the empty string!). Same deal for sets: The " |
| 176 |
"expression ``[0-9]+`` would match *every integer number there is*! I know " |
| 177 |
"what you're thinking, and you're right: If you use that in the above case of" |
| 178 |
" matching page numbers, wouldn't that be the single one expression to match " |
| 179 |
"all the page numbers? Yes, the expression ``Page [0-9]+ of 423`` would match" |
| 180 |
" every page number in that book!" |
| 181 |
msgstr "" |
| 182 |
|
| 183 |
# 5257f39f80ff4316931eac9f90b4540f |
| 184 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:46 |
| 185 |
msgid "" |
| 186 |
"A note on these quantifiers: They generally try to match as much text as " |
| 187 |
"possible, so be careful when using them. This is called \"greedy " |
| 188 |
"behaviour\"- I'm sure you get why. It gets problematic when you, say, try to" |
| 189 |
" match a tag. Consider, for example, the string ``\"<p " |
| 190 |
"class=\"calibre2\">Title here</p>\"`` and let's say you'd want to match the " |
| 191 |
"opening tag (the part between the first pair of angle brackets, a little " |
| 192 |
"more on tags later). You'd think that the expression ``<p.*>`` would match " |
| 193 |
"that tag, but actually, it matches the whole string! (The character \".\" is" |
| 194 |
" another special character. It matches anything *except* linebreaks, so, " |
| 195 |
"basically, the expression ``.*`` would match any single line you can think " |
| 196 |
"of.) Instead, try using ``<p.*?>`` which makes the quantifier ``\"*\"`` non-" |
| 197 |
"greedy. That expression would only match the first opening tag, as intended." |
| 198 |
" There's actually another way to accomplish this: The expression " |
| 199 |
"``<p[^>]*>`` will match that same opening tag- you'll see why after the next" |
| 200 |
" section. Just note that there quite frequently is more than one way to " |
| 201 |
"write a regular expression." |
| 202 |
msgstr "" |
| 203 |
|
| 204 |
# 0d6d36e2ae854c5682b5a620c138ca60 |
| 205 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:50 |
| 206 |
msgid "" |
| 207 |
"Well, these special characters are very neat and all, but what if I wanted " |
| 208 |
"to match a dot or a question mark?" |
| 209 |
msgstr "" |
| 210 |
|
| 211 |
# 7463bcac393c4687a5214bc13ae177bf |
| 212 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:52 |
| 213 |
msgid "" |
| 214 |
"You can of course do that: Just put a backslash in front of any special " |
| 215 |
"character and it is interpreted as the literal character, without any " |
| 216 |
"special meaning. This pair of a backslash followed by a single character is " |
| 217 |
"called an escape sequence, and the act of putting a backslash in front of a " |
| 218 |
"special character is called escaping that character. An escape sequence is " |
| 219 |
"interpreted as a single element. There are of course escape sequences that " |
| 220 |
"do more than just escaping special characters, for example ``\"\\t\"`` means" |
| 221 |
" a tabulator. We'll get to some of the escape sequences later. Oh, and by " |
| 222 |
"the way, concerning those special characters: Consider any character we " |
| 223 |
"discuss in this introduction as having some function to be special and thus " |
| 224 |
"needing to be escaped if you want the literal character." |
| 225 |
msgstr "" |
| 226 |
|
| 227 |
# 51de6b05caa8408e91b9a2e949bbd266 |
| 228 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:55 |
| 229 |
msgid "So, what are the most useful sets?" |
| 230 |
msgstr "" |
| 231 |
|
| 232 |
# c699ca3b8e5a4defbd9f1507ec3a63b0 |
| 233 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:57 |
| 234 |
msgid "" |
| 235 |
"Knew you'd ask. Some useful sets are ``[0-9]`` matching a single number, " |
| 236 |
"``[a-z]`` matching a single lowercase letter, ``[A-Z]`` matching a single " |
| 237 |
"uppercase letter, ``[a-zA-Z]`` matching a single letter and ``[a-zA-Z0-9]`` " |
| 238 |
"matching a single letter or number. You can also use an escape sequence as " |
| 239 |
"shorthand::" |
| 240 |
msgstr "" |
| 241 |
|
| 242 |
# 4f4c538dfd1441e3bcf1b945ea412738 |
| 243 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:64 |
| 244 |
msgid "" |
| 245 |
"\"Whitespace\" is a term for anything that won't be printed. These " |
| 246 |
"characters include space, tabulator, line feed, form feed and carriage " |
| 247 |
"return." |
| 248 |
msgstr "" |
| 249 |
|
| 250 |
# b203354c57db4dc5a0da7c1c3025254d |
| 251 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:66 |
| 252 |
msgid "" |
| 253 |
"As a last note on sets, you can also define a set as any character *but* " |
| 254 |
"those in the set. You do that by including the character ``\"^\"`` as the " |
| 255 |
"*very first character in the set*. Thus, ``[^a]`` would match any character " |
| 256 |
"excluding \"a\". That's called complementing the set. Those escape sequence " |
| 257 |
"shorthands we saw earlier can also be complemented: ``\"\\D\"`` means any " |
| 258 |
"non-number character, thus being equivalent to ``[^0-9]``. The other " |
| 259 |
"shorthands can be complemented by, you guessed it, using the respective " |
| 260 |
"uppercase letter instead of the lowercase one. So, going back to the example" |
| 261 |
" ``<p[^>]*>`` from the previous section, now you can see that the character " |
| 262 |
"set it's using tries to match any character except for a closing angle " |
| 263 |
"bracket." |
| 264 |
msgstr "" |
| 265 |
|
| 266 |
# 3603ff5f214a43e9ac1208139c91caa4 |
| 267 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:69 |
| 268 |
msgid "" |
| 269 |
"But if I had a few varying strings I wanted to match, things get " |
| 270 |
"complicated?" |
| 271 |
msgstr "" |
| 272 |
|
| 273 |
# 9422ef0970454b15bcc7eca1c7edea02 |
| 274 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:71 |
| 275 |
msgid "" |
| 276 |
"Fear not, life still is good and easy. Consider this example: The book " |
| 277 |
"you're converting has \"Title\" written on every odd page and \"Author\" " |
| 278 |
"written on every even page. Looks great in print, right? But in ebooks, it's" |
| 279 |
" annoying. You can group whole expressions in normal parentheses, and the " |
| 280 |
"character ``\"|\"`` will let you match *either* the expression to its right " |
| 281 |
"*or* the one to its left. Combine those and you're done. Too fast for you? " |
| 282 |
"Okay, first off, we group the expressions for odd and even pages, thus " |
| 283 |
"getting ``(Title)(Author)`` as our two needed expressions. Now we make " |
| 284 |
"things simpler by using the vertical bar (``\"|\"`` is called the vertical " |
| 285 |
"bar character): If you use the expression ``(Title|Author)`` you'll either " |
| 286 |
"get a match for \"Title\" (on the odd pages) or you'd match \"Author\" (on " |
| 287 |
"the even pages). Well, wasn't that easy?" |
| 288 |
msgstr "" |
| 289 |
|
| 290 |
# cc79e8ce52b741449d0f304f60bdcf03 |
| 291 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:73 |
| 292 |
msgid "" |
| 293 |
"You can, of course, use the vertical bar without using grouping parentheses," |
| 294 |
" as well. Remember when I said that quantifiers repeat the element preceding" |
| 295 |
" them? Well, the vertical bar works a little differently: The expression " |
| 296 |
"\"Title|Author\" will also match either the string \"Title\" or the string " |
| 297 |
"\"Author\", just as the above example using grouping. *The vertical bar " |
| 298 |
"selects between the entire expression preceding and following it*. So, if " |
| 299 |
"you wanted to match the strings \"Calibre\" and \"calibre\" and wanted to " |
| 300 |
"select only between the upper- and lowercase \"c\", you'd have to use the " |
| 301 |
"expression ``(c|C)alibre``, where the grouping ensures that only the \"c\" " |
| 302 |
"will be selected. If you were to use ``c|Calibre``, you'd get a match on the" |
| 303 |
" string \"c\" or on the string \"Calibre\", which isn't what we wanted. In " |
| 304 |
"short: If in doubt, use grouping together with the vertical bar." |
| 305 |
msgstr "" |
| 306 |
|
| 307 |
# 91650b1352b841818dba00532cc30cff |
| 308 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:76 |
| 309 |
msgid "You missed..." |
| 310 |
msgstr "" |
| 311 |
|
| 312 |
# 3634067a874f41beb50b1b96585f0a52 |
| 313 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:78 |
| 314 |
msgid "" |
| 315 |
"... wait just a minute, there's one last, really neat thing you can do with " |
| 316 |
"groups. If you have a group that you previously matched, you can use " |
| 317 |
"references to that group later in the expression: Groups are numbered " |
| 318 |
"starting with 1, and you reference them by escaping the number of the group " |
| 319 |
"you want to reference, thus, the fifth group would be referenced as ``\\5``." |
| 320 |
" So, if you searched for ``([^ ]+) \\1`` in the string \"Test Test\", you'd " |
| 321 |
"match the whole string!" |
| 322 |
msgstr "" |
| 323 |
|
| 324 |
# af1108bdcaaf43f7a3d30dea4368ad42 |
| 325 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:82 |
| 326 |
msgid "" |
| 327 |
"In the beginning, you said there was a way to make a regular expression case" |
| 328 |
" insensitive?" |
| 329 |
msgstr "" |
| 330 |
|
| 331 |
# 65e3fb907b164e84b5e5a445043e5589 |
| 332 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:84 |
| 333 |
msgid "" |
| 334 |
"Yes, I did, thanks for paying attention and reminding me. You can tell " |
| 335 |
"calibre how you want certain things handled by using something called flags." |
| 336 |
" You include flags in your expression by using the special construct " |
| 337 |
"``(?flags go here)`` where, obviously, you'd replace \"flags go here\" with " |
| 338 |
"the specific flags you want. For ignoring case, the flag is ``i``, thus you " |
| 339 |
"include ``(?i)`` in your expression. Thus, ``test(?i)`` would match " |
| 340 |
"\"Test\", \"tEst\", \"TEst\" and any case variation you could think of." |
| 341 |
msgstr "" |
| 342 |
|
| 343 |
# 0cb07cd7968a46289b4ba7ebca391256 |
| 344 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:86 |
| 345 |
msgid "" |
| 346 |
"Another useful flag lets the dot match any character at all, *including* the" |
| 347 |
" newline, the flag ``s``. If you want to use multiple flags in an " |
| 348 |
"expression, just put them in the same statement: ``(?is)`` would ignore case" |
| 349 |
" and make the dot match all. It doesn't matter which flag you state first, " |
| 350 |
"``(?si)`` would be equivalent to the above. By the way, good places for " |
| 351 |
"putting flags in your expression would be either the very beginning or the " |
| 352 |
"very end. That way, they don't get mixed up with anything else." |
| 353 |
msgstr "" |
| 354 |
|
| 355 |
# 7a1bc891e0d041b196e08800071b3aeb |
| 356 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:89 |
| 357 |
msgid "" |
| 358 |
"I think I'm beginning to understand these regular expressions now... how do " |
| 359 |
"I use them in calibre?" |
| 360 |
msgstr "" |
| 361 |
|
| 362 |
# 7d68a50b94f74ec58b3fecee5af86c6a |
| 363 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:92 |
| 364 |
msgid "Conversions" |
| 365 |
msgstr "" |
| 366 |
|
| 367 |
# 53db003d6ee5440f84e4ba532cefbaac |
| 368 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:94 |
| 369 |
msgid "" |
| 370 |
"Let's begin with the conversion settings, which is really neat. In the " |
| 371 |
"Search and Replace part, you can input a regexp (short for regular " |
| 372 |
"expression) that describes the string that will be replaced during the " |
| 373 |
"conversion. The neat part is the wizard. Click on the wizard staff and you " |
| 374 |
"get a preview of what calibre \"sees\" during the conversion process. Scroll" |
| 375 |
" down to the string you want to remove, select and copy it, paste it into " |
| 376 |
"the regexp field on top of the window. If there are variable parts, like " |
| 377 |
"page numbers or so, use sets and quantifiers to cover those, and while " |
| 378 |
"you're at it, remember to escape special characters, if there are some. Hit " |
| 379 |
"the button labeled :guilabel:`Test` and calibre highlights the parts it " |
| 380 |
"would replace were you to use the regexp. Once you're satisfied, hit OK and " |
| 381 |
"convert. Be careful if your conversion source has tags like this example::" |
| 382 |
msgstr "" |
| 383 |
|
| 384 |
# 638f70fe8393477f98470cec66b550f1 |
| 385 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:104 |
| 386 |
msgid "" |
| 387 |
"(shamelessly ripped out of `this thread " |
| 388 |
"<http://www.mobileread.com/forums/showthread.php?t=75594\">`_). You'd have " |
| 389 |
"to remove some of the tags as well. In this example, I'd recommend beginning" |
| 390 |
" with the tag ``<b class=\"calibre2\">``, now you have to end with the " |
| 391 |
"corresponding closing tag (opening tags are ``<tag>``, closing tags are " |
| 392 |
"``</tag>``), which is simply the next ``</b>`` in this case. (Refer to a " |
| 393 |
"good HTML manual or ask in the forum if you are unclear on this point.) The " |
| 394 |
"opening tag can be described using ``<b.*?>``, the closing tag using " |
| 395 |
"``</b>``, thus we could remove everything between those tags using " |
| 396 |
"``<b.*?>.*?</b>``. But using this expression would be a bad idea, because it" |
| 397 |
" removes everything enclosed by <b>- tags (which, by the way, render the " |
| 398 |
"enclosed text in bold print), and it's a fair bet that we'll remove portions" |
| 399 |
" of the book in this way. Instead, include the beginning of the enclosed " |
| 400 |
"string as well, making the regular expression " |
| 401 |
"``<b.*?>\\s*Generated\\s+by\\s+ABC\\s+Amber\\s+LIT.*?</b>`` The ``\\s`` with" |
| 402 |
" quantifiers are included here instead of explicitly using the spaces as " |
| 403 |
"seen in the string to catch any variations of the string that might occur. " |
| 404 |
"Remember to check what calibre will remove to make sure you don't remove any" |
| 405 |
" portions you want to keep if you test a new expression. If you only check " |
| 406 |
"one occurrence, you might miss a mismatch somewhere else in the text. Also " |
| 407 |
"note that should you accidentally remove more or fewer tags than you " |
| 408 |
"actually wanted to, calibre tries to repair the damaged code after doing the" |
| 409 |
" removal." |
| 410 |
msgstr "" |
| 411 |
|
| 412 |
# 79327ba31ff04de791c3d7b1bdb1bc84 |
| 413 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:107 |
| 414 |
msgid "Adding books" |
| 415 |
msgstr "" |
| 416 |
|
| 417 |
# 4bd48334fd1d4acaa8bd62043528e3ff |
| 418 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:109 |
| 419 |
msgid "" |
| 420 |
"Another thing you can use regular expressions for is to extract metadata " |
| 421 |
"from filenames. You can find this feature in the \"Adding books\" part of " |
| 422 |
"the settings. There's a special feature here: You can use field names for " |
| 423 |
"metadata fields, for example ``(?P<title>)`` would indicate that calibre " |
| 424 |
"uses this part of the string as book title. The allowed field names are " |
| 425 |
"listed in the windows, together with another nice test field. An example: " |
| 426 |
"Say you want to import a whole bunch of files named like ``Classical Texts: " |
| 427 |
"The Divine Comedy by Dante Alighieri.mobi``. (Obviously, this is already in " |
| 428 |
"your library, since we all love classical italian poetry) or ``Science " |
| 429 |
"Fiction epics: The Foundation Trilogy by Isaac Asimov.epub``. This is " |
| 430 |
"obviously a naming scheme that calibre won't extract any meaningful data out" |
| 431 |
" of - its standard expression for extracting metadata is ``(?P<title>.+) - " |
| 432 |
"(?P<author>[^_]+)``. A regular expression that works here would be " |
| 433 |
"``[a-zA-Z]+: (?P<title>.+) by (?P<author>.+)``. Please note that, inside the" |
| 434 |
" group for the metadata field, you need to use expressions to describe what " |
| 435 |
"the field actually matches. And also note that, when using the test field " |
| 436 |
"calibre provides, you need to add the file extension to your testing " |
| 437 |
"filename, otherwise you won't get any matches at all, despite using a " |
| 438 |
"working expression." |
| 439 |
msgstr "" |
| 440 |
|
| 441 |
# 8d5f4d4f2daa4e3cb729fff58426608a |
| 442 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:113 |
| 443 |
msgid "Bulk editing metadata" |
| 444 |
msgstr "" |
| 445 |
|
| 446 |
# 574d62c3dd1e4b4b8eacca77fd19e99b |
| 447 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:115 |
| 448 |
msgid "" |
| 449 |
"The last part is regular expression search and replace in metadata fields. " |
| 450 |
"You can access this by selecting multiple books in the library and using " |
| 451 |
"bulk metadata edit. Be very careful when using this last feature, as it can " |
| 452 |
"do **Very Bad Things** to your library! Doublecheck that your expressions do" |
| 453 |
" what you want them to using the test fields, and only mark the books you " |
| 454 |
"really want to change! In the regular expression search mode, you can search" |
| 455 |
" in one field, replace the text with something and even write the result " |
| 456 |
"into another field. A practical example: Say your library contained the " |
| 457 |
"books of Frank Herbert's Dune series, named after the fashion ``Dune 1 - " |
| 458 |
"Dune``, ``Dune 2 - Dune Messiah`` and so on. Now you want to get ``Dune`` " |
| 459 |
"into the series field. You can do that by searching for ``(.*?) \\d+ - .*`` " |
| 460 |
"in the title field and replacing it with ``\\1`` in the series field. See " |
| 461 |
"what I did there? That's a reference to the first group you're replacing the" |
| 462 |
" series field with. Now that you have the series all set, you only need to " |
| 463 |
"do another search for ``.*? -`` in the title field and replace it with " |
| 464 |
"``\"\"`` (an empty string), again in the title field, and your metadata is " |
| 465 |
"all neat and tidy. Isn't that great? By the way, instead of replacing the " |
| 466 |
"entire field, you can also append or prepend to the field, so, if you " |
| 467 |
"*wanted* the book title to be prepended with series info, you could do that " |
| 468 |
"as well. As you by now have undoubtedly noticed, there's a checkbox labeled " |
| 469 |
":guilabel:`Case sensitive`, so you won't have to use flags to select " |
| 470 |
"behaviour here." |
| 471 |
msgstr "" |
| 472 |
|
| 473 |
# a2915431275c422fab5ed9dad9ab631f |
| 474 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:117 |
| 475 |
msgid "" |
| 476 |
"Well, that just about concludes the very short introduction to regular " |
| 477 |
"expressions. Hopefully I'll have shown you enough to at least get you " |
| 478 |
"started and to enable you to continue learning by yourself- a good starting " |
| 479 |
"point would be the `Python documentation for regexps " |
| 480 |
"<http://docs.python.org/library/re.html>`_." |
| 481 |
msgstr "" |
| 482 |
|
| 483 |
# fe9db8c3bafa4faaaa41b9229c176c86 |
| 484 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:119 |
| 485 |
msgid "" |
| 486 |
"One last word of warning, though: Regexps are powerful, but also really easy" |
| 487 |
" to get wrong. calibre provides really great testing possibilities to see if" |
| 488 |
" your expressions behave as you expect them to. Use them. Try not to shoot " |
| 489 |
"yourself in the foot. (God, I love that expression...) But should you, " |
| 490 |
"despite the warning, injure your foot (or any other body parts), try to " |
| 491 |
"learn from it." |
| 492 |
msgstr "" |
| 493 |
|
| 494 |
# c6b4e37520e8416ebf54cef4f4578fc1 |
| 495 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:122 |
| 496 |
msgid "Credits" |
| 497 |
msgstr "" |
| 498 |
|
| 499 |
# 58ea0c062aab42a2a70a717e48268f99 |
| 500 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:124 |
| 501 |
msgid "Thanks for helping with tips, corrections and such:" |
| 502 |
msgstr "" |
| 503 |
|
| 504 |
# 89e06515c5ea45b5ab75d253630867d8 |
| 505 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:126 |
| 506 |
msgid "ldolse" |
| 507 |
msgstr "" |
| 508 |
|
| 509 |
# 42b4d18481da4acc9196f8b7973c6b96 |
| 510 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:127 |
| 511 |
msgid "kovidgoyal" |
| 512 |
msgstr "" |
| 513 |
|
| 514 |
# fa5c56e414fd4c7188d999df2d15c072 |
| 515 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:128 |
| 516 |
msgid "chaley" |
| 517 |
msgstr "" |
| 518 |
|
| 519 |
# b7e4df7f30c54339a321546c45ced10c |
| 520 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:129 |
| 521 |
msgid "dwanthny" |
| 522 |
msgstr "" |
| 523 |
|
| 524 |
# d26b2ec3618b4e52a79c7662255bb53d |
| 525 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:130 |
| 526 |
msgid "kacir" |
| 527 |
msgstr "" |
| 528 |
|
| 529 |
# a2a0cd1deab34151acf1805a1b8911c5 |
| 530 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:131 |
| 531 |
msgid "Starson17" |
| 532 |
msgstr "" |
| 533 |
|
| 534 |
# c8bfa3576bfe48699afb40ca55d64e79 |
| 535 |
#: ../../home/kovid/work/calibre/manual/regexp.rst:133 |
| 536 |
msgid "" |
| 537 |
"For more about regexps see `The Python User Manual " |
| 538 |
"<http://docs.python.org/library/re.html>`_." |
| 539 |
msgstr "" |