shivawu/topcoder-greed — pull request #70 by vexorian (2013-11-16 23:11:27+00:00)
Title: Add HTML renderer. "grid" option.

Many TopCoder problems use String[] arguments to represent a grid. Like Problem FourBlocks in SRM 444. They usually have input presented in this format:

{"...1.",
".1..1"}

If one would have liked to see that in a statement generated by greed, maybe it would have been possible with complicated template usage. But there's the issue of whether you really want all String[] values to be formatted this way. An idea for a good compromise is to only do that formatting if all strings in the array have the same length. But that certainly needs code.

I also noticed that when there are strings in the value, the statement template doesn't convert the surrounding quote characters "" to &quot; so we needed a renderer. It is not a bad idea to have an html renderer to render the objects in greed that need to be rendered in an HTML file, and let it have some utilities. So far the ;html renderer has two uses:

* If the object is a text and it is surrounded by "", the quotes are stripped to HTML entities.
* If the object is a ParamValue, it does the same with string value, or the string values inside the array.
* In addition, if you render a ParamValue in using: in;html("grid") and if all the elements of the String[] value have equal length, it will render String[]s as a grid. This cannot be used in the default template though because multiple lines break the format of the example cases. But modifying (or not) the default statement template is a topic for another day.