darkmouun 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +114 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/darkmouun.gemspec +35 -0
- data/lib/darkmouun.rb +7 -0
- data/lib/darkmouun/converter/span.rb +19 -0
- data/lib/darkmouun/main.rb +117 -0
- data/lib/darkmouun/parser/extensions.rb +55 -0
- data/lib/darkmouun/parser/span.rb +42 -0
- data/lib/darkmouun/version.rb +3 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a03a06ad91e45c525cfbd4d383a96acad54e732d814363dba4a48a9e93564075
|
4
|
+
data.tar.gz: 0243d803cf79fcdf316175c089705cf91509ffcbc62e336e85534054769b90cd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3e6416a73e0adb2d82cd736b977e7de7de535e5d081e19c61d2659f384b327cb490a5bb5e0453044768e4faef1b66b367181ff5fdc59375236c9873ee6af029f
|
7
|
+
data.tar.gz: 7319cfbb531f7135313633c014dc0cbe28f679f22ec57b653234427c15bffabd753f056da1e48b502d72a075a1a002e38fe82f657d3e3440b3b860c223d3bc45
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at akinori.ichigo@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Akinori Ichigo
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
# Darkmouun
|
2
|
+
|
3
|
+
## Overview
|
4
|
+
|
5
|
+
Darkmouun is the converter from a markdown text enhanced by [kramdown](https://github.com/gettalong/kramdown) to a HTML document.
|
6
|
+
|
7
|
+
Darkmouun can define:
|
8
|
+
* Pre-processing (to a markdown document)
|
9
|
+
* Extracting templates by Mustache
|
10
|
+
* Converting from markdown to HTML by kramdown
|
11
|
+
* Post-processing (to a HTML document)
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'darkmouun'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install darkmouun
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
Darkmouun.document.new takes 3 arguments.
|
32
|
+
|
33
|
+
* 1st arg: Target Markdown file name
|
34
|
+
* 2nd arg: Kramdown's parser option (cf. [kramdown's usage](https://kramdown.gettalong.org/documentation.html#usage))
|
35
|
+
* 3rd arg: Kramdown's converter name(ex. if converter class name is ItlHtml, converter name is to_itl_html.)
|
36
|
+
|
37
|
+
2nd and 3rd argument has default value.
|
38
|
+
|
39
|
+
* 2nd arg: {}
|
40
|
+
* 3rd arg: to_html
|
41
|
+
|
42
|
+
(Darkmouun instance).convert makes a HTML document from the target markdown document.
|
43
|
+
|
44
|
+
You can define pre_process and post_process as a Proc object.
|
45
|
+
|
46
|
+
```
|
47
|
+
dkmn = Darkmouun.document.new("MARKDOWN DOCUMENT", {:auto_ids => false})
|
48
|
+
dkmn.pre_process = lambda do |i|
|
49
|
+
i.gsub!(/MARKDOWN/, "Markdown")
|
50
|
+
end
|
51
|
+
dkmn.post_process = lambda do |i|
|
52
|
+
i.gsub!(/DOCUMENT/, "Document")
|
53
|
+
end
|
54
|
+
dkmn.convert #=> "<p>Markdown Document</p>
|
55
|
+
```
|
56
|
+
|
57
|
+
You can write the parts that Mustache extracts with templates in your markdown document.
|
58
|
+
Template is written as Ruby script, and it is made to define as the subclass of Mustache class.
|
59
|
+
|
60
|
+
The part of template extacting in the markdown document starts '<<template_name>>'.
|
61
|
+
Parameters of the template are written below with YAML format.
|
62
|
+
|
63
|
+
```
|
64
|
+
# Template file 'template_a.rb'
|
65
|
+
|
66
|
+
class Template_A < Mustache
|
67
|
+
Template = <<EOS
|
68
|
+
'<p>{{fig1}} + {{fig2}}' is {{calc}}.</p>
|
69
|
+
EOS
|
70
|
+
|
71
|
+
def calc
|
72
|
+
(fig1.to_i + fig2.to_i).to_s
|
73
|
+
end
|
74
|
+
```
|
75
|
+
|
76
|
+
```
|
77
|
+
# converting code
|
78
|
+
|
79
|
+
dkmn = Darkmouun.document.new(<<BODY, {:auto_ids => false, :input => 'sekd'}, :se_html)
|
80
|
+
The calculation:
|
81
|
+
|
82
|
+
<<Template_A>>
|
83
|
+
fig1: 1
|
84
|
+
fig2: 2
|
85
|
+
BODY
|
86
|
+
|
87
|
+
dkmn.add_templates "#{__dir__}/templates/", # 1st arg is the directory of templates.
|
88
|
+
'template_a.rb' # 2nd or later args are the files of templates.
|
89
|
+
|
90
|
+
dkmn.convert #=> <p>The Calculation:</p>
|
91
|
+
<p>1 + 2 is 3.</p>
|
92
|
+
```
|
93
|
+
|
94
|
+
## kramdown extensions
|
95
|
+
|
96
|
+
Darkmouun has extended to kramdown. Extensions are below;
|
97
|
+
|
98
|
+
1. **Plain Span element form.** `[[spanned phrase]]` is converted to `<span>spanned phrase</span>`.
|
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 "`;`".
|
101
|
+
|
102
|
+
## Development
|
103
|
+
|
104
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
105
|
+
|
106
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
107
|
+
|
108
|
+
## License
|
109
|
+
|
110
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
111
|
+
|
112
|
+
## Code of Conduct
|
113
|
+
|
114
|
+
Everyone interacting in the Darkmouun project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/darkmouun/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "darkmouun"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/darkmouun.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative 'lib/darkmouun/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "darkmouun"
|
5
|
+
spec.version = Darkmouun::VERSION
|
6
|
+
spec.authors = ["Akinori Ichigo"]
|
7
|
+
spec.email = ["akinori.ichigo@gmail.com"]
|
8
|
+
|
9
|
+
spec.summary = %q{The Processting tool from Markdown to HTML}
|
10
|
+
spec.description = %q{Darkmouun converts Markdown document to HTML by processing of pre, Mustache template, Kramdown, and post.}
|
11
|
+
spec.homepage = "https://github.com/akinori-ichigo/darkmouun"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
+
|
15
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
+
spec.metadata["source_code_uri"] = "https://github.com/akinori-ichigo/darkmouun"
|
17
|
+
spec.metadata["changelog_uri"] = "https://github.com/akinori-ichigo/darkmouun"
|
18
|
+
|
19
|
+
# Specify which files should be added to the gem when it is released.
|
20
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
22
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
+
end
|
24
|
+
spec.bindir = "exe"
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
+
spec.require_paths = ["lib"]
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
31
|
+
|
32
|
+
spec.add_runtime_dependency "mustache"
|
33
|
+
spec.add_runtime_dependency "kramdown"
|
34
|
+
spec.add_runtime_dependency "htmlbeautifier"
|
35
|
+
end
|
data/lib/darkmouun.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# copyright (c) 2017 akinori ichigo <akinori.ichigo@gmail.com>
|
5
|
+
|
6
|
+
require 'kramdown/parser'
|
7
|
+
require 'kramdown/converter'
|
8
|
+
require 'kramdown/utils'
|
9
|
+
|
10
|
+
module Kramdown
|
11
|
+
module Converter
|
12
|
+
class Html
|
13
|
+
def convert_span(el, indent)
|
14
|
+
format_as_span_html('span', el.attr, inner(el, indent))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require "mustache"
|
2
|
+
require "Kramdown"
|
3
|
+
require "htmlbeautifier"
|
4
|
+
|
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
|
21
|
+
|
22
|
+
module Darkmouun
|
23
|
+
class << self
|
24
|
+
def document
|
25
|
+
Darkmouun
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Darkmouun
|
30
|
+
attr_accessor :pre_process, :post_process
|
31
|
+
|
32
|
+
def initialize(source, options ={}, converter = :html)
|
33
|
+
@source, @options = source, options
|
34
|
+
@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
|
47
|
+
end
|
48
|
+
|
49
|
+
def add_templates(dir, *tmpls)
|
50
|
+
# for Mustache
|
51
|
+
tmpls.each do |tmpl|
|
52
|
+
abs_path = dir + tmpl
|
53
|
+
tmpl_module = Module.new
|
54
|
+
tmpl_module.module_eval(File.read(abs_path), abs_path)
|
55
|
+
tmpl_module.constants.each do |i|
|
56
|
+
c = tmpl_module.const_get(i)
|
57
|
+
if c.is_a?(Class) && c.superclass == Mustache
|
58
|
+
@templates[i] = c
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def convert
|
65
|
+
do_pre_process
|
66
|
+
apply_mustache
|
67
|
+
apply_kramdown
|
68
|
+
do_post_process
|
69
|
+
beautify
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def do_pre_process
|
75
|
+
begin
|
76
|
+
@pre_process.call(@source) unless @pre_process.nil?
|
77
|
+
rescue => e
|
78
|
+
raise e.class.new("\n#{e.message}\n\n>>> ERROR in \"Pre-process\" <<<\n")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def apply_mustache
|
83
|
+
begin
|
84
|
+
@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 }
|
88
|
+
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
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def apply_kramdown
|
97
|
+
begin
|
98
|
+
@result = Kramdown::Document.new(@source, @options).send(@converter)
|
99
|
+
rescue => e
|
100
|
+
raise e.class.new("\n#{e.message}\n\n>>> ERROR in \"kramdown-process\" <<<\n")
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def do_post_process
|
105
|
+
begin
|
106
|
+
@post_process.call(@result) unless @post_process.nil?
|
107
|
+
rescue => e
|
108
|
+
raise e.class.new("\n#{e.message}\n\n>>> ERROR in \"Post-process\" <<<\n")
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def beautify
|
113
|
+
HtmlBeautifier.beautify(@result)
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,55 @@
|
|
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
|
+
|
10
|
+
require 'kramdown'
|
11
|
+
|
12
|
+
module Kramdown
|
13
|
+
module Parser
|
14
|
+
class Kramdown
|
15
|
+
|
16
|
+
# Parse the string +str+ and extract all attributes and add all found attributes to the hash
|
17
|
+
# +opts+.
|
18
|
+
def parse_attribute_list(str, opts)
|
19
|
+
return if str.strip.empty? || str.strip == ':'
|
20
|
+
style_attr = []
|
21
|
+
attrs = str.scan(ALD_TYPE_ANY)
|
22
|
+
attrs.each do |key, sep, val, style_key, style_val, ref, id_and_or_class, _, _|
|
23
|
+
if ref
|
24
|
+
(opts[:refs] ||= []) << ref
|
25
|
+
elsif id_and_or_class
|
26
|
+
id_and_or_class.scan(ALD_TYPE_ID_OR_CLASS).each do |id_attr, class_attr|
|
27
|
+
if class_attr
|
28
|
+
opts[IAL_CLASS_ATTR] = (opts[IAL_CLASS_ATTR] || '') << " #{class_attr}"
|
29
|
+
opts[IAL_CLASS_ATTR].lstrip!
|
30
|
+
else
|
31
|
+
opts['id'] = id_attr
|
32
|
+
end
|
33
|
+
end
|
34
|
+
elsif style_key
|
35
|
+
style_attr << (style_key + style_val)
|
36
|
+
else
|
37
|
+
val.gsub!(/\\(\}|#{sep})/, "\\1")
|
38
|
+
if /\Astyle\Z/i =~ key
|
39
|
+
style_attr << val
|
40
|
+
else
|
41
|
+
opts[key] = val
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
(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
|
47
|
+
end
|
48
|
+
|
49
|
+
ALD_TYPE_STYLE_ATTR = /%(#{ALD_ID_NAME}:)\s*?((?:\\\}|\\;|[^\};])*?;)/
|
50
|
+
remove_const(:ALD_TYPE_ANY)
|
51
|
+
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
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,42 @@
|
|
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
|
+
#
|
9
|
+
|
10
|
+
module Kramdown
|
11
|
+
module Parser
|
12
|
+
class Kramdown
|
13
|
+
|
14
|
+
SPAN_START = /(?:\[\[\s*?)/
|
15
|
+
|
16
|
+
# Parse the span at the current location.
|
17
|
+
def parse_span
|
18
|
+
start_line_number = @src.current_line_number
|
19
|
+
saved_pos = @src.save_pos
|
20
|
+
|
21
|
+
result = @src.scan(SPAN_START)
|
22
|
+
stop_re = /(?:\s*?\]\])/
|
23
|
+
|
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
|
28
|
+
|
29
|
+
if found
|
30
|
+
@src.scan(stop_re)
|
31
|
+
@tree.children << el
|
32
|
+
else
|
33
|
+
@src.revert_pos(saved_pos)
|
34
|
+
@src.pos += result.length
|
35
|
+
add_text(result)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
define_parser(:span, SPAN_START, '\[\[')
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: darkmouun
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Akinori Ichigo
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-09-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mustache
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: kramdown
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: htmlbeautifier
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Darkmouun converts Markdown document to HTML by processing of pre, Mustache
|
98
|
+
template, Kramdown, and post.
|
99
|
+
email:
|
100
|
+
- akinori.ichigo@gmail.com
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- CODE_OF_CONDUCT.md
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- bin/console
|
111
|
+
- bin/setup
|
112
|
+
- darkmouun.gemspec
|
113
|
+
- lib/darkmouun.rb
|
114
|
+
- lib/darkmouun/converter/span.rb
|
115
|
+
- lib/darkmouun/main.rb
|
116
|
+
- lib/darkmouun/parser/extensions.rb
|
117
|
+
- lib/darkmouun/parser/span.rb
|
118
|
+
- lib/darkmouun/version.rb
|
119
|
+
homepage: https://github.com/akinori-ichigo/darkmouun
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
metadata:
|
123
|
+
homepage_uri: https://github.com/akinori-ichigo/darkmouun
|
124
|
+
source_code_uri: https://github.com/akinori-ichigo/darkmouun
|
125
|
+
changelog_uri: https://github.com/akinori-ichigo/darkmouun
|
126
|
+
post_install_message:
|
127
|
+
rdoc_options: []
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: 2.3.0
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
requirements: []
|
141
|
+
rubygems_version: 3.1.4
|
142
|
+
signing_key:
|
143
|
+
specification_version: 4
|
144
|
+
summary: The Processting tool from Markdown to HTML
|
145
|
+
test_files: []
|