]> gerrit.simantics Code Review - simantics/platform.git/blob
62d95e1a37f6e6be659aec748e839d5d68e9165d
[simantics/platform.git] /
1 package org.simantics.scl.compiler.markdown.nodes;
2
3 import org.simantics.scl.compiler.markdown.internal.ExtensionNodeHandler;
4
5 public class ExtensionBlockNode extends Node {
6     String extension;
7     String content;
8     
9     public ExtensionBlockNode(String extension, String content) {
10         this.extension = extension;
11         this.content = content;
12     }
13     
14     @Override
15     public void processExtensionNodes(ExtensionNodeHandler handler) {
16         DocumentNode replacingNodes = handler.expandBlock(extension, content);
17         if(replacingNodes != null) {
18             if(replacingNodes.firstChild == null)
19                 remove();
20             else {
21                 for(Node child = replacingNodes.firstChild; child != null; child = child.next)
22                     child.parent = parent;
23                 if(prev == null)
24                     parent.firstChild = replacingNodes.firstChild;
25                 else {
26                     replacingNodes.firstChild.prev = prev;
27                     prev.next = replacingNodes.firstChild;
28                 }
29                 if(next == null)
30                     parent.lastChild = replacingNodes.lastChild;
31                 else {
32                     replacingNodes.lastChild.next = next;
33                     next.prev = replacingNodes.lastChild;
34                 }
35             }
36         }
37     }
38     
39     @Override
40     public void toHtml(StringBuilder b) {
41         b.append("::").append(extension).append('[').append(content).append(']');
42     }
43 }