ssmd
ssmd copied to clipboard
Markdown Links always converted to Audio
Hello,
consider the following Markdown:
This is a [link](http://example.com/).
This will be converted to
...
<audio src="http://example.com/">
<desc>
link
</desc>
</audio>
This is obviously not audio :D
-
maybe we can guess if it's an audio link from the extension (last 3 chars in path) https://en.wikipedia.org/wiki/Audio_file_format
-
if it's not an audio link, have you a proposal of what would be the resulting ssml ?
As it is possible to link to a audio file without extension, I think, we should have a more flexible solution - at least to not break existing behaviour. It should be possible to select one of the following options
- 'expect audio' -> Markdown links are always converted to
<audio>
(as it is now) - 'smart detect' -> detect audio file via file extension. Use the given wikipedia list as default. (maybe we should sort out old, uncommon formats), would be nice if you could overwrite the list.
- 'no audio' -> Do not convert to
<audio>
, even if the link ends with e.g. *.mp3.
If it's not an audio link, it is a link to everything else but audio (obvious, right? :D). So, I think, the resulting ssml should contain:
- if the link description and link are equal = Only the description
- else both description and actual link
- without brackets and maybe with emphasis
My current workaround is to strip the markdown-links with a regex:
/**
* Deletes the markdown link and replaces with the link description
* @example '[link description](www.example.com)' is transformed to '**link description**'
* @param text
*/
private static stripLinksFromMarkdown(markdownText: string = ''): string {
return markdownText.replace(/\[(.*?)]\((.*?)\)/gm, '**$1**');
}
`
``