ssmd 0.3.1 → 0.4.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 -0
- data/SPECIFICATION.md +4 -2
- data/lib/ssmd/converter.rb +12 -6
- data/lib/ssmd/processors/paragraph_processor.rb +21 -0
- data/lib/ssmd/processors/prosody_processor.rb +1 -1
- data/lib/ssmd/processors.rb +1 -0
- data/lib/ssmd/version.rb +1 -1
- data/lib/ssmd.rb +14 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bf70e02b121cec8728e59ae56a22e8a96024336
|
4
|
+
data.tar.gz: '00582115495e3b0ccc088f5c268cd367e0602630'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8cfcf7f8f4c809a980970b2e5c9380d7ec798263352896fa27203be998eb4d1cd4a3c57891d7c5e8e257ae76251d29bce00658896cf6df274aa261d03786f33
|
7
|
+
data.tar.gz: 65aadce5e10d597d1d1c14eca36bd843ad6092f3342910915d5bcf10faca47d751c0f9c0da5763f2e105d4a5c8e0a10ca3c0451f91a6c47d9162d95e89efaf25
|
data/README.md
CHANGED
data/SPECIFICATION.md
CHANGED
@@ -133,12 +133,14 @@ First prepare the ingredients.
|
|
133
133
|
Don't forget to wash them first.
|
134
134
|
|
135
135
|
Lastly mix them all together.
|
136
|
+
|
137
|
+
Don't forget to do the dishes after!
|
136
138
|
```
|
137
139
|
|
138
140
|
SSML:
|
139
141
|
```html
|
140
|
-
<p>First prepare the ingredients.
|
141
|
-
|
142
|
+
<p>First prepare the ingredients.
|
143
|
+
Don't forget to wash them first.</p><p>Lastly mix them all together.</p><p>Don't forget to do the dishes after!</p>
|
142
144
|
```
|
143
145
|
|
144
146
|
***
|
data/lib/ssmd/converter.rb
CHANGED
@@ -4,8 +4,12 @@ module SSMD
|
|
4
4
|
class Converter
|
5
5
|
attr_reader :input
|
6
6
|
|
7
|
-
def initialize(input)
|
7
|
+
def initialize(input, skip: [])
|
8
8
|
@input = input
|
9
|
+
|
10
|
+
processors.delete_if do |processor|
|
11
|
+
Array(skip).any? { |name| processor.name =~ /\ASSMD::Processors::#{name}Processor\Z/i }
|
12
|
+
end
|
9
13
|
end
|
10
14
|
|
11
15
|
def convert
|
@@ -23,12 +27,14 @@ module SSMD
|
|
23
27
|
end
|
24
28
|
|
25
29
|
def processors
|
26
|
-
|
30
|
+
@processors ||= begin
|
31
|
+
p = SSMD::Processors
|
27
32
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
33
|
+
[
|
34
|
+
p::EmphasisProcessor, p::AnnotationProcessor, p::MarkProcessor,
|
35
|
+
p::ProsodyProcessor, p::ParagraphProcessor
|
36
|
+
]
|
37
|
+
end
|
32
38
|
end
|
33
39
|
|
34
40
|
def process(processor, input, strip: false)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative 'processor'
|
2
|
+
|
3
|
+
module SSMD::Processors
|
4
|
+
class ParagraphProcessor < Processor
|
5
|
+
def result
|
6
|
+
"<p>" + match.string.gsub(regex, "</p><p>") + "</p>"
|
7
|
+
end
|
8
|
+
|
9
|
+
def regex
|
10
|
+
/\n\n+/
|
11
|
+
end
|
12
|
+
|
13
|
+
def substitute(input)
|
14
|
+
result if match
|
15
|
+
end
|
16
|
+
|
17
|
+
def strip_ssmd(input)
|
18
|
+
input.gsub(regex, "\n") if match
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/ssmd/processors.rb
CHANGED
data/lib/ssmd/version.rb
CHANGED
data/lib/ssmd.rb
CHANGED
@@ -4,17 +4,27 @@ require "ssmd/converter"
|
|
4
4
|
module SSMD
|
5
5
|
module_function
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
##
|
8
|
+
# Translates the given SSMD text to SSML.
|
9
|
+
#
|
10
|
+
# @param ssmd [String] The SSMD markup to be converted to SSML
|
11
|
+
# @param skip [Array<Symbol>] Formats (e.g. `:paragraph`, `:prosody`) to skip.
|
12
|
+
#
|
13
|
+
# @return [String] Resulting SSML
|
14
|
+
def to_ssml(ssmd, skip: [])
|
15
|
+
Converter.new(ssmd, skip: skip).convert
|
9
16
|
end
|
10
17
|
|
11
18
|
##
|
12
19
|
# Returns the given string without any SSMD annotations.
|
13
20
|
# For instance for `hello *world*` would return `hello world`.
|
14
21
|
#
|
22
|
+
# @param ssmd [String] The SSMD markup to strip from SSMD annotations.
|
23
|
+
# @param skip [Array<Symbol>] Formats (e.g. `:paragraph`, `:prosody`) to skip.
|
24
|
+
#
|
15
25
|
# @return [String]
|
16
|
-
def strip_ssmd(ssmd)
|
17
|
-
Converter.new(ssmd).strip
|
26
|
+
def strip_ssmd(ssmd, skip: [])
|
27
|
+
Converter.new(ssmd, skip: skip).strip
|
18
28
|
end
|
19
29
|
|
20
30
|
def root_dir
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ssmd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Markus Kahl
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/ssmd/processors/annotation_processor.rb
|
117
117
|
- lib/ssmd/processors/emphasis_processor.rb
|
118
118
|
- lib/ssmd/processors/mark_processor.rb
|
119
|
+
- lib/ssmd/processors/paragraph_processor.rb
|
119
120
|
- lib/ssmd/processors/processor.rb
|
120
121
|
- lib/ssmd/processors/prosody_processor.rb
|
121
122
|
- lib/ssmd/version.rb
|