• 
      

    Make long-form text entries use markdown formatting.

    Review Request #4506 — Created Aug. 28, 2013 and submitted

    Information

    Review Board
    master

    Reviewers

    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.

    Description From Last Updated

    Col: 42 E231 missing whitespace after ','

    reviewbotreviewbot

    Why this change?

    chipx86chipx86

    This should probably go first, since it applies to all.

    chipx86chipx86

    Is this needed after your other fixes?

    chipx86chipx86
    reviewbot
    1. 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
      
      
    2. Show all issues
      Col: 42
       E231 missing whitespace after ','
      
    3. 
        
    reviewbot
    1. 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
      
      
    2. 
        
    chipx86
    1. 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.
    2. Show all issues
      Why this change?
    3. reviewboard/static/rb/css/reviews.less (Diff revision 1)
       
       
       
       
       
      Show all issues
      This should probably go first, since it applies to all.
    4. reviewboard/static/rb/css/reviews.less (Diff revision 1)
       
       
      Show all issues
      Is this needed after your other fixes?
      1. Nope! I just forgot to remove it.
    5. 
        
    david
    reviewbot
    1. 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
      
      
    2. 
        
    reviewbot
    1. 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
      
      
    2. 
        
    chipx86
    1. Ship It!
    2. 
        
    david
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to master (916e7c7).