Forum Discussion

wsurguy's avatar
wsurguy
Adept
10 years ago

<br> being added to <table> in REST API message post

All,

  I am posting content via the REST API.  Lithium is adding a lot of <br/> tags inside a <p> tag to the start of the html that is being posted.

Is there something I can do to prevent this on the posting of conent via the REST API?

 

My original html has the following structure minus the content.

 

<table style="border-collapse: collapse; border: 1px solid #CCC;" border="0" cellspacing="0" cellpadding="0">
<br>
<tbody>
<br>
<tr>
<br>
<td style="background-color: #eee; width: 130px; border: 1px solid #CCC; vertical-align: top; font-weight: bold; padding: 8px 16px;"></td>
<br>
<td style="border: 1px solid #CCC; vertical-align: top; padding: 8px 16px;"></td>
<br>
</tr>
<br>
<tr>
<br>
<td style="background-color: #eee; width: 130px; border: 1px solid #CCC; vertical-align: top; font-weight: bold; padding: 8px 16px;"></td>
<br>
<td style="border: 1px solid #CCC; vertical-align: top; padding: 8px 16px;">
<br>
<p></p>
<br>
<p></p>
<br>
<p></p>
<br>
</td>
<br>
</tr>
<br>
<tr>
<br>
<td style="background-color: #eee; width: 130px; border: 1px solid #CCC; vertical-align: top; font-weight: bold; padding: 8px 16px;"></td>
<br>
<td style="border: 1px solid #CCC; vertical-align: top; padding: 8px 16px;">
<ol>
<br>
<li></li>
<br>
<li></strong><strong></strong>
<li><strong></strong></li>
<br>
</ol>
</td>
<br>
</tr>
<br>
<tr>
<br>
<td style="background-color: #eee; width: 130px; border: 1px solid #CCC; vertical-align: top; font-weight: bold; padding: 8px 16px;"></td>
<br>
<td style="border: 1px solid #CCC; vertical-align: top; padding: 8px 16px;"></td>
<br>
</tr>
<br>
<tr>
<br>
<td style="background-color: #eee; width: 130px; border: 1px solid #CCC; vertical-align: top; font-weight: bold; padding: 8px 16px;"></td>
<br>
<td style="border: 1px solid #CCC; vertical-align: top; padding: 8px 16px; color: #f00;"></td>
<br>
</tr>
<br>
</tbody>
<br>
</table>

 

 

After it is posted with the REST API it has the following structure.

 

<p><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /></p>
<table

style="border-collapse: collapse; border: 1px solid #CCC;" border="0" cellspacing="0" cellpadding="0">
<br>
<tbody>
<br>
<tr>
<br>
<td style="background-color: #eee; width: 130px; border: 1px solid #CCC; vertical-align: top; font-weight: bold; padding: 8px 16px;"></td>
<br>
<td style="border: 1px solid #CCC; vertical-align: top; padding: 8px 16px;"></td>
<br>
</tr>
<br>
<tr>
<br>
<td style="background-color: #eee; width: 130px; border: 1px solid #CCC; vertical-align: top; font-weight: bold; padding: 8px 16px;"></td>
<br>
<td style="border: 1px solid #CCC; vertical-align: top; padding: 8px 16px;">
<br>
<p></p>
<br>
<p></p>
<br>
<p></p>
<br>
</td>
<br>
</tr>
<br>
<tr>
<br>
<td style="background-color: #eee; width: 130px; border: 1px solid #CCC; vertical-align: top; font-weight: bold; padding: 8px 16px;"></td>
<br>
<td style="border: 1px solid #CCC; vertical-align: top; padding: 8px 16px;">
<ol>
<br>
<li></li>
<br>
<li></strong><strong></strong>
<li><strong></strong></li>
<br>
</ol>
</td>
<br>
</tr>
<br>
<tr>
<br>
<td style="background-color: #eee; width: 130px; border: 1px solid #CCC; vertical-align: top; font-weight: bold; padding: 8px 16px;"></td>
<br>
<td style="border: 1px solid #CCC; vertical-align: top; padding: 8px 16px;"></td>
<br>
</tr>
<br>
<tr>
<br>
<td style="background-color: #eee; width: 130px; border: 1px solid #CCC; vertical-align: top; font-weight: bold; padding: 8px 16px;"></td>
<br>
<td style="border: 1px solid #CCC; vertical-align: top; padding: 8px 16px; color: #f00;"></td>
<br>
</tr>
<br>
</tbody>
<br>
</table>

 

  • Did you try posting a plain text? This seems to be picked up from a RTE with a lot of formatting attached.
    • OlivierS's avatar
      OlivierS
      Lithium Alumni (Retired)

      wsurguy I wonder if you don't have any hidden characters / white space at the begining of your document ... Also, what's happening if you copy your text and paste it in your community (without using the API) ?

      • wsurguy's avatar
        wsurguy
        Adept

        Hi Olivier,

          I will double check the content again for anything at the beginning.

        If I take the content and enter it in the communitiy using the 'insert code' 

        and it works fine.  That is what is so odd.

         

        Wayne

    • wsurguy's avatar
      wsurguy
      Adept

      Thank you for your replay.

       

      This is content that is being migrated into Lithium from another knowledge board product.

      I am unable to strip out the html formatting and still maintain the proper presentation of

      the content.

       

      Wayne