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

Image title incorrect #24

Open
davidearl opened this issue Jun 23, 2016 · 1 comment
Open

Image title incorrect #24

davidearl opened this issue Jun 23, 2016 · 1 comment

Comments

@davidearl
Copy link

At present the alt text for an image is also put into the title, where the spec[1] puts the title as an optional string after the URL.

I think you can fix it as follows:
(a) change the links pattern at line 24 to
links: /!?\[([^\]<>]+)\]\(([^ \)<>]+)( "([^\(\)\"]+)")?\)/g,
(that is, to be enable extraction of the title text between the quotes), and

(b) replace the img element construction at line 190 with
str = str.replace(stra[0], '<img src="' + stra[2] + '" alt="' + stra[1] + '"' + (stra[4] ? '" title="' + stra[4] + '" ' : '') + '/>');
recognising that title is optional.

Thanks for this useful library.

[1] https://daringfireball.net/projects/markdown/syntax#img

@davidearl
Copy link
Author

Sorry, I had an extra quote, I meant:
str = str.replace(stra[0], '<img src="' + stra[2] + '" alt="' + stra[1] + '"' + (stra[4] ? ' title="' + stra[4] + '" ' : '') + '/>');

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

1 participant