I want to add multiple excerpts to a page that I am generating in Python and writing via the REST API. I am beginning to feel that this is another feature that has been removed from Confluence when the V2 editor was introduced.
I am writhing the following:
h2. ADC_OFFSET_I_REG
h3. Register Overview
{excerpt:hidden=false|name=ADC_OFFSET_I_REG|atlassian-macro-output-type=BLOCK}
|Title |address|description |reset|
|ADC_OFFSET_I_REG|0x116| |0x00|
h3. Bitfield Descriptions
*Description of settings in register ADC_OFFSET_I_REG*
||*Setting* ||*Bits* ||*Mode* ||*Description* ||*Reset* ||
|ADC_OFFSET_I|7-0|RW|Programmable ADC offset|0x00|
{excerpt}
The excerpt macro is being stripped from the page (or at least the V2 editor is not displaying it.
I hope that this can be done since the alternative is to create 300+ pages containing individual tables? Any help would be appreciated.
Through trial an error I managed to find the solution to my problem so I thought i would share it for the rest of the community.
To read the page in structured format I used the following API call:
temp = wws.get_page_by_id(2106916966, expand="body.storage")
print(temp['body']['storage']['value'])
To turn the above page into the correct format I used the following content (excerpt code highlighted in bold:
<ac:structured-macro ac:name="excerpt" ac:schema-version="1" data-layout="default"><ac:parameter ac:name="name">ADC_OFFSET_I_REG</ac:parameter><ac:rich-text-body>
<h2>ADC_OFFSET_I_REG</h2>
<h3>Register Overview</h3>
<table data-layout="default">
<colgroup>
<col style="width: 180.0px;" />
<col style="width: 100.0px;" />
<col style="width: 300.0px;" />
<col style="width: 120.0px;" />
</colgroup>
<tbody><tr><th><p>Title</p></th>
<th><p>address</p></th>
<th><p>description</p></th>
<th><p>reset</p></th></tr>
<tr><td><p>ADC_OFFSET_I_REG</p></td>
<td><p>0x116</p></td>
<td><p>Offset value for I register</p></td>
<td><p>0x00</p></td></tr></tbody>
</table>
<p><strong>Description of settings in register ADC_OFFSET_I_REG</strong></p>
<table data-layout="default">
<colgroup>
<col style="width: 147.0px;" />
<col style="width: 48.0px;" />
<col style="width: 108.0px;" />
<col style="width: 363.0px;" />
<col style="width: 60.0px;" />
</colgroup>
<tbody>
<tr><th><p><strong>Setting</strong></p></th>
<th><p><strong>Bits</strong></p></th>
<th><p><strong>Mode</strong></p></th>
<th><p><strong>Description</strong></p></th>
<th><p><strong>Reset</strong></p></th></tr><tr><td><p>ADC_OFFSET_I</p></td>
<td><p>7-0</p></td>
<td><p>RW</p></td>
<td><p>Programmable ADC offset</p></td>
<td><p>0x00</p></td>
</tr>
</tbody></table>
</ac:rich-text-body></ac:structured-macro><p />
Please use the below answer
Use the Python wrapper below for reference
https://atlassian-python-api.readthedocs.io/confluence.html
Let me know if you have any queries
Thanks,
Pramodh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So is it correct that you can only add the macro in storage format, not in Wiki format. I will have to recode everything to output storage format and try it again. How do I get the body of the page in storage format so I can see how to encode it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Got it. Unfortunately I do not have enough information to get the page output in storage <xml?> format. What I get looks more like <html>:
<h2 id="ExcerptTestPage-ADC_OFFSET_I_REG">ADC_OFFSET_I_REG</h2>
<h3 id="ExcerptTestPage-RegisterOverview">Register Overview</h3>
<span class="conf-macro output-inline" data-hasbody="true" data-macro-name="excerpt" data-macro-id="9075f925-e326-477a-b974-a16e7263568f" data-layout="default" data-local-id="31287b1e-4b75-473a-800f-59b1a4069f75">
blah blah<p></p>
<p>blah di bla</p>
<div class="table-wrap">
<table data-layout="default" data-local-id="098aa3c8-5254-4bcb-bfc7-29d25d093801" class="confluenceTable">
<colgroup>
<col style="width: 170.0px;"/>
<col style="width: 170.0px;"/>
<col style="width: 170.0px;"/>
<col style="width: 170.0px;"/>
</colgroup>
<tbody>
<tr>
<td class="confluenceTd"><p>Title </p></td>
<td class="confluenceTd"><p>address</p></td>
<td class="confluenceTd"><p>description </p></td>
<td class="confluenceTd">
<p>reset</p></td>
</tr>
<tr>
<td class="confluenceTd"><p>ADC_OFFSET_I_REG</p></td>
<td class="confluenceTd"><p>0x116</p></td>
<td class="confluenceTd"><p> </p></td>
<td class="confluenceTd"><p>0x00</p></td>
</tr>
</tbody>
</table>
</div>
<h3 id="ExcerptTestPage-BitfieldDescriptions">Bitfield Descriptions</h3>
<p><strong>Description of settings in register ADC_OFFSET_I_REG</strong>
</p>
<div class="table-wrap">
<table data-layout="default" data-local-id="eb74d975-024a-437d-9625-db702bb35bd1" class="confluenceTable">
<colgroup>
<col style="width: 136.0px;"/>
<col style="width: 136.0px;"/>
<col style="width: 136.0px;"/>
<col style="width: 136.0px;"/>
<col style="width: 136.0px;"/>
</colgroup>
<tbody>
<tr>
<th class="confluenceTh"><p><strong>Setting</strong> </p>
</th>
<th class="confluenceTh"><p><strong>Bits</strong> </p></th>
<th class="confluenceTh"><p><strong>Mode</strong> </p></th>
<th class="confluenceTh"><p><strong>Description</strong> </p></th>
<th class="confluenceTh"><p><strong>Reset</strong> </p>
</th>
</tr>
<tr>
<td class="confluenceTd"><p>ADC_OFFSET_I</p></td>
<td class="confluenceTd"><p>7-0</p></td>
<td class="confluenceTd"><p>RW</p></td>
<td class="confluenceTd"><p>Programmable ADC offset</p></td>
<td class="confluenceTd"><p>0x00</p></td>
</tr>
</tbody>
</table>
</div>
<div class="table-wrap">
<table data-layout="default" data-local-id="37ff912a-4aea-4fd2-a047-4c16dbc7ec57" class="confluenceTable">
<colgroup>
<col style="width: 136.0px;"/>
<col style="width: 136.0px;"/>
<col style="width: 136.0px;"/>
<col style="width: 136.0px;"/>
<col style="width: 136.0px;"/>
</colgroup>
<tbody>
<tr>
<th class="confluenceTh"><p><strong>Setting</strong> </p></th>
<th class="confluenceTh"><p><strong>Bits</strong> </p></th>
<th class="confluenceTh"><p><strong>Mode</strong> </p></th>
<th class="confluenceTh"><p><strong>Description</strong> </p>
</th><th class="confluenceTh"><p><strong>Reset</strong> </p>
</th>
</tr>
<tr>
<td class="confluenceTd"><p>ADC_OFFSET_I</p></td>
<td class="confluenceTd"><p>7-0</p></td>
<td class="confluenceTd"><p>RW</p></td>
<td class="confluenceTd"><p>Programmable ADC offset</p></td>
<td class="confluenceTd">
<p>0x00</p></td>
</tr>
</tbody>
</table>
</div>
<p />
</span>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Luca,
I did solve this. I had to recode all of my creation scripts to generate Confluence storage format which is a strange proprietary format. I then created 2 functions to start and end the excerpt.
def start_excerpt(self, name):
"""Start an excerpt on a Confluence page
End Excerpt using the end_excerpt method
"""
assert not self.excerpt_active, "Cannot nest Excerpts"
self.excerpt_active = True
self.wr('<ac:structured-macro ac:name="excerpt" ac:schema-version="1" data-layout="default">')
self.wr('<ac:parameter ac:name="name">' + name + '</ac:parameter>')
self.wr('<ac:rich-text-body>')
def end_excerpt(self):
"""Finish the prviously started excerpt
"""
assert self.excerpt_active, "No active Excerpt to close"
self.wr("</ac:rich-text-body></ac:structured-macro>")
self.excerpt_active = False
where self.wr simply writes to a text file opened elsewhere in the class.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.