At the time of writing (20th August, 2021), STVTallier::getTextResult() returns the HTML string generated by ::getHtmlResult(). This satisfies the immediate need that the user can copy+paste the result elsewhere but has a couple of issues:
- The output is unreadable
- The output relies on CSS that might not available on other wikis (including on the Wikipedias)
Making ::getTextResult() return wikitext address these issues.
Notes
- We might be able to flip the relationship between ::getTextResult() and ::getHtmlResult() – the latter could use the wikitext parser on the output of the former
- If we don't do the above, then both methods will share a lot of the same code – iteration over rounds and sorting of various sets of data. We should extract an interface for formatting the results of this particular tallier, e.g.
namespace MediaWiki\Extensions\SecurePoll\Talliers\Stv; interface StvFormatter { function formatPreamble( array $elected, array $eliminated ): string; function formatRoundsPreamble(): string; function formatRound( array $round ): string }
The wikitext and HTML formatters would be implemented in MediaWiki\Extensions\SecurePoll\Talliers\Stv\WikitextFormatter and HtmlFormatter, respectively. Both classes would have one responsibility and no collaborators so they would be relatively easy to test.