Keep the text alignment while using xhtml

Bug #1361165 reported by Mathieu Leplatre on 2014-08-25
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Appy
Undecided
Gaëtan Delannay

Bug Description

As described in blueprint https://blueprints.launchpad.net/appy/+spec/pod-add-text-align-xhtml-support, POD does not keep the paragraph alignment (justify, center, ...) when importing XHTML

Hi Mathieu,

I suppose you would like the "xhtml" function to be able to analyze the CSS property "text-align" in "style" tags.
Indeed, pod does not support this for the moment. Analyzing CSS within style tags is not difficult. What is tricky is that in ODF, any style-related information must be stored in a new style definition. So, for every new combination of CSS properties used in style tags, a new style must dynamically be created in the resulting odt file. This is a headache (to my knowlegde).

In the meanwhile, what you could do (if relevant in your specific case of course) is to use style mappings. Recently, I have added the possibility to implement complex style mappings that can contain CSS attributes.

Let's take an example. If you want to get right-aligned and justified paragraphs in your odt result, define 2 paragraph styles in it, ie named "justified" and "right".

Then, define a styles mapping like that (the syntax is explained in appy/pod/styles_manager.py, method "checkStylesMapping"), either on the global renderer, either as a parameter of a given call to the xhtml function:

stylesMapping={'p[text-align=justify]': 'justified', 'p[text-align=right]': 'right'}

Cheers
G

Hi Gaetan,

Thank you very much for this very detailed response!

Actually, this helps me a lot for https://bugs.launchpad.net/appy/+bug/1361166 !

But for paragraphs, I thought it could "inherit" the style of the template.

In my situation, I have a block of text, whose paragraph style is justified.
When I run "do text from xhtml(...)", it becomes left aligned.
Maybe I should look for default style instead of mapping. I'll read the code...

Thanks a lot anyway !

PS: look what we already achieve, appypod is fantastic :)
http://rando.ecrins-parcnational.fr/fr/files/api/trek/trek-903492.pdf

Hi Mathieu,
I have committed a change to appy.pod (xhtml function) that supports:
- CSS attributes text-align on "p", "div" and "td" tags;
- CSS attributes "margin-left", "margin-right", "margin-top" and "margin-bottom" on "p" and "div" tags.
Cheers,
Gaëtan

Changed in appy:
status: New → Fix Committed
milestone: none → 0.9.3

Hi Gaetan!
Great, thank you very much!
I'll ping the guys at Makina Corpus to let them know :) They'll like it!
Congratz for your work on Appy!
Mathieu

You're welcome :)

Changed in appy:
status: Fix Committed → Fix Released
assignee: nobody → Gaëtan Delannay (gaetan-delannay)
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers