forked from smooth80/flutter-intellij
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHtmlBuilder.java
54 lines (43 loc) · 1.34 KB
/
HtmlBuilder.java
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* Copyright 2019 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
package io.flutter.utils;
public class HtmlBuilder {
public static String span(String style, String contents) {
return "<span style = \"" + style + "\"> " + contents + "</span>";
}
public static String span(String contents) {
return tag("span", contents);
}
public static String attr(String attribute, String value) {
return attribute + " = \"" + value + "\"";
}
public static String html(String... contents) {
return tag("html", join(contents));
}
public static String pre(String... contents) {
return tag("pre", join(contents));
}
public static String body(String... contents) {
return join(contents);
}
private static String join(String... contents) {
final StringBuilder sb = new StringBuilder();
for (String c : contents) {
sb.append(c);
sb.append('\n');
}
return sb.toString();
}
public static String tag(String tag, String contents) {
return "<" + tag + ">" + contents + "</" + tag + ">";
}
public static String div(String attrs, String contents) {
return "<div " + attrs + ">" + contents + "</div>";
}
public static String cls(String value) {
return attr("class", value);
}
}