speechmarkdown / speechmarkdown-js

Speech Markdown grammar, parser, and formatters for use with JavaScript.
MIT License
76 stars 16 forks source link

Special characters are ignored by the formatters in the output #21

Closed rmtuckerphx closed 5 years ago

rmtuckerphx commented 5 years ago

The markdown includes special characters that help form constructs such as:

Text modifier - (text)[key:’value’;key;key:’value’) Header - #[ key:’value’; key:’value’] Audio - ![‘url’]

When these special characters are included in non-markdown text or as the text portion of the text modifier,these characters are not rendering even though they should.

For example, the following Speech Markdown:

This is text with (parens) but this and other special characters: []()*~`@#\\_!+- are ignored

Is currently being rendered as:

<speak>
This is text with parens but this and other special characters:  are ignored
</speak>

When instead it should be rendered as:

<speak>
This is text with (parens) but this and other special characters: []()*~`@#\\_!+- are ignored
</speak>
rmtuckerphx commented 5 years ago

See skipped tests in modifier-text-allowed-chars.spec.ts

cdiggins commented 5 years ago

Looking at: this.inline = m.choice(this.textModifier, this.emphasis, this.shortBreak, this.breakStrength, this.breakTime, this.audio, this.plainText, this.any).unless(m.newLine);

Maybe you just need to create a new named rule to replace the 'this.any`. For example:

this.specialChar = m.newLine;

And then:

this.inline = m.choice(this.textModifier, this.emphasis, this.shortBreak, this.breakStrength, this.breakTime, this.audio, this.plainText, this.specialChar).unless(m.newLine);

Your formatter will then be able to handle specialChar and pass it through.

I hope this helps.