add solutions for hw7 (markup) and tests
Some checks failed
Fast Reverse Tests / test (push) Failing after 17s
Markup Tests / test (push) Failing after 13s
Reverse Tests / test (push) Failing after 13s
Sum Tests / test (push) Failing after 13s
Word Stat Tests / test (push) Failing after 13s
Word Stat++ Tests / test (push) Failing after 13s
Some checks failed
Fast Reverse Tests / test (push) Failing after 17s
Markup Tests / test (push) Failing after 13s
Reverse Tests / test (push) Failing after 13s
Sum Tests / test (push) Failing after 13s
Word Stat Tests / test (push) Failing after 13s
Word Stat++ Tests / test (push) Failing after 13s
This commit is contained in:
35
java/markup/AbstractMarkup.java
Normal file
35
java/markup/AbstractMarkup.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package markup;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractMarkup implements MarkupElement {
|
||||
protected final List<MarkupElement> elements;
|
||||
|
||||
public AbstractMarkup(List<MarkupElement> elements) {
|
||||
this.elements = elements;
|
||||
}
|
||||
|
||||
protected void toMarkdown(StringBuilder sb, String delimiter) {
|
||||
sb.append(delimiter);
|
||||
for (MarkupElement element : elements) {
|
||||
element.toMarkdown(sb);
|
||||
}
|
||||
sb.append(delimiter);
|
||||
}
|
||||
|
||||
protected void toHtml(StringBuilder sb, String tag) {
|
||||
sb.append("<").append(tag).append(">");
|
||||
for (MarkupElement element : elements) {
|
||||
element.toHtml(sb);
|
||||
}
|
||||
sb.append("</").append(tag).append(">");
|
||||
}
|
||||
|
||||
protected void toTex(StringBuilder sb, String command) {
|
||||
sb.append(command).append("{");
|
||||
for (MarkupElement element : elements) {
|
||||
element.toTex(sb);
|
||||
}
|
||||
sb.append("}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user