You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Jochen Eddelbuettel (JIRA)" <ji...@apache.org> on 2017/02/27 16:28:45 UTC

[jira] [Updated] (GROOVY-8100) MarkupBuilder cant yield before first tag

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

Jochen Eddelbuettel updated GROOVY-8100:
----------------------------------------
    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. 

{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}


  was:
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. 

{quote}
def html = new groovy.xml.MarkupBuilder(new PrintWriter(System.out))
//html.state = 2
html.mkp.yieldUnescaped("<!DOCTYPE html>\n")
html.h1("Header")
{quote}

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:

{quote}
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 -- }
}
{quote}



> 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
>         Environment: Oracle Java 1.8.0_112, Windows 10 x64
>            Reporter: Jochen Eddelbuettel
>            Priority: Minor
>
> 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
(v6.3.15#6346)