Last active
February 16, 2026 19:54
-
-
Save rgchris/e325347625b1688a1a1fe686610c68ba to your computer and use it in GitHub Desktop.
Build a minimal ODT (ODF Text) in Rebol 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Rebol [ | |
| Title: "Package a Minimal OpenText Document" | |
| Date: 30-Dec-2021 | |
| Author: "Christopher Ross-Gill" | |
| Rights: http://opensource.org/licenses/Apache-2.0 | |
| Home: https://gist.github.com/rgchris/e325347625b1688a1a1fe686610c68ba | |
| Needs: [ | |
| r3:rgchris:zip | |
| ] | |
| ] | |
| write target: %minimal.odt zip/create [ | |
| add-file %mimetype "application/vnd.oasis.opendocument.text" | |
| add-file %META-INF/manifest.xml trim/tail trim/auto { | |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE manifest:manifest PUBLIC "-//OpenOffice.org//DTD Manifest 1.0//EN" "Manifest.dtd"> | |
| <manifest:manifest | |
| xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"> | |
| <manifest:file-entry | |
| manifest:media-type="application/vnd.oasis.opendocument.text" | |
| manifest:full-path="/" | |
| /> | |
| <manifest:file-entry | |
| manifest:media-type="text/xml" | |
| manifest:full-path="meta.xml" | |
| /> | |
| <manifest:file-entry | |
| manifest:media-type="text/xml" | |
| manifest:full-path="styles.xml" | |
| /> | |
| <manifest:file-entry | |
| manifest:media-type="text/xml" | |
| manifest:full-path="content.xml" | |
| /> | |
| </manifest:manifest> | |
| } | |
| add-file %meta.xml trim/tail trim/auto { | |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <office:document-meta | |
| office:version="1.0" | |
| xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" | |
| xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"> | |
| <office:meta> | |
| <meta:generator>R3C/0.0.1</meta:generator> | |
| </office:meta> | |
| </office:document-meta> | |
| } | |
| add-file %styles.xml trim/tail trim/auto { | |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <office:document-styles | |
| office:version="1.0" | |
| xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" | |
| xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" | |
| xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" | |
| xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"> | |
| <office:font-face-decls> | |
| <style:font-face | |
| style:name="Helvetica" | |
| svg:font-family="Helvetica" | |
| /> | |
| </office:font-face-decls> | |
| <office:styles> | |
| <style:default-style | |
| style:family="paragraph"> | |
| <style:paragraph-properties | |
| style:tab-stop-distance="36pt" | |
| /> | |
| <style:text-properties | |
| style:font-name="Helvetica" | |
| fo:font-size="12pt" | |
| /> | |
| </style:default-style> | |
| <style:style | |
| style:name="Standard" | |
| style:family="paragraph" | |
| style:class="text" | |
| /> | |
| </office:styles> | |
| <office:automatic-styles> | |
| <style:page-layout | |
| style:name="Standard"> | |
| <style:page-layout-properties | |
| fo:page-width="612pt" | |
| fo:page-height="792pt" | |
| style:print-orientation="portrait" | |
| fo:margin-top="36pt" | |
| fo:margin-bottom="36pt" | |
| fo:margin-left="72pt" | |
| fo:margin-right="72pt" | |
| /> | |
| </style:page-layout> | |
| </office:automatic-styles> | |
| <office:master-styles> | |
| <style:master-page | |
| style:name="Standard" | |
| style:page-layout-name="Standard"> | |
| </style:master-page> | |
| </office:master-styles> | |
| </office:document-styles> | |
| } | |
| add-file %content.xml trim/tail trim/auto { | |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <office:document-content | |
| office:version="1.0" | |
| xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" | |
| xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" | |
| xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" | |
| xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"> | |
| <office:font-face-decls> | |
| <style:font-face | |
| style:name="Helvetica" | |
| svg:font-family="Helvetica" | |
| /> | |
| </office:font-face-decls> | |
| <office:automatic-styles> | |
| <style:style | |
| style:name="Body" | |
| style:family="paragraph" | |
| style:parent-style-name="Standard"> | |
| <style:text-properties | |
| style:font-name="Helvetica" | |
| fo:font-size="12pt" | |
| /> | |
| </style:style> | |
| </office:automatic-styles> | |
| <office:body> | |
| <office:text> | |
| <text:p text:style-name="Body">Hello World!</text:p> | |
| </office:text> | |
| </office:body> | |
| </office:document-content> | |
| } | |
| ] | |
| print "----------------------------------" | |
| call/wait reduce [ | |
| "zipinfo" "-l" target | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment