Escape leading spaces and tabs in markdown processing.

Review Request #6200 — Created Aug. 5, 2014 and submitted

Information

Review Board
release-2.0.x
15b0600...

Reviewers

When escaping plain text as markdown, we need to handle leading spaces (four or
more) and leading tabs, as these blocks are considered to be code samples. This
meant that some basic syntax highlighting would be applied (often erroneously),
and that URLs were not properly linked.

After experimenting for quite some time with escaping the first tab or space, I
gave up on that approach. Markdown renderers do not handle escaped spaces well.
The solution that I settled on was to replace the first space with a
non-breaking space entity (for leading spaces), and prepend the line with an
nbsp (for leading tabs). This renders correctly while still allowing us to
escape and unescape.

  • Reproduced the bug (using --description="$(git log -n 1)" in rbt post) and
    saw that it indented the commit message without treating it as a code block.
  • Used the API with ?force-text-type=plain to verify unescaping of the nbsp
    entities.
  • Ran unit tests.
Description From Last Updated

Col: 1 W391 blank line at end of file

reviewbotreviewbot
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/markdown_utils.py
        reviewboard/reviews/tests.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/markdown_utils.py
        reviewboard/reviews/tests.py
    
    
  2. 
      
chipx86
  1. Can you also add unit tests for the unescaping?

  2. 
      
david
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/reviews/markdown_utils.py
        reviewboard/reviews/tests.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/reviews/markdown_utils.py
        reviewboard/reviews/tests.py
    
    
  2. reviewboard/reviews/tests.py (Diff revision 2)
     
     
    Show all issues
    Col: 1
     W391 blank line at end of file
    
  3. 
      
chipx86
  1. Ship It!

  2. 
      
david
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-2.0.x (f43b839)
Loading...