ssmd 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d42b96948cc0f6cba51d32c373859288da241fb8
4
- data.tar.gz: d8e345a4e1447f8f57b50d5f75bcf596257ecf0e
2
+ SHA256:
3
+ metadata.gz: d09b748d209127855bbf790dc89eaa53891d978b3070773212203a6c1d460dc4
4
+ data.tar.gz: 90495308c981fd7cd3b857c05461a478ed287878fe79832584b67625ed768351
5
5
  SHA512:
6
- metadata.gz: 27513191b8e046618af615c43dc0ac517095cdcd2a4608374cde81aa15db9b7b60a400b6c36a3d574371ace84fbfe6b908a10559dcec46fe2821fd9a82290cdc
7
- data.tar.gz: 4e0dd07a0420d06b991495690a4c5843fdcc71236de492c389c6ddb2fd5f559b507d060eca10005427e5b2e14b4ef9486f60932c06381ced2ae874d559194aa7
6
+ metadata.gz: 80f139fc45586b23c2247275f7ffcca9c06d1664a123e25f7ff418ee15613cc0b59515d22b6de3aaca2b96eb61e9bb6921bec7a91b9ce5b001f19b49f18e16d1
7
+ data.tar.gz: 236365024367acb03f85422e30c4b773e80c478ef5d8743b4f65b85abc434511bbaa440b6a656cf011b743a7146c6b7e535597e5884eb325c904465e85a57b66
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/machisuji/ssmd.svg?branch=master)](https://travis-ci.org/machisuji/ssmd)
4
4
 
5
- Speech Synthesis Markdown (SSMD) is an lightweight alternative syntax for [SSML](https://www.w3.org/TR/speech-synthesis/).
5
+ Speech Synthesis Markdown (SSMD) is a lightweight alternative syntax for [SSML](https://www.w3.org/TR/speech-synthesis/).
6
6
  This repository contains both the reference implementation of the SSMD-to-SSML conversion tool (`ssmd`) as well
7
7
  as the [specification](SPECIFICATION.md) of the language.
8
8
 
@@ -28,6 +28,8 @@ Or install it yourself as:
28
28
 
29
29
  ## Usage
30
30
 
31
+ You can convert SSML to SSMD using `SSMD::to_ssml`:
32
+
31
33
  ```ruby
32
34
  require 'ssmd'
33
35
 
@@ -38,6 +40,19 @@ puts ssml
38
40
  # Output: <speak>hello <emphasis>SSMD</emphasis>!</speak>
39
41
  ```
40
42
 
43
+ Sometimes you will want to see just the plain text without any SSMD annotations.
44
+ For this you can use `SSMD::stip_ssmd`:
45
+
46
+ ```ruby
47
+ require 'ssmd'
48
+
49
+ ssmd = "[hallo](de) *SSMD*!"
50
+ plain_text = SSMD.strip_ssmd ssmd
51
+
52
+ puts plain_text
53
+ # Output: hallo SSMD!
54
+ ```
55
+
41
56
  **Note:**
42
57
 
43
58
  This version is still under development. See below which essential SSML constructs are implemented so far:
@@ -107,7 +107,7 @@ I saw <lang xml:lang="de-DE">"Die Häschenschule"</lang> in the cinema.
107
107
 
108
108
  ### Mark
109
109
 
110
- Sections of text can be tagged using marks. They do not effect the synthesis but
110
+ Sections of text can be tagged using marks. They do not affect the synthesis but
111
111
  can be returned by SSML processing engines as meta information and to emit
112
112
  events during processing based on these marks.
113
113
 
@@ -242,7 +242,7 @@ medium
242
242
  ```
243
243
 
244
244
  The shortcuts are listed first. While they can be combined, sometimes it's easier and shorter to just use
245
- the explizit form shown in the last 2 lines. All of them can be nested, too.
245
+ the explicit form shown in the last 2 lines. All of them can be nested, too.
246
246
  Moreover changes in volume (`[louder](v: +10dB)`) and pitch (`[lower](p: -4%)`) can also be given explicitly in relative values.
247
247
 
248
248
  ***
@@ -1,4 +1,5 @@
1
1
  require 'ssmd/processors'
2
+ require 'cgi'
2
3
 
3
4
  module SSMD
4
5
  class Converter
@@ -14,7 +15,7 @@ module SSMD
14
15
  end
15
16
 
16
17
  def convert
17
- result = processors.inject(input.encode(xml: :text)) do |text, processor|
18
+ result = processors.inject(escape_xml(input)) do |text, processor|
18
19
  process processor.new(processor_options), text
19
20
  end
20
21
 
@@ -22,9 +23,11 @@ module SSMD
22
23
  end
23
24
 
24
25
  def strip
25
- processors.inject(input) do |text, processor|
26
+ result = processors.inject(escape_xml(input)) do |text, processor|
26
27
  process processor.new(processor_options), text, strip: true
27
28
  end
29
+
30
+ unescape_xml result
28
31
  end
29
32
 
30
33
  def processors
@@ -50,5 +53,22 @@ module SSMD
50
53
  def processor_options
51
54
  { skip: skip }
52
55
  end
56
+
57
+ ##
58
+ # Substitutes special characters with their XML entity.
59
+ # E.g. it substitutes "<" with "&lt;".
60
+ def escape_xml(text)
61
+ text.encode(xml: :text)
62
+ end
63
+
64
+ ##
65
+ # Substitutes back XML entities with their plain text equivalent.
66
+ # E.g. it substitutes "&lt;" with "<".
67
+ #
68
+ # @TODO Find alternative which applies to XML in general.
69
+ # Not sure if it even makes a difference in this case, though.
70
+ def unescape_xml(text)
71
+ CGI.unescape_html text
72
+ end
53
73
  end
54
74
  end
@@ -1,3 +1,3 @@
1
1
  module SSMD
2
- VERSION = "0.7.3"
2
+ VERSION = "0.7.4"
3
3
  end
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.7.3
4
+ version: 0.7.4
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-06-09 00:00:00.000000000 Z
11
+ date: 2018-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  version: '0'
145
145
  requirements: []
146
146
  rubyforge_project:
147
- rubygems_version: 2.6.12
147
+ rubygems_version: 2.7.6
148
148
  signing_key:
149
149
  specification_version: 4
150
150
  summary: Speech Synthesis Markdown (SSMD) is an lightweight alternative syntax for