mato 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/mato/html_filters/task_list.rb +26 -7
- data/lib/mato/version.rb +1 -1
- data/mato.gemspec +5 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7985e295c016bbc58c5cc8accc3c81e33e8351a13ed23e9ccc9bb55fe083a01
|
4
|
+
data.tar.gz: d18bb43005111174d922335385453ae4779d449a6efe75431693930fc72309f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08a8c3e69c1af3426109ff111846d3eba57fd91ff3095a606b9c3bae412b7b8947782017143dd894d161872b2907f3084611fe8bfb27e8e900f392bb321e09f5'
|
7
|
+
data.tar.gz: a4dc40fb37b6db9c12e5011e9ea3391d155e78ecbd922d6021a73d2d00ccdb7bc56708e2a17f972d604674accec01ad792f7535abfb385caceb192997179663f
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
# The revision history of Mato
|
2
2
|
|
3
|
+
## v2.3.0 - 2020/06/16
|
4
|
+
|
5
|
+
* Add `convert_empty_task_list` option to TaskList filter to convert task list event if the text is empty. [#23](https://github.com/bitjourney/mato/pull/23)
|
6
|
+
|
3
7
|
## v2.2.0 - 2020/05/08
|
4
8
|
|
5
9
|
https://github.com/bitjourney/mato/compare/v2.1.4...v2.2.0
|
6
10
|
|
11
|
+
* BREAKING: Drop support for Ruby 2.3
|
7
12
|
* Display code block as plan text if Rouge raises an error [#21](https://github.com/bitjourney/mato/pull/21)
|
8
13
|
|
9
14
|
|
@@ -3,15 +3,18 @@
|
|
3
3
|
module Mato
|
4
4
|
module HtmlFilters
|
5
5
|
class TaskList
|
6
|
-
CHECKED_MARK =
|
7
|
-
UNCHECKED_MARK =
|
6
|
+
CHECKED_MARK = /\A\[x\] /
|
7
|
+
UNCHECKED_MARK = /\A\[ \] /
|
8
|
+
CHECKED_MARK_FOR_EMPTY_TASK_LIST = /\A\[x\] ?/
|
9
|
+
UNCHECKED_MARK_FOR_EMPTY_TASK_LIST = /\A\[ \] ?/
|
8
10
|
|
9
11
|
DEFAULT_TASK_LIST_CLASS = "task-list-item"
|
10
12
|
DEFAULT_CHECKBOX_CLASS = "task-list-item-checkbox"
|
11
13
|
|
12
|
-
def initialize(task_list_class: DEFAULT_TASK_LIST_CLASS, checkbox_class: DEFAULT_CHECKBOX_CLASS)
|
14
|
+
def initialize(task_list_class: DEFAULT_TASK_LIST_CLASS, checkbox_class: DEFAULT_CHECKBOX_CLASS, convert_empty_task_list: false)
|
13
15
|
@task_list_class = task_list_class
|
14
16
|
@checkbox_class = checkbox_class
|
17
|
+
@convert_empty_task_list = convert_empty_task_list
|
15
18
|
end
|
16
19
|
|
17
20
|
# @param [Nokogiri::HTML::DocumentFragment] doc
|
@@ -37,18 +40,34 @@ module Mato
|
|
37
40
|
end
|
38
41
|
|
39
42
|
def has_checked_mark?(text_node)
|
40
|
-
text_node&.content&.
|
43
|
+
text_node&.content&.match?(checked_mark)
|
41
44
|
end
|
42
45
|
|
43
46
|
def has_unchecked_mark?(text_node)
|
44
|
-
text_node&.content&.
|
47
|
+
text_node&.content&.match?(unchecked_mark)
|
45
48
|
end
|
46
49
|
|
47
50
|
def trim_mark(content, checked)
|
48
51
|
if checked
|
49
|
-
content.sub(
|
52
|
+
content.sub(checked_mark, '')
|
50
53
|
else
|
51
|
-
content.sub(
|
54
|
+
content.sub(unchecked_mark, '')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def checked_mark
|
59
|
+
if @convert_empty_task_list
|
60
|
+
CHECKED_MARK_FOR_EMPTY_TASK_LIST
|
61
|
+
else
|
62
|
+
CHECKED_MARK
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def unchecked_mark
|
67
|
+
if @convert_empty_task_list
|
68
|
+
UNCHECKED_MARK_FOR_EMPTY_TASK_LIST
|
69
|
+
else
|
70
|
+
UNCHECKED_MARK
|
52
71
|
end
|
53
72
|
end
|
54
73
|
|
data/lib/mato/version.rb
CHANGED
data/mato.gemspec
CHANGED
@@ -13,6 +13,11 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "https://github.com/bitjourney/mato"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
18
|
+
spec.metadata["changelog_uri"] = 'https://github.com/bitjourney/mato/blob/master/CHANGELOG.md'
|
19
|
+
spec.metadata['bug_tracker_uri'] = 'https://github.com/bitjourney/mato/issues'
|
20
|
+
|
16
21
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
22
|
f.match(%r{^(?:test|spec|features|example)/})
|
18
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- FUJI Goro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commonmarker
|
@@ -93,7 +93,11 @@ files:
|
|
93
93
|
homepage: https://github.com/bitjourney/mato
|
94
94
|
licenses:
|
95
95
|
- MIT
|
96
|
-
metadata:
|
96
|
+
metadata:
|
97
|
+
homepage_uri: https://github.com/bitjourney/mato
|
98
|
+
source_code_uri: https://github.com/bitjourney/mato
|
99
|
+
changelog_uri: https://github.com/bitjourney/mato/blob/master/CHANGELOG.md
|
100
|
+
bug_tracker_uri: https://github.com/bitjourney/mato/issues
|
97
101
|
post_install_message:
|
98
102
|
rdoc_options: []
|
99
103
|
require_paths:
|