speechmarkdown/speechmarkdown-js

Grammar - multiple modifiers for the same text

Closed this issue · 0 comments

When you have more than one modifier on the same text:

Your balance is: (12345)[number;emphasis:"strong"].

The resulting SSML should return nested tags:

      <speak>
      Your balance is: <say-as interpret-as="number"><emphasis level="strong">12345</emphasis></say-as>.
      </speak>

Various tests in multiple-modifiers-same-text.spec.ts have been skipped. Need to fix the formatters for Alexa and Google Assistant to handle processing multiple tags.

The solution should include a list of valid SSML tags with a sortId so that the rendering of the SSML is consistent regardless of the order of the modifiers in Speech Markdown.

The .ast ending in the rules in SpeechMarkdownGrammar.ts specify what will appear as nodes in the Abstract Syntax Tree (AST). Currently textModifier, textModifierText, and textModifierKey have .ast. Possibly another rule needs .ast so that each key/value pair will appear together.

Use the following to see a text rendering of the AST:

const smd = require('speechmarkdown-js');

const markdown = `Your balance is: (12345)[number;emphasis:"strong"].`;
const options = {
    platform: 'amazon-alexa'
};

const speech = new smd.SpeechMarkdown();
const tree = speech.toASTString(markdown);

The result will be something like:

(document: (paragraph: (simpleLine: (plainText: Your balance is: ) (textModifier: (plainText: 12345) (textModifierKey: number) (textModifierKey: emphasis) (textModifierText: strong)) (plainText: .) (lineEnd: ))))