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: 6msgid "" 7msgstr "" 8"Project-Id-Version: calibre\n" 9"Report-Msgid-Bugs-To: \n" 10"POT-Creation-Date: 2021-10-07 03:23+0000\n" 11"PO-Revision-Date: 2021-10-03 01:41+0000\n" 12"Last-Translator: Kovid Goyal <kovid@kovidgoyal.net>\n" 13"Language-Team: Breton (http://www.transifex.com/calibre/calibre/language/br/)\n" 14"MIME-Version: 1.0\n" 15"Content-Type: text/plain; charset=UTF-8\n" 16"Content-Transfer-Encoding: 8bit\n" 17"Language: br\n" 18"Plural-Forms: nplurals=5; plural=((n%10 == 1) && (n%100 != 11) && (n%100 !=71) && (n%100 !=91) ? 0 :(n%10 == 2) && (n%100 != 12) && (n%100 !=72) && (n%100 !=92) ? 1 :(n%10 ==3 || n%10==4 || n%10==9) && (n%100 < 10 || n% 100 > 19) && (n%100 < 70 || n%100 > 79) && (n%100 < 90 || n%100 > 99) ? 2 :(n != 0 && n % 1000000 == 0) ? 3 : 4);\n" 19 20#: ../../__w/calibre/calibre/manual/function_mode.rst:2 21msgid "Function mode for Search & replace in the Editor" 22msgstr "" 23 24#: ../../__w/calibre/calibre/manual/function_mode.rst:4 25msgid "" 26"The :guilabel:`Search & replace` tool in the editor support a *function " 27"mode*. In this mode, you can combine regular expressions (see :doc:`regexp`)" 28" with arbitrarily powerful Python functions to do all sorts of advanced text" 29" processing." 30msgstr "" 31 32#: ../../__w/calibre/calibre/manual/function_mode.rst:9 33msgid "" 34"In the standard *regexp* mode for search and replace, you specify both a " 35"regular expression to search for as well as a template that is used to " 36"replace all found matches. In function mode, instead of using a fixed " 37"template, you specify an arbitrary function, in the `Python programming " 38"language <https://docs.python.org>`_. This allows you to do lots of things " 39"that are not possible with simple templates." 40msgstr "" 41 42#: ../../__w/calibre/calibre/manual/function_mode.rst:16 43msgid "" 44"Techniques for using function mode and the syntax will be described by means" 45" of examples, showing you how to create functions to perform progressively " 46"more complex tasks." 47msgstr "" 48 49#: ../../__w/calibre/calibre/manual/function_mode.rstNone 50msgid "The Function mode" 51msgstr "" 52 53#: ../../__w/calibre/calibre/manual/function_mode.rst:26 54msgid "Automatically fixing the case of headings in the document" 55msgstr "" 56 57#: ../../__w/calibre/calibre/manual/function_mode.rst:28 58msgid "" 59"Here, we will leverage one of the builtin functions in the editor to " 60"automatically change the case of all text inside heading tags to title " 61"case::" 62msgstr "" 63 64#: ../../__w/calibre/calibre/manual/function_mode.rst:33 65msgid "" 66"For the function, simply choose the :guilabel:`Title-case text (ignore " 67"tags)` builtin function. The will change titles that look like: ``<h1>some " 68"TITLE</h1>`` to ``<h1>Some Title</h1>``. It will work even if there are " 69"other HTML tags inside the heading tags." 70msgstr "" 71 72#: ../../__w/calibre/calibre/manual/function_mode.rst:40 73msgid "Your first custom function - smartening hyphens" 74msgstr "" 75 76#: ../../__w/calibre/calibre/manual/function_mode.rst:42 77msgid "" 78"The real power of function mode comes from being able to create your own " 79"functions to process text in arbitrary ways. The Smarten Punctuation tool in" 80" the editor leaves individual hyphens alone, so you can use the this " 81"function to replace them with em-dashes." 82msgstr "" 83 84#: ../../__w/calibre/calibre/manual/function_mode.rst:47 85msgid "" 86"To create a new function, simply click the :guilabel:`Create/edit` button to" 87" create a new function and copy the Python code from below." 88msgstr "" 89 90#: ../../__w/calibre/calibre/manual/function_mode.rst:55 91msgid "" 92"Every :guilabel:`Search & replace` custom function must have a unique name " 93"and consist of a Python function named replace, that accepts all the " 94"arguments shown above. For the moment, we won't worry about all the " 95"different arguments to ``replace()`` function. Just focus on the ``match`` " 96"argument. It represents a match when running a search and replace. Its full " 97"documentation in available `here <https://docs.python.org/library/re.html" 98"#match-objects>`_. ``match.group()`` simply returns all the matched text and" 99" all we do is replace hyphens in that text with em-dashes, first replacing " 100"double hyphens and then single hyphens." 101msgstr "" 102 103#: ../../__w/calibre/calibre/manual/function_mode.rst:65 104msgid "Use this function with the find regular expression::" 105msgstr "" 106 107#: ../../__w/calibre/calibre/manual/function_mode.rst:69 108msgid "" 109"And it will replace all hyphens with em-dashes, but only in actual text and " 110"not inside HTML tag definitions." 111msgstr "" 112 113#: ../../__w/calibre/calibre/manual/function_mode.rst:74 114msgid "" 115"The power of function mode - using a spelling dictionary to fix mis-" 116"hyphenated words" 117msgstr "" 118 119#: ../../__w/calibre/calibre/manual/function_mode.rst:76 120msgid "" 121"Often, e-books created from scans of printed books contain mis-hyphenated " 122"words -- words that were split at the end of the line on the printed page. " 123"We will write a simple function to automatically find and fix such words." 124msgstr "" 125 126#: ../../__w/calibre/calibre/manual/function_mode.rst:101 127msgid "Use this function with the same find expression as before, namely::" 128msgstr "" 129 130#: ../../__w/calibre/calibre/manual/function_mode.rst:105 131msgid "" 132"And it will magically fix all mis-hyphenated words in the text of the book. " 133"The main trick is to use one of the useful extra arguments to the replace " 134"function, ``dictionaries``. This refers to the dictionaries the editor " 135"itself uses to spell check text in the book. What this function does is look" 136" for words separated by a hyphen, remove the hyphen and check if the " 137"dictionary recognizes the composite word, if it does, the original words are" 138" replaced by the hyphen free composite word." 139msgstr "" 140 141#: ../../__w/calibre/calibre/manual/function_mode.rst:113 142msgid "" 143"Note that one limitation of this technique is it will only work for mono-" 144"lingual books, because, by default, ``dictionaries.recognized()`` uses the " 145"main language of the book." 146msgstr "" 147 148#: ../../__w/calibre/calibre/manual/function_mode.rst:119 149msgid "Auto numbering sections" 150msgstr "" 151 152#: ../../__w/calibre/calibre/manual/function_mode.rst:121 153msgid "" 154"Now we will see something a little different. Suppose your HTML file has " 155"many sections, each with a heading in an :code:`<h2>` tag that looks like " 156":code:`<h2>Some text</h2>`. You can create a custom function that will " 157"automatically number these headings with consecutive section numbers, so " 158"that they look like :code:`<h2>1. Some text</h2>`." 159msgstr "" 160 161#: ../../__w/calibre/calibre/manual/function_mode.rst:137 162msgid "Use it with the find expression::" 163msgstr "" 164 165#: ../../__w/calibre/calibre/manual/function_mode.rst:141 166msgid "" 167"Place the cursor at the top of the file and click :guilabel:`Replace all`." 168msgstr "" 169 170#: ../../__w/calibre/calibre/manual/function_mode.rst:143 171msgid "" 172"This function uses another of the useful extra arguments to ``replace()``: " 173"the ``number`` argument. When doing a :guilabel:`Replace All` number is " 174"automatically incremented for every successive match." 175msgstr "" 176 177#: ../../__w/calibre/calibre/manual/function_mode.rst:147 178msgid "" 179"Another new feature is the use of ``replace.file_order`` -- setting that to " 180"``'spine'`` means that if this search is run on multiple HTML files, the " 181"files are processed in the order in which they appear in the book. See " 182":ref:`file_order_replace_all` for details." 183msgstr "" 184 185#: ../../__w/calibre/calibre/manual/function_mode.rst:154 186msgid "Auto create a Table of Contents" 187msgstr "" 188 189#: ../../__w/calibre/calibre/manual/function_mode.rst:156 190msgid "" 191"Finally, lets try something a little more ambitious. Suppose your book has " 192"headings in ``h1`` and ``h2`` tags that look like ``<h1 id=\"someid\">Some " 193"Text</h1>``. We will auto-generate an HTML Table of Contents based on these " 194"headings. Create the custom function below:" 195msgstr "" 196 197#: ../../__w/calibre/calibre/manual/function_mode.rst:199 198msgid "And use it with the find expression::" 199msgstr "" 200 201#: ../../__w/calibre/calibre/manual/function_mode.rst:203 202msgid "" 203"Run the search on :guilabel:`All text files` and at the end of the search, a" 204" window will popup with \"Debug output from your function\" which will have " 205"the HTML Table of Contents, ready to be pasted into :file:`toc.html`." 206msgstr "" 207 208#: ../../__w/calibre/calibre/manual/function_mode.rst:207 209msgid "" 210"The function above is heavily commented, so it should be easy to follow. The" 211" key new feature is the use of another useful extra argument to the " 212"``replace()`` function, the ``data`` object. The ``data`` object is a Python" 213" *dict* that persists between all successive invocations of ``replace()`` " 214"during a single :guilabel:`Replace All` operation." 215msgstr "" 216 217#: ../../__w/calibre/calibre/manual/function_mode.rst:213 218msgid "" 219"Another new feature is the use of ``call_after_last_match`` -- setting that " 220"to ``True`` on the ``replace()`` function means that the editor will call " 221"``replace()`` one extra time after all matches have been found. For this " 222"extra call, the match object will be ``None``." 223msgstr "" 224 225#: ../../__w/calibre/calibre/manual/function_mode.rst:218 226msgid "" 227"This was just a demonstration to show you the power of function mode, if you" 228" really needed to generate a Table of Contents from headings in your book, " 229"you would be better off using the dedicated Table of Contents tool in " 230":guilabel:`Tools->Table of Contents`." 231msgstr "" 232 233#: ../../__w/calibre/calibre/manual/function_mode.rst:224 234msgid "The API for the function mode" 235msgstr "" 236 237#: ../../__w/calibre/calibre/manual/function_mode.rst:226 238msgid "" 239"All function mode functions must be Python functions named replace, with the" 240" following signature::" 241msgstr "" 242 243#: ../../__w/calibre/calibre/manual/function_mode.rst:232 244msgid "" 245"When a find/replace is run, for every match that is found, the ``replace()``" 246" function will be called, it must return the replacement string for that " 247"match. If no replacements are to be done, it should return ``match.group()``" 248" which is the original string. The various arguments to the ``replace()`` " 249"function are documented below." 250msgstr "" 251 252#: ../../__w/calibre/calibre/manual/function_mode.rst:239 253msgid "The ``match`` argument" 254msgstr "" 255 256#: ../../__w/calibre/calibre/manual/function_mode.rst:241 257msgid "" 258"The ``match`` argument represents the currently found match. It is a `Python" 259" Match object <https://docs.python.org/library/re.html#match-objects>`_. Its" 260" most useful method is ``group()`` which can be used to get the matched text" 261" corresponding to individual capture groups in the search regular " 262"expression." 263msgstr "" 264 265#: ../../__w/calibre/calibre/manual/function_mode.rst:248 266msgid "The ``number`` argument" 267msgstr "" 268 269#: ../../__w/calibre/calibre/manual/function_mode.rst:250 270msgid "" 271"The ``number`` argument is the number of the current match. When you run " 272":guilabel:`Replace All`, every successive match will cause ``replace()`` to " 273"be called with an increasing number. The first match has number 1." 274msgstr "" 275 276#: ../../__w/calibre/calibre/manual/function_mode.rst:255 277msgid "The ``file_name`` argument" 278msgstr "" 279 280#: ../../__w/calibre/calibre/manual/function_mode.rst:257 281msgid "" 282"This is the filename of the file in which the current match was found. When " 283"searching inside marked text, the ``file_name`` is empty. The ``file_name`` " 284"is in canonical form, a path relative to the root of the book, using ``/`` " 285"as the path separator." 286msgstr "" 287 288#: ../../__w/calibre/calibre/manual/function_mode.rst:263 289msgid "The ``metadata`` argument" 290msgstr "" 291 292#: ../../__w/calibre/calibre/manual/function_mode.rst:265 293msgid "" 294"This represents the metadata of the current book, such as title, authors, " 295"language, etc. It is an object of class " 296":class:`calibre.ebooks.metadata.book.base.Metadata`. Useful attributes " 297"include, ``title``, ``authors`` (a list of authors) and ``language`` (the " 298"language code)." 299msgstr "" 300 301#: ../../__w/calibre/calibre/manual/function_mode.rst:271 302msgid "The ``dictionaries`` argument" 303msgstr "" 304 305#: ../../__w/calibre/calibre/manual/function_mode.rst:273 306msgid "" 307"This represents the collection of dictionaries used for spell checking the " 308"current book. Its most useful method is ``dictionaries.recognized(word)`` " 309"which will return ``True`` if the passed in word is recognized by the " 310"dictionary for the current book's language." 311msgstr "" 312 313#: ../../__w/calibre/calibre/manual/function_mode.rst:279 314msgid "The ``data`` argument" 315msgstr "" 316 317#: ../../__w/calibre/calibre/manual/function_mode.rst:281 318msgid "" 319"This a simple Python ``dict``. When you run :guilabel:`Replace all`, every " 320"successive match will cause ``replace()`` to be called with the same " 321"``dict`` as data. You can thus use it to store arbitrary data between " 322"invocations of ``replace()`` during a :guilabel:`Replace all` operation." 323msgstr "" 324 325#: ../../__w/calibre/calibre/manual/function_mode.rst:288 326msgid "The ``functions`` argument" 327msgstr "" 328 329#: ../../__w/calibre/calibre/manual/function_mode.rst:290 330msgid "" 331"The ``functions`` argument gives you access to all other user defined " 332"functions. This is useful for code re-use. You can define utility functions " 333"in one place and re-use them in all your other functions. For example, " 334"suppose you create a function name ``My Function`` like this:" 335msgstr "" 336 337#: ../../__w/calibre/calibre/manual/function_mode.rst:303 338msgid "" 339"Then, in another function, you can access the ``utility()`` function like " 340"this:" 341msgstr "" 342 343#: ../../__w/calibre/calibre/manual/function_mode.rst:311 344msgid "" 345"You can also use the functions object to store persistent data, that can be " 346"re-used by other functions. For example, you could have one function that " 347"when run with :guilabel:`Replace All` collects some data and another " 348"function that uses it when it is run afterwards. Consider the following two " 349"functions:" 350msgstr "" 351 352#: ../../__w/calibre/calibre/manual/function_mode.rst:331 353msgid "Debugging your functions" 354msgstr "" 355 356#: ../../__w/calibre/calibre/manual/function_mode.rst:333 357msgid "" 358"You can debug the functions you create by using the standard ``print()`` " 359"function from Python. The output of print will be displayed in a popup " 360"window after the Find/replace has completed. You saw an example of using " 361"``print()`` to output an entire table of contents above." 362msgstr "" 363 364#: ../../__w/calibre/calibre/manual/function_mode.rst:341 365msgid "Choose file order when running on multiple HTML files" 366msgstr "" 367 368#: ../../__w/calibre/calibre/manual/function_mode.rst:343 369msgid "" 370"When you run a :guilabel:`Replace all` on multiple HTML files, the order in " 371"which the files are processes depends on what files you have open for " 372"editing. You can force the search to process files in the order in which the" 373" appear by setting the ``file_order`` attribute on your function, like this:" 374msgstr "" 375 376#: ../../__w/calibre/calibre/manual/function_mode.rst:355 377msgid "" 378"``file_order`` accepts two values, ``spine`` and ``spine-reverse`` which " 379"cause the search to process multiple files in the order they appear in the " 380"book, either forwards or backwards, respectively." 381msgstr "" 382 383#: ../../__w/calibre/calibre/manual/function_mode.rst:360 384msgid "" 385"Having your function called an extra time after the last match is found" 386msgstr "" 387 388#: ../../__w/calibre/calibre/manual/function_mode.rst:362 389msgid "" 390"Sometimes, as in the auto generate table of contents example above, it is " 391"useful to have your function called an extra time after the last match is " 392"found. You can do this by setting the ``call_after_last_match`` attribute on" 393" your function, like this:" 394msgstr "" 395 396#: ../../__w/calibre/calibre/manual/function_mode.rst:376 397msgid "Appending the output from the function to marked text" 398msgstr "" 399 400#: ../../__w/calibre/calibre/manual/function_mode.rst:378 401msgid "" 402"When running search and replace on marked text, it is sometimes useful to " 403"append so text to the end of the marked text. You can do that by setting the" 404" ``append_final_output_to_marked`` attribute on your function (note that you" 405" also need to set ``call_after_last_match``), like this:" 406msgstr "" 407 408#: ../../__w/calibre/calibre/manual/function_mode.rst:393 409msgid "Suppressing the result dialog when performing searches on marked text" 410msgstr "" 411 412#: ../../__w/calibre/calibre/manual/function_mode.rst:395 413msgid "" 414"You can also suppress the result dialog (which can slow down the repeated " 415"application of a search/replace on many blocks of text) by setting the " 416"``suppress_result_dialog`` attribute on your function, like this:" 417msgstr "" 418 419#: ../../__w/calibre/calibre/manual/function_mode.rst:408 420msgid "More examples" 421msgstr "" 422 423#: ../../__w/calibre/calibre/manual/function_mode.rst:410 424msgid "" 425"More useful examples, contributed by calibre users, can be found in the " 426"`calibre E-book editor forum " 427"<https://www.mobileread.com/forums/showthread.php?t=237181>`_." 428msgstr "" 429