public override string toHtml(capex.text.RichTextDocumentReferenceResolver refs) { string reftitle = null; string href = null; if (cape.String.isEmpty(text) == false) { reftitle = text; } if (cape.String.isEmpty(reftitle)) { if (refs != null) { reftitle = refs.getReferenceTitle(reference); } else { reftitle = reference; } } if (refs != null) { href = refs.getReferenceHref(reference); } else { href = reference; } if (cape.String.isEmpty(href)) { return(""); } if (cape.String.isEmpty(reftitle)) { reftitle = href; } return("<p class=\"reference\"><a href=\"" + capex.text.HTMLString.sanitize(href) + "\">" + capex.text.HTMLString.sanitize(reftitle) + "</a></p>\n"); }
public override string toHtml(capex.text.RichTextDocumentReferenceResolver refs) { var sb = new cape.StringBuilder(); var tag = "p"; if (heading > 0) { tag = "h" + cape.String.forInteger(heading); } sb.append("<"); sb.append(tag); sb.append(">"); if (segments != null) { var n = 0; var m = segments.Count; for (n = 0; n < m; n++) { var sg = segments[n]; if (sg != null) { var aOpen = false; var text = sg.getText(); var link = sg.getLink(); if (cape.String.isEmpty(link) == false) { if (sg.getIsInline()) { sb.append("<img src=\"" + capex.text.HTMLString.sanitize(link) + "\" />"); } else { var targetblank = ""; if (sg.getLinkPopup()) { targetblank = " target=\"_blank\""; } sb.append("<a" + targetblank + " class=\"urlLink\" href=\"" + capex.text.HTMLString.sanitize(link) + "\">"); aOpen = true; } } if (cape.String.isEmpty(sg.getReference()) == false) { var @ref = sg.getReference(); string href = null; if (refs != null) { href = refs.getReferenceHref(@ref); if (cape.String.isEmpty(text)) { text = refs.getReferenceTitle(@ref); } } if (cape.String.isEmpty(href) == false) { if (cape.String.isEmpty(text)) { text = @ref; } sb.append("<a class=\"referenceLink\" href=\"" + capex.text.HTMLString.sanitize(href) + "\">"); aOpen = true; } } var span = false; if (sg.getBold() || sg.getItalic() || sg.getUnderline() || cape.String.isEmpty(sg.getColor()) == false) { span = true; sb.append("<span style=\""); if (sg.getBold()) { sb.append(" font-weight: bold;"); } if (sg.getItalic()) { sb.append(" font-style: italic;"); } if (sg.getUnderline()) { sb.append(" text-decoration: underline;"); } if (cape.String.isEmpty(sg.getColor()) == false) { sb.append(" color: " + capex.text.HTMLString.sanitize(sg.getColor()) + ""); } sb.append("\">"); } if (sg.getIsInline() == false) { sb.append(capex.text.HTMLString.sanitize(text)); } if (span) { sb.append("</span>"); } if (aOpen) { sb.append("</a>"); } } } } sb.append("</" + tag + ">"); return(sb.toString()); }