From 6883e6e084f17a96d3cbb6f84b69603533f4f2c2 Mon Sep 17 00:00:00 2001
From: Robert Speicher <rspeicher@gmail.com>
Date: Wed, 29 Apr 2015 17:53:32 -0400
Subject: [PATCH] Remove all references to `parse_tasks`

---
 app/views/projects/issues/show.html.haml      |   2 +-
 .../merge_requests/show/_mr_box.html.haml     |   2 +-
 lib/gitlab/markdown.rb                        |  31 +----
 spec/helpers/gitlab_markdown_helper_spec.rb   | 109 ------------------
 4 files changed, 5 insertions(+), 139 deletions(-)

diff --git a/app/views/projects/issues/show.html.haml b/app/views/projects/issues/show.html.haml
index 2d248c15f4f..c1438dd7183 100644
--- a/app/views/projects/issues/show.html.haml
+++ b/app/views/projects/issues/show.html.haml
@@ -34,7 +34,7 @@
         .description.js-task-list-container
           .wiki
             = preserve do
-              = markdown(@issue.description, parse_tasks: true)
+              = markdown(@issue.description)
           %textarea.hidden.js-task-list-field
             = @issue.description
 
diff --git a/app/views/projects/merge_requests/show/_mr_box.html.haml b/app/views/projects/merge_requests/show/_mr_box.html.haml
index 80cfeb1c88c..d5aab122b75 100644
--- a/app/views/projects/merge_requests/show/_mr_box.html.haml
+++ b/app/views/projects/merge_requests/show/_mr_box.html.haml
@@ -6,6 +6,6 @@
     .description.js-task-list-container
       .wiki
         = preserve do
-          = markdown(@merge_request.description, parse_tasks: true)
+          = markdown(@merge_request.description)
       %textarea.hidden.js-task-list-field
         = @merge_request.description
diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb
index bbae6ae3e74..63294aa54c0 100644
--- a/lib/gitlab/markdown.rb
+++ b/lib/gitlab/markdown.rb
@@ -32,9 +32,9 @@ module Gitlab
     # Public: Parse the provided text with GitLab-Flavored Markdown
     #
     # text         - the source text
-    # options      - parse_tasks          - render tasks
-    #              - xhtml                - output XHTML instead of HTML
-    #              - reference_only_path  - Use relative path for reference links
+    # options      - A Hash of options used to customize output (default: {}):
+    #                :xhtml               - output XHTML instead of HTML
+    #                :reference_only_path - Use relative path for reference links
     # project      - the project
     # html_options - extra options for the reference links as given to link_to
     def gfm_with_options(text, options = {}, project = @project, html_options = {})
@@ -46,7 +46,6 @@ module Gitlab
       text = text.dup.to_str
 
       options.reverse_merge!(
-        parse_tasks:          false,
         xhtml:                false,
         reference_only_path:  true
       )
@@ -77,10 +76,6 @@ module Gitlab
 
       text = result[:output].to_html(save_with: save_options)
 
-      # if options[:parse_tasks]
-      #   text = parse_tasks(text)
-      # end
-
       text.html_safe
     end
 
@@ -112,25 +107,5 @@ module Gitlab
         TaskList::Filter
       ]
     end
-
-    # Turn list items that start with "[ ]" into HTML checkbox inputs.
-    def parse_tasks(text)
-      li_tag = '<li class="task-list-item">'
-      unchecked_box = '<input type="checkbox" value="on" disabled />'
-      checked_box = unchecked_box.sub(/\/>$/, 'checked="checked" />')
-
-      # Regexp captures don't seem to work when +text+ is an
-      # ActiveSupport::SafeBuffer, hence the `String.new`
-      String.new(text).gsub(Taskable::TASK_PATTERN_HTML) do
-        checked = $LAST_MATCH_INFO[:checked].downcase == 'x'
-        p_tag = $LAST_MATCH_INFO[:p_tag]
-
-        if checked
-          "#{li_tag}#{p_tag}#{checked_box}"
-        else
-          "#{li_tag}#{p_tag}#{unchecked_box}"
-        end
-      end
-    end
   end
 end
diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb
index b6be82e4109..2f67879efdc 100644
--- a/spec/helpers/gitlab_markdown_helper_spec.rb
+++ b/spec/helpers/gitlab_markdown_helper_spec.rb
@@ -43,115 +43,6 @@ describe GitlabMarkdownHelper do
         expect(gfm(actual)).to match(expected)
       end
     end
-
-    context 'parse_tasks: true' do
-      before(:all) do
-        @source_text_asterisk = <<-EOT.strip_heredoc
-          * [ ] valid unchecked task
-          * [x] valid lowercase checked task
-          * [X] valid uppercase checked task
-              * [ ] valid unchecked nested task
-              * [x] valid checked nested task
-
-          [ ] not an unchecked task - no list item
-          [x] not a checked task - no list item
-
-          * [  ] not an unchecked task - too many spaces
-          * [x ] not a checked task - too many spaces
-          * [] not an unchecked task - no spaces
-          * Not a task [ ] - not at beginning
-        EOT
-
-        @source_text_dash = <<-EOT.strip_heredoc
-          - [ ] valid unchecked task
-          - [x] valid lowercase checked task
-          - [X] valid uppercase checked task
-              - [ ] valid unchecked nested task
-              - [x] valid checked nested task
-        EOT
-      end
-
-      it 'should render checkboxes at beginning of asterisk list items' do
-        rendered_text = markdown(@source_text_asterisk, parse_tasks: true)
-
-        expect(rendered_text).to match(/<input.*checkbox.*valid unchecked task/)
-        expect(rendered_text).to match(
-          /<input.*checkbox.*valid lowercase checked task/
-        )
-        expect(rendered_text).to match(
-          /<input.*checkbox.*valid uppercase checked task/
-        )
-      end
-
-      it 'should render checkboxes at beginning of dash list items' do
-        rendered_text = markdown(@source_text_dash, parse_tasks: true)
-
-        expect(rendered_text).to match(/<input.*checkbox.*valid unchecked task/)
-        expect(rendered_text).to match(
-          /<input.*checkbox.*valid lowercase checked task/
-        )
-        expect(rendered_text).to match(
-          /<input.*checkbox.*valid uppercase checked task/
-        )
-      end
-
-      it 'should render checkboxes for nested tasks' do
-        rendered_text = markdown(@source_text_asterisk, parse_tasks: true)
-
-        expect(rendered_text).to match(
-          /<input.*checkbox.*valid unchecked nested task/
-        )
-        expect(rendered_text).to match(
-          /<input.*checkbox.*valid checked nested task/
-        )
-      end
-
-      it 'should not be confused by whitespace before bullets' do
-        rendered_text_asterisk = markdown(@source_text_asterisk, parse_tasks: true)
-        rendered_text_dash = markdown(@source_text_dash, parse_tasks: true)
-
-        expect(rendered_text_asterisk).to match(
-          /<input.*checkbox.*valid unchecked nested task/
-        )
-        expect(rendered_text_asterisk).to match(
-          /<input.*checkbox.*valid checked nested task/
-        )
-        expect(rendered_text_dash).to match(
-          /<input.*checkbox.*valid unchecked nested task/
-        )
-        expect(rendered_text_dash).to match(
-          /<input.*checkbox.*valid checked nested task/
-        )
-      end
-
-      it 'should not render checkboxes outside of list items' do
-        rendered_text = markdown(@source_text_asterisk, parse_tasks: true)
-
-        expect(rendered_text).not_to match(
-          /<input.*checkbox.*not an unchecked task - no list item/
-        )
-        expect(rendered_text).not_to match(
-          /<input.*checkbox.*not a checked task - no list item/
-        )
-      end
-
-      it 'should not render checkboxes with invalid formatting' do
-        rendered_text = markdown(@source_text_asterisk, parse_tasks: true)
-
-        expect(rendered_text).not_to match(
-          /<input.*checkbox.*not an unchecked task - too many spaces/
-        )
-        expect(rendered_text).not_to match(
-          /<input.*checkbox.*not a checked task - too many spaces/
-        )
-        expect(rendered_text).not_to match(
-          /<input.*checkbox.*not an unchecked task - no spaces/
-        )
-        expect(rendered_text).not_to match(
-          /Not a task.*<input.*checkbox.*not at beginning/
-        )
-      end
-    end
   end
 
   describe '#link_to_gfm' do
-- 
GitLab