Hi. I want to generate the following HTML using karax.
    
    
    <div>
      This is description text.<br>
      I want to add link.<br>
      Example:<br>
      Nim install guide is <a 
href="https://nim-lang.org/install.html";>here</a>.<br>
    </div>
    
    
    Run

I think I came up with the following code.
    
    
    const description = """
    This is description text.
    I want to add link in text.
    Example:
    Nim install guide is <a href="https://nim-lang.org/install.html";>here</a>.
    """
    
    proc createDom(): VNode =
      result = buildHtml(tdiv):
        for line in description.spritLine:
          text line
          br()
    
    setRenderer createDom
    
    
    Run

But, anchor tags are escaped. I know it's safe and good.

This can be achieved with the following code. But, I don't like this. Is there 
any other good way?
    
    
    proc createDom(): VNode =
      result = buildHtml(tdiv):
        text "This is description text."
        br()
        text "I want to add link."
        br()
        text "Example:"
        br()
        text "Nim install guide is "
        a(href="https://nim-lang.org/install.html";):
          text "here"
    
    
    Run

Reply via email to