Commit 71b1a2c7 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'rs-issue-1645' into 'master'

Use task_list fork to fix list items in notes

Closes #1645

See https://github.com/github/task_list/pull/60

See merge request !680
parents 9fe8c74d 8ee38208
...@@ -94,7 +94,7 @@ gem "seed-fu" ...@@ -94,7 +94,7 @@ gem "seed-fu"
# Markdown and HTML processing # Markdown and HTML processing
gem 'html-pipeline', '~> 1.11.0' gem 'html-pipeline', '~> 1.11.0'
gem 'task_list', '~> 1.0.0', require: 'task_list/railtie' gem 'task_list', '1.0.2', require: 'task_list/railtie'
gem 'github-markup' gem 'github-markup'
gem 'redcarpet', '~> 3.2.3' gem 'redcarpet', '~> 3.2.3'
gem 'RedCloth' gem 'RedCloth'
......
...@@ -338,7 +338,7 @@ GEM ...@@ -338,7 +338,7 @@ GEM
method_source (0.8.2) method_source (0.8.2)
mime-types (1.25.1) mime-types (1.25.1)
mimemagic (0.3.0) mimemagic (0.3.0)
mini_portile (0.6.1) mini_portile (0.6.2)
minitest (5.3.5) minitest (5.3.5)
mousetrap-rails (1.4.6) mousetrap-rails (1.4.6)
multi_json (1.10.1) multi_json (1.10.1)
...@@ -350,7 +350,7 @@ GEM ...@@ -350,7 +350,7 @@ GEM
net-ssh (>= 2.6.5) net-ssh (>= 2.6.5)
net-ssh (2.8.0) net-ssh (2.8.0)
newrelic_rpm (3.9.4.245) newrelic_rpm (3.9.4.245)
nokogiri (1.6.5) nokogiri (1.6.6.2)
mini_portile (~> 0.6.0) mini_portile (~> 0.6.0)
nprogress-rails (0.1.2.3) nprogress-rails (0.1.2.3)
oauth (0.4.7) oauth (0.4.7)
...@@ -802,7 +802,7 @@ DEPENDENCIES ...@@ -802,7 +802,7 @@ DEPENDENCIES
spring-commands-spinach (= 1.0.0) spring-commands-spinach (= 1.0.0)
stamp stamp
state_machine state_machine
task_list (~> 1.0.0) task_list (= 1.0.2)
test_after_commit test_after_commit
thin thin
tinder (~> 1.9.2) tinder (~> 1.9.2)
......
...@@ -79,11 +79,11 @@ ul.notes { ...@@ -79,11 +79,11 @@ ul.notes {
word-wrap: break-word; word-wrap: break-word;
@include md-typography; @include md-typography;
// Reduce left padding of first ul element // Reduce left padding of first task list ul element
ul.task-list:first-child { ul.task-list:first-child {
padding-left: 10px; padding-left: 10px;
// sub-lists should be padded normally // sub-tasks should be padded normally
ul { ul {
padding-left: 20px; padding-left: 20px;
} }
......
require 'html/pipeline' require 'html/pipeline'
require 'task_list/filter'
module Gitlab module Gitlab
# Custom parser for GitLab-flavored Markdown # Custom parser for GitLab-flavored Markdown
...@@ -19,6 +18,7 @@ module Gitlab ...@@ -19,6 +18,7 @@ module Gitlab
autoload :SanitizationFilter, 'gitlab/markdown/sanitization_filter' autoload :SanitizationFilter, 'gitlab/markdown/sanitization_filter'
autoload :SnippetReferenceFilter, 'gitlab/markdown/snippet_reference_filter' autoload :SnippetReferenceFilter, 'gitlab/markdown/snippet_reference_filter'
autoload :TableOfContentsFilter, 'gitlab/markdown/table_of_contents_filter' autoload :TableOfContentsFilter, 'gitlab/markdown/table_of_contents_filter'
autoload :TaskListFilter, 'gitlab/markdown/task_list_filter'
autoload :UserReferenceFilter, 'gitlab/markdown/user_reference_filter' autoload :UserReferenceFilter, 'gitlab/markdown/user_reference_filter'
# Public: Parse the provided text with GitLab-Flavored Markdown # Public: Parse the provided text with GitLab-Flavored Markdown
...@@ -113,7 +113,7 @@ module Gitlab ...@@ -113,7 +113,7 @@ module Gitlab
Gitlab::Markdown::CommitReferenceFilter, Gitlab::Markdown::CommitReferenceFilter,
Gitlab::Markdown::LabelReferenceFilter, Gitlab::Markdown::LabelReferenceFilter,
TaskList::Filter Gitlab::Markdown::TaskListFilter
] ]
end end
end end
......
require 'task_list/filter'
module Gitlab
module Markdown
# Work around a bug in the default TaskList::Filter that adds a `task-list`
# class to every list element, regardless of whether or not it contains a
# task list.
#
# This is a (hopefully) temporary fix, pending a new release of the
# task_list gem.
#
# See https://github.com/github/task_list/pull/60
class TaskListFilter < TaskList::Filter
def add_css_class(node, *new_class_names)
if new_class_names.include?('task-list')
super if node.children.any? { |c| c['class'] == 'task-list-item' }
else
super
end
end
end
end
end
require 'spec_helper'
module Gitlab::Markdown
describe TaskListFilter do
def filter(html, options = {})
described_class.call(html, options)
end
it 'does not apply `task-list` class to non-task lists' do
exp = act = %(<ul><li>Item</li></ul>)
expect(filter(act).to_html).to eq exp
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment