darkmouun 1.1.0 → 2.1.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 +4 -4
- data/README.md +2 -2
- data/lib/darkmouun/{converter/span.rb → kramdown/converter/html.rb} +1 -6
- data/lib/darkmouun/{parser → kramdown/parser/kramdown}/extensions.rb +0 -9
- data/lib/darkmouun/kramdown/parser/kramdown/link.rb +90 -0
- data/lib/darkmouun/{parser → kramdown/parser/kramdown}/span.rb +9 -16
- data/lib/darkmouun/kramdown.rb +13 -0
- data/lib/darkmouun/main.rb +12 -36
- data/lib/darkmouun/version.rb +1 -1
- data/lib/darkmouun.rb +2 -6
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0e5ba37ba1ee837c723ff67a384a4104f24aa592c1b33d4fa328faaf089a539
|
4
|
+
data.tar.gz: 72e1fbe968e1a41b657918349ea2692516ece783fabfaf762e1ab7cab10b7264
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e208d87f52f188804fd3b25e28313f5d257e703984dc3f8d4091b09c7010e14721d9d64eae1ec799c37fe97ea990d260b8ad686f33f5f2bd19a3c2a54f5ce861
|
7
|
+
data.tar.gz: 0f58155fc090699282ca2020b48eb1a39d78c2bb6b31b619248d98b141bc2c7f8588b6d74540c9bb899e41a2c0bdf9f07f4244121ba0a6da8a8b0c71107fe17c
|
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
|
98
|
+
1. **Plain span element form.** `[spanned phrase]` is converted to `<span>spanned phrase</span>`.
|
99
99
|
|
100
|
-
2. **Style
|
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,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,90 @@
|
|
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
|
+
parse_span
|
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
|
+
link_id = normalize_link_id(@src[1] || alt_text)
|
40
|
+
if @link_defs.key?(link_id)
|
41
|
+
link_def = @link_defs[link_id]
|
42
|
+
add_link(el, link_def[0], link_def[1], alt_text,
|
43
|
+
link_def[2] && link_def[2].options[:ial])
|
44
|
+
else
|
45
|
+
@src.revert_pos(saved_pos)
|
46
|
+
parse_span
|
47
|
+
end
|
48
|
+
return
|
49
|
+
end
|
50
|
+
|
51
|
+
# link url in parentheses
|
52
|
+
if @src.scan(/\(<(.*?)>/)
|
53
|
+
link_url = @src[1]
|
54
|
+
if @src.scan(/\)/)
|
55
|
+
add_link(el, link_url, nil, alt_text)
|
56
|
+
return
|
57
|
+
end
|
58
|
+
else
|
59
|
+
link_url = +''
|
60
|
+
nr_of_brackets = 0
|
61
|
+
while (temp = @src.scan_until(LINK_PAREN_STOP_RE))
|
62
|
+
link_url << temp
|
63
|
+
if @src[2]
|
64
|
+
nr_of_brackets -= 1
|
65
|
+
break if nr_of_brackets == 0
|
66
|
+
elsif @src[1]
|
67
|
+
nr_of_brackets += 1
|
68
|
+
else
|
69
|
+
break
|
70
|
+
end
|
71
|
+
end
|
72
|
+
link_url = link_url[1..-2]
|
73
|
+
link_url.strip!
|
74
|
+
|
75
|
+
if nr_of_brackets == 0
|
76
|
+
add_link(el, link_url, nil, alt_text)
|
77
|
+
return
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
if @src.scan(LINK_INLINE_TITLE_RE)
|
82
|
+
add_link(el, link_url, @src[2], alt_text)
|
83
|
+
else
|
84
|
+
@src.revert_pos(saved_pos)
|
85
|
+
add_text(result)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
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
|
-
|
22
|
-
|
14
|
+
span_start = /(?:\[\s*?)/
|
15
|
+
result = @src.scan(span_start)
|
16
|
+
stop_re = /(?:\s*?\])/
|
23
17
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
+
|
data/lib/darkmouun/main.rb
CHANGED
@@ -1,23 +1,10 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
1
3
|
require "mustache"
|
2
4
|
require "Kramdown"
|
3
5
|
require "htmlbeautifier"
|
4
6
|
|
5
|
-
|
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
|
-
|
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
|
-
|
86
|
-
|
87
|
-
|
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
|
|
data/lib/darkmouun/version.rb
CHANGED
data/lib/darkmouun.rb
CHANGED
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:
|
4
|
+
version: 2.1.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-
|
11
|
+
date: 2021-09-06 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/
|
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.
|
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: []
|