Skip to content

Commit

Permalink
Enforce blank lines before code blocks.
Browse files Browse the repository at this point in the history
Helps a little with #66.
  • Loading branch information
Wilfred committed Nov 5, 2016
1 parent d7e7333 commit 2975da2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions racer.el
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,16 @@ the user to choose."
(setq current-section-lines nil))
;; If this is an opening ```
((s-starts-with-p "```" line)
;; Ensure we have a blank line in the previous text.
;; This is primarily a workaround for https://github.com/phildawes/racer/issues/646
;; but it's prettier too.
(funcall finish-text-section)
(when sections
;; Ensure the previous section ends with a blank line.
(let ((previous-section (car sections)))
(unless (s-ends-with-p "\n" previous-section)
(setf (car sections)
(concat previous-section "\n")))))
(setq in-code t))
;; Headings
((and (not in-code) (s-starts-with-p "# " line))
Expand Down
18 changes: 18 additions & 0 deletions test/racer-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,24 @@ struct Foo {}
" #[derive(Debug)]
struct Foo {}")))

(ert-deftest racer--propertize-docstring-code-newlines ()
"Ensure we always have a blank line before a code block."

(should
(equal
(racer--remove-properties
(racer--propertize-docstring "```bar()
```
foo
```
bar();
```"))
" bar();
foo
bar();")))

(ert-deftest racer--propertize-docstring-newlines ()
"Ensure we still handle links that have been split over two lines."
(should
Expand Down

0 comments on commit 2975da2

Please sign in to comment.