Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Markdown parser in Concordion 3.0.0 changes table text layout #316

Closed
nigelcharman opened this issue May 20, 2021 · 4 comments · Fixed by #317
Closed

Updated Markdown parser in Concordion 3.0.0 changes table text layout #316

nigelcharman opened this issue May 20, 2021 · 4 comments · Fixed by #317
Assignees

Comments

@nigelcharman
Copy link
Member

nigelcharman commented May 20, 2021

Report from a user:

Our test suite is using Markdown specifications. For logging purposes, our tests are using the special variable #TEXT to obtain the text of each row of a Concordion table. Prior to Concordion 3.0.0, individual cells in the row were delineated by \n. With the updated Markdown parser in Concordion 3.0.0 this is no longer the case and the cells are only delineated by whitespace. This affects our ability to parse the contents of the row. What workarounds can we use to restore this behaviour so our logging works correctly?

See attached test case for an example. This can be applied to the cubano-demo project. With the latest cubano-concordion:1.0.2 package, the test fails with IndexOutOfBoundsException. Change back to the Concordion 2.2.0 version using the build.gradle configuration below, and everything works fine.

TestMarkdownUpdates.java

package example.markdownparser;


import org.concordion.api.MultiValueResult;
import org.concordion.cubano.template.framework.CubanoDemoBrowserFixture;
import org.concordion.ext.storyboard.CardResult;
import org.concordion.ext.storyboard.StockCardImage;

public class TestMarkdownUpdates extends CubanoDemoBrowserFixture {

    public MultiValueResult parse(String data) throws Exception {
        System.out.println("-----------------");
        System.out.println(data);
        System.out.println("=-----------------=");

        System.out.println(data.split("\\n")[2].trim());
        System.out.println(data.split("\\n")[3].trim());
        System.out.println(data.split("\\n")[4].trim());

        MultiValueResult mvr = new MultiValueResult();
        mvr.put("id", 1);
        mvr.put("result", "Passed");

        getStoryboard().addSectionContainer(String.format("'%s' is '%s'", data.split("\\n")[2].trim(), data.split("\\n")[3].trim()));
        getStoryboard().addNotification("Hello", "Hello", StockCardImage.JSON, CardResult.SUCCESS);

        return mvr;
    }

}

TestMarkdownUpdates.md

# Heading

## [Test](-) 

Test ..... 

| [note][][An Id][]   |  Outcome     							  | Comment  | [Results][] |
| ------------------------------  | -------------- | ---------------------------------------- | -------- |
|                                 | Scenario1	 							  | True     | Passed      |
|                                 | Scenario2	 							  | False    | Passed      |
|                                 | Scenario3 								  | True     | Passed      |
|                                 | Scenario4                                | False    | Passed      |

[note]: - "#out = parse(#TEXT)"			
[An Id]: - "c:echo=#out.id"
[Results]: - "?=#out.result"
@nigelcharman
Copy link
Member Author

Could be fixed by #313

@nigelcharman
Copy link
Member Author

With Concordion 2.2.0, the table body is converted from Markdown to HTML as:

  <tbody>
    <tr>
      <td> </td>
      <td>Scenario1 </td>
      <td>True </td>
      <td>Passed </td>
    </tr>
    <tr>
      <td> </td>
      <td>Scenario2 </td>
      <td>False </td>
      <td>Passed </td>
    </tr>
    <tr>
      <td> </td>
      <td>Scenario3 </td>
      <td>True </td>
      <td>Passed </td>
    </tr>
    <tr>
      <td> </td>
      <td>Scenario4 </td>
      <td>False </td>
      <td>Passed </td>
    </tr>
  </tbody>

With Concordion 3.0.0, the table body is converted as:

<tbody>
<tr><td>                                 </td><td> Scenario1	 							  </td><td> True     </td><td> Passed      </td></tr>
<tr><td>                                 </td><td> Scenario2	 							  </td><td> False    </td><td> Passed      </td></tr>
<tr><td>                                 </td><td> Scenario3 								  </td><td> True     </td><td> Passed      </td></tr>
<tr><td>                                 </td><td> Scenario4                                </td><td> False    </td><td> Passed      </td></tr>
</tbody>

@nigelcharman nigelcharman self-assigned this May 20, 2021
@nigelcharman
Copy link
Member Author

Solving the issue as presented is complex but possible. See ac56c1f.

However, this is implementation specific behaviour that we don't want to create new specifications for. It would be better if a fix for #313 could be implemented. This would require some minor changes to the Concordion tests that are relying on the format of #TEXT for a table row.

@nigelcharman
Copy link
Member Author

The 8eab13e implementation for issue #313 would resolve this issue, with changes to the Markdown spec and the fixture class as follows:

public class TestMarkdownUpdates extends CubanoDemoBrowserFixture {

    public MultiValueResult parse(Map row) throws Exception {
        System.out.println("-----------------");
        System.out.println(row);
        System.out.println("=-----------------=");

        MultiValueResult mvr = new MultiValueResult();
        mvr.put("id", 1);
        mvr.put("result", "Passed");

        getStoryboard().addSectionContainer(String.format("'%s' is '%s'", row.get("Outcome"), row.get("Comment")));
        getStoryboard().addNotification("Hello", "Hello", StockCardImage.JSON, CardResult.SUCCESS);

        return mvr;
    }

}
# Heading

## [Test](-) 

Test1 ..... 

| [note][][An Id][] | Outcome   | Comment | [Results][] |
| ----------------- | --------- |-------- | ----------- |
|                   | Scenario1	| True    | Passed      |
|                   | Scenario2	| False   | Passed      |
|                   | Scenario3 | True    | Passed      |
|                   | Scenario4 | False   | Passed      |

[note]: - "#out = parse(#ROW)"			
[An Id]: - "c:echo=#out.id"
[Results]: - "?=#out.result"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant