ssmd 0.7.5 → 0.7.6

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: ecf3d2d52ae18bc5e1c7c996801388fa512866e3495ba546d6258124834c758d
4
- data.tar.gz: 951665f3407e4af8b3bf7fd8d6a595fe5c0be4f157ddf7aabf8ce7a0f23d1b0f
3
+ metadata.gz: 8f97931187a7312f6201c4ce78a63fe5ec3080ee7f4b2f6e24cce97616acc4c9
4
+ data.tar.gz: 4ee02c2d7331421f9572a65166fba8f5378e61b19b0b9ad6b3227f6d9e7dbbb1
5
5
  SHA512:
6
- metadata.gz: e95c06cdafd4d7f1db0b9ef48178113f16fc965230532e8881dbb156e8610595bd934dcc44688bb9cbf9c7681f24d2793e758563147efc9b90cf56b05628f647
7
- data.tar.gz: 94066e29be12d5a3878de87a8718e7922eeda54865b46cd915eedd8d9891e5c4f3f23e34cdfc5a0aaa6065882245881d2bd39051cf864f81d6accb554b1cd85d
6
+ metadata.gz: 8954f80d12937fa5de3714c286de4456b3757b35d2fc5995c55df99a5af166e4b9ac3a74dcf13e3df387e0d04528f21aed33c581562747e10265c6f6e7a8e29b
7
+ data.tar.gz: 16f0810ebe1eee55da7484c5f0d6a0c6c92576d967d4d04cefd29264bab4ece6db31780297ff6d86e55228f2ae5ab99f3eac3b5f9f518dafcca27a47c21f43d9
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  /.bundle/
2
+ /.idea/
2
3
  /.yardoc
3
4
  /Gemfile.lock
4
5
  /_yardoc/
@@ -6,6 +6,16 @@ module SSMD::Processors
6
6
  class AnnotationProcessor < Processor
7
7
  attr_reader :annotations
8
8
 
9
+ def self.annotations
10
+ a = SSMD::Annotations
11
+
12
+ [
13
+ a::LanguageAnnotation, a::PhonemeAnnotation, a::ProsodyAnnotation,
14
+ a::SubstitutionAnnotation
15
+ ]
16
+ .freeze
17
+ end
18
+
9
19
  def initialize(options = {})
10
20
  super
11
21
 
@@ -28,16 +38,6 @@ module SSMD::Processors
28
38
  end
29
39
  end
30
40
 
31
- def self.annotations
32
- a = SSMD::Annotations
33
-
34
- [
35
- a::LanguageAnnotation, a::PhonemeAnnotation, a::ProsodyAnnotation,
36
- a::SubstitutionAnnotation
37
- ]
38
- .freeze
39
- end
40
-
41
41
  def ok?
42
42
  !@text.nil? && Array(@annotations).size > 0
43
43
  end
@@ -1,7 +1,10 @@
1
1
  require_relative 'processor'
2
+ require_relative 'concerns/no_content'
2
3
 
3
4
  module SSMD::Processors
4
5
  class BreakProcessor < Processor
6
+ prepend NoContent
7
+
5
8
  def result
6
9
  name, value = attribute
7
10
 
@@ -13,7 +16,7 @@ module SSMD::Processors
13
16
  end
14
17
 
15
18
  def regex
16
- /(?<=\s)\.\.\.(?:(?<comma>c)|(?<sentence>s)|(?<paragraph>p)|(?<s>\d+s)|(?<ms>\d+ms)|(?<num>\d+))?(?=\s)/
19
+ /(?<=\s|\A)\.\.\.(?:(?<comma>c)|(?<sentence>s)|(?<paragraph>p)|(?<s>\d+s)|(?<ms>\d+ms)|(?<num>\d+))?(?=\s|\z)/
17
20
  end
18
21
 
19
22
  def attribute
@@ -35,18 +38,5 @@ module SSMD::Processors
35
38
  ["strength", "x-strong"]
36
39
  end
37
40
  end
38
-
39
- private
40
-
41
- def join_parts(prefix, text, suffix)
42
- leading_ws = /\A\s/
43
- trailing_ws = /\s\z/
44
-
45
- if prefix =~ trailing_ws && suffix =~ leading_ws && text == ""
46
- prefix.sub(trailing_ws, "") + suffix
47
- else
48
- super
49
- end
50
- end
51
41
  end
52
42
  end
@@ -0,0 +1,27 @@
1
+ ##
2
+ # This is for annotations which do not have any content, i.e. no enclosed
3
+ # text or other annotations. This is mostly relevant for stripping where
4
+ # this means that simply removing the annotation would leave an extra space.
5
+ #
6
+ # Prepending this module to processors for these kinds of annotations
7
+ # prevents that.
8
+ module NoContent
9
+ def join_parts(prefix, text, suffix)
10
+ leading_ws = /\A\s/
11
+ trailing_ws = /\s\z/
12
+
13
+ if text == ""
14
+ if prefix =~ trailing_ws && suffix =~ leading_ws
15
+ prefix.sub(trailing_ws, "") + suffix
16
+ elsif prefix == ""
17
+ suffix.sub(leading_ws, "")
18
+ elsif suffix == ""
19
+ prefix.sub(trailing_ws, "")
20
+ else
21
+ super
22
+ end
23
+ else
24
+ super
25
+ end
26
+ end
27
+ end
@@ -1,9 +1,18 @@
1
1
  require_relative 'processor'
2
+ require_relative 'concerns/no_content'
2
3
 
3
4
  module SSMD::Processors
4
5
  class MarkProcessor < Processor
6
+ prepend NoContent
7
+
5
8
  def result
6
- "<mark name=\"#{text}\"/>"
9
+ name = match.captures.first
10
+
11
+ "<mark name=\"#{name}\"/>"
12
+ end
13
+
14
+ def text
15
+ ""
7
16
  end
8
17
 
9
18
  def regex
@@ -1,3 +1,3 @@
1
1
  module SSMD
2
- VERSION = "0.7.5"
2
+ VERSION = "0.7.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ssmd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Kahl
@@ -116,6 +116,7 @@ files:
116
116
  - lib/ssmd/processors.rb
117
117
  - lib/ssmd/processors/annotation_processor.rb
118
118
  - lib/ssmd/processors/break_processor.rb
119
+ - lib/ssmd/processors/concerns/no_content.rb
119
120
  - lib/ssmd/processors/emphasis_processor.rb
120
121
  - lib/ssmd/processors/mark_processor.rb
121
122
  - lib/ssmd/processors/paragraph_processor.rb