I am attempting to create a user macro that generally mimics Confluence's "include Excerpt" macro. I am having trouble actually parsing the content to only extract the content within the Excerpt macro. What I've learned: fetching the body.view content allows me to get all the required content (i.e. images, macros, etc.) and body.storage allows me to understand where the content in the macro ends. I've also tried using the rest api to get the content of the macro, but this only returns the storage format of the macro body. Is there any insight into how the confluence Include Excerpt macro works to make this a bit simpler for me? For additional context - the functionality that I am looking to add to the base Include Excerpt macro is: 1) allow content to be able to pull from specific versions of the page 2) allow multiple instances of the macro on one page. These two pieces are not the issue however, I can get almost all of this functioning, I am just missing the piece of selecting the Excerpt content. Thank you!
Hi @Troy S
No sure if I fully understand "I am just missing the piece of selecting the Excerpt content" but for me it would like parsing body.storage and looking what is inside the <ac:macro ac:name="excerpt">.. to be more specific the content is inside those tags
Example:
<ac:macro ac:name="excerpt">
<ac:rich-text-body>
<p>Content here... </p>
</ac:rich-text-body>
</ac:macro>
Pulling from specific version?
Yes it should be same just you grab older version of a page. There is a API request for that
GET /rest/api/content/{contentId}?version={versionNumber}
Thank you Mirek for your response. The issue is that this does not cover all of the possible content within the macro. In the past I have used the method you pointed out here, however, when there are other sorts of content like images and other macros for example, they are not included. I believe the main way to get around this would be through the Post method that allows conversions from the storage format to the view format. This is not an option for me due to security restrictions on the company's network. In the time that I've posted and you've responded I've tried many different methods, and one interesting thing I've come to notice is: I pull the response from the server, then parse the html using a DomParser, I am able to select the content using querySelectorAll() function. After running a querySelectorAll() to search for the excerpt content a closing </span> tag is ADDED by the function. This causes me to run into an issue where only the first line of content is captured by the macro. My next step is to build my on parsing method but there seems like there should be an easier way to go about these problems. Thank you!
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.