darkmouun 1.2.0 → 2.0.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: 2ed1b6143ae074a945157a6ae8a448e551bfe3ba62314851a5eb1466e64f4c40
4
- data.tar.gz: 8fa7d1c9ddcffe5fc1b0da67deb41b787d0e1cb364c58e57fdd3041d1191ee51
3
+ metadata.gz: 4402d38faf236b8d8ae285750e9b6711bc8fe10e85090dba4ef04ebcefb21564
4
+ data.tar.gz: 6093ca51565f4b148a7f5a54043c7ebd6e17f4ff25c3dde1c8797f894e17c363
5
5
  SHA512:
6
- metadata.gz: 4ae829259c0d4fd85b7032c65a8c7644cc4740d8eec72c445777cc10e661975f6cf185c032845996af439531e067f7a6529eb32fb4fab9e307aad65c20432f2e
7
- data.tar.gz: '09b875fad61ab9f544e89c748e91c93f4090c5c6d12b8ad80d04bf6827a920a718a5555f4df6ebcc81f842b42c7fbad6b1bb76927a04ecbb6c001997760e0abb'
6
+ metadata.gz: 57b91ad4f2d72203bb195b7c8bae10ef43b8f258ca194581a62dea4e2e0acccafab5cfde498c5bb30de9ac4b68d67c0e745339a0ea1b56d803cfe85aca1a2313
7
+ data.tar.gz: eb212f8d4a899efe746a31731ab2e8a47a46293d8d446530b353904ed81b087bac1e0a4cc94d7c25fb4807e9ba735228c9b282127311e2e298c52e9964903373
@@ -1,11 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- #
3
- #--
4
- # copyright (c) 2017 akinori ichigo <akinori.ichigo@gmail.com>
5
2
 
6
- require 'kramdown/parser'
7
- require 'kramdown/converter'
8
- require 'kramdown/utils'
3
+ require 'kramdown'
9
4
 
10
5
  module Kramdown
11
6
  module Converter
@@ -1,11 +1,4 @@
1
1
  # -*- coding: utf-8 -*-
2
- #
3
- #--
4
- # Copyright (C) 2017 Akinori Ichigo <akinori.ichigo@gmail.com>
5
- #
6
- # This file is part of kramdown which is licensed under the MIT.
7
- #++
8
- #
9
2
 
10
3
  require 'kramdown'
11
4
 
@@ -13,8 +6,6 @@ module Kramdown
13
6
  module Parser
14
7
  class Kramdown
15
8
 
16
- # Parse the string +str+ and extract all attributes and add all found attributes to the hash
17
- # +opts+.
18
9
  def parse_attribute_list(str, opts)
19
10
  return if str.strip.empty? || str.strip == ':'
20
11
  style_attr = []
