daimon-markdown 0.2.4 → 0.3.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/lib/daimon/markdown/filter/plugin.rb +12 -5
- data/lib/daimon/markdown/parser.rb +13 -0
- data/lib/daimon/markdown/plugin.rb +5 -0
- data/lib/daimon/markdown/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8d9ae79f89262e2e5b173fd510137589bc6356a
|
4
|
+
data.tar.gz: b8e4072e934cac8da673c2efd259abc3435fba79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f56abca8ff5b504bcdf82e984a3b86efc7df6fd065eaa63e49b7b7e894670c3bf7f456321d64f8bdbc2cd6838fd59c10ec0973e82970a9eeabca4a4ef463acbd
|
7
|
+
data.tar.gz: b09300574c8c6475eda6c85ef1c8d2a9620743fa0be147e21fb08a2eaef5c527bf0577b9def206ec0d832e280a8bf27ed2b28b89fd368263fc6dbf3f9079ddcb
|
@@ -9,11 +9,18 @@ module Daimon
|
|
9
9
|
next if node.parent.name == "code" # skip code block
|
10
10
|
result[:plugins] = []
|
11
11
|
node.to_s.scan(/{{(.+?)}}/m) do |str|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
begin
|
13
|
+
parser = Daimon::Markdown::Parser.new(str[0])
|
14
|
+
parser.parse
|
15
|
+
plugin_class = Daimon::Markdown::Plugin.lookup(parser.name)
|
16
|
+
plugin = plugin_class.new(doc, node, result, context)
|
17
|
+
plugin.call(*parser.args)
|
18
|
+
rescue Daimon::Markdown::Parser::Error => ex
|
19
|
+
message = "#{node} (#{ex.class}: #{ex.message})"
|
20
|
+
node.replace(message)
|
21
|
+
rescue Daimon::Markdown::Plugin::UnknownPluginError => ex
|
22
|
+
node.replace(ex.message)
|
23
|
+
end
|
17
24
|
end
|
18
25
|
unless result[:plugins].empty?
|
19
26
|
scanner = StringScanner.new(node.to_s)
|
@@ -4,6 +4,9 @@ module Daimon
|
|
4
4
|
module Markdown
|
5
5
|
class Parser < Ripper
|
6
6
|
|
7
|
+
class Error < StandardError
|
8
|
+
end
|
9
|
+
|
7
10
|
KEYWORDS = {
|
8
11
|
"nil" => nil,
|
9
12
|
"true" => true,
|
@@ -83,6 +86,16 @@ module Daimon
|
|
83
86
|
@arrays[@level - 1] << @arrays[@level]
|
84
87
|
@level -= 1
|
85
88
|
end
|
89
|
+
|
90
|
+
def on_parse_error(message)
|
91
|
+
compile_error(message)
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
|
96
|
+
def compile_error(message)
|
97
|
+
raise Error, message
|
98
|
+
end
|
86
99
|
end
|
87
100
|
end
|
88
101
|
end
|
@@ -4,9 +4,14 @@ module Daimon
|
|
4
4
|
|
5
5
|
PLUGIN_REGISTRY = {}
|
6
6
|
|
7
|
+
class UnknownPluginError < StandardError
|
8
|
+
end
|
9
|
+
|
7
10
|
class << self
|
8
11
|
def lookup(name)
|
9
12
|
PLUGIN_REGISTRY.fetch(name)
|
13
|
+
rescue KeyError
|
14
|
+
raise UnknownPluginError, "Unknown plugin: #{name}"
|
10
15
|
end
|
11
16
|
|
12
17
|
def register(name, klass)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: daimon-markdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- daimon developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: html-pipeline
|