question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to pass through custom tags?

See original GitHub issue

Hi, I’m attempting to render some Markdown documents that often include custom HTML tags, for example a tag like ac:structured-macro when a document is going to be published to a Confluence site.

With the simple, naïve, vanilla conversion that I’ve implemented so far, the custom tags are escaped in the output.

For example:

<ac:structured-macro ac:name="include"
                          ac:schema-version="1"
                          ac:macro-id="fbad7a5b-35fa-4d13-87ed-953ffd4dc456">
       <ac:parameter ac:name="">
         <ac:link><ri:page ri:content-title="mt" /></ac:link>
       </ac:parameter>
     </ac:structured-macro>

is being rendered as

<p>&lt;ac:structured-macro ac:name=&quot;include&quot;
ac:schema-version=&quot;1&quot;
ac:macro-id=&quot;fbad7a5b-35fa-4d13-87ed-953ffd4dc456&quot;&gt;
&lt;ac:parameter ac:name=&quot;&quot;&gt;
<a href="ac:link">ac:link</a>&lt;ri:page ri:content-title=&quot;mt&quot; /&gt;&lt;/ac:link&gt;
&lt;/ac:parameter&gt;
&lt;/ac:structured-macro&gt;</p>

I perused the docs, including the Javadocs, but didn’t see much that seemed directly relevant to this. (I did notice HtmlRenderer.Builder.escapeHtml() but I’m not calling that method, so the default, false should be in effect.)

Is there a way to do this?

Thank you!

(I’m using 0.15.0 on AdoptOpenJDK 13.0.2+8 on an AMD64 machine running MacOS 10.15.5.)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
aviflaxcommented, Jun 2, 2020

Thanks @robinst! I really appreciate your thorough and clear response.

It seems like the best course of action here, in terms of this library, is to wait and see if/when the spec is updated to account for this.

I can live with that, especially because I’ve worked out a workaround. I stumbled across section 4.6 of the spec, on HTML Blocks. While reading that it occurred to me that if I could wrap my “custom” namespaced XHTML tags with section tags, that would mean they’d be part of an HTML block, and the spec says:

An HTML block is a group of lines that is treated as raw HTML (and will not be escaped in HTML output).

So I thought that might work. My tests show that yes, the approach should work as I thought, but I encountered another complication: the end condition for variants 6 and 7 is that a “line is followed by a blank line.” Some of my content had blank lines, so I was stymied, but it was only temporary — I rigged up a way to remove blank lines from my content.

So I’m good, for now.

That said, I’d rather not have to remove blank lines, or worry about them at all, so I do hope that at some point I’ll be able to pass namespaced “custom” tags through without worrying about all this.

Feel free to close this issue if you’d like, the only reason I’m not doing so is because I thought maybe you’d want to keep it open as a reminder to keep an eye on that spec discussion.

Thank you!

1reaction
robinstcommented, Jun 2, 2020

Ah look at this, opened 14 days ago 😃: https://github.com/commonmark/commonmark-spec/pull/648

Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing data to custom tags - Adobe Support
You can create more flexible custom tags by passing parameters using attributes. Variables created within a custom tag are deleted when the ......
Read more >
How to pass through custom tags? · Issue #172 - GitHub
Hi, I'm attempting to render some Markdown documents that often include custom HTML tags, for example a tag like ac:structured-macro when a ...
Read more >
Passing a value to a custom tag - java - Stack Overflow
Here is the relevant code from the JSP. I'm using Struts 2 in my form, and I've marked the line where I'm calling...
Read more >
Custom tags - Tag Manager Help - Google Support
Click Tags and then New. · Click Tag Configuration and select Custom HTML. · Copy the tag code provided by the vendor and...
Read more >
How to use Custom HTML Tags in Google Tag Manager
Let's talk about custom HTML Tags. These Tags are commonly used in GTM for JavaScript where no Tag Templates are available.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found