darkmouun 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4402d38faf236b8d8ae285750e9b6711bc8fe10e85090dba4ef04ebcefb21564
4
- data.tar.gz: 6093ca51565f4b148a7f5a54043c7ebd6e17f4ff25c3dde1c8797f894e17c363
3
+ metadata.gz: 492ae2025363d14715feebc98f4887f2af2dc816116fe76f36f91ace07741bd5
4
+ data.tar.gz: '01881945504107cba0d53f15d60ab88e9117d3f693d17b0c607a8f2bb2378813'
5
5
  SHA512:
6
- metadata.gz: 57b91ad4f2d72203bb195b7c8bae10ef43b8f258ca194581a62dea4e2e0acccafab5cfde498c5bb30de9ac4b68d67c0e745339a0ea1b56d803cfe85aca1a2313
7
- data.tar.gz: eb212f8d4a899efe746a31731ab2e8a47a46293d8d446530b353904ed81b087bac1e0a4cc94d7c25fb4807e9ba735228c9b282127311e2e298c52e9964903373
6
+ metadata.gz: 9156693f93d1a156b41835ecb685b3799945bd1aee46a37f8b85b43d889e47f28b79f1664f1500badca0f5fcf89762b406c4803255975687d9443b1a9aac9f66
7
+ data.tar.gz: 1c0191411b440d3c97fde80a6031d3c4d3d7f29fbbd906d347652c2646fee4045ff7c55c091b0bae8b50d4930762a302cde63da7f0cc5b0528e3a6fc2766c10e
data/README.md CHANGED
@@ -95,9 +95,9 @@ dkmn.convert #=> <p>The Calculation:</p>
95
95
 
96
96
  Darkmouun has extended to kramdown. Extensions are below;
97
97
 
98
- 1. **Plain Span element form.** `[[spanned phrase]]` is converted to `<span>spanned phrase</span>`.
98
+ 1. **Plain span element form.** `[spanned phrase]` is converted to `<span>spanned phrase</span>`.
99
99
 
100
- 2. **Style attribute abbreviation form.** `%attritute_name:value;` in IAL is converted to `style="attribute_name:value;"`.<br/>**ex.** `{:%color:#ffffff; %font-weight:bold;}` -> `style="color:#ffffff; font-weight:bold;"`<br/>**ATTENSION:** Every attribute must be started from "`%`" and ended with "`;`".
100
+ 2. **Style IAL form.** `%attritute_name:value;` in IAL is converted to `style="attribute_name:value;"`.<br/>**ex.** `{:%color:#ffffff; %font-weight:bold;}` -> `style="color:#ffffff; font-weight:bold;"`<br/>**ATTENSION:** Every attribute must be started from "`%`" and ended with "`;`".
101
101
 
102
102
  ## Development
103
103
 
@@ -6,7 +6,11 @@ module Kramdown
6
6
  module Converter
7
7
  class Html
8
8
  def convert_span(el, indent)
9
- format_as_span_html('span', el.attr, inner(el, indent))
9
+ if el.attr.empty?
10
+ "[#{inner(el, indent)}]"
11
+ else
12
+ format_as_span_html('span', el.attr, inner(el, indent))
13
+ end
10
14
  end
11
15
  end
12
16
  end
@@ -1,11 +1,18 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'kramdown'
1
+ # -*- coding: utf-8; frozen_string_literal: true -*-
2
+ #
3
+ #--
4
+ # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
5
+ #
6
+ # This file is part of kramdown which is licensed under the MIT.
7
+ #++
8
+ #
4
9
 
5
10
  module Kramdown
6
11
  module Parser
7
12
  class Kramdown
8
13
 
14
+ # Parse the string +str+ and extract all attributes and add all found attributes to the hash
15
+ # +opts+.
9
16
  def parse_attribute_list(str, opts)
10
17
  return if str.strip.empty? || str.strip == ':'
11
18
  style_attr = []
@@ -16,8 +23,7 @@ module Kramdown
16
23
  elsif id_and_or_class
