diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-05-08 09:39:48 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-05-08 09:39:48 +0000 |
commit | 6c32abc5f7f090d4932054e5cc1ff0594edd5ff1 (patch) | |
tree | a0479bec69170a6052abf806eee3faeb64aeb861 /lib | |
parent | 757084f715ffc06f563bdf971302995a3b181c06 (diff) | |
parent | da8d6feb2c9a273a32b072fbed30f958435c2eeb (diff) | |
download | gitlab-ce-6c32abc5f7f090d4932054e5cc1ff0594edd5ff1.tar.gz |
Merge branch 'rs-task_list' into 'master'
Use task_list gem for task lists
Task Lists can now be used in comments, and they'll render in previews. :clap:
Closes internal https://dev.gitlab.org/gitlab/gitlabhq/issues/2271
See merge request !599
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/markdown.rb | 36 | ||||
-rw-r--r-- | lib/gitlab/markdown/table_of_contents_filter.rb | 2 | ||||
-rw-r--r-- | lib/tasks/jasmine.rake | 12 |
3 files changed, 20 insertions, 30 deletions
diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb index 8348e28d0f5..63294aa54c0 100644 --- a/lib/gitlab/markdown.rb +++ b/lib/gitlab/markdown.rb @@ -1,4 +1,5 @@ require 'html/pipeline' +require 'task_list/filter' module Gitlab # Custom parser for GitLab-flavored Markdown @@ -31,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 = {}) @@ -45,7 +46,6 @@ module Gitlab text = text.dup.to_str options.reverse_merge!( - parse_tasks: false, xhtml: false, reference_only_path: true ) @@ -76,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 @@ -106,28 +102,10 @@ module Gitlab Gitlab::Markdown::SnippetReferenceFilter, Gitlab::Markdown::CommitRangeReferenceFilter, Gitlab::Markdown::CommitReferenceFilter, - Gitlab::Markdown::LabelReferenceFilter - ] - end + Gitlab::Markdown::LabelReferenceFilter, - # 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 + TaskList::Filter + ] end end end diff --git a/lib/gitlab/markdown/table_of_contents_filter.rb b/lib/gitlab/markdown/table_of_contents_filter.rb index c97612dafb8..38887c9778c 100644 --- a/lib/gitlab/markdown/table_of_contents_filter.rb +++ b/lib/gitlab/markdown/table_of_contents_filter.rb @@ -31,7 +31,7 @@ module Gitlab id = text.downcase id.gsub!(PUNCTUATION_REGEXP, '') # remove punctuation id.gsub!(' ', '-') # replace spaces with dash - id.squeeze!(' -') # replace multiple spaces or dashes with one + id.squeeze!('-') # replace multiple dashes with one uniq = (headers[id] > 0) ? "-#{headers[id]}" : '' headers[id] += 1 diff --git a/lib/tasks/jasmine.rake b/lib/tasks/jasmine.rake new file mode 100644 index 00000000000..9e2cceffa19 --- /dev/null +++ b/lib/tasks/jasmine.rake @@ -0,0 +1,12 @@ +# Since we no longer explicitly require the 'jasmine' gem, we lost the +# `jasmine:ci` task used by GitLab CI jobs. +# +# This provides a simple alias to run the `spec:javascript` task from the +# 'jasmine-rails' gem. +task jasmine: ['jasmine:ci'] + +namespace :jasmine do + task :ci do + Rake::Task['spec:javascript'].invoke + end +end |