darkmouun 1.2.0 → 2.1.1

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: 4a2c3b66f4fb9ab93a3c8671b722b770baed774650dfc2ce0d84d300198d5c30
4
+ data.tar.gz: 98b7467119e5af5bd55f0b5e309db72fb3063a40eb2577a907319b87d2ddd24c
5
5
  SHA512:
6
- metadata.gz: 4ae829259c0d4fd85b7032c65a8c7644cc4740d8eec72c445777cc10e661975f6cf185c032845996af439531e067f7a6529eb32fb4fab9e307aad65c20432f2e
7
- data.tar.gz: '09b875fad61ab9f544e89c748e91c93f4090c5c6d12b8ad80d04bf6827a920a718a5555f4df6ebcc81f842b42c7fbad6b1bb76927a04ecbb6c001997760e0abb'
6
+ metadata.gz: 818936002fd0553e472bbf6cf3b533d80659729db7c066dbed502c42c44c17497a0e83722ae86b887b1575c68c2e4546d75ff1775f0e4fc80a0ecb90f6d78904
7
+ data.tar.gz: 3ce4f78657b946b1f23f8f73c4eb218ebc77a7ec70cf58387ab005f2357e96b481fbee0b3daca212bcf129837a36ee5ae4a7f235ab4d72c428fcc7ea2bcc6a69
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,14 +1,12 @@
1
- # -*- coding: utf-8 -*-
1
+ # -*- coding: utf-8; frozen_string_literal: true -*-
2
2
  #
3
3
  #--
4
- # Copyright (C) 2017 Akinori Ichigo <akinori.ichigo@gmail.com>
4
+ # Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
5
5
  #
6
6
  # This file is part of kramdown which is licensed under the MIT.
7
7
  #++
8
8
  #
9
9
 
10
- require 'kramdown'
11
-
12
10
  module Kramdown
13
11
  module Parser
14
12
  class Kramdown
@@ -25,8 +23,7 @@ module Kramdown
25
23
  elsif id_and_or_class
26
24
  id_and_or_class.scan(ALD_TYPE_ID_OR_CLASS).each do |id_attr, class_attr|
27
25
  if class_attr
28
- opts[IAL_CLASS_ATTR] = (opts[IAL_CLASS_ATTR] || '') << " #{class_attr}"
29
- opts[IAL_CLASS_ATTR].lstrip!
26
+ opts[IAL_CLASS_ATTR] = "#{opts[IAL_CLASS_ATTR]} #{class_attr}".lstrip
30
27
  else
31
28
  opts['id'] = id_attr
32
29
  end
@@ -43,7 +40,7 @@ module Kramdown
43
40
  end
44
41
  end
45
42
  (opts['style'] = style_attr.join(' ')) unless style_attr.empty?
46
- 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?
47
44
  end
48
45
 
49
46
  ALD_TYPE_STYLE_ATTR = /%((?:--)?#{ALD_ID_NAME}:)\s*?((?:\\\}|\\;|[^\};])*?;)/
@@ -0,0 +1,110 @@
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
+ #
9
+
10
+ require 'kramdown/parser/kramdown/escaped_chars'
11
+
12
+ module Kramdown
13
+ module Parser
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.
18
+ def parse_link
19
+ start_line_number = @src.current_line_number
20
+ result = @src.scan(LINK_START)
21
+ cur_pos = @src.pos
22
+ saved_pos = @src.save_pos
23
+
24
+ link_type = (result =~ /^!/ ? :img : :a)
25
+
26
+ # no nested links allowed
27
+ if link_type == :a && (@tree.type == :img || @tree.type == :a ||
28
+ @stack.any? {|t, _| t && (t.type == :img || t.type == :a) })
29
+ add_text(result)
30
+ return
31
+ end
32
+ el = Element.new(link_type, nil, nil, location: start_line_number)
33
+
34
+ count = 1
35
+ found = parse_spans(el, LINK_BRACKET_STOP_RE) do
36
+ count += (@src[1] ? -1 : 1)
37
+ count - el.children.select {|c| c.type == :img }.size == 0
38
+ end
39
+ unless found
40
+ @src.revert_pos(saved_pos)
41
+ add_text(result)
42
+ return
43
+ end
44
+ alt_text = extract_string(cur_pos...@src.pos, @src).gsub(ESCAPED_CHARS, '\1')
45
+ @src.scan(LINK_BRACKET_STOP_RE)
46
+
47
+ # reference style link or no link url
48
+ if @src.scan(LINK_INLINE_ID_RE) || !@src.check(/\(/)
49
+ emit_warning = !@src[1]
50
+ link_id = normalize_link_id(@src[1] || alt_text)
51
+ if @link_defs.key?(link_id)
52
+ link_def = @link_defs[link_id]
53
+ add_link(el, link_def[0], link_def[1], alt_text,
54
+ link_def[2] && link_def[2].options[:ial])
55
+ else
56
+ if emit_warning
57
+ warning("No link definition for link ID '#{link_id}' found on line #{start_line_number}")
58
+ end
59
+ @src.revert_pos(saved_pos)
60
+ if @src.check(/./) == ']'
61
+ add_text(result)
62
+ else
63
+ parse_span
64
+ end
65
+ end
66
+ return
67
+ end
68
+
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!
92
+
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, '!?\[')
107
+
108
+ end
109
+ end
110
+ end
@@ -1,30 +1,24 @@
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*?)/
15
-
16
9
  # Parse the span at the current location.
17
10
  def parse_span
18
11
  start_line_number = @src.current_line_number
19
12
  saved_pos = @src.save_pos
20
13
 
21
- result = @src.scan(SPAN_START)
22
- stop_re = /(?:\s*?\]\])/
14
+ span_start = /(?:\[\s*?)/
15
+ result = @src.scan(span_start)
16
+ stop_re = /(?:\s*?\])/
23
17
 
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
18
+ el = Element.new(:span, nil, nil, :location => start_line_number)
19
+ found = parse_spans(el, stop_re) do
20
+ el.children.size > 0
21
+ end
28
22
 
29
23
  if found
30
24
  @src.scan(stop_re)
@@ -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
@@ -0,0 +1,13 @@
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
+ end
13
+
@@ -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.1.1"
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.1.1
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-08-14 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
@@ -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
@@ -139,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
141
  version: '0'
140
142
  requirements: []
141
143
  rubygems_version: 3.1.6
142
- signing_key:
144
+ signing_key:
143
145
  specification_version: 4
144
146
  summary: The Processting tool from Markdown to HTML
145
147
  test_files: []