Unwrapping element inserts extra spaces

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
zuza
Posts: 20
Joined: Fri May 13, 2016 5:34 pm

Unwrapping element inserts extra spaces

Post by zuza » Fri Jan 03, 2020 5:08 pm

Hi,

I am trying to remove unnecessary <p> elements inside <li>, <entry>, etc. I have found the following happens for this example:

Code: Select all

<ul>
  <li><p>something</p></li>
  <li>
    <p>else</p>
  </li>
</ul>
  • In Text mode, using either Refactoring>Delete Element Tags (Alt+Shift+X) or Refactoring>Elements>Unwrap element with target element "li/p", the result will be:

    Code: Select all

    <ul>
      <li>something</li>
      <li>
          else
       </li>
     </ul>
    This results in extra space before and after "else", which is not equivalent with the original. With Format and Indent we can see the extra spaces:

    Code: Select all

    <ul>
      <li>something</li>
      <li> else </li>
    </ul>
  • Looking at the same example in Author mode, Refactoring>Elements>Unwrap element with target element "li/p" gives the same result:

    Code: Select all

    <ul>
       <li>something</li>
      <li>
         else
      </li>
    </ul>
  • However, using Refactoring>Delete Element Tags (Alt+Shift+X) in Author mode does what I expect it to do and the result is:

    Code: Select all

    <ul>
      <li>something</li>
      <li>else</li>
    </ul>
From my point of view, the first 2 are bugs and the result should always be the same as with (3) ( Refactoring>Delete Element Tags (Alt+Shift+X) in Author mode) .


Thank you.

Best regards,
Ozana

sorin_carbunaru
Site Admin
Posts: 303
Joined: Mon May 09, 2016 9:37 am

Re: Unwrapping element inserts extra spaces

Post by sorin_carbunaru » Mon Jan 06, 2020 11:02 am

Hello Ozana,

I can't say the behavior you mentioned as unwanted for you is a bug. For XML Refactoring, it's just the way the script is working with the XML text. And actually, when the paragraph is on a new line, there are quite a lot of spaces before and after it...

Regarding the Delete Element Tags in the Author page, it is just implemented differently, and it works with Author-page-related structures and information, which is more than the information we have with plain XML text.

Kind regards,
Sorin Carbunaru
oXygen XML

zuza
Posts: 20
Joined: Fri May 13, 2016 5:34 pm

Re: Unwrapping element inserts extra spaces

Post by zuza » Tue Jan 07, 2020 2:59 pm

Hello,

Thanks for your reply.

I tried switching on/off different options in Preference > Editor > XML to try to get from this:

Code: Select all

<li>
  <p>else</p>
 </li>
to this:

Code: Select all

<li><p>else</p></li>
when doing format+indent, so that I can then use the unwrap.

The only thing I managed to get is this:

Code: Select all

<li> <p>else</p> </li>
which has the extra spaces and will mess up the spacing in the published output if I do the unwrap.


Is there any option I have missed, or any steps I can follow to get what I need?

If not, is it possible to add an option in a future version of oXygen Editor? It's too much manual work as it is now.

Thank you.

Best regards,
Ozana

chrispitude
Posts: 176
Joined: Thu May 02, 2019 2:32 pm

Re: Unwrapping element inserts extra spaces

Post by chrispitude » Wed Jan 08, 2020 5:06 am

It seems like the text-mode unwrap operation should be enhanced to be schema-aware so it knows which elements are space-preserved and which are not.

sorin_carbunaru
Site Admin
Posts: 303
Joined: Mon May 09, 2016 9:37 am

Re: Unwrapping element inserts extra spaces

Post by sorin_carbunaru » Wed Jan 08, 2020 9:54 am

Hello,

Ozana, I am afraid there is no format & indent option for this. I created an improvement request for this (EXM-44839 - for reference purposes).

Chris, thank you for your intervention! I also created an issue to investigate what could be done at the XML refactoring operation level (EXM-44840).

All the best wishes,
Sorin C.

chrispitude
Posts: 176
Joined: Thu May 02, 2019 2:32 pm

Re: Unwrapping element inserts extra spaces

Post by chrispitude » Sun Jan 12, 2020 2:39 pm

Hi Sorin,

It was Radu that taught me about schema-awareness when we ran into a similar issue with extra blank lines showing up in the editor due to this effect. :)

Post Reply