Improve the model and capabilities for rich text in the API.

Review Request #5127 — Created Dec. 16, 2013 and submitted — Latest diff uploaded

Information

Review Board
master

Reviewers

Improve the model and capabilities for rich text in the API.

This updates the rich text support in the API to allow clients to force
text to be of a specific type. There's now a ?force-text-type= query
parameter that will cause all Markdown-aware fields to be formatted in
the requested way. If passing "plain", then any Markdown escaping will be
unescaped before being returned, and if "markdown", then any plain text
will be escaped.

This can later be expanded. For example, we may add "html" to do the
rendering server-side, further reducing the burden on the client.

In order to be consistent, this also replaces the rich_text field in
request and response paylods with text_type. For response payloads,
this will show "markdown" or "plain" (instead of True/False), or will
show the forced text mode (if/when a different mode is supported). For
requests, it will accept only "markdown" or "plain".

This is the first half of the change. The second half moves the
JavaScript codebase and templates to make use of the new API changes.

(NOTE: The current build of Review Board on this server has a breakage
causing base_comment.py to fail to render. The rest is reviewable.)

Unit tests pass.

Performed some requests, forcing Markdown text to plain, and plain to
Markdown.

In the case of Markdown-to-plain, any escaped content became unescaped.

For plain-to-Markdown, Markdown-unsafe characters became escaped.

Markdown-to-Markdown and plain-to-plain stayed as-is.