Customising generated html tags

Roger Ragulan Rajaratnam's Avatar

Roger Ragulan Rajaratnam

14 Mar, 2014 08:18 PM

Hey,

I was wondering if it would be possible to add an option to customise the html tags that get generated by Marked. I was working with confluence at the moment and it uses the following tags to wrap code blockages:


true/ac:parameter xml/ac:parameter true/ac:parameter ac:plain-text-body<![CDATA[This is my code]]>/ac:plain-text-body /ac:structured-macro

Marked currently generates:

This is my code

The content between he tags should not be html encoded as it is wrapped in a CDATA block.

  1. 1 Posted by Roger Ragulan R... on 14 Mar, 2014 08:21 PM

    Roger Ragulan Rajaratnam's Avatar

    Here is the confluence snippet again, it looks messed up above.

    <ac:structured-macro ac:name="code">
      <ac:parameter ac:name="linenumbers">true</ac:parameter>
      <ac:parameter ac:name="language">xml</ac:parameter>
      <ac:parameter ac:name="collapse">true</ac:parameter>
      <ac:plain-text-body><![CDATA[This is my code]]></ac:plain-text-body>
    </ac:structured-macro>
    
  2. Support Staff 2 Posted by Brett on 14 Mar, 2014 08:38 PM

    Brett's Avatar

    It's entirely possible to use a custom processor that produces the code
    you're looking for, but I have no knowledge of Confluence or any related
    processing. What you see by default is MultiMarkdown output, and it's
    not configurable. It would be up to you to find a command-line processor
    to plug in.

    -Brett

  3. 3 Posted by Roger Ragulan R... on 14 Mar, 2014 09:26 PM

    Roger Ragulan Rajaratnam's Avatar

    Here is an example of what I am trying to achieve, lets say I have the following code block:

    {
        key: "value"
    }
    

    it produces this output:

    <pre><code class="json">{
        key: &quot;value&quot;
    }</code></pre>
    

    What I would like to do is produce this instead:

    <ac:structured-macro ac:name="code">
        <ac:parameter ac:name="linenumbers">true</ac:parameter>
        <ac:parameter ac:name="language">xml</ac:parameter>
        <ac:parameter ac:name="collapse">true</ac:parameter>
        <ac:plain-text-body><![CDATA[
            {
                key: "value"
            }
        ]]></ac:plain-text-body>
    </ac:structured-macro>
    

    Is a custom processor the best way to go for that?

  4. Support Staff 4 Posted by Brett on 14 Mar, 2014 11:25 PM

    Brett's Avatar

    It's the only way to go. How does this markup usually get generated? Do
    you know of anything that creates it from Markdown?

  5. 5 Posted by Roger Ragulan R... on 14 Mar, 2014 11:41 PM

    Roger Ragulan Rajaratnam's Avatar

    I think confluence uses a java markdown parser, I'll come back to you on which one specifically.

    The way I am using it is, I general the html documents outside of confluence and then add the html to confluence via a web UI. So that's why I wanted to know if Marked could be adapted to do the above.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac