Skip to content

Commit 44e1002

Browse files
authored
Allow explicit inclusion of end tag to support Bixby audio (#44)
1 parent 0ccf17c commit 44e1002

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/formatters/SamsungBixbySsmlFormatter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export class SamsungBixbySsmlFormatter extends SsmlFormatterBase {
215215
// }
216216
case 'audio': {
217217
const url = ast.children[0].allText;
218-
return this.addTagWithAttrs(lines, null, 'audio', { src: url });
218+
return this.addTagWithAttrs(lines, null, 'audio', { src: url }, true);
219219
}
220220
case 'simpleLine': {
221221
this.processAst(ast.children, lines);

src/formatters/SsmlFormatterBase.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,15 @@ export abstract class SsmlFormatterBase extends FormatterBase {
149149
return '<' + tag + attrStr + '/>';
150150
}
151151

152-
protected addTagWithAttrs(lines: string[], text: string, tag: string, attrs: any): string[] {
152+
protected addTagWithAttrs(lines: string[], text: string, tag: string, attrs: any, forceEndTag:boolean = false): string[] {
153153

154-
if (text) {
154+
if (text || forceEndTag) {
155155
lines.push(this.startTag(tag, attrs));
156-
lines.push(text);
156+
157+
if (text) {
158+
lines.push(text);
159+
}
160+
157161
lines.push(this.endTag(tag, false));
158162
}
159163
else {

tests/audio-standard.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('audio-standard', () => {
5454

5555
const expected = dedent`
5656
<speak>
57-
<audio src="https://www.speechmarkdown.org/test.mp3"/>
57+
<audio src="https://www.speechmarkdown.org/test.mp3"></audio>
5858
Announcing Speech Markdown.
5959
</speak>
6060
`;
@@ -130,7 +130,7 @@ describe('audio-standard single quote', () => {
130130

131131
const expected = dedent`
132132
<speak>
133-
<audio src="https://www.speechmarkdown.org/test.mp3"/>
133+
<audio src="https://www.speechmarkdown.org/test.mp3"></audio>
134134
Announcing Speech Markdown.
135135
</speak>
136136
`;
@@ -202,7 +202,7 @@ describe('audio-standard soundbank', () => {
202202

203203
const expected = dedent`
204204
<speak>
205-
<audio src="soundbank://soundlibrary/alarms/air_horns/air_horn_01"/> Air horn
205+
<audio src="soundbank://soundlibrary/alarms/air_horns/air_horn_01"></audio> Air horn
206206
</speak>
207207
`;
208208

0 commit comments

Comments
 (0)