* Need for dedicated kinds of paragraphs
@ 2022-10-17 6:52 Damien Cassou
2022-10-17 7:25 ` Sébastien Miquel
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Damien Cassou @ 2022-10-17 6:52 UTC (permalink / raw)
To: emacs-orgmode
Hi,
I'm implementing an odt-based exporter for a French magazine named
GNU/Linux Magazine. This magazine defines several kinds of boxes, which
are small paragraphs of a certain type among "Default", "Attention",
"Warning" and "PAO". When published, the magazine will change the
background of these boxes depending on the type (e.g., using red color
for warning boxes).
I'm not sure what kind of markup to use nor how to transcode that
markup. I tried with:
#+BOX: attention
This text will appear with a red background
Does that make sense? Do you have a better suggestion?
From Worg's org-syntax.html file [1], I understand that this is an
"affiliated keyword" and that it must be declared in
`org-element-affiliated-keywords' but this variable is a `defconst' so
I'm reluctant to change it in my exporter.
I have an `ox-linuxmag--paragraph' transcoder for the `paragraph' type
but I don't know how to get the value of the "BOX" keyword.
Do you have any suggestion?
If I have a look at how org-odt transcodes paragraphs, I see this
function:
(defun org-odt-paragraph (paragraph contents info)
"Transcode a PARAGRAPH element from Org to ODT.
CONTENTS is the contents of the paragraph, as a string. INFO is
the plist used as a communication channel."
(org-odt--format-paragraph
paragraph contents info
(or (org-element-property :style paragraph) "Text_20_body")
"OrgCenter"
"Quotations"))
Could I use the :style property? What would the markup be like to make
that work?
Thank you so much for Org!
[1] https://orgmode.org/worg/dev/org-syntax.html#Affiliated_Keywords
--
Damien Cassou
"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Need for dedicated kinds of paragraphs
2022-10-17 6:52 Need for dedicated kinds of paragraphs Damien Cassou
@ 2022-10-17 7:25 ` Sébastien Miquel
2022-10-17 18:44 ` Damien Cassou
2022-10-17 8:16 ` Fraga, Eric
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Sébastien Miquel @ 2022-10-17 7:25 UTC (permalink / raw)
To: Damien Cassou; +Cc: emacs-orgmode
Hi,
Damien Cassou writes:
> I'm implementing an odt-based exporter for a French magazine named
> GNU/Linux Magazine. This magazine defines several kinds of boxes, which
> are small paragraphs of a certain type among "Default", "Attention",
> "Warning" and "PAO". When published, the magazine will change the
> background of these boxes depending on the type (e.g., using red color
> for warning boxes).
>
> I'm not sure what kind of markup to use nor how to transcode that
> markup. I tried with:
>
> #+BOX: attention
> This text will appear with a red background
>
> Does that make sense? Do you have a better suggestion?
I think special blocks are a good fit for this purpose.
--
Sébastien Miquel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Need for dedicated kinds of paragraphs
2022-10-17 7:25 ` Sébastien Miquel
@ 2022-10-17 18:44 ` Damien Cassou
0 siblings, 0 replies; 6+ messages in thread
From: Damien Cassou @ 2022-10-17 18:44 UTC (permalink / raw)
To: sebastien.miquel; +Cc: emacs-orgmode
Hi all,
thank you very much for your answers:
Sébastien Miquel <sebastien.miquel@posteo.eu> writes:
> I think special blocks are a good fit for this purpose.
"Fraga, Eric" <e.fraga@ucl.ac.uk> writes:
> Have you tried /special blocks/, as in […]
following this idea (also suggested by yantar92 on IRC) I tried this
approach but failed because of:
https://lists.gnu.org/archive/html/emacs-orgmode/2022-10/msg00565.html
I could have introduced several kinds of boxes instead of just one with
parameters but I felt that was a bit heavyweight.
Ihor Radchenko <yantar92@posteo.net> writes:
> Note that #+BOX is not a valid affiliated keyword. Only keywords from
> org-element-affiliated-keywords + #+ATTR_X keywords are considered
> affiliated.
that's also what I understood after reading the code some more.
> Something like
>
> #+ATTR_BACKEND: :style attention
> This text will appear with a red background
Max Nikulin <manikulin@gmail.com> writes:
> If you have derived your export backend from ox-odt then you may use
> something like
>
> #+attr_odt: :type attention
> or perhaps even
> #+attr_linuxmag: :type attention
This is exactly what I finally decided to use.
Thank you very much all of you!
--
Damien Cassou
"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Need for dedicated kinds of paragraphs
2022-10-17 6:52 Need for dedicated kinds of paragraphs Damien Cassou
2022-10-17 7:25 ` Sébastien Miquel
@ 2022-10-17 8:16 ` Fraga, Eric
2022-10-17 11:33 ` Ihor Radchenko
2022-10-17 11:37 ` Max Nikulin
3 siblings, 0 replies; 6+ messages in thread
From: Fraga, Eric @ 2022-10-17 8:16 UTC (permalink / raw)
To: Damien Cassou; +Cc: emacs-orgmode@gnu.org
Hi Damien,
On Monday, 17 Oct 2022 at 08:52, Damien Cassou wrote:
> I'm not sure what kind of markup to use nor how to transcode that
> markup. I tried with:
Have you tried /special blocks/, as in
#+begin_attention
This text will appear with a red backround.
#+end_attention
? In LaTeX and HTML, this exports in such a way that the paragraph is
within a special environment (LaTeX) or class (HTML). I'm not sure how
it exports to ODT but it may provide the basis for what you want.
--
: Eric S Fraga, with org release_9.5.5-840-g52be6f in Emacs 29.0.50
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Need for dedicated kinds of paragraphs
2022-10-17 6:52 Need for dedicated kinds of paragraphs Damien Cassou
2022-10-17 7:25 ` Sébastien Miquel
2022-10-17 8:16 ` Fraga, Eric
@ 2022-10-17 11:33 ` Ihor Radchenko
2022-10-17 11:37 ` Max Nikulin
3 siblings, 0 replies; 6+ messages in thread
From: Ihor Radchenko @ 2022-10-17 11:33 UTC (permalink / raw)
To: Damien Cassou; +Cc: emacs-orgmode
Damien Cassou <damien@cassou.me> writes:
> I'm not sure what kind of markup to use nor how to transcode that
> markup. I tried with:
>
> #+BOX: attention
> This text will appear with a red background
>
> Does that make sense? Do you have a better suggestion?
Note that #+BOX is not a valid affiliated keyword. Only keywords from
org-element-affiliated-keywords + #+ATTR_X keywords are considered
affiliated.
So, you example is actually parsed as
<keyword :name "BOX" ...>
<paragraph>
not as
<paragraph :BOX ...>
In addition to special blocks suggested by others, a natural way to
customize paragraph export is using #+ATTR_YOURBACKEND keywords.
Something like
#+ATTR_BACKEND: :style attention
This text will appear with a red background
Then, you can use
(plist-get (org-export-read-attribute :attr_backend paragraph-element)
:style)
from inside the paragraph transcoder.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Need for dedicated kinds of paragraphs
2022-10-17 6:52 Need for dedicated kinds of paragraphs Damien Cassou
` (2 preceding siblings ...)
2022-10-17 11:33 ` Ihor Radchenko
@ 2022-10-17 11:37 ` Max Nikulin
3 siblings, 0 replies; 6+ messages in thread
From: Max Nikulin @ 2022-10-17 11:37 UTC (permalink / raw)
To: emacs-orgmode
On 17/10/2022 13:52, Damien Cassou wrote:
>
> #+BOX: attention
> This text will appear with a red background
If you have derived your export backend from ox-odt then you may use
something like
#+attr_odt: :type attention
or perhaps even
#+attr_linuxmag: :type attention
> Does that make sense? Do you have a better suggestion?
I see that you have tried special blocks. Unfortunately I do not see
anything related to parameters in the `org-element-special-block-parser'
`org-element-special-block-interpreter' pair.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-10-17 18:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-17 6:52 Need for dedicated kinds of paragraphs Damien Cassou
2022-10-17 7:25 ` Sébastien Miquel
2022-10-17 18:44 ` Damien Cassou
2022-10-17 8:16 ` Fraga, Eric
2022-10-17 11:33 ` Ihor Radchenko
2022-10-17 11:37 ` Max Nikulin
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).