Skip to content

Commit

Permalink
implemented Break; version 0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
machisuji committed May 16, 2017
1 parent a6c03eb commit 8c84d69
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ This version is still under development. See below which essential SSML construc

* [x] Text
* [x] Emphasis
* [ ] Break
* [x] Break
* [x] Language
* [x] Mark
* [x] Paragraph
Expand Down
16 changes: 8 additions & 8 deletions SPECIFICATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ Hello ...100 world (100 millisecond break (max 10000ms))

SSML:
```html
Hello <break strength="x-strong"/> world
Hello - <break strength="none"/> world
Hello <break strength="medium"/> world
Hello <break strength="strong"/> world
Hello <break strength="x-strong"/> world
Hello <break time="5s"/> world
Hello <break time="100ms"/> world
Hello <break time="100ms"/> world
Hello <break strength="x-strong"/> world (default: x-strong break like after a paragraph)
Hello - <break strength="none"/> world (skip break when there would otherwise be one like after this dash)
Hello <break strength="medium"/> world (medium break like after a comma)
Hello <break strength="strong"/> world (strong break like after a sentence)
Hello <break strength="x-strong"/> world (extra string break like after a paragraph)
Hello <break time="5s"/> world (5 second break (max 10s))
Hello <break time="100ms"/> world (100 millisecond break (max 10000ms))
Hello <break time="100ms"/> world (100 millisecond break (max 10000ms))
```

***
Expand Down
2 changes: 1 addition & 1 deletion lib/ssmd/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def processors

[
p::EmphasisProcessor, p::AnnotationProcessor, p::MarkProcessor,
p::ProsodyProcessor, p::ParagraphProcessor
p::ProsodyProcessor, p::ParagraphProcessor, p::BreakProcessor
]
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/ssmd/processors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module SSMD::Processors

require 'ssmd/processors/processor'
require 'ssmd/processors/annotation_processor'
require 'ssmd/processors/break_processor'
require 'ssmd/processors/emphasis_processor'
require 'ssmd/processors/mark_processor'
require 'ssmd/processors/prosody_processor'
Expand Down
35 changes: 35 additions & 0 deletions lib/ssmd/processors/break_processor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require_relative 'processor'

module SSMD::Processors
class BreakProcessor < Processor
def result
name, value = attribute

"<break #{name}=\"#{value}\"/>"
end

def regex
/(?<=\s)\.\.\.(?:(?<comma>c)|(?<sentence>s)|(?<paragraph>p)|(?<s>\d+s)|(?<ms>\d+ms)|(?<num>\d+))?(?=\s)/
end

def attribute
if ms = (match[:num] || match[:ms])
if ms == "0"
["strength", "none"]
else
["time", "#{ms.to_i}ms"]
end
elsif s = match[:s]
["time", "#{s.to_i}s"]
elsif match[:paragraph]
["strength", "x-strong"]
elsif match[:sentence]
["strength", "strong"]
elsif match[:comma]
["strength", "medium"]
else
["strength", "x-strong"]
end
end
end
end
2 changes: 1 addition & 1 deletion lib/ssmd/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module SSMD
VERSION = "0.5.0"
VERSION = "0.6.0"
end
4 changes: 4 additions & 0 deletions spec/ssmd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def check_case(title, skip: [])
expect(result).to eq spec.output
end

it "converts Break" do
check_case "Break"
end

it "converts Emphasis" do
check_case "Emphasis"
end
Expand Down

0 comments on commit 8c84d69

Please sign in to comment.