I'm working on the jiraissues macro in Confluence that will let you list issues from JIRA in a table in Confluence.
The problem I have is that I have no way of knowing if custom fields in the response are using the Default Text Renderer or the Wiki Style Renderer. The only safe assumption is to assume text and HTML escape the field values. Of course for fields that have been rendered this does not lead to the display you would hope for.
The issue data is retrieved from the XML 'API' e.g.
http://<server>/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?jqlQuery=<someQuery>&tempMax=1000&pager/start=0
Custom fields are returned like -
<customfields> <customfield id="customfield_10103" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea"> <customfieldname>ReleaseNote</customfieldname> <customfieldvalues> <customfieldvalue> &lt;ol&gt; &lt;li&gt;&lt;b&gt;bold&lt;/b&gt;&lt;/li&gt; &lt;li&gt;&lt;em&gt;italics&lt;/em&gt;&lt;/li&gt; &lt;li&gt;&lt;h3&gt;&lt;a name=&quot;headings&quot;&gt;&lt;/a&gt;headings&lt;/h3&gt;&lt;/li&gt; &lt;li&gt;^superscript&lt;/li&gt; &lt;li&gt; </customfieldvalue> </customfieldvalues> </customfield>
How do I discover the way JIRA is handling a custom field so I can do the same?
Community moderators have prevented the ability to post new answers.
Pretty sure this information is not available in any of the multifarious remote APIs... I guess you could add a new API to jira to return this information, or possibly add a new API that returns the values pre-escaped/formatted.
There are other possible renderers too apart from plain text and wiki markup, which are provided by plugins... although probably rarely enough used for you not to worry about them. But if that did concern you then the second option might be the best...?
In JIRA 5.0 land you could use new expand "renderedFields" which will give you fully rendered markup regardless of raw text (still available fields section)
E,g, <base url>/rest/api/latest/issue/<ISSUE-KEY>?expand=renderedFields would give you both raw and rendered values. AFAIK the type of rendered used is still not exposed, but if you want to handle just Text Rendered vs. Wiki Style Rendered, then you could just see if an opening HTML tag (usually <p>, <ul> or similar) is preceding field value in renderedFields section which would usually (i.e. always unless some other pluggable renderers are used) mean wiki renderer used there. For text renderer the value of given field in renderedFields section starts with pure text or \r if the first line was empty.
In versions prior to 5.0 you could use ?expand=html to achieve something similar.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks.
I'm a little reluctant to try and automatically recognise HTML from the start of the field. Erroneous matches could lead to be outputting something which is actually broken HTML and potentially break the display of the page completely in Confluence.
I guess I could run 'suspected' HTML through CyberNeko to ensure that it is valid but this is quite a bit of processing to be doing for potentially a large number of issues.
I think ultimately my best solution will be the inelegant approach of asking the macro user to decide what to do with individual fields. I'm discussing this over on the original JIRA issue.
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.