17
24
  id_and_or_class.scan(ALD_TYPE_ID_OR_CLASS).each do |id_attr, class_attr|
18
25
  if class_attr
19
- opts[IAL_CLASS_ATTR] = (opts[IAL_CLASS_ATTR] || '') << " #{class_attr}"
20
- opts[IAL_CLASS_ATTR].lstrip!
26
+ opts[IAL_CLASS_ATTR] = "#{opts[IAL_CLASS_ATTR]} #{class_attr}".lstrip
21
27
  else
22
28
  opts['id'] = id_attr
23
29
  end
@@ -34,7 +40,7 @@ module Kramdown
34
40
  end
35
41
  end
36
42
  (opts['style'] = style_attr.join(' ')) unless style_attr.empty?
37
- warning("No or invalid attributes found in IAL/ALD content: #{str}") if attrs.length == 0
43
+ warning("No or invalid attributes found in IAL/ALD content: #{str}") if attrs.empty?
38
44
  end
39
45
 
40
46
  ALD_TYPE_STYLE_ATTR = /%((?:--)?#{ALD_ID_NAME}:)\s*?((?:\\\}|\\;|[^\};])*?;)/
@@ -1,10 +1,20 @@
1
- # -*- coding: utf-8 -*-
1
+ # -*- coding: utf-8; frozen_string_literal: true -*-
2
+ #
3
+ #--
4
+ # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
5
+ #
6
+ # This file is part of kramdown which is licensed under the MIT.
7
+ #++
8
+ #
2
9
 
3
10
  require 'kramdown/parser/kramdown/escaped_chars'
4
11
 
5
12
  module Kramdown
6
13
  module Parser
7
14
  class Kramdown
15
+
16
+ # Parse the link at the current scanner position. This method is used to parse normal links as
17
+ # well as image links, plain spans.
8
18
  def parse_link
9
19
  start_line_number = @src.current_line_number
10
20
  result = @src.scan(LINK_START)
@@ -24,7 +34,7 @@ module Kramdown
24
34
  count = 1
25
35
  found = parse_spans(el, LINK_BRACKET_STOP_RE) do
26
36
  count += (@src[1] ? -1 : 1)
27
- count - el.children.select {|c| c.type == :img || c.type == :span }.size == 0
37
+ count - el.children.select {|c| c.type == :img }.size == 0
28
38
  end
29
39
  unless found
30
40
  @src.revert_pos(saved_pos)
@@ -47,48 +57,54 @@ module Kramdown
47
57
  warning("No link definition for link ID '#{link_id}' found on line #{start_line_number}")
48
58
  end
49
59
  @src.revert_pos(saved_pos)
50
- add_text(result)
60
+ if @src.check(/./) == ']'
61
+ add_text(result)
62
+ else
63
+ parse_span
64
+ end
51
65
  end
52
66
  return
53
67
  end
54
68
 
55
- # link url in parentheses
56
- if @src.scan(/\(<(.*?)>/)
57
- link_url = @src[1]
58
- if @src.scan(/\)/)
59
- add_link(el, link_url, nil, alt_text)
60
- return
61
- end
62
- else
63
- link_url = +''
64
- nr_of_brackets = 0
65
- while (temp = @src.scan_until(LINK_PAREN_STOP_RE))
66
- link_url << temp
67
- if @src[2]
68
- nr_of_brackets -= 1
69
- break if nr_of_brackets == 0
70
- elsif @src[1]
71
- nr_of_brackets += 1
72
- else
73
- break
74
- end
75
- end
76
- link_url = link_url[1..-2]
77
- link_url.strip!
69
+ # link url in parentheses
70
+ if @src.scan(/\(<(.*?)>/)
71
+ link_url = @src[1]
72
+ if @src.scan(/\)/)
73
+ add_link(el, link_url, nil, alt_text)
74
+ return
75
+ end
76
+ else
77
+ link_url = +''
78
+ nr_of_brackets = 0
79
+ while (temp = @src.scan_until(LINK_PAREN_STOP_RE))
80
+ link_url << temp
81
+ if @src[2]
82
+ nr_of_brackets -= 1
83
+ break if nr_of_brackets == 0
84
+ elsif @src[1]
85
+ nr_of_brackets += 1
86
+ else
87
+ break
88
+ end
89
+ end
90
+ link_url = link_url[1..-2]
91
+ link_url.strip!
78
92
 
79
- if nr_of_brackets == 0
80
- add_link(el, link_url, nil, alt_text)
81
- return
82
- end
83
- end
93
+ if nr_of_brackets == 0
94
+ add_link(el, link_url, nil, alt_text)
95
+ return
96
+ end
97
+ end
98
+
99
+ if @src.scan(LINK_INLINE_TITLE_RE)
100
+ add_link(el, link_url, @src[2], alt_text)
101
+ else
102
+ @src.revert_pos(saved_pos)
103
+ add_text(result)
104
+ end
105
+ end
106
+ # define_parser(:link, LINK_START, '!?\[')
84
107
 
85
- if @src.scan(LINK_INLINE_TITLE_RE)
86
- add_link(el, link_url, @src[2], alt_text)
87
- else
88
- @src.revert_pos(saved_pos)
89
- add_text(result)
90
- end
91
- end
92
108
  end
93
109
  end
94
110
  end
@@ -6,14 +6,13 @@ module Kramdown
6
6
  module Parser
7
7
  class Kramdown
8
8
 
9
- SPAN_START = /(?:\[\s*?)/
10
-
11
9
  # Parse the span at the current location.
12
10
  def parse_span
13
11
  start_line_number = @src.current_line_number
14
12
  saved_pos = @src.save_pos
15
13
 
16
- result = @src.scan(SPAN_START)
14
+ span_start = /(?:\[\s*?)/
15
+ result = @src.scan(span_start)
17
16
  stop_re = /(?:\s*?\])/
18
17
 
19
18
  el = Element.new(:span, nil, nil, :location => start_line_number)
@@ -23,11 +22,6 @@ module Kramdown
23
22
 
24
23
  if found
25
24
  @src.scan(stop_re)
26
- if @src.check(/\(/)
27
- @src.revert_pos(saved_pos)
28
- parse_link
29
- return
30
- end
31
25
  @tree.children << el
32
26
  else
33
27
  @src.revert_pos(saved_pos)
@@ -35,7 +29,6 @@ module Kramdown
35
29
  add_text(result)
36
30
  end
37
31
  end
38
- define_parser(:span, SPAN_START, '\[')
39
32
 
40
33
  end
41
34
  end
@@ -9,15 +9,5 @@ module Kramdown
9
9
  class Element
10
10
  CATEGORY[:span] = :span
11
11
  end
12
-
13
- module Parser
14
- class Kramdown
15
- alias_method :super_initialize, :initialize
16
- def initialize(source, options)
17
- super_initialize(source, options)
18
- @span_parsers.insert(5, :span)
19
- end
20
- end
21
- end
22
12
  end
23
13
 
@@ -1,3 +1,3 @@
1
1
  module Darkmouun
2
- VERSION = "2.0.0"
2
+ VERSION = "2.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: darkmouun
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akinori Ichigo
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-05 00:00:00.000000000 Z
11
+ date: 2021-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -125,7 +125,7 @@ metadata:
125
125
  homepage_uri: https://github.com/akinori-ichigo/darkmouun
126
126
  source_code_uri: https://github.com/akinori-ichigo/darkmouun
127
127
  changelog_uri: https://github.com/akinori-ichigo/darkmouun
128
- post_install_message:
128
+ post_install_message:
129
129
  rdoc_options: []
130
130
  require_paths:
131
131
  - lib
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  version: '0'
142
142
  requirements: []
143
143
  rubygems_version: 3.1.6
144
- signing_key:
144
+ signing_key:
145
145
  specification_version: 4
146
146
  summary: The Processting tool from Markdown to HTML
147
147
  test_files: []