darkmouun 1.0.4 → 2.0.2

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: a03a06ad91e45c525cfbd4d383a96acad54e732d814363dba4a48a9e93564075
4
- data.tar.gz: 0243d803cf79fcdf316175c089705cf91509ffcbc62e336e85534054769b90cd
3
+ metadata.gz: 8ee7a1c55cc3dbae755416b1fc4dc3e8cc6718fbf133197755d164768a81ca32
4
+ data.tar.gz: 4fb1e37d283016f36be823dcd0b3bbc45123d8978f6ea3cb8658aeb5bd3fed6c
5
5
  SHA512:
6
- metadata.gz: 3e6416a73e0adb2d82cd736b977e7de7de535e5d081e19c61d2659f384b327cb490a5bb5e0453044768e4faef1b66b367181ff5fdc59375236c9873ee6af029f
7
- data.tar.gz: 7319cfbb531f7135313633c014dc0cbe28f679f22ec57b653234427c15bffabd753f056da1e48b502d72a075a1a002e38fe82f657d3e3440b3b860c223d3bc45
6
+ metadata.gz: 0bf23967422b37d38af009ae0bd6add04b1d884da54d5f93bb2be99aecb3fd90eed0fdc67a9ac3b8fad9a013b2549c40474f985073bcfa9560f1718afb86b28d
7
+ data.tar.gz: ffca9b7b0298cfdce242c746f73a0279bd3e814ec55cf77c9ab6d792aca49d94713784d3ffb0f375f74fc48d491fb230cd1da76968e0215e5d1fac64f2ca7aab
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
 
@@ -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 = []
@@ -46,7 +37,7 @@ module Kramdown
46
37
  warning("No or invalid attributes found in IAL/ALD content: #{str}") if attrs.length == 0
47
38
  end
48
39
 
49
- ALD_TYPE_STYLE_ATTR = /%(#{ALD_ID_NAME}:)\s*?((?:\\\}|\\;|[^\};])*?;)/
40
+ ALD_TYPE_STYLE_ATTR = /%((?:--)?#{ALD_ID_NAME}:)\s*?((?:\\\}|\\;|[^\};])*?;)/
50
41
  remove_const(:ALD_TYPE_ANY)
51
42
  ALD_TYPE_ANY = /(?:\A|\s)(?:#{ALD_TYPE_KEY_VALUE_PAIR}|#{ALD_TYPE_STYLE_ATTR}|#{ALD_TYPE_REF}|#{ALD_TYPE_ID_OR_CLASS_MULTI})(?=\s|\Z)/
52
43
 
@@ -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[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)
@@ -80,16 +56,16 @@ module Darkmouun
80
56
  end
81
57
 
82
58
  def apply_mustache
83
- begin
84
59
  @source = @source.gsub(/<<(.+?)>>\n((?:[# \-]*[\w_][\w\d_]*: *\n?(?: +.+\n)+)+)/) do |s|
85
- obj_spot_template, data = (@templates[$1.to_sym]).new, $2
86
- YAML.load_stream(data).compact.reduce(&:merge).each do |k, v|
87
- obj_spot_template.define_singleton_method(k){ v }
60
+ begin
61
+ obj_spot_template, data = (@templates[$1.to_sym]).new, $2
62
+ YAML.load_stream(data).compact.reduce(&:merge).each do |k, v|
63
+ obj_spot_template.define_singleton_method(k){ v }
64
+ end
65
+ obj_spot_template.render + "\n"
66
+ rescue => e
67
+ raise e.class.new("\n#{e.message} in \"Mustache-process\" at *** #{s} ***\n")
88
68
  end
89
- obj_spot_template.render + "\n"
90
- end
91
- rescue => e
92
- raise e.class.new("\n#{e.message}\n\n>>> ERROR in \"Mustache-process\" <<<\nMaybe, incorrect tags of the template exist.\n")
93
69
  end
94
70
  end
95
71
 
@@ -1,3 +1,3 @@
1
1
  module Darkmouun
2
- VERSION = "1.0.4"
2
+ VERSION = "2.0.2"
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.0.4
4
+ version: 2.0.2
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: 2020-09-27 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:
@@ -123,7 +125,7 @@ metadata:
123
125
  homepage_uri: https://github.com/akinori-ichigo/darkmouun
124
126
  source_code_uri: https://github.com/akinori-ichigo/darkmouun
125
127
  changelog_uri: https://github.com/akinori-ichigo/darkmouun
126
- post_install_message:
128
+ post_install_message:
127
129
  rdoc_options: []
128
130
  require_paths:
129
131
  - lib
@@ -138,8 +140,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
140
  - !ruby/object:Gem::Version
139
141
  version: '0'
140
142
  requirements: []
141
- rubygems_version: 3.1.4
142
- signing_key:
143
+ rubygems_version: 3.1.6
144
+ signing_key:
143
145
  specification_version: 4
144
146
  summary: The Processting tool from Markdown to HTML
145
147
  test_files: []