ssmd 0.2.2 → 0.2.3

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
  SHA1:
3
- metadata.gz: 7ffb94aa873d4d92d8693c8c6144b271619fcc39
4
- data.tar.gz: 33d056ee0db82b7b9f865910aabd8eb0e684bf00
3
+ metadata.gz: 221fb4fbe3144a2331545c9ac3ab79a0dc4933b4
4
+ data.tar.gz: 508c4b8101fad140db26dc76350e45dc0d324d6d
5
5
  SHA512:
6
- metadata.gz: 6bd797db0dc2b8c36883a1e46cd42a37e1fc1401832db9bcf19ee6d7036efa281c9c31060316e90fea993370f9b7e6f2a07154c4eaa534f741c1bcbc5efda1a3
7
- data.tar.gz: 3ce6c6cb968839fea5a0a2e9c4137b4ca1dc0dff501d9b42961f89e26f8d229760855e7e78b15c4ee08e14858302dbd2c69694fa42f31dae3d43d8a3bbc74821
6
+ metadata.gz: 511a816ea8a953420f4a7bb7433fed1618c4c68f872add28efc73c38ff2045718fddedd134c5629682e1071d24085e0e484084368db36a1db2d16339ef534725
7
+ data.tar.gz: 23d2381df4964f49dfb0bf3f377fd2d0a827b6ebcb580a82be145cdf9034008e7a896d3765cf1dc844bef1599e7988c607aa3b98ec4087bb15bcde125a9bd4a9
@@ -41,12 +41,12 @@ SSML:
41
41
 
42
42
  SSMD:
43
43
  ```
44
- *word*
44
+ *command* & conquer
45
45
  ```
46
46
 
47
47
  SSML:
48
48
  ```html
49
- <emphasis>word</emphasis>
49
+ <emphasis>command</emphasis> &amp; conquer
50
50
  ```
51
51
 
52
52
  ***
@@ -14,7 +14,7 @@ module SSMD
14
14
  #
15
15
  # @return [String]
16
16
  def strip_ssmd(ssmd)
17
- Converter.new(to_ssml(ssmd)).strip
17
+ Converter.new(ssmd).strip
18
18
  end
19
19
 
20
20
  def root_dir
@@ -1,5 +1,4 @@
1
1
  require 'ssmd/processors'
2
- require 'rexml/document'
3
2
 
4
3
  module SSMD
5
4
  class Converter
@@ -10,7 +9,7 @@ module SSMD
10
9
  end
11
10
 
12
11
  def convert
13
- result = processors.inject(input) do |text, processor|
12
+ result = processors.inject(input.encode(xml: :text)) do |text, processor|
14
13
  process processor.new, text
15
14
  end
16
15
 
@@ -18,20 +17,8 @@ module SSMD
18
17
  end
19
18
 
20
19
  def strip
21
- doc = ::REXML::Document.new input
22
-
23
- if doc.root
24
- xml_text doc.root
25
- else
26
- input # no XML so we assume it is already stripped
27
- end
28
- end
29
-
30
- def xml_text(node)
31
- if node.is_a? REXML::Text
32
- node.to_s
33
- else
34
- node.children.map { |c| xml_text c }.join
20
+ processors.inject(input) do |text, processor|
21
+ process processor.new, text, strip: true
35
22
  end
36
23
  end
37
24
 
@@ -43,9 +30,10 @@ module SSMD
43
30
  ]
44
31
  end
45
32
 
46
- def process(processor, input)
33
+ def process(processor, input, strip: false)
47
34
  if processor.matches? input
48
- process processor, processor.substitute(input)
35
+ result = strip ? processor.strip_ssmd(input) : processor.substitute(input)
36
+ process processor, result, strip: strip
49
37
  else
50
38
  input
51
39
  end
@@ -4,10 +4,10 @@ require 'ssmd/annotations'
4
4
 
5
5
  module SSMD::Processors
6
6
  class AnnotationProcessor < Processor
7
- attr_reader :text, :annotations
7
+ attr_reader :annotations
8
8
 
9
9
  def result
10
- @text, annotations_text = match.captures
10
+ _, annotations_text = match.captures
11
11
 
12
12
  if annotations_text
13
13
  @annotations = combine_annotations parse_annotations(annotations_text)
@@ -3,8 +3,6 @@ require_relative 'processor'
3
3
  module SSMD::Processors
4
4
  class EmphasisProcessor < Processor
5
5
  def result
6
- text = match.captures.first
7
-
8
6
  "<emphasis>#{text}</emphasis>"
9
7
  end
10
8
 
@@ -3,8 +3,6 @@ require_relative 'processor'
3
3
  module SSMD::Processors
4
4
  class MarkProcessor < Processor
5
5
  def result
6
- text = match.captures.first
7
-
8
6
  "<mark name=\"#{text}\"/>"
9
7
  end
10
8
 
@@ -14,6 +14,16 @@ module SSMD::Processors
14
14
  end
15
15
  end
16
16
 
17
+ def strip_ssmd(input)
18
+ if match
19
+ match.pre_match + text + match.post_match
20
+ end
21
+ end
22
+
23
+ def text
24
+ match.captures.first
25
+ end
26
+
17
27
  def result
18
28
  raise "subclass responsibility"
19
29
  end
@@ -1,3 +1,3 @@
1
1
  module SSMD
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
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.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Kahl