@@ -0,0 +1,94 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'kramdown/parser/kramdown/escaped_chars'
4
+
5
+ module Kramdown
6
+ module Parser
7
+ class Kramdown
8
+ def parse_link
9
+ start_line_number = @src.current_line_number
10
+ result = @src.scan(LINK_START)
11
+ cur_pos = @src.pos
12
+ saved_pos = @src.save_pos
13
+
14
+ link_type = (result =~ /^!/ ? :img : :a)
15
+
16
+ # no nested links allowed
17
+ if link_type == :a && (@tree.type == :img || @tree.type == :a ||
18
+ @stack.any? {|t, _| t && (t.type == :img || t.type == :a) })
19
+ add_text(result)
20
+ return
21
+ end
22
+ el = Element.new(link_type, nil, nil, location: start_line_number)
23
+
24
+ count = 1
25
+ found = parse_spans(el, LINK_BRACKET_STOP_RE) do
26
+ count += (@src[1] ? -1 : 1)
27
+ count - el.children.select {|c| c.type == :img || c.type == :span }.size == 0
28
+ end
29
+ unless found
30
+ @src.revert_pos(saved_pos)
31
+ add_text(result)
32
+ return
33
+ end
34
+ alt_text = extract_string(cur_pos...@src.pos, @src).gsub(ESCAPED_CHARS, '\1')
35
+ @src.scan(LINK_BRACKET_STOP_RE)
36
+
37
+ # reference style link or no link url
38
+ if @src.scan(LINK_INLINE_ID_RE) || !@src.check(/\(/)
39
+ emit_warning = !@src[1]
40
+ link_id = normalize_link_id(@src[1] || alt_text)
41
+ if @link_defs.key?(link_id)
42
+ link_def = @link_defs[link_id]
43
+ add_link(el, link_def[0], link_def[1], alt_text,
44
+ link_def[2] && link_def[2].options[:ial])
45
+ else
46
+ if emit_warning
47
+ warning("No link definition for link ID '#{link_id}' found on line #{start_line_number}")
48
+ end
49
+ @src.revert_pos(saved_pos)
50
+ add_text(result)
51
+ end
52
+ return
53
+ end
54
+
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!
78
+
79
+ if nr_of_brackets == 0
80
+ add_link(el, link_url, nil, alt_text)
81
+ return
82
+ end
83
+ end
84
+
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
+ end
93
+ end
94
+ end
@@ -1,17 +1,12 @@
1
1
  # -*- coding: utf-8 -*-
2
- #
3
- #--
4
- # Copyright (C) 2016 Akinori Ichigo <akinori.ichigo@gmail.com>
5
- #
6
- # This file is part of kramdown which is licensed under the MIT.
7
- #++
8
- #
2
+
3
+ require 'kramdown'
9
4
 
10
5
  module Kramdown
11
6
  module Parser
12
7
  class Kramdown
13
8
 
14
- SPAN_START = /(?:\[\[\s*?)/
9
+ SPAN_START = /(?:\[\s*?)/
15
10
 
16
11
  # Parse the span at the current location.
17
12
  def parse_span
@@ -19,15 +14,20 @@ module Kramdown
19
14
  saved_pos = @src.save_pos
20
15
 
21
16
  result = @src.scan(SPAN_START)
22
- stop_re = /(?:\s*?\]\])/
17
+ stop_re = /(?:\s*?\])/
23
18
 
24
- el = Element.new(:span, nil, nil, :location => start_line_number)
25
- found = parse_spans(el, stop_re) do
26
- el.children.size > 0
27
- end
19
+ el = Element.new(:span, nil, nil, :location => start_line_number)
20
+ found = parse_spans(el, stop_re) do
21
+ el.children.size > 0
22
+ end
28
23
 
29
24
  if found
30
25
  @src.scan(stop_re)
26
+ if @src.check(/\(/)
27
+ @src.revert_pos(saved_pos)
28
+ parse_link
29
+ return
30
+ end
31
31
  @tree.children << el
32
32
  else
33
33
  @src.revert_pos(saved_pos)
@@ -35,7 +35,7 @@ module Kramdown
35
35
  add_text(result)
36
36
  end
37
37
  end
38
- define_parser(:span, SPAN_START, '\[\[')
38
+ define_parser(:span, SPAN_START, '\[')
39
39
 
40
40
  end
41
41
  end
@@ -0,0 +1,23 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require_relative "kramdown/parser/kramdown/extensions"
4
+ require_relative "kramdown/parser/kramdown/span"
5
+ require_relative "kramdown/parser/kramdown/link"
6
+ require_relative "kramdown/converter/html"
7
+
8
+ module Kramdown
9
+ class Element
10
+ CATEGORY[:span] = :span
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
+ end
23
+
@@ -1,23 +1,10 @@
1
+ # -*- coding: utf-8 -*-
2
+
1
3
  require "mustache"
2
4
  require "Kramdown"
3
5
  require "htmlbeautifier"
4
6
 
5
- require "darkmouun/version"
6
- require "darkmouun/parser/extensions"
7
- require "darkmouun/parser/span"
8
- require "darkmouun/converter/span"
9
-
10
- module Kramdown
11
- module Parser
12
- class Kramdown
13
- alias_method :super_initialize, :initialize
14
- def initialize(source, options)
15
- super_initialize(source, options)
16
- @span_parsers.insert(5, :span)
17
- end
18
- end
19
- end
20
- end
7
+ require_relative "kramdown"
21
8
 
22
9
  module Darkmouun
23
10
  class << self
@@ -32,18 +19,7 @@ module Darkmouun
32
19
  def initialize(source, options ={}, converter = :html)
33
20
  @source, @options = source, options
34
21
  @templates = {}
35
- begin
36
- @converter = case converter
37
- when String
38
- ('to_' + converter).intern
39
- when Symbol
40
- ('to_' + (converter.to_s)).intern
41
- else
42
- Exception.new "Invalid converter: Neither Symbol nor String"
43
- end
44
- rescue => e
45
- p e
46
- end
22
+ @converter = ('to_' + (converter.to_s)).intern
47
23
  end
48
24
 
49
25
  def add_templates(dir, *tmpls)
@@ -1,3 +1,3 @@
1
1
  module Darkmouun
2
- VERSION = "1.2.0"
2
+ VERSION = "2.0.0"
3
3
  end
data/lib/darkmouun.rb CHANGED
@@ -1,7 +1,3 @@
1
- require "darkmouun/version"
2
- require "darkmouun/main"
1
+ require_relative "darkmouun/version"
2
+ require_relative "darkmouun/main"
3
3
 
4
- module Darkmouun
5
- class Error < StandardError; end
6
- # Your code goes here...
7
- 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: 1.2.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akinori Ichigo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-14 00:00:00.000000000 Z
11
+ date: 2021-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -111,10 +111,12 @@ files:
111
111
  - bin/setup
112
112
  - darkmouun.gemspec
113
113
  - lib/darkmouun.rb
114
- - lib/darkmouun/converter/span.rb
114
+ - lib/darkmouun/kramdown.rb
115
+ - lib/darkmouun/kramdown/converter/html.rb
116
+ - lib/darkmouun/kramdown/parser/kramdown/extensions.rb
117
+ - lib/darkmouun/kramdown/parser/kramdown/link.rb
118
+ - lib/darkmouun/kramdown/parser/kramdown/span.rb
115
119
  - lib/darkmouun/main.rb
116
- - lib/darkmouun/parser/extensions.rb
117
- - lib/darkmouun/parser/span.rb
118
120
  - lib/darkmouun/version.rb
119
121
  homepage: https://github.com/akinori-ichigo/darkmouun
120
122
  licenses: