* ox-odt: List items contain body paragraphs, confusing styles
@ 2017-08-17 2:47 James Harkins
2017-08-17 14:33 ` Nicolas Goaziou
0 siblings, 1 reply; 9+ messages in thread
From: James Harkins @ 2017-08-17 2:47 UTC (permalink / raw)
To: emacs-orgmode
Hi, haven't been active here for a while (which is a good thing -- it means I haven't had any problems worth mentioning!).
Now I have one -- ODT export encodes list items as a list-item containing a "text:p":
<text:list text:style-name="OrgBulletedList" text:continue-numbering="false">
<text:list-item>
<text:p text:style-name="Text_20_body">blah blah</text:p>
</text:list-item>
</text:list>
When LibreOffice reads this, it applies indentation settings from the Text_20_body paragraph style to the list item. So, for instance, if you're writing for a journal that requires a .doc and it also requires paragraphs to be first-line indented, it becomes impossible to have hanging bullets in bullet lists -- the list outdents the bullet by 0.25" but the paragraph style then indents this by 0.5" for a net indent of 0.25".
ask.libreoffice.org says "It is usually preferable to make paragraph styles formatting lists independent from bulk text styles"[1] -- i.e., applying the same style to a list-item paragraph as to a free-standing paragraph is not recommended.
I can guess structurally why this occurs -- I suppose org parses it as a list-item node containing a paragraph node, and the paragraph node is encoded first, without any knowledge of its context.
I will try to write a filter for this, but this looks like an unexpected interaction, so, perhaps a bug.
Thanks,
hjh
[1] https://ask.libreoffice.org/en/question/123222/text-body-style-with-intent-affects-bulleted-list-style-as-well/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ox-odt: List items contain body paragraphs, confusing styles
2017-08-17 2:47 ox-odt: List items contain body paragraphs, confusing styles James Harkins
@ 2017-08-17 14:33 ` Nicolas Goaziou
2017-08-18 3:27 ` James Harkins
0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2017-08-17 14:33 UTC (permalink / raw)
To: James Harkins; +Cc: emacs-orgmode
Hello,
James Harkins <jamshark70@zoho.com> writes:
> Hi, haven't been active here for a while (which is a good thing -- it means I haven't had any problems worth mentioning!).
>
> Now I have one -- ODT export encodes list items as a list-item containing a "text:p":
>
> <text:list text:style-name="OrgBulletedList" text:continue-numbering="false">
> <text:list-item>
>
> <text:p text:style-name="Text_20_body">blah blah</text:p>
>
> </text:list-item>
> </text:list>
>
> When LibreOffice reads this, it applies indentation settings from the
> Text_20_body paragraph style to the list item. So, for instance, if
> you're writing for a journal that requires a .doc and it also requires
> paragraphs to be first-line indented, it becomes impossible to have
> hanging bullets in bullet lists -- the list outdents the bullet by
> 0.25" but the paragraph style then indents this by 0.5" for a net
> indent of 0.25".
>
> ask.libreoffice.org says "It is usually preferable to make paragraph
> styles formatting lists independent from bulk text styles"[1] -- i.e.,
> applying the same style to a list-item paragraph as to a free-standing
> paragraph is not recommended.
>
> I can guess structurally why this occurs -- I suppose org parses it as
> a list-item node containing a paragraph node, and the paragraph node
> is encoded first, without any knowledge of its context.
So, what style-name should have the inner paragraph? If it is a new
style, what would be its definition?
It's not difficult to check, upon exporting a paragraph, if it belongs
to a list item or not: (org-element-lineage paragraph '(item))
BTW, is it different for nested paragraphs, e.g., what should be the
style for the following 3 paragraphs:
- para 1
para 2
- para 3
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ox-odt: List items contain body paragraphs, confusing styles
2017-08-17 14:33 ` Nicolas Goaziou
@ 2017-08-18 3:27 ` James Harkins
2017-08-19 8:36 ` Nicolas Goaziou
0 siblings, 1 reply; 9+ messages in thread
From: James Harkins @ 2017-08-18 3:27 UTC (permalink / raw)
To: Nicolas Goaziou, emacs-orgmode
---- On Thu, 17 Aug 2017 10:33:29 -0400 Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote ----
> So, what style-name should have the inner paragraph? If it is a new
> style, what would be its definition?
>
> It's not difficult to check, upon exporting a paragraph, if it belongs
> to a list item or not: (org-element-lineage paragraph '(item))
>
> BTW, is it different for nested paragraphs, e.g., what should be the
> style for the following 3 paragraphs:
>
> - para 1
>
> para 2
>
> - para 3
Hm. Good question.
I'm going to admit to a bit of frustration now... after about 45 minutes poking around in XML, I did a fresh ox-odt test with a fresh style sheet, and I can't reproduce the problem. !!! Hours, over the last two days, wasted.
So I must have done something funky to that initial stylesheet. (WYSIWYG tools, who knows what it could be. Really teed off at that journal for not allowing LaTeX.)
So I would say, postpone this issue unless I can gather more evidence.
A short answer to your questions is that every list item does consist of paragraphs, and each paragraph must have a paragraph style, but -- the paragraph style can be the same one, even at different list levels. There is no need for a different paragraph style for each list level, and you don't have to do anything special for multiple paragraphs within a list item.
hjh
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ox-odt: List items contain body paragraphs, confusing styles
2017-08-18 3:27 ` James Harkins
@ 2017-08-19 8:36 ` Nicolas Goaziou
2017-08-19 10:40 ` James Harkins
0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2017-08-19 8:36 UTC (permalink / raw)
To: James Harkins; +Cc: emacs-orgmode
Hello,
James Harkins <jamshark70@zoho.com> writes:
> So I would say, postpone this issue unless I can gather more evidence.
OK.
> A short answer to your questions is that every list item does consist
> of paragraphs, and each paragraph must have a paragraph style, but --
> the paragraph style can be the same one, even at different list
> levels. There is no need for a different paragraph style for each list
> level, and you don't have to do anything special for multiple
> paragraphs within a list item.
Adding a special style to every paragraph contained in a plain list is
very easy to do. Just let me know if it happens to be the way to solve
the issue at hand.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ox-odt: List items contain body paragraphs, confusing styles
2017-08-19 8:36 ` Nicolas Goaziou
@ 2017-08-19 10:40 ` James Harkins
2017-08-19 11:55 ` Nicolas Goaziou
0 siblings, 1 reply; 9+ messages in thread
From: James Harkins @ 2017-08-19 10:40 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
---- On Sat, 19 Aug 2017 04:36:58 -0400 Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote ----
> Adding a special style to every paragraph contained in a plain list is
> very easy to do. Just let me know if it happens to be the way to solve
> the issue at hand.
I think that is the correct solution. (Again, only one paragraph style for all list levels.)
I realized just now, I couldn't reproduce the problem because I was still using the filter! I just disabled the filter, regenerated the stylesheet, and the problem reappeared.
So here are steps to reproduce:
1. According to the org-manual[1], create an empty org odt document to export to ODT (creating org-specific styles). C-e o O to export and open.
2. In this document, edit "Text body" to add 0.5" of first-line indent.
3. Save the document.
4. Create a new org document including ~#+ODT_STYLES_FILE: "./ox-odt-generate-stylesheet.odt"~ (replacing with your path) and some list items.
5. C-e o O, and you'll see incorrect indentation for the list items.
hjh
[1] http://orgmode.org/manual/Applying-custom-styles.html#Applying-custom-styles
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ox-odt: List items contain body paragraphs, confusing styles
2017-08-19 10:40 ` James Harkins
@ 2017-08-19 11:55 ` Nicolas Goaziou
2017-08-20 6:10 ` James Harkins
0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2017-08-19 11:55 UTC (permalink / raw)
To: James Harkins; +Cc: emacs-orgmode
James Harkins <jamshark70@zoho.com> writes:
> ---- On Sat, 19 Aug 2017 04:36:58 -0400 Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote ----
>> Adding a special style to every paragraph contained in a plain list is
>> very easy to do. Just let me know if it happens to be the way to solve
>> the issue at hand.
>
> I think that is the correct solution. (Again, only one paragraph style for all list levels.)
>
> I realized just now, I couldn't reproduce the problem because I was still using the filter! I just disabled the filter, regenerated the stylesheet, and the problem reappeared.
>
> So here are steps to reproduce:
>
> 1. According to the org-manual[1], create an empty org odt document to export to ODT (creating org-specific styles). C-e o O to export and open.
>
> 2. In this document, edit "Text body" to add 0.5" of first-line indent.
>
> 3. Save the document.
>
> 4. Create a new org document including ~#+ODT_STYLES_FILE: "./ox-odt-generate-stylesheet.odt"~ (replacing with your path) and some list items.
>
> 5. C-e o O, and you'll see incorrect indentation for the list items.
OK. So could you tell me what should be the style name?
Do we need to add it to some style file somewhere? If so, what would be
its definition?
Regards,
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ox-odt: List items contain body paragraphs, confusing styles
2017-08-19 11:55 ` Nicolas Goaziou
@ 2017-08-20 6:10 ` James Harkins
2017-08-20 10:13 ` Nicolas Goaziou
0 siblings, 1 reply; 9+ messages in thread
From: James Harkins @ 2017-08-20 6:10 UTC (permalink / raw)
To: Nicolas Goaziou, emacs-orgmode
---- On Sat, 19 Aug 2017 07:55:00 -0400 Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote ----
> OK. So could you tell me what should be the style name?
>
> Do we need to add it to some style file somewhere? If so, what would be
> its definition?
OK, I just got the expected output by the following:
- Add "OrgListTextBody" to the stylesheet. I didn't try to do it directly in text (I don't know ODT XML that well). I created the style with that name in LO, setting the indent parameters to 0. That gave me this definition in styles.xml:
<style:style style:name="OrgListTextBody" style:family="paragraph" style:parent-style-name="Text_20_body">
<style:paragraph-properties fo:margin-left="0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false"/>
</style:style>
It's probably enough to specify only ~fo:text-indent="0in"~, but I didn't test that because I'm not sure how to write the modified styles.xml back into the ODT archive. (LO auto-generated all 4 parameters.)
- Then, use my filter to apply OrgListTextBody to the paragraphs contained within list items.
The resulting display in LO is correct.
hjh
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ox-odt: List items contain body paragraphs, confusing styles
2017-08-20 6:10 ` James Harkins
@ 2017-08-20 10:13 ` Nicolas Goaziou
2017-08-20 12:46 ` James Harkins
0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2017-08-20 10:13 UTC (permalink / raw)
To: James Harkins; +Cc: emacs-orgmode
Hello,
James Harkins <jamshark70@zoho.com> writes:
> OK, I just got the expected output by the following:
>
> - Add "OrgListTextBody" to the stylesheet. I didn't try to do it directly in text (I don't know ODT XML that well). I created the style with that name in LO, setting the indent parameters to 0. That gave me this definition in styles.xml:
>
> <style:style style:name="OrgListTextBody" style:family="paragraph" style:parent-style-name="Text_20_body">
> <style:paragraph-properties fo:margin-left="0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false"/>
> </style:style>
>
> It's probably enough to specify only ~fo:text-indent="0in"~, but I didn't test that because I'm not sure how to write the modified styles.xml back into the ODT archive. (LO auto-generated all 4 parameters.)
>
> - Then, use my filter to apply OrgListTextBody to the paragraphs contained within list items.
>
> The resulting display in LO is correct.
Out of curiosity, instead of creating a new style, wouldn't some
standard style be enough, e.g., "Text_20_body_20_indent"?
Also, what happens in the following cases
- ...
#+begin_quote
Quoted paragraph
#+end_quote
#+begin_center
Centered paragraph
#+end_center
Should the use "Quotations" and "OrgCenter", which inherit from
"Text_20_body", or some new style inheriting from the one dedicated to
text in plain lists?
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: ox-odt: List items contain body paragraphs, confusing styles
2017-08-20 10:13 ` Nicolas Goaziou
@ 2017-08-20 12:46 ` James Harkins
0 siblings, 0 replies; 9+ messages in thread
From: James Harkins @ 2017-08-20 12:46 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
On August 20, 2017 18:13:13 Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> Out of curiosity, instead of creating a new style, wouldn't some
> standard style be enough, e.g., "Text_20_body_20_indent"?
>
> Also, what happens in the following cases
>
> - ...
>
> #+begin_quote
> Quoted paragraph
> #+end_quote
>
> #+begin_center
> Centered paragraph
> #+end_center
>
> Should the use "Quotations" and "OrgCenter", which inherit from
> "Text_20_body", or some new style inheriting from the one dedicated to
> text in plain lists?
Interesting questions -- however, I'm leaving tomorrow for a week's
holiday. So I won't get to this for awhile.
I should also say: This is the first time I've needed the ODT exporter for
anything serious. So, I shouldn't be taken as any sort of authority on how
the styles "should" work. I'm reporting behavior that seemed odd to me and,
to the extent that I have time, I don't mind prowling around in the ODT
data structures to see what is going on inside. That's about the extent of
what I can do. I'm not affiliated with LibreOffice in any way... In fact, I
quite dread using it. TBH I prefer exporting to LaTeX, but it's a
humanities journal and they don't understand about superior technology :D
That said, I'm not sure why those cases would be challenging. In the normal
list item case, you have a list item node enclosing one or more paragraph
nodes. In the cases you mentioned, the list item node would contain a quote
block or centered block node. As I understand the exporter, the depth-first
traversal would encode the child nodes normally, and pass the encoded
result up to the list item parent. My observation of LO is that it tries to
merge properties from the list style and paragraph style, which it would do
if it's centered, block quote or whatever. So my guess is, do nothing
special for these cases. But that's a guess.
hjh
Sent with AquaMail for Android
http://www.aqua-mail.com
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-08-20 12:47 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-17 2:47 ox-odt: List items contain body paragraphs, confusing styles James Harkins
2017-08-17 14:33 ` Nicolas Goaziou
2017-08-18 3:27 ` James Harkins
2017-08-19 8:36 ` Nicolas Goaziou
2017-08-19 10:40 ` James Harkins
2017-08-19 11:55 ` Nicolas Goaziou
2017-08-20 6:10 ` James Harkins
2017-08-20 10:13 ` Nicolas Goaziou
2017-08-20 12:46 ` James Harkins
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).