Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.8, 3.0.0-rc-2
-
None
-
Oracle Java 1.8.0_112, Windows 10 x64
Description
Trying to produce an HTML5 compliant !DOCTYPE before starting with the HTML-Elements. Without setting the private field 'state' to 2, the output does not show the yielded output.
def html = new groovy.xml.MarkupBuilder(new PrintWriter(System.out)) //html.state = 2 html.mkp.yieldUnescaped("<!DOCTYPE html>\n") html.h1("Header")
I suggest fixing this by changing the yield-Method to not check the state before doing the output, so that we see some output when the initial state is still 0:
void yield(String value, boolean escaping) { if (state == 1) { state = 2; this.nodeIsEmpty = false; out.print(">"); } // -- remove -- if (state == 2 || state == 3) { out.print(escaping ? escapeElementContent(value) : value); // -- remove -- } }