-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathTextModifier.java
More file actions
33 lines (28 loc) · 1002 Bytes
/
TextModifier.java
File metadata and controls
33 lines (28 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package markup;
import java.util.List;
public abstract class TextModifier implements Block {
protected List<Block> contents;
protected final String markdownModifier;
protected final String HtmlStartModifier;
protected final String HtmlEndModifier;
protected TextModifier(List<Block> contents, String markdownModifier, String HtmlModifier) {
this.contents = contents;
this.markdownModifier = markdownModifier;
this.HtmlStartModifier = "<" + HtmlModifier + ">";
this.HtmlEndModifier = "</" + HtmlModifier + ">";
}
public final void toMarkdown(StringBuilder sb) {
sb.append(markdownModifier);
for (Block block : contents) {
block.toMarkdown(sb);
}
sb.append(markdownModifier);
}
public final void toHtml(StringBuilder sb) {
sb.append(HtmlStartModifier);
for (Block block : contents) {
block.toMarkdown(sb);
}
sb.append(HtmlEndModifier);
}
}