Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown Links always converted to Audio #6

Open
de-dan opened this issue Jun 26, 2020 · 3 comments
Open

Markdown Links always converted to Audio #6

de-dan opened this issue Jun 26, 2020 · 3 comments

Comments

@de-dan
Copy link

de-dan commented Jun 26, 2020

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

@fabien88
Copy link
Owner

@de-dan
Copy link
Author

de-dan commented Jun 26, 2020

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
Copy link
Author

de-dan commented Jun 26, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants