1 module hunt.markdown.node.Link;
2 
3 import hunt.markdown.node.Node;
4 import hunt.markdown.node.Visitor;
5 
6 /**
7  * A link with a destination and an optional title; the link text is in child nodes.
8  * <p>
9  * Example for an inline link in a CommonMark document:
10  * <pre><code>
11  * [link](/uri "title")
12  * </code></pre>
13  * <p>
14  * The corresponding Link node would look like this:
15  * <ul>
16  * <li>{@link #getDestination()} returns {@code "/uri"}
17  * <li>{@link #getTitle()} returns {@code "title"}
18  * <li>A {@link Text} child node with {@link Text#getLiteral() getLiteral} that returns {@code "link"}</li>
19  * </ul>
20  * <p>
21  * Note that the text in the link can contain inline formatting, so it could also contain an {@link Image} or
22  * {@link Emphasis}, etc.
23  */
24 class Link : Node {
25 
26     private string destination;
27     private string title;
28 
29     public this() {
30     }
31 
32     public this(string destination, string title) {
33         this.destination = destination;
34         this.title = title;
35     }
36 
37     override public void accept(Visitor visitor) {
38         visitor.visit(this);
39     }
40 
41     public string getDestination() {
42         return destination;
43     }
44 
45     public void setDestination(string destination) {
46         this.destination = destination;
47     }
48 
49     public string getTitle() {
50         return title;
51     }
52 
53     public void setTitle(string title) {
54         this.title = title;
55     }
56 
57     override protected string toStringAttributes() {
58         return "destination=" ~ destination ~ ", title=" ~ title;
59     }
60 }