Make long-form text entries use markdown formatting.
Review Request #4506 — Created Aug. 28, 2013 and submitted
Make long-form text entries use markdown formatting. There are several places in Review Board where users can enter long-form text: the review request description and testing done fields, comments, review body top and bottom, and change descriptions. Until now, all of these have just been preformatted text. This change integrates client-side markdown rendering for these fields. Because old text wasn't written with any feedback for what it would look like as markdown, this functionality is gated for only new entries in the database. A new boolean field called "rich_text" has been added to everything that could potentially be rendered. The evolutions ensure that all the old models have this set to false, and new ones will have it set to true. The way this works on the client side is that fields in the HTML are annotated with a data-rich-text attribute, which will be either true or false based on the rich_text field in the model. The various views which use these have been changed to call RB.formatText(), which will handle the hard work of formatting the text using marked.js if appropriate, as well as handle the special stuff we need to have it work with the inline editor. The style throughout is done to keep things visually pretty close to plain text, but with the nice benefits of emphasis, code samples, tables, lists, etc. One extreme example of this is that the font size is consistent throughout, even including headings. One thing which is left to do for this is to render the markdown text for use in HTML emails. I'm going to do that as a separate change because it's likely to be pretty big itself, and I'll need to do some research on rendering github-flavored markdown in python. This change is based loosely on Greg Wang's change from https://reviews.reviewboard.org/r/3892/
- Checked that old review requests/comments were not rendered with markdown. - Tested using markdown syntax in each of the different rich text boxes. - Tested that rendering occured for each box after page load, and that things re-rendered after the values were changed. - Verified that bugs and review requests were properly linkified. - Tried inserting HTML (especially <script> tags) and saw that it was escaped properly.
-
This is a review from Review Bot. Tool: Pyflakes Processed Files: reviewboard/reviews/views.py reviewboard/changedescs/evolutions/__init__.py reviewboard/settings.py reviewboard/reviews/models.py reviewboard/reviews/evolutions/__init__.py reviewboard/reviews/templatetags/reviewtags.py reviewboard/changedescs/models.py reviewboard/changedescs/evolutions/rich_text.py reviewboard/reviews/evolutions/rich_text.py Ignored Files: reviewboard/templates/reviews/review_reply.html reviewboard/static/rb/css/reviews.less reviewboard/static/rb/js/views/reviewBoxListView.js reviewboard/static/rb/js/views/reviewRequestEditorView.js reviewboard/templates/reviews/review_detail.html reviewboard/templates/reviews/review_request_box.html reviewboard/templates/reviews/review_header.html reviewboard/static/rb/js/views/reviewReplyEditorView.js reviewboard/static/rb/js/utils/textUtils.js reviewboard/static/rb/js/views/reviewBoxView.js
-
This isn't nearly as massive a change as I expected. Awesome. Only minor nits, but some food for thought for future updates. It would be pretty cool to optimistically have code highlighting for the language of a file being commented on, if commenting on code. We should also turn off line numbers for code, since they're likely to be very out of sync with the lines commented on, and that could be weird. I think in general, syntax-highlighted code could use some restyling from the markdown defaults a bit, but that can be later.
-
-
-
- Diff:
-
Revision 2 (+218 -38)
-
This is a review from Review Bot. Tool: PEP8 Style Checker Processed Files: reviewboard/reviews/views.py reviewboard/changedescs/evolutions/__init__.py reviewboard/settings.py reviewboard/reviews/models.py reviewboard/reviews/evolutions/__init__.py reviewboard/reviews/templatetags/reviewtags.py reviewboard/changedescs/models.py reviewboard/changedescs/evolutions/rich_text.py reviewboard/reviews/evolutions/rich_text.py Ignored Files: reviewboard/templates/reviews/review_reply.html reviewboard/static/rb/css/reviews.less reviewboard/static/rb/js/views/reviewBoxListView.js reviewboard/static/rb/js/views/reviewRequestEditorView.js reviewboard/templates/reviews/review_detail.html reviewboard/templates/reviews/review_request_box.html reviewboard/templates/reviews/review_header.html reviewboard/static/rb/js/views/reviewReplyEditorView.js reviewboard/static/rb/js/utils/textUtils.js reviewboard/static/rb/js/views/reviewBoxView.js
-
This is a review from Review Bot. Tool: Pyflakes Processed Files: reviewboard/reviews/views.py reviewboard/changedescs/evolutions/__init__.py reviewboard/settings.py reviewboard/reviews/models.py reviewboard/reviews/evolutions/__init__.py reviewboard/reviews/templatetags/reviewtags.py reviewboard/changedescs/models.py reviewboard/changedescs/evolutions/rich_text.py reviewboard/reviews/evolutions/rich_text.py Ignored Files: reviewboard/templates/reviews/review_reply.html reviewboard/static/rb/css/reviews.less reviewboard/static/rb/js/views/reviewBoxListView.js reviewboard/static/rb/js/views/reviewRequestEditorView.js reviewboard/templates/reviews/review_detail.html reviewboard/templates/reviews/review_request_box.html reviewboard/templates/reviews/review_header.html reviewboard/static/rb/js/views/reviewReplyEditorView.js reviewboard/static/rb/js/utils/textUtils.js reviewboard/static/rb/js/views/reviewBoxView.js