|
1 | | -using Contentstack.Utils.Enums; |
| 1 | +using System; |
| 2 | +using Contentstack.Utils.Enums; |
2 | 3 | using Contentstack.Utils.Interfaces; |
3 | 4 |
|
4 | 5 | namespace Contentstack.Utils.Models |
@@ -85,69 +86,68 @@ public virtual string RenderMark(MarkType markType, string text) |
85 | 86 | return text; |
86 | 87 | } |
87 | 88 |
|
88 | | - public virtual string RenderNode(NodeType nodeType, Node node, NodeChildrenCallBack callBack) |
| 89 | + public virtual string RenderNode(string nodeType, Node node, NodeChildrenCallBack callBack) |
89 | 90 | { |
90 | 91 | string href = ""; |
91 | | - |
92 | 92 | switch (nodeType) |
93 | 93 | { |
94 | | - case NodeType.Paragraph: |
| 94 | + case "p": |
95 | 95 | return $"<p>{callBack(node.children)}</p>"; |
96 | | - case NodeType.Link: |
| 96 | + case "a": |
97 | 97 | if (node.attrs.ContainsKey("url")) |
98 | 98 | { |
99 | 99 | href = (string)node.attrs["url"]; |
100 | 100 | } |
101 | 101 | return $"<a href=\"{href}\">{callBack(node.children)}</a>"; |
102 | | - case NodeType.Image: |
| 102 | + case "img": |
103 | 103 | if (node.attrs.ContainsKey("url")) |
104 | 104 | { |
105 | 105 | href = (string)node.attrs["url"]; |
106 | 106 | } |
107 | 107 | return $"<img src=\"{href}\" />{callBack(node.children)}"; |
108 | | - case NodeType.Embed: |
| 108 | + case "embed": |
109 | 109 | if (node.attrs.ContainsKey("url")) |
110 | 110 | { |
111 | 111 | href = (string)node.attrs["url"]; |
112 | 112 | } |
113 | 113 | return $"<iframe src=\"{href}\">{callBack(node.children)}</iframe>"; |
114 | | - case NodeType.Heading_1: |
| 114 | + case "h1": |
115 | 115 | return $"<h1>{callBack(node.children)}</h1>"; |
116 | | - case NodeType.Heading_2: |
| 116 | + case "h2": |
117 | 117 | return $"<h2>{callBack(node.children)}</h2>"; |
118 | | - case NodeType.Heading_3: |
| 118 | + case "h3": |
119 | 119 | return $"<h3>{callBack(node.children)}</h3>"; |
120 | | - case NodeType.Heading_4: |
| 120 | + case "h4": |
121 | 121 | return $"<h4>{callBack(node.children)}</h4>"; |
122 | | - case NodeType.Heading_5: |
| 122 | + case "h5": |
123 | 123 | return $"<h5>{callBack(node.children)}</h5>"; |
124 | | - case NodeType.Heading_6: |
| 124 | + case "h6": |
125 | 125 | return $"<h6>{callBack(node.children)}</h6>"; |
126 | | - case NodeType.OrderList: |
| 126 | + case "ol": |
127 | 127 | return $"<ol>{callBack(node.children)}</ol>"; |
128 | | - case NodeType.UnOrderList: |
| 128 | + case "ul": |
129 | 129 | return $"<ul>{callBack(node.children)}</ul>"; |
130 | | - case NodeType.ListItem: |
| 130 | + case "li": |
131 | 131 | return $"<li>{callBack(node.children)}</li>"; |
132 | | - case NodeType.Hr: |
| 132 | + case "hr": |
133 | 133 | return $"<hr>"; |
134 | | - case NodeType.Table: |
| 134 | + case "table": |
135 | 135 | return $"<table>{callBack(node.children)}</table>"; |
136 | | - case NodeType.TableHeader: |
| 136 | + case "thead": |
137 | 137 | return $"<thead>{callBack(node.children)}</thead>"; |
138 | | - case NodeType.TableBody: |
| 138 | + case "tbody": |
139 | 139 | return $"<tbody>{callBack(node.children)}</tbody>"; |
140 | | - case NodeType.TableFooter: |
| 140 | + case "tfoot": |
141 | 141 | return $"<tfoot>{callBack(node.children)}</tfoot>"; |
142 | | - case NodeType.TableRow: |
| 142 | + case "tr": |
143 | 143 | return $"<tr>{callBack(node.children)}</tr>"; |
144 | | - case NodeType.TableHead: |
| 144 | + case "th": |
145 | 145 | return $"<th>{callBack(node.children)}</th>"; |
146 | | - case NodeType.TableData: |
| 146 | + case "td": |
147 | 147 | return $"<td>{callBack(node.children)}</td>"; |
148 | | - case NodeType.BlockQuote: |
| 148 | + case "blockquote": |
149 | 149 | return $"<blockquote>{callBack(node.children)}</blockquote>"; |
150 | | - case NodeType.Code: |
| 150 | + case "code": |
151 | 151 | return $"<code>{callBack(node.children)}</code>"; |
152 | 152 | default: |
153 | 153 | return callBack(node.children); |
|
0 commit comments