Re: Need for dedicated kinds of paragraphs

2022-10-17 Thread Damien Cassou
Hi all,

thank you very much for your answers:

Sébastien Miquel  writes:
> I think special blocks are a good fit for this purpose.
"Fraga, Eric"  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  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  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



Re: Need for dedicated kinds of paragraphs

2022-10-17 Thread Max Nikulin

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.







Re: Need for dedicated kinds of paragraphs

2022-10-17 Thread Ihor Radchenko
Damien Cassou  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




not as



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 .
Support Org development at ,
or support my work at 



Re: Need for dedicated kinds of paragraphs

2022-10-17 Thread Fraga, Eric
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


Re: Need for dedicated kinds of paragraphs

2022-10-17 Thread Sébastien Miquel

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



Need for dedicated kinds of paragraphs

2022-10-17 Thread Damien Cassou
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