Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Formatting html table via user macro

Akeles
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 11, 2011

I tried to insert a user macro for a table via html.

<table border="1" width="400">
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table>

However, when the width setting is not rendered and the class confluencetable is appended as below.

<table class="confluenceTable">
  <tbody><tr>
    <th class="confluenceTh">Month</th>
    <th class="confluenceTh">Savings</th>
  </tr>
  <tr>
    <td class="confluenceTd">January</td>
    <td class="confluenceTd">$100</td>
  </tr>
  <tr>
    <td class="confluenceTd">February</td>
    <td class="confluenceTd">$80</td>
  </tr>
</tbody></table>

Is there any way to get around this? Thanks in advance.

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
December 11, 2011

Why not add a class to the table or wrap it in a div e.g.

<style>
  #com-atlassian-confluence table.savings { width: 400px; }
</style>

<table class="savings">
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table>

or

<style>
  #com-atlassian-confluence .savings table { width:400px; }
</style>

<div class="savings">
  <table>
    <tr>
      <th>Month</th>
      <th>Savings</th>
    </tr>
    <tr>
      <td>January</td>
      <td>$100</td>
    </tr>
    <tr>
      <td>February</td>
      <td>$80</td>
    </tr>
  </table>
</div>

Akeles
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 11, 2011

Hi David,

Yes, it works. Thanks :)

0 votes
Jim Bethancourt
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 18, 2014

The suggestion to inject styling provided at https://confluence.atlassian.com/display/CONFKB/HTML+table+in+User+Macro+not+Respecting+Inline+Style may help as well.

0 votes
B_ Normann P_ Nielsen
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 16, 2013

Excellent - I have actually mangled a bit with tables, and Your solution was needed for my box at http://www.mos-eisley.dk/display/it/mos-box

0 votes
NielsJ
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 11, 2011

Hi Huasoon,

could you please explain in more detail what you want to do? I am not sure about what you mean... Does Confluence do some magic transformation of you macro's HTML code?

Regards,
Niels

Akeles
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 11, 2011

Hi Niels,

Thanks for replying. I wanted to render some customized content with a table using a user macro instead of the user having to create the table using the wiki markup. Another reason is also because I wanted to formatted the width of the table which the editor is unable to do so.

The codes I provided on top demonstrates that Confluence rendering engine will ignore the attributes of the <table> tag and transform the output as in the 2nd set of code.

So I am wondering anyone experienced this and how to set the attributes (e.g. width) of the table. I did further testing and found out that the class is not filtered. I guess it is forcing people to use css instead of html to define the attributes of the table.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events