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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d94a4026d7fadd8bc561d9489f2a89238ce6b4100e4e8d887832be86304feb33
4
- data.tar.gz: fb26a18fa1f92dfc655f2b53a5aac5af2b3fe945bf2a42cbc8c0966d8f964044
3
+ metadata.gz: f7985e295c016bbc58c5cc8accc3c81e33e8351a13ed23e9ccc9bb55fe083a01
4
+ data.tar.gz: d18bb43005111174d922335385453ae4779d449a6efe75431693930fc72309f9
5
5
  SHA512:
6
- metadata.gz: d698ea373d885e1c9716077dffd1aefc50426c398b68038c288e83f05fb016f26aa1302a1fc93447ec9d8c1b409f2c6f03e2474315075cfdb6e72037c20dfb1a
7
- data.tar.gz: c39ed1a90becdb01f2d3b8447b67b79f3ce6efa8dcfbfce39d4c4c5d7e315ae69941655ff0d831829e955b6fd0102db592923501354c6cc74208f3065b8926ad
6
+ metadata.gz: '08a8c3e69c1af3426109ff111846d3eba57fd91ff3095a606b9c3bae412b7b8947782017143dd894d161872b2907f3084611fe8bfb27e8e900f392bb321e09f5'
7
+ data.tar.gz: a4dc40fb37b6db9c12e5011e9ea3391d155e78ecbd922d6021a73d2d00ccdb7bc56708e2a17f972d604674accec01ad792f7535abfb385caceb192997179663f
@@ -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 = "[x] "
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&.start_with?(CHECKED_MARK)
43
+ text_node&.content&.match?(checked_mark)
41
44
  end
42
45
 
43
46
  def has_unchecked_mark?(text_node)
44
- text_node&.content&.start_with?(UNCHECKED_MARK)
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(CHECKED_MARK, '')
52
+ content.sub(checked_mark, '')
50
53
  else
51
- content.sub(UNCHECKED_MARK, '')
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mato
4
- VERSION = "2.2.0"
4
+ VERSION = "2.3.0"
5
5
  end
@@ -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.2.0
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-05-08 00:00:00.000000000 Z
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: