kjambunathan / org-mode-ox-odt

The Authoritative fork of Org mode's ODT exporter
GNU General Public License v3.0
47 stars 9 forks source link

How do I export a src block or a quote block with custom style and within a textbox? #83

Open kjambunathan opened 3 years ago

kjambunathan commented 3 years ago

See https://redd.it/mc8v32

Hello Emacsers,

I am working on something for a publisher using emacs org-mode markup. In the past, this publisher has accepted my work in HTML format, and I used HTML export along with some Python scripts to put my work in the format they required. In particular, there are a couple of special quote-type blocks that I handled using special blocks (#+BEGIN_foo).

Suddenly they're asking for my work in word format, so my plan is to use ODT export. Works pretty awesomely, except that my special blocks are just normal text.

I did not see any mention (or at least didn't comprehend if it was mentioned) of using special blocks with ODT export. Is there a way I can have these blocks exported as, say, text boxes with a particular style?

kjambunathan commented 3 years ago

How do I export a src block or a quote block with custom style and within a textbox?

#+options: ':nil *:t -:t ::t <:t H:3 \n:nil ^:t arch:headline
#+options: author:nil broken-links:mark c:nil creator:nil
#+options: d:(not "LOGBOOK") date:nil e:t email:t f:t inline:t num:t
#+options: p:nil pri:nil prop:nil stat:t tags:t tasks:t tex:t
#+options: timestamp:t title:t toc:nil todo:t |:t
#+title: test
#+date: <2021-03-25 Thu>
#+author: Jambunathan K
#+email: kjambunathan@gmail.com
#+language: en
#+select_tags: export
#+exclude_tags: noexport
#+creator: Emacs 28.0.50 (Org mode 9.3.7)

#+options: tex:nil
#+description:
#+keywords:
#+subtitle:
#+odt_preferred_output_format:
#+odt_styles_file:
#+odt_extra_images:
#+odt_extra_styles:
#+odt_extra_automatic_styles:
#+odt_master_styles:
#+odt_content_template_file:
#+odt_automatic_styles:
#+odt_display_outline_level: 2
#+odt_endnote_regexp: ^$
#+bib_file:

#+odt_extra_styles: <style:style style:name="MyFrame" style:family="graphic">
#+odt_extra_styles:  <style:graphic-properties svg:width="16.15cm" style:rel-width="95%" fo:min-height="0.34cm" text:anchor-type="paragraph" svg:x="0cm" svg:y="0cm" fo:margin-left="0.201cm" fo:margin-right="0.201cm" fo:margin-top="0.201cm" fo:margin-bottom="0.201cm" style:wrap="none" style:vertical-pos="top" style:vertical-rel="paragraph-content" style:horizontal-pos="left" style:horizontal-rel="paragraph-content" fo:padding="0.15cm" fo:border="0.06pt solid #000000" draw:wrap-influence-on-position="once-concurrent" loext:allow-overlap="true" loext:rel-width-rel="paragraph">
#+odt_extra_styles:   <style:columns fo:column-count="1" fo:column-gap="0cm"/>
#+odt_extra_styles:  </style:graphic-properties>
#+odt_extra_styles: </style:style>

#+odt_extra_styles: <style:style style:name="OrgSrcblockFrame" style:family="graphic" style:parent-style-name="MyFrame">
#+odt_extra_styles:  <style:graphic-properties style:vertical-pos="top" style:vertical-rel="paragraph-content" style:horizontal-pos="left" style:horizontal-rel="paragraph-content" loext:rel-width-rel="paragraph"/>
#+odt_extra_styles: </style:style>

#+odt_extra_styles: <style:style style:name="OrgQuoteBlock" style:family="paragraph" style:parent-style-name="Text_20_body">
#+odt_extra_styles:  <style:paragraph-properties fo:margin-left="0.4cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"/>
#+odt_extra_styles:  <style:text-properties fo:font-style="italic"/>
#+odt_extra_styles: </style:style>

#+ATTR_ODT: :width 16.15 :style "OrgSrcblockFrame"
#+begin_textbox
#+begin_src elisp
  (defun hello-world ()
    (message "Hello World"))
#+end_src
#+end_textbox

#+begin_textbox
#+ATTR_ODT: :style "OrgQuoteBlock"
#+begin_quote
Disobedience, in the eyes of any one who has read history, is man's
original virtue. It is through disobedience that progress has been
made, through disobedience and through rebellion.

--- Oscar Wilde in "The Soul of Man Under Socialism (1891)"
#+end_quote
#+end_textbox

Screenshot from 2021-03-25 18-58-40

kjambunathan commented 3 years ago

How do I export a src block or a quote block with custom style and within a textbox?

Here is an snippet that uses a non-standard foo block.

#+options: ':nil *:t -:t ::t <:t H:3 \n:nil ^:t arch:headline
#+options: author:nil broken-links:mark c:nil creator:nil
#+options: d:(not "LOGBOOK") date:nil e:t email:t f:t inline:t num:t
#+options: p:nil pri:nil prop:nil stat:t tags:t tasks:t tex:t
#+options: timestamp:t title:t toc:nil todo:t |:t
#+title: test
#+date: <2021-03-25 Thu>
#+author: Jambunathan K
#+email: kjambunathan@gmail.com
#+language: en
#+select_tags: export
#+exclude_tags: noexport
#+creator: Emacs 28.0.50 (Org mode 9.3.7)

#+options: tex:nil
#+description:
#+keywords:
#+subtitle:
#+odt_preferred_output_format:
#+odt_styles_file:
#+odt_extra_images:
#+odt_extra_styles:
#+odt_extra_automatic_styles:
#+odt_master_styles:
#+odt_content_template_file:
#+odt_automatic_styles:
#+odt_display_outline_level: 2
#+odt_endnote_regexp: ^$
#+bib_file:

#+odt_extra_styles: <style:style style:name="MyFrame" style:family="graphic">
#+odt_extra_styles:  <style:graphic-properties svg:width="16.15cm" style:rel-width="95%" fo:min-height="0.34cm" text:anchor-type="paragraph" svg:x="0cm" svg:y="0cm" fo:margin-left="0.201cm" fo:margin-right="0.201cm" fo:margin-top="0.201cm" fo:margin-bottom="0.201cm" style:wrap="none" style:vertical-pos="top" style:vertical-rel="paragraph-content" style:horizontal-pos="left" style:horizontal-rel="paragraph-content" fo:padding="0.15cm" fo:border="0.06pt solid #000000" draw:wrap-influence-on-position="once-concurrent" loext:allow-overlap="true" loext:rel-width-rel="paragraph">
#+odt_extra_styles:   <style:columns fo:column-count="1" fo:column-gap="0cm"/>
#+odt_extra_styles:  </style:graphic-properties>
#+odt_extra_styles: </style:style>

#+odt_extra_styles: <style:style style:name="OrgSrcblockFrame" style:family="graphic" style:parent-style-name="MyFrame">
#+odt_extra_styles:  <style:graphic-properties style:vertical-pos="top" style:vertical-rel="paragraph-content" style:horizontal-pos="left" style:horizontal-rel="paragraph-content" loext:rel-width-rel="paragraph"/>
#+odt_extra_styles: </style:style>

#+odt_extra_styles: <style:style style:name="OrgQuoteBlock" style:family="paragraph" style:parent-style-name="Text_20_body">
#+odt_extra_styles:  <style:paragraph-properties fo:margin-left="0.4cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"/>
#+odt_extra_styles:  <style:text-properties fo:font-style="italic"/>
#+odt_extra_styles: </style:style>

#+odt_extra_styles: <style:style style:name="OrgQuoteBlockAttribution" style:family="paragraph" style:parent-style-name="OrgQuoteBlock">
#+odt_extra_styles:  <style:paragraph-properties fo:text-align="end" style:justify-single-word="false"/>
#+odt_extra_styles: </style:style>

#+ATTR_ODT: :width 16.15 :style "OrgSrcblockFrame"
#+begin_textbox
#+begin_src elisp
  (defun hello-world ()
    (message "Hello World"))
#+end_src
#+end_textbox

#+begin_quote
Disobedience, in the eyes of any one who has read history, is man's
original virtue. It is through disobedience that progress has been
made, through disobedience and through rebellion.

--- Oscar Wilde in "The Soul of Man Under Socialism (1891)"
#+end_quote

#+ATTR_ODT: :width 16.15 :style "OrgSrcblockFrame"
#+begin_textbox
#+ATTR_ODT: :style "OrgQuoteBlock"
#+begin_foo
Disobedience, in the eyes of any one who has read history, is man's
original virtue. It is through disobedience that progress has been
made, through disobedience and through rebellion.

#+ATTR_ODT: :style OrgQuoteBlockAttribution"
--- Oscar Wilde in "The Soul of Man Under Socialism (1891)"
#+end_foo
#+end_textbox

Screenshot from 2021-03-25 20-09-18