[ 
https://issues.apache.org/jira/browse/GROOVY-8100?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniel Sun resolved GROOVY-8100.
--------------------------------
    Fix Version/s: 3.0.5
                   4.0.0-alpha-1
         Assignee: Daniel Sun
       Resolution: Fixed

The proposed PR has been merged. Thanks for your contribution!

> MarkupBuilder cant yield before first tag
> -----------------------------------------
>
>                 Key: GROOVY-8100
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8100
>             Project: Groovy
>          Issue Type: Bug
>          Components: XML Processing
>    Affects Versions: 2.4.8, 3.0.0-rc-2
>         Environment: Oracle Java 1.8.0_112, Windows 10 x64
>            Reporter: Jochen Eddelbuettel
>            Assignee: Daniel Sun
>            Priority: Major
>             Fix For: 4.0.0-alpha-1, 3.0.5
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> 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. 
> {code}
> def html = new groovy.xml.MarkupBuilder(new PrintWriter(System.out))
> //html.state = 2
> html.mkp.yieldUnescaped("<!DOCTYPE html>\n")
> html.h1("Header")
> {code}
> 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:
> {code}
> 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 -- }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to