| 1 |
======================= |
| 2 |
Odt Writer for Docutils |
| 3 |
======================= |
| 4 |
|
| 5 |
:Author: Dave Kuhlman |
| 6 |
:Contact: [email protected] |
| 7 |
:Revision: $Revision$ |
| 8 |
:Date: $Date$ |
| 9 |
:Copyright: This document has been placed in the public domain. |
| 10 |
|
| 11 |
:abstract: This document describes the Docutils odtwriter |
| 12 |
(rst2odt.py). |
| 13 |
|
| 14 |
.. sectnum:: |
| 15 |
|
| 16 |
.. contents:: |
| 17 |
|
| 18 |
|
| 19 |
Introduction |
| 20 |
============ |
| 21 |
|
| 22 |
What it does -- ``rst2odt.py`` translates reST |
| 23 |
(reStructuredText) into a Open Document Format ``.odt`` file. You |
| 24 |
can learn more about the ODF format here: |
| 25 |
|
| 26 |
- `OASIS Open Document Format for Office Applications |
| 27 |
(OpenDocument) TC`_ |
| 28 |
|
| 29 |
- `Open Document at Wikipedia`_ |
| 30 |
|
| 31 |
You should be able to open documents (.odt files) generated with |
| 32 |
``rst2odt.py`` in ``OpenOffice/oowriter``. |
| 33 |
|
| 34 |
You can learn more about Docutils and reST here: `Docutils`_ |
| 35 |
|
| 36 |
|
| 37 |
Requirements |
| 38 |
============ |
| 39 |
|
| 40 |
In addition to the Docutils standard requirements, ``odtwriter`` |
| 41 |
requires: |
| 42 |
|
| 43 |
- Optional -- `Pygments`_ is required if you want syntax |
| 44 |
highlighting of code in literal blocks. See section `Syntax |
| 45 |
highlighting`_. |
| 46 |
|
| 47 |
- Optional -- `Python Imaging Library`_ (PIL) is required if on an |
| 48 |
image or figure directive, you specify ``scale`` but not ``width`` |
| 49 |
and ``height``. See section `Images and figures`_. |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
How to Use It |
| 54 |
============= |
| 55 |
|
| 56 |
Run it from the command line as follows:: |
| 57 |
|
| 58 |
$ rst2odt.py myinput.txt myoutput.odt |
| 59 |
|
| 60 |
To see usage information and to learn about command line options |
| 61 |
that you can use, run the following:: |
| 62 |
|
| 63 |
$ rst2odt.py --help |
| 64 |
|
| 65 |
Examples:: |
| 66 |
|
| 67 |
$ rst2odt.py -s -g python_comments.txt python_comments.odt |
| 68 |
|
| 69 |
$ rst2odt.py --source-url=odtwriter.txt --generator \ |
| 70 |
--stylesheet=/myconfigs/styles.odt odtwriter.txt odtwriter.odt |
| 71 |
|
| 72 |
|
| 73 |
Configuration file |
| 74 |
------------------ |
| 75 |
|
| 76 |
The options described below can also be set in a configuration file. |
| 77 |
Use section ``[odf_odt writer]`` to set options specific to the |
| 78 |
``odtwriter``. For example:: |
| 79 |
|
| 80 |
[odf_odt writer] |
| 81 |
stylesheet: styles1.odt |
| 82 |
|
| 83 |
See the "Docutils Configuration" document for more information on |
| 84 |
Docutils configuration files, including locations which are |
| 85 |
searched. |
| 86 |
|
| 87 |
|
| 88 |
Command line options |
| 89 |
-------------------- |
| 90 |
|
| 91 |
The following command line options are specific to ``odtwriter``: |
| 92 |
|
| 93 |
--stylesheet=<URL> Specify a stylesheet URL, used verbatim. |
| 94 |
Default: writers/odf_odt/styles.odt in the |
| 95 |
installation directory. |
| 96 |
--odf-config-file=<file> |
| 97 |
Specify a configuration/mapping file relative to the |
| 98 |
current working directory for additional ODF options. |
| 99 |
In particular, this file may contain a section named |
| 100 |
"Formats" that maps default style names to names to be |
| 101 |
used in the resulting output file allowing for |
| 102 |
adhering to external standards. For more info and the |
| 103 |
format of the configuration/mapping file, see the |
| 104 |
odtwriter doc. |
| 105 |
--cloak-email-addresses |
| 106 |
Obfuscate email addresses to confuse harvesters while |
| 107 |
still keeping email links usable with standards- |
| 108 |
compliant browsers. |
| 109 |
--no-cloak-email-addresses |
| 110 |
Do not obfuscate email addresses. |
| 111 |
--table-border-thickness=TABLE_BORDER_THICKNESS |
| 112 |
Specify the thickness of table borders in thousands of |
| 113 |
a cm. Default is 35. |
| 114 |
--add-syntax-highlighting |
| 115 |
Add syntax highlighting in literal code blocks. |
| 116 |
--no-syntax-highlighting |
| 117 |
Do not add syntax highlighting in literal code blocks. |
| 118 |
(default) |
| 119 |
--create-sections Create sections for headers. (default) |
| 120 |
--no-sections Do not create sections for headers. |
| 121 |
--create-links Create links. |
| 122 |
--no-links Do not create links. (default) |
| 123 |
--endnotes-end-doc Generate endnotes at end of document, not footnotes at |
| 124 |
bottom of page. |
| 125 |
--no-endnotes-end-doc Generate footnotes at bottom of page, not endnotes at |
| 126 |
end of document. (default) |
| 127 |
--generate-list-toc Generate a bullet list table of contents, not an |
| 128 |
ODF/``oowriter`` table of contents. |
| 129 |
--generate-oowriter-toc |
| 130 |
Generate an ODF/``oowriter`` table of contents, |
| 131 |
not a bullet list. (default) **Note:** |
| 132 |
``odtwriter`` is not able to determine page |
| 133 |
numbers, so you will need to open the |
| 134 |
generated document in ``oowriter``, then |
| 135 |
right-click on the table of contents and |
| 136 |
select "Update" to insert page numbers. |
| 137 |
--custom-odt-header=CUSTOM_HEADER |
| 138 |
Specify the contents of an custom header line. See |
| 139 |
odf_odt writer documentation for details about special |
| 140 |
field character sequences. See section |
| 141 |
`Custom header/footers: inserting page numbers, date, time, etc`_ |
| 142 |
for details |
| 143 |
--custom-odt-footer=CUSTOM_FOOTER |
| 144 |
Specify the contents of an custom footer line. See |
| 145 |
odf_odt writer documentation for details about special |
| 146 |
field character sequences. See section |
| 147 |
`Custom header/footers: inserting page numbers, date, time, etc`_ |
| 148 |
for details |
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
Styles and Classes |
| 153 |
================== |
| 154 |
|
| 155 |
``odtwriter`` uses a number of styles that are defined in |
| 156 |
``styles.xml`` in the default ``styles.odt``. This section |
| 157 |
describes those styles. |
| 158 |
|
| 159 |
Note that with the ``--stylesheet`` command line option, you can |
| 160 |
use either ``styles.odt`` or ``styles.xml``, as described below. |
| 161 |
Use of ``styles.odt`` is recommended over ``styles.xml``. |
| 162 |
|
| 163 |
You can modify the look of documents generated by ``odtwriter`` in |
| 164 |
several ways: |
| 165 |
|
| 166 |
- Open (a copy of) ``styles.odt`` in ``OpenOffice/oowriter`` and |
| 167 |
modify the style you wish to change. Now, save this document, |
| 168 |
then generate your documents using this modified copy of |
| 169 |
``styles.odt``. |
| 170 |
|
| 171 |
In my version of ``oowriter``, to modify styles, either (1) |
| 172 |
press F11 or (2) use menu item "Format/Styles and Formatting", |
| 173 |
then right-click on the relevant style and select "Modify". |
| 174 |
Modify the style, then save your document. |
| 175 |
|
| 176 |
- Open a document generated by ``odtwriter`` in `oowriter``. Now, |
| 177 |
edit the style you are interested in modifying. Now, you |
| 178 |
can extract the styles.xml file from your document and either |
| 179 |
(1) use this as your default styles file or (2) copy and paste |
| 180 |
the relevant style definition into your styles.xml. |
| 181 |
|
| 182 |
- Extract ``styles.xml`` from ``styles.odt`` using your favorite |
| 183 |
``zip/unzip`` tool. Then modify ``styles.xml`` with a text |
| 184 |
editor. Now re-zip it back into your own ``styles.odt``, or use |
| 185 |
it directly by specifying it with the ``--stylesheet`` command |
| 186 |
line option. **Hint:** If you intend to extract ``styles.xml`` |
| 187 |
from an ``.odt`` file (and then "re-zip" it), you should turn off |
| 188 |
XML optimization/compression in ``oowriter``. In order to this |
| 189 |
in ``oowriter``, use Tools --> Options... --> Load-Save --> |
| 190 |
General and turn off "Size optimization for XML format". |
| 191 |
|
| 192 |
- Open an empty (or new) document in ``oowriter``. Define all of |
| 193 |
the styles described in this section. Then, use that document (a |
| 194 |
.odt file) as your stylesheet. ``odtwriter`` will extract the |
| 195 |
``styles.xml`` file from that document and insert it into the |
| 196 |
output document. |
| 197 |
|
| 198 |
- Some combination of the above. |
| 199 |
|
| 200 |
|
| 201 |
Styles used by odtwriter |
| 202 |
------------------------ |
| 203 |
|
| 204 |
This section describes the styles used by ``odtwriter``. |
| 205 |
|
| 206 |
Note that we do not describe the "look" of these styles. That can |
| 207 |
be easily changed by using ``oowriter`` to edit the document |
| 208 |
``styles.odt`` (or a copy of it), and modifying any of the styles |
| 209 |
described here. |
| 210 |
|
| 211 |
To change the definition and appearance of these styles, open |
| 212 |
``styles.odt`` in ``oowriter`` and open the Styles and Formatting |
| 213 |
window by using the following menu item:: |
| 214 |
|
| 215 |
Format --> Styles and Formatting |
| 216 |
|
| 217 |
Then, click on the Paragraph Styles button or the Character Styles |
| 218 |
button at the top of the Styles and Formatting window. You may |
| 219 |
also need to select "All Styles" from the drop-down selection list |
| 220 |
at the bottom of the Styles and Formatting window in order to see |
| 221 |
the styles used by ``odtwriter``. |
| 222 |
|
| 223 |
Notice that you can make a copy of file ``styles.odt``, modify it |
| 224 |
using ``oowriter``, and then use your copy with the |
| 225 |
``--stylesheet=<file>`` command line option. Example:: |
| 226 |
|
| 227 |
$ rst2odt.py --stylesheet=mystyles.odt test2.txt test2.odt |
| 228 |
|
| 229 |
|
| 230 |
Paragraph styles |
| 231 |
~~~~~~~~~~~~~~~~ |
| 232 |
|
| 233 |
rststyle-attribution |
| 234 |
The style for attributions, for example, the attribution in a |
| 235 |
``.. epigraph::`` directive. Derived from |
| 236 |
``rststyle-blockquote``. |
| 237 |
|
| 238 |
rststyle-blockindent |
| 239 |
An indented block. |
| 240 |
|
| 241 |
rststyle-blockquote |
| 242 |
A block quote. |
| 243 |
|
| 244 |
rststyle-blockquote-bulletitem |
| 245 |
The style for bullet list items inside block quote. |
| 246 |
|
| 247 |
rststyle-blockquote-enumitem |
| 248 |
The style for enumerated list items inside block quote. |
| 249 |
|
| 250 |
rststyle-bodyindent |
| 251 |
An indented block. |
| 252 |
|
| 253 |
rststyle-bulletitem |
| 254 |
An item in an bullet list. |
| 255 |
|
| 256 |
rststyle-caption |
| 257 |
The caption in a figure or image. Also see |
| 258 |
``rststyle-legend``. |
| 259 |
|
| 260 |
rststyle-codeblock |
| 261 |
Literal code blocks -- A block of example code. Created with |
| 262 |
double colon ("::") followed by an indented block or with the |
| 263 |
``.. parsed-literal::`` directive. Derived from the |
| 264 |
``Preformatted Text`` style in ``oowriter``. |
| 265 |
|
| 266 |
rststyle-enumitem |
| 267 |
An item in an enumerated list. |
| 268 |
|
| 269 |
rststyle-epigraph |
| 270 |
The style for epigraphs, for example, the body of an |
| 271 |
``.. epigraph::`` directive. Derived from |
| 272 |
``rststyle-blockquote``. |
| 273 |
|
| 274 |
rststyle-epigraph-bulletitem |
| 275 |
The style for bullet list items inside epigraphs. |
| 276 |
|
| 277 |
rststyle-epigraph-enumitem |
| 278 |
The style for enumerated list items inside epigraphs. |
| 279 |
|
| 280 |
rststyle-footer |
| 281 |
The style for footers. The footer content originates from the |
| 282 |
``..footer::`` directive and in response to the command line |
| 283 |
flags for generator (``--generator``), date/time generated |
| 284 |
(``--date`` and ``--time``), and view source link |
| 285 |
(``--source-link`` and ``--source-url=URL``). |
| 286 |
|
| 287 |
rststyle-header |
| 288 |
The style for headers. The header content originates from the |
| 289 |
``..header::`` directive. |
| 290 |
|
| 291 |
rststyle-highlights |
| 292 |
The style for highlightss, for example, the body of an |
| 293 |
``.. highlights::`` directive. Derived from |
| 294 |
``rststyle-blockquote``. |
| 295 |
|
| 296 |
rststyle-highlights-bulletitem |
| 297 |
The style for bullet list items inside highlights. |
| 298 |
|
| 299 |
rststyle-highlights-enumitem |
| 300 |
The style for enumerated list items inside highlights. |
| 301 |
|
| 302 |
rststyle-horizontalline |
| 303 |
A horizontal line, e.g. used for transitions. |
| 304 |
|
| 305 |
rststyle-legend |
| 306 |
The legend in a figure. See the Docutils figure directive. Also |
| 307 |
see ``rststyle-caption``. |
| 308 |
|
| 309 |
rststyle-table-title |
| 310 |
The style for titles of tables. See section `The table |
| 311 |
directive`_. |
| 312 |
|
| 313 |
rststyle-textbody |
| 314 |
Normal text. The style for paragraphs. Derived from the ``Text |
| 315 |
body`` style in ``oowriter``. |
| 316 |
|
| 317 |
|
| 318 |
Character styles |
| 319 |
~~~~~~~~~~~~~~~~ |
| 320 |
|
| 321 |
rststyle-emphasis |
| 322 |
Emphasis. Normally rendered as italics. |
| 323 |
|
| 324 |
rststyle-inlineliteral |
| 325 |
An inline literal. |
| 326 |
|
| 327 |
rststyle-strong |
| 328 |
Strong emphasis. Normally rendered as boldface. |
| 329 |
|
| 330 |
rststyle-quotation |
| 331 |
In-line quoted material. |
| 332 |
|
| 333 |
rststyle-codeblock-classname |
| 334 |
Syntax highlighting in literal code blocks -- class names. |
| 335 |
|
| 336 |
rststyle-codeblock-comment |
| 337 |
Syntax highlighting in literal code blocks -- comments. |
| 338 |
|
| 339 |
rststyle-codeblock-functionname |
| 340 |
Syntax highlighting in literal code blocks -- function names. |
| 341 |
|
| 342 |
rststyle-codeblock-keyword |
| 343 |
Syntax highlighting in literal code blocks -- Python language |
| 344 |
keywords. |
| 345 |
|
| 346 |
rststyle-codeblock-name |
| 347 |
Syntax highlighting in literal code blocks -- other names, for |
| 348 |
example, variables. |
| 349 |
|
| 350 |
rststyle-codeblock-number |
| 351 |
Syntax highlighting in literal code blocks -- literal numbers, |
| 352 |
including integers, floats, hex numbers, and octal numbers. |
| 353 |
|
| 354 |
rststyle-codeblock-operator |
| 355 |
Syntax highlighting in literal code blocks -- Python operators. |
| 356 |
|
| 357 |
rststyle-codeblock-string |
| 358 |
Syntax highlighting in literal code blocks -- literal strings. |
| 359 |
|
| 360 |
|
| 361 |
List styles |
| 362 |
~~~~~~~~~~~ |
| 363 |
|
| 364 |
rststyle-bulletlist |
| 365 |
Bullet lists (but not in the table of contents) |
| 366 |
|
| 367 |
rststyle-blockquote-bulletlist |
| 368 |
Bullet lists in block quotes. |
| 369 |
|
| 370 |
rststyle-blockquote-enumlist |
| 371 |
Enumerated lists in block quotes. |
| 372 |
|
| 373 |
rststyle-enumlist-arabic |
| 374 |
Enumerated lists, arabic (but not in the table of contents) |
| 375 |
|
| 376 |
rststyle-enumlist-loweralpha |
| 377 |
Enumerated lists, lower alpha (but not in the table of contents) |
| 378 |
|
| 379 |
rststyle-enumlist-lowerroman |
| 380 |
Enumerated lists, lower roman (but not in the table of contents) |
| 381 |
|
| 382 |
rststyle-enumlist-upperalpha |
| 383 |
Enumerated lists, upper alpha (but not in the table of contents) |
| 384 |
|
| 385 |
rststyle-enumlist-upperroman |
| 386 |
Enumerated lists, upper roman (but not in the table of contents) |
| 387 |
|
| 388 |
rststyle-epigraph-bulletlist |
| 389 |
Bullet lists in epigraphs. See the ``.. epigraph::`` |
| 390 |
directive. |
| 391 |
|
| 392 |
rststyle-epigraph-enumlist |
| 393 |
Enumerated lists in epigraphs. See the ``.. epigraph::`` |
| 394 |
directive. |
| 395 |
|
| 396 |
rststyle-highlights-bulletlist |
| 397 |
Bullet lists in highlights blocks. See the ``.. highlights::`` |
| 398 |
directive. |
| 399 |
|
| 400 |
rststyle-highlights-enumlist |
| 401 |
Enumerated lists in highlights blocks. See the ``.. highlights::`` |
| 402 |
directive. |
| 403 |
|
| 404 |
rststyle-tocbulletlist |
| 405 |
Lists in the table of contents when section numbering is off. |
| 406 |
|
| 407 |
rststyle-tocenumlist |
| 408 |
Lists in the table of contents when section numbering is on. |
| 409 |
|
| 410 |
|
| 411 |
Admonition styles |
| 412 |
~~~~~~~~~~~~~~~~~ |
| 413 |
|
| 414 |
rststyle-admon-attention-hdr |
| 415 |
The style for the attention admonition header/title. |
| 416 |
|
| 417 |
rststyle-admon-attention-body |
| 418 |
The style for the attention admonition body/paragraph. |
| 419 |
|
| 420 |
rststyle-admon-caution-hdr |
| 421 |
The style for the caution admonition header/title. |
| 422 |
|
| 423 |
rststyle-admon-caution-body |
| 424 |
The style for the caution admonition body/paragraph. |
| 425 |
|
| 426 |
rststyle-admon-danger-hdr |
| 427 |
The style for the admonition header/title. |
| 428 |
|
| 429 |
rststyle-admon-danger-body |
| 430 |
The style for the danger admonition body/paragraph. |
| 431 |
|
| 432 |
rststyle-admon-error-hdr |
| 433 |
The style for the error admonition header/title. |
| 434 |
|
| 435 |
rststyle-admon-error-body |
| 436 |
The style for the error admonition body/paragraph. |
| 437 |
|
| 438 |
rststyle-admon-hint-hdr |
| 439 |
The style for the hint admonition header/title. |
| 440 |
|
| 441 |
rststyle-admon-hint-body |
| 442 |
The style for the hint admonition body/paragraph. |
| 443 |
|
| 444 |
rststyle-admon-hint-hdr |
| 445 |
The style for the hint admonition header/title. |
| 446 |
|
| 447 |
rststyle-admon-hint-body |
| 448 |
The style for the hint admonition body/paragraph. |
| 449 |
|
| 450 |
rststyle-admon-important-hdr |
| 451 |
The style for the important admonition header/title. |
| 452 |
|
| 453 |
rststyle-admon-important-body |
| 454 |
The style for the important admonition body/paragraph. |
| 455 |
|
| 456 |
rststyle-admon-note-hdr |
| 457 |
The style for the note admonition header/title. |
| 458 |
|
| 459 |
rststyle-admon-note-hdr |
| 460 |
The style for the note admonition header/title. |
| 461 |
|
| 462 |
rststyle-admon-tip-body |
| 463 |
The style for the tip admonition body/paragraph. |
| 464 |
|
| 465 |
rststyle-admon-tip-hdr |
| 466 |
The style for the tip admonition header/title. |
| 467 |
|
| 468 |
rststyle-admon-warning-body |
| 469 |
The style for the warning admonition body/paragraph. |
| 470 |
|
| 471 |
rststyle-admon-warning-hdr |
| 472 |
The style for the warning admonition header/title. |
| 473 |
|
| 474 |
rststyle-admon-generic-body |
| 475 |
The style for the generic admonition body/paragraph. |
| 476 |
|
| 477 |
rststyle-admon-generic-hdr |
| 478 |
The style for the generic admonition header/title. |
| 479 |
|
| 480 |
|
| 481 |
Rubric style |
| 482 |
~~~~~~~~~~~~ |
| 483 |
|
| 484 |
rststyle-rubric |
| 485 |
The style for the text in a rubric directive. |
| 486 |
|
| 487 |
The rubric directive recognizes a "class" option. If entered, |
| 488 |
odtwriter uses the value of that option instead of the |
| 489 |
``rststyle-rubric`` style. Here is an example which which attaches |
| 490 |
the ``rststyle-heading1`` style to the generated rubric:: |
| 491 |
|
| 492 |
.. rubric:: This is my first rubric |
| 493 |
:class: rststyle-heading1 |
| 494 |
|
| 495 |
|
| 496 |
Table styles |
| 497 |
~~~~~~~~~~~~ |
| 498 |
|
| 499 |
A table style is generated by ``oowriter`` for each table that you |
| 500 |
create. Therefore, ``odtwriter`` attempts to do something similar. |
| 501 |
These styles are created in the ``content.xml`` document in the |
| 502 |
generated ``.odt`` file. These styles have names prefixed with |
| 503 |
"rststyle-table-". |
| 504 |
|
| 505 |
There are two ways in which you can control the styles of your |
| 506 |
tables: one simple, the other a bit more complex, but more |
| 507 |
powerful. |
| 508 |
|
| 509 |
First, you can change the thickness of the borders of all tables |
| 510 |
generated in a document using the "--table-border-thickness" |
| 511 |
command line option. |
| 512 |
|
| 513 |
Second, you can control additional table properties and you can |
| 514 |
apply different styles to different tables within the same document |
| 515 |
by customizing and using tables in your stylesheet: ``styles.odt`` |
| 516 |
or whatever you name your copy of it using the --stylesheet command |
| 517 |
line option. Then, follow these rules to apply a table style to |
| 518 |
the tables in your document: |
| 519 |
|
| 520 |
- The default table style -- Optionally, alter and customize the |
| 521 |
style applied by default to tables in your document by modifying |
| 522 |
table "rststyle-table-0" in your stylesheet (``styles.odt`` or a |
| 523 |
copy). Caution: Do not change the name of this table. |
| 524 |
|
| 525 |
- User-created table styles -- Add one or more new table styles to |
| 526 |
be applied selectively to tables in your document by doing the |
| 527 |
following: |
| 528 |
|
| 529 |
1. Using ``oowriter``, add a table to your stylesheet and give it |
| 530 |
a name that starts with the prefix "rststyle-table-", for |
| 531 |
example "rststyle-table-vegetabledata". Customize the table's |
| 532 |
border thickness, border color, and table background color. |
| 533 |
|
| 534 |
2. In your reStructuredText document, apply your new table style |
| 535 |
to a specific table by placing the ".. class::" directive |
| 536 |
immediately before the table, for example:: |
| 537 |
|
| 538 |
.. class:: rststyle-table-vegetabledata |
| 539 |
|
| 540 |
The default table style will be applied to all tables for which you |
| 541 |
do not specify a style with the ".. class::" directive. |
| 542 |
|
| 543 |
Customize the table properties in ``oowriter`` using the table |
| 544 |
properties dialog for the table (style) that you wish to customize. |
| 545 |
|
| 546 |
Note that "--table-border-thickness" command line option overrides |
| 547 |
the border thickness specified in the stylesheet. |
| 548 |
|
| 549 |
The specific properties that you can control with this second |
| 550 |
method are the following: |
| 551 |
|
| 552 |
- Border thickness and border color. |
| 553 |
|
| 554 |
- Background color -- When you change the background color of a |
| 555 |
table to be used as a style (in ``styles.odt`` or whatever you |
| 556 |
name it), make sure you change the background color for the |
| 557 |
*table* and *not* for a cell in the table. ``odtwriter`` picks |
| 558 |
the background color from the table, not from a cell within the |
| 559 |
table. |
| 560 |
|
| 561 |
|
| 562 |
Line block styles |
| 563 |
~~~~~~~~~~~~~~~~~~ |
| 564 |
|
| 565 |
The line block styles wrap the various nested levels of line |
| 566 |
blocks. There is one line block style for each indent level. |
| 567 |
|
| 568 |
rststyle-lineblock1 |
| 569 |
Line block style for line block with no indent. |
| 570 |
|
| 571 |
rststyle-lineblock2 |
| 572 |
Line block style for line block indented 1 level. |
| 573 |
|
| 574 |
rststyle-lineblock3 |
| 575 |
Line block style for line block indented 2 levels. |
| 576 |
|
| 577 |
rststyle-lineblock4 |
| 578 |
Line block style for line block indented 3 levels. |
| 579 |
|
| 580 |
rststyle-lineblock5 |
| 581 |
Line block style for line block indented 4 levels. |
| 582 |
|
| 583 |
rststyle-lineblock6 |
| 584 |
Line block style for line block indented 5 levels. |
| 585 |
|
| 586 |
Notes: |
| 587 |
|
| 588 |
- ``odtwriter`` does not check for a maximum level of indents |
| 589 |
within line blocks. Therefore, you can define additional line |
| 590 |
block styles for additional levels if you need them. Define |
| 591 |
these styles with the names ``rststyle-lineblock7``, |
| 592 |
``rststyle-lineblock8``, ... |
| 593 |
|
| 594 |
- Since the line block style is used to create indentation, a line |
| 595 |
block that is inside a block quote will use |
| 596 |
``rststyle-lineblock2`` as its first level of indentation. |
| 597 |
|
| 598 |
|
| 599 |
Footnote and citation styles |
| 600 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 601 |
|
| 602 |
rststyle-footnote |
| 603 |
The style for footnotes. This style affects the footnote |
| 604 |
content, *not* the footnote reference in the body of the document. |
| 605 |
|
| 606 |
rststyle-citation |
| 607 |
The style for citations. This style affects the citation |
| 608 |
content, *not* the citation reference in the body of the document. |
| 609 |
You might need to adjust the indentation in this style |
| 610 |
depending on the length of the label used in your citations. |
| 611 |
|
| 612 |
|
| 613 |
Heading and title styles |
| 614 |
~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 615 |
|
| 616 |
rststyle-heading{1|2|3|4|5} |
| 617 |
The styles for headings (section titles and sub-titles). Five |
| 618 |
levels of sub-headings are provided: rststyle-heading1 through |
| 619 |
rststyle-heading5. |
| 620 |
|
| 621 |
rststyle-title |
| 622 |
The style for the document title. |
| 623 |
|
| 624 |
rststyle-subtitle |
| 625 |
The style for the document sub-title. |
| 626 |
|
| 627 |
|
| 628 |
Image and figure styles |
| 629 |
~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 630 |
|
| 631 |
rststyle-image |
| 632 |
The style applied to an image, either an image by itself or an |
| 633 |
image in a figure. |
| 634 |
|
| 635 |
rststyle-figureframe |
| 636 |
The style applied to a figure (actually to the frame that |
| 637 |
surrounds a figure). |
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
Defining and using a custom stylesheet |
| 642 |
--------------------------------------- |
| 643 |
|
| 644 |
You can create your own custom stylesheet. Here is how: |
| 645 |
|
| 646 |
1. Make a copy of ``styles.odt``, which is in the distribution. |
| 647 |
|
| 648 |
2. Open your copy of ``styles.odt`` in ``oowriter``. Modify styles |
| 649 |
in that document. Then, save it. |
| 650 |
|
| 651 |
3. When you run ``rst2odt.py``, use the ``--stylesheet`` command |
| 652 |
line option to use your custom stylesheet. Run ``rst2odt.py |
| 653 |
--help`` to learn more about these options. |
| 654 |
|
| 655 |
|
| 656 |
Why custom stylesheets |
| 657 |
~~~~~~~~~~~~~~~~~~~~~~~ |
| 658 |
|
| 659 |
Here are a few reasons and ideas: |
| 660 |
|
| 661 |
- The page size is stored in the style sheet. The default page |
| 662 |
size is ``Letter``. You can change the page size (for example, |
| 663 |
to ``A4``) in your custom stylesheet by opening it in |
| 664 |
``oowriter``, then clicking on menu: ``Format/Page...``, then |
| 665 |
clicking on the ``Page`` tab. |
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
Defining and using custom style names |
| 670 |
------------------------------------- |
| 671 |
|
| 672 |
[Credits: Stefan Merten designed and implemented the custom style names |
| 673 |
capability. Thank you, Stefan.] |
| 674 |
|
| 675 |
You can also instruct ``odtwriter`` to use style names of your own |
| 676 |
choice. |
| 677 |
|
| 678 |
|
| 679 |
Why custom style names |
| 680 |
~~~~~~~~~~~~~~~~~~~~~~ |
| 681 |
|
| 682 |
Here are a few reasons and ideas: |
| 683 |
|
| 684 |
- Suppose that your organization has a standard set of styles in |
| 685 |
OOo ``oowriter`` and suppose that the use of these styles is |
| 686 |
required. You would like to generate ODF documents from |
| 687 |
reST text files, and you want the generated documents to contain |
| 688 |
these styles. |
| 689 |
|
| 690 |
- Suppose that your company or organization has a policy of using a |
| 691 |
certain MS Word template for some set of documents. You would |
| 692 |
like to generate ODF documents that use these custom style names, |
| 693 |
so that you can export these documents from ODF ``oowriter`` to MS |
| 694 |
Word documents that use these style names. |
| 695 |
|
| 696 |
- Suppose that your documents are written in a language other than |
| 697 |
English. You would like the style names visible in the "Styles |
| 698 |
and Formatting" window in OOo ``oowriter`` (menu item |
| 699 |
``Format/Styles and Formatting``) to be understandable in the |
| 700 |
language of your users. |
| 701 |
|
| 702 |
- ``odtwriter`` maps single asterisks/stars (for example, \*stuff\*) |
| 703 |
to emphasis and double stars to strong. You'd like to reverse |
| 704 |
these. Or, you would like to generate headings level 3 and 4 |
| 705 |
where headings level 1 and 2 would normally be produced. |
| 706 |
|
| 707 |
|
| 708 |
How to use custom style names |
| 709 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 710 |
|
| 711 |
In order to define custom style names and to generate documents that |
| 712 |
contain them, do the following: |
| 713 |
|
| 714 |
|
| 715 |
1. Create a configuration file containing a "Formats" section. The |
| 716 |
configuration file obeys the file format supported by the Python |
| 717 |
ConfigParser module: |
| 718 |
`ConfigParser -- Configuration file parser -- |
| 719 |
https://docs.python.org/3/library/configparser.html |
| 720 |
<https://docs.python.org/3/library/configparser.html>`_. |
| 721 |
|
| 722 |
2. In the "Formats" section of the configuration file, create one |
| 723 |
option (a name-value pair) for each custom style name that you |
| 724 |
wish to define. The option name is the standard ``odtwriter`` |
| 725 |
style name (without "rststyle-"), and the value is your custom |
| 726 |
style name. Here is an example:: |
| 727 |
|
| 728 |
[Formats] |
| 729 |
textbody: mytextbody |
| 730 |
bulletitem: mybulletitem |
| 731 |
heading1: myheading1 |
| 732 |
o |
| 733 |
o |
| 734 |
o |
| 735 |
|
| 736 |
3. Create a styles document that defines the styles generated by |
| 737 |
``odtwriter``. You can create and edit the styles in OOo |
| 738 |
``oowriter``. It may be helpful to begin by making a copy of the |
| 739 |
styles document that is part of the ``odtwriter`` distribution |
| 740 |
(``styles.odt``). |
| 741 |
|
| 742 |
4. When you run ``odtwriter``, specify the ``--odf-config-file`` |
| 743 |
option. You might also want to specify your styles document |
| 744 |
using the ``--stylesheet`` option in order to include your |
| 745 |
custom style definitions. For example:: |
| 746 |
|
| 747 |
rst2odt.py --odf-config-file=mymappingfile.ini \ |
| 748 |
--stylesheet=mystyles.odt mydoc.txt mydoc.odt |
| 749 |
|
| 750 |
|
| 751 |
Classes |
| 752 |
------- |
| 753 |
|
| 754 |
``odtwriter`` uses the following Docutils class to provide additional |
| 755 |
control of the generation of ODF content: |
| 756 |
|
| 757 |
- Class ``wrap`` -- Use this to cause the wrapping of text around |
| 758 |
an image. The default is *not* to wrap text around images. |
| 759 |
Here is an example:: |
| 760 |
|
| 761 |
.. class:: wrap |
| 762 |
.. image:: images/flower01.png |
| 763 |
:alt: A bright yellow flower |
| 764 |
:height: 55 |
| 765 |
:width: 60 |
| 766 |
|
| 767 |
|
| 768 |
Roles |
| 769 |
------- |
| 770 |
|
| 771 |
You can use a Docutils custom interpreted text role to attach a |
| 772 |
character style to an inline area of text. This capability also |
| 773 |
enables you to attach a new character style (with a new name) that |
| 774 |
you define yourself. Do this by defining your role in a stylesheet |
| 775 |
as a character style with "rststyle-" prefixed to your role name, |
| 776 |
then use the ``role`` directive and inline markup to apply your |
| 777 |
role. |
| 778 |
|
| 779 |
In order to use this capability, do the following: |
| 780 |
|
| 781 |
- Define the character style for your custom role in a stylesheet |
| 782 |
(a copy of ``styles.odt``) with the prefix "rststyle-". |
| 783 |
Remember: (1) If the name of your custom role is "pretty", then |
| 784 |
define a character style named "rststyle-pretty". (2) Define the |
| 785 |
style as a *character* style, and *not*, for example as a |
| 786 |
paragraph style. |
| 787 |
|
| 788 |
- Declare your role in the source reStructuredText document in a |
| 789 |
``role`` directive. Example:: |
| 790 |
|
| 791 |
.. role:: pretty |
| 792 |
|
| 793 |
- Use inline markup to apply your role to text. Example:: |
| 794 |
|
| 795 |
We have :pretty:`very nice` apples. |
| 796 |
|
| 797 |
Here is another example:: |
| 798 |
|
| 799 |
.. role:: fancy |
| 800 |
|
| 801 |
Here is some :fancy:`pretty text` that looks fancy. |
| 802 |
|
| 803 |
For more on roles see: |
| 804 |
`Custom Interpreted Text Roles -- |
| 805 |
https://docutils.sourceforge.io/docs/ref/rst/directives.html#custom-interpreted-text-roles |
| 806 |
<https://docutils.sourceforge.io/docs/ref/rst/directives.html#custom-interpreted-text-roles>`_. |
| 807 |
|
| 808 |
**Note:** The ability to base a role on another existing role is |
| 809 |
*not* supported by ``odtwriter``. |
| 810 |
|
| 811 |
|
| 812 |
Hints and Suggestions and Features |
| 813 |
================================== |
| 814 |
|
| 815 |
Table of contents |
| 816 |
----------------- |
| 817 |
|
| 818 |
The ``..contents::`` directive causes ``odtwriter`` to generate |
| 819 |
either: |
| 820 |
|
| 821 |
1. A static, outline style table of contents, if the |
| 822 |
``--generate-list-toc`` command line option is specified, or |
| 823 |
|
| 824 |
2. An ODF/``oowriter`` style table of contents containing |
| 825 |
dynamically updated page numbers and with the formatting control |
| 826 |
that ``oowriter`` gives you. This is the default, or use the |
| 827 |
command line option ``--generate-list-toc``. **Note:** |
| 828 |
``odtwriter`` is not able to determine page numbers, so you will |
| 829 |
need to open the generated document in ``oowriter``, then |
| 830 |
right-click on the table of contents and select "Update" to |
| 831 |
insert correct page numbers. |
| 832 |
|
| 833 |
|
| 834 |
Syntax highlighting |
| 835 |
------------------- |
| 836 |
|
| 837 |
``odtwriter`` can add syntax highlighting to code in code |
| 838 |
blocks. In order to activate this, do all of the following: |
| 839 |
|
| 840 |
1. Install `Pygments`_ and ... |
| 841 |
|
| 842 |
2. Use the command line option ``--add-syntax-highlighting``. |
| 843 |
Example:: |
| 844 |
|
| 845 |
$ rst2odt.py --add-syntax-highlight test.txt test.odt |
| 846 |
|
| 847 |
The following styles are defined in styles.odt and are used for |
| 848 |
literal code blocks and syntax highlighting: |
| 849 |
|
| 850 |
- Paragraph styles: |
| 851 |
|
| 852 |
- rststyle-codeblock -- The style for the code block as a whole. |
| 853 |
|
| 854 |
- Character styles: |
| 855 |
|
| 856 |
- rststyle-codeblock-classname -- class names. |
| 857 |
|
| 858 |
- rststyle-codeblock-comment -- comments. |
| 859 |
|
| 860 |
- rststyle-codeblock-functionname -- function names. |
| 861 |
|
| 862 |
- rststyle-codeblock-keyword -- Python language keywords. |
| 863 |
|
| 864 |
- rststyle-codeblock-name -- other names, for example, |
| 865 |
variables. |
| 866 |
|
| 867 |
- rststyle-codeblock-number -- literal numbers, including |
| 868 |
integers, floats, hex numbers, and octal numbers. |
| 869 |
|
| 870 |
- rststyle-codeblock-operator -- Python operators. |
| 871 |
|
| 872 |
- rststyle-codeblock-string -- literal strings. |
| 873 |
|
| 874 |
Each of the above styles has a default appearance that is defined |
| 875 |
in ``styles.odt``. To change that definition and appearance, open |
| 876 |
``styles.odt`` in ``oowriter`` and use menu item:: |
| 877 |
|
| 878 |
Format --> Styles and Formatting |
| 879 |
|
| 880 |
Then, click on the Paragraph Styles button or the Character Styles |
| 881 |
button at the top of the Styles and Formatting window. You may |
| 882 |
also need to select "All Styles" from the drop-down selection list |
| 883 |
at the bottom of the Styles and Formatting window. |
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
The container directive |
| 888 |
----------------------- |
| 889 |
|
| 890 |
There is limited support for the ``container`` directive. The |
| 891 |
limitations and rules for the container directive are the following: |
| 892 |
|
| 893 |
- Only the first class in the list of classes (arguments) is used. |
| 894 |
|
| 895 |
- That class/style must be a paragraph style and not (for example) a |
| 896 |
character style. |
| 897 |
|
| 898 |
- The style/class given to the container directive will have a |
| 899 |
"rststyle-" prefix in the odt file. |
| 900 |
|
| 901 |
So, for example:: |
| 902 |
|
| 903 |
.. container:: style-1 style-2 style-3 |
| 904 |
|
| 905 |
a block of text |
| 906 |
|
| 907 |
- Only ``style-1`` is used; ``style-2`` and ``style-3`` are ignored. |
| 908 |
|
| 909 |
- ``rststyle-style-1`` must be defined. It should be an existing, |
| 910 |
predefined style, or you should define it in your stylesheet |
| 911 |
(``styles.odt`` or the argument to the ``--stylesheet`` command |
| 912 |
line option). |
| 913 |
|
| 914 |
- ``rststyle-style-1`` must be a paragraph style. |
| 915 |
|
| 916 |
To define a paragraph style, use the following menu item in |
| 917 |
``oowriter``:: |
| 918 |
|
| 919 |
Format --> Styles and Formatting |
| 920 |
|
| 921 |
Then, click on the Paragraph Styles button. |
| 922 |
|
| 923 |
The following example attaches the ``rststyle-heading2`` style (a |
| 924 |
predefined style) to each paragraph/line in the container:: |
| 925 |
|
| 926 |
.. container:: heading2 |
| 927 |
|
| 928 |
Line 1 of container. |
| 929 |
|
| 930 |
Line 2 of container. |
| 931 |
|
| 932 |
More information on how to define a new style (for example, in your |
| 933 |
``styles.odt``) can be found in section |
| 934 |
`Defining and using custom style names`_. |
| 935 |
|
| 936 |
|
| 937 |
|
| 938 |
The table directive |
| 939 |
------------------- |
| 940 |
|
| 941 |
The ``table`` directive can be used to add a title to a table. |
| 942 |
Example:: |
| 943 |
|
| 944 |
.. table:: A little test table |
| 945 |
|
| 946 |
=========== ============= |
| 947 |
Name Value |
| 948 |
=========== ============= |
| 949 |
Dave Cute |
| 950 |
Mona Smart |
| 951 |
=========== ============= |
| 952 |
|
| 953 |
The above will insert the title "A little test table" at the top of the |
| 954 |
table. You can modify the appearance of the title by modifying the |
| 955 |
paragraph style ``rststyle-table-title``. |
| 956 |
|
| 957 |
|
| 958 |
Footnotes and citations |
| 959 |
----------------------- |
| 960 |
|
| 961 |
Footnotes and citations are supported. |
| 962 |
|
| 963 |
There are additional styles ``rststyle-footnote`` and |
| 964 |
``rststyle-citation`` for footnotes and citations. See |
| 965 |
`Footnote and citation styles`_. |
| 966 |
|
| 967 |
You may need to modify the citation style to fit the length of your |
| 968 |
citation references. |
| 969 |
|
| 970 |
Endnotes -- There are command line options that control whether |
| 971 |
``odtwriter`` creates endnotes instead of footnotes. Endnotes |
| 972 |
appear at the end of the document instead of at the bottom of the |
| 973 |
page. See flags ``--endnotes-end-doc`` and |
| 974 |
``--no-endnotes-end-doc`` in section `Command line options`_. |
| 975 |
|
| 976 |
|
| 977 |
Images and figures |
| 978 |
------------------ |
| 979 |
|
| 980 |
If on the image or the figure directive you provide the scale option |
| 981 |
but do not provide the width and height options, then ``odtwriter`` |
| 982 |
will attempt to determine the size of the image using the `Python |
| 983 |
Imaging Library`_ (PIL). If ``odtwriter`` cannot find and import |
| 984 |
Python Imaging Library, it will raise an exception. If this |
| 985 |
ocurrs, you can fix it by doing one of the following: |
| 986 |
|
| 987 |
- Install the Python Imaging Library or |
| 988 |
|
| 989 |
- Remove the ``scale`` option or |
| 990 |
|
| 991 |
- Add both the ``width`` and the ``height`` options. |
| 992 |
|
| 993 |
So, the rule is: if on any image or figure, you specify scale but |
| 994 |
not both width and height, you must install the `Python Imaging |
| 995 |
Library`_ library. |
| 996 |
|
| 997 |
For more information about PIL, see: `Python Imaging Library`_. |
| 998 |
|
| 999 |
|
| 1000 |
The raw directive |
| 1001 |
----------------- |
| 1002 |
|
| 1003 |
The ``raw`` directive is supported. Use output format type "odt". |
| 1004 |
|
| 1005 |
You will need to be careful about the formatting of the raw |
| 1006 |
content. In particular, introduced whitespace might be a problem. |
| 1007 |
|
| 1008 |
In order to produce content for the raw directive for use by |
| 1009 |
``odtwriter``, you might want to extract the file ``content.xml`` |
| 1010 |
from a ``.odt`` file (using some Zip tool), and then clip, paste, |
| 1011 |
and modify a selected bit of it. |
| 1012 |
|
| 1013 |
Here is an example:: |
| 1014 |
|
| 1015 |
.. raw:: odt |
| 1016 |
|
| 1017 |
<text:p text:style-name="rststyle-textbody">Determining |
| 1018 |
<text:span text:style-name="rststyle-emphasis">which</text:span> |
| 1019 |
namespace a name is in is static. It can be determined by a |
| 1020 |
lexical scan of the code. If a variable is assigned a value |
| 1021 |
<text:span text:style-name="rststyle-emphasis">anywhere</text:span> |
| 1022 |
in a scope (specifically within a function or method body), |
| 1023 |
then that variable is local to that scope. If Python does |
| 1024 |
not find a variable in the local scope, then it looks next |
| 1025 |
in the global scope (also sometimes called the module scope) |
| 1026 |
and then in the built-ins scope. But, the |
| 1027 |
<text:span text:style-name="rststyle-inlineliteral">global</text:span> |
| 1028 |
statement can be used to force Python to find and use a global |
| 1029 |
variable (a variable defined at top level in a module) rather |
| 1030 |
than create a local one.</text:p> |
| 1031 |
|
| 1032 |
|
| 1033 |
The meta directive |
| 1034 |
------------------ |
| 1035 |
|
| 1036 |
``odtwriter`` supports the ``meta`` directive. "keywords" |
| 1037 |
and "description" are set in their respective odt fields. |
| 1038 |
Other meta fields are set as "Custom Properties". |
| 1039 |
Here is an example:: |
| 1040 |
|
| 1041 |
.. meta:: |
| 1042 |
:keywords: reStructuredText, docutils, formatting |
| 1043 |
:description lang=en: A reST document, contains formatted |
| 1044 |
text in a formatted style. |
| 1045 |
:custom_var: Value |
| 1046 |
|
| 1047 |
To see the results of the ``meta`` directive in ``oowriter``, |
| 1048 |
select menu item "File/Properties...", then click on the |
| 1049 |
"Description" tab ("keywords" and "description" fields) and the |
| 1050 |
"Custom Properties" tab. |
| 1051 |
|
| 1052 |
|
| 1053 |
Footnote references inside footnotes |
| 1054 |
------------------------------------ |
| 1055 |
|
| 1056 |
Not supported. |
| 1057 |
|
| 1058 |
Get a grip. Be serious. Try a dose of reality. |
| 1059 |
|
| 1060 |
``odtwriter`` ignores them. |
| 1061 |
|
| 1062 |
They cause ``oowriter`` to croak. |
| 1063 |
|
| 1064 |
|
| 1065 |
Page size |
| 1066 |
--------- |
| 1067 |
|
| 1068 |
The default page size, in documents generated by ``odtwriter`` is |
| 1069 |
``Letter``. You can change this (for example to ``A4``) by using a |
| 1070 |
custom stylesheet. See `Defining and using a custom stylesheet`_ |
| 1071 |
for instructions on how to do this. |
| 1072 |
|
| 1073 |
On machines which support ``paperconf``, ``odtwriter`` can insert |
| 1074 |
the default page size for your locale. In order for this to work, |
| 1075 |
the following conditions must be met: |
| 1076 |
|
| 1077 |
1. The program ``paperconf`` must be available on your system. |
| 1078 |
``odtwriter`` uses ``paperconf -s`` to obtain the paper size. |
| 1079 |
See ``man paperconf`` for more information. |
| 1080 |
|
| 1081 |
2. The default page height and width must be removed from the |
| 1082 |
``styles.odt`` used to generate the document. A Python script |
| 1083 |
``rst2odt_prepstyles.py`` is distributed with ``odtwriter`` and |
| 1084 |
is installed in the ``bin`` directory. You can remove the page |
| 1085 |
height and width with something like the following:: |
| 1086 |
|
| 1087 |
$ rst2odt_prepstyles.py styles.odt |
| 1088 |
|
| 1089 |
.. warning:: If you edit your stylesheet in ``oowriter`` and then |
| 1090 |
save it, ``oowriter`` automatically inserts a page height and |
| 1091 |
width in the styles for that (stylesheet) document. If that is |
| 1092 |
not the page size that you want and you want ``odtwriter`` to |
| 1093 |
insert a default page size using ``paperconf``, then you will |
| 1094 |
need to strip the page size from your stylesheet each time you |
| 1095 |
edit that stylesheet with ``oowriter``. |
| 1096 |
|
| 1097 |
|
| 1098 |
|
| 1099 |
Custom header/footers: inserting page numbers, date, time, etc |
| 1100 |
---------------------------------------------------------------- |
| 1101 |
|
| 1102 |
You can specify custom headers and footers for your document from |
| 1103 |
the command line. These headers and footers can be used to insert |
| 1104 |
fields such as the page number, page count, date, time, etc. See |
| 1105 |
below for a complete list. |
| 1106 |
|
| 1107 |
To insert a custom header or footer, use the "--custom-odt-header" |
| 1108 |
or "--custom-odt-footer" command line options. For example, the |
| 1109 |
following inserts a footer containing the page number and page |
| 1110 |
count:: |
| 1111 |
|
| 1112 |
$ rst2odt.py --custom-odt-footer="Page %p% of %P%" f1.txt f1.odt |
| 1113 |
|
| 1114 |
|
| 1115 |
Field specifiers |
| 1116 |
~~~~~~~~~~~~~~~~~~ |
| 1117 |
|
| 1118 |
You can use the following field specifiers to insert ``oowriter`` |
| 1119 |
fields in your custom headers and footers: |
| 1120 |
|
| 1121 |
%p% |
| 1122 |
The current page number. |
| 1123 |
|
| 1124 |
%P% |
| 1125 |
The number of pages in the document. |
| 1126 |
|
| 1127 |
%d1% |
| 1128 |
The current date in format 12/31/99. |
| 1129 |
|
| 1130 |
%d2% |
| 1131 |
The current date in format 12/31/1999. |
| 1132 |
|
| 1133 |
%d3% |
| 1134 |
The current date in format Dec 31, 1999. |
| 1135 |
|
| 1136 |
%d4% |
| 1137 |
The current date in format December 31, 1999. |
| 1138 |
|
| 1139 |
%d5% |
| 1140 |
The current date in format 1999-12-31. |
| 1141 |
|
| 1142 |
%t1% |
| 1143 |
The current time in format 14:22. |
| 1144 |
|
| 1145 |
%t2% |
| 1146 |
The current time in format 14:22:33. |
| 1147 |
|
| 1148 |
%t3% |
| 1149 |
The current time in format 02:22 PM. |
| 1150 |
|
| 1151 |
%t4% |
| 1152 |
The current time in format 02:22:33 PM. |
| 1153 |
|
| 1154 |
%a% |
| 1155 |
The author of the document (actually the initial creator). |
| 1156 |
|
| 1157 |
%t% |
| 1158 |
The document title. |
| 1159 |
|
| 1160 |
%s% |
| 1161 |
The document subject. |
| 1162 |
|
| 1163 |
|
| 1164 |
**Note:** The use of the above field specifiers in the body of your |
| 1165 |
reStructuredText document is **not** supported, because these |
| 1166 |
specifiers are not standard across Docutils writers. |
| 1167 |
|
| 1168 |
|
| 1169 |
|
| 1170 |
Credits |
| 1171 |
======= |
| 1172 |
|
| 1173 |
Stefan Merten designed and implemented the custom style names |
| 1174 |
capability. Thank you, Stefan. |
| 1175 |
|
| 1176 |
Michael Schutte supports the Debian GNU/Linux distribution of |
| 1177 |
``odtwriter``. Thank you, Michael, for providing and supporting |
| 1178 |
the Debian package. |
| 1179 |
|
| 1180 |
Michael Schutte implemented the fix that enables ``odtwriter`` to |
| 1181 |
pick up the default paper size on platforms where the program |
| 1182 |
``paperconf`` is available. Thank you. |
| 1183 |
|
| 1184 |
|
| 1185 |
|
| 1186 |
|
| 1187 |
.. _`Pygments`: |
| 1188 |
https://pygments.org/ |
| 1189 |
|
| 1190 |
.. _`Docutils`: |
| 1191 |
https://docutils.sourceforge.io/ |
| 1192 |
|
| 1193 |
.. _`Python Imaging Library`: |
| 1194 |
https://en.wikipedia.org/wiki/Python_Imaging_Library |
| 1195 |
|
| 1196 |
.. _`Open Document at Wikipedia`: |
| 1197 |
https://en.wikipedia.org/wiki/OpenDocument |
| 1198 |
|
| 1199 |
.. _`OASIS Open Document Format for Office Applications (OpenDocument) TC`: |
| 1200 |
http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=office |