         else if input.slice(0,3) == '%md'
             # a markdown editor
             editor = 'md'
-            to_html   = (code) -> misc_page.markdown_to_html(code).s
+            to_html   = (code) -> misc_page.markdown_to_html(code).s.trim()
             from_html = to_markdown
         else
             editor = undefined

        input = cell_start_template.clone()
        if not @readonly
            input.addClass('sagews-input-live')
            input.click () =>
                f = () =>
                    @insert_new_cell(mark.find().from.line)
                if IS_MOBILE
                    # It is way too easy to accidentally click on the insert new cell line on mobile.
                    bootbox.confirm "Create new cell?", (result) =>

their 900 clients in parallel.

###



CLICK_TO_EDIT = "(click to edit)"

# seconds to wait for synchronized doc editing session, before reporting an error.
# Don't make this too short, since when we open a link to a file in a project that
