ssmd icon indicating copy to clipboard operation
ssmd copied to clipboard

Markdown Links always converted to Audio

Open de-dan opened this issue 4 years ago • 3 comments

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

de-dan avatar Jun 26 '20 10:06 de-dan

  • 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 ?

fabien88 avatar Jun 26 '20 16:06 fabien88

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

  1. 'expect audio' -> Markdown links are always converted to <audio> (as it is now)
  2. '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.
  3. '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

de-dan avatar Jun 26 '20 19:06 de-dan

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**');
}
`
``

de-dan avatar Jun 26 '20 21:06 de-dan