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

Bug - Converting an <img> tag with a hypen in src and a src greater than 74 characters adds a newline after the hypen in the output #105

Open
mkmoisen opened this issue Sep 4, 2016 · 5 comments

Comments

@mkmoisen
Copy link

mkmoisen commented Sep 4, 2016

I noticed an odd bug when Converting an <img> tag containing:

  • A hyphen in the src
  • A src longer than 74 characters

Converting a <img> tag with a src of 74 characters or less works fine

> # Note the missing "y" in the last word, "supply"
>img = '<img src="http://matthewmoisen.com/blog/wp-content/matthew_moisen_tractor_suppl.jpg">'
>html2text.html2text(img)
u'![](http://matthewmoisen.com/blog/wp-content/matthew_moisen_tractor_suppl.jpg)\n\n'

> # Note the addition of the "y" in the last word, "supply"
>img = '<img src="http://matthewmoisen.com/blog/wp-content/matthew_moisen_tractor_supply.jpg">'
>html2text.html2text(img)
u'![](http://matthewmoisen.com/blog/wp-\ncontent/matthew_moisen_tractor_supply.jpg)\n\n'

See how a \n character has been added after wp- ?

@Alir3z4
Copy link

Alir3z4 commented Sep 5, 2016

@mkmoisen you might wanna have a look a this #91
The project has been moved to https://github.com/Alir3z4/html2text/

@JQ-K
Copy link

JQ-K commented Mar 3, 2020

I noticed an odd bug when Converting an <img> tag containing:

  • A hyphen in the src
  • A src longer than 74 characters

Converting a <img> tag with a src of 74 characters or less works fine

> # Note the missing "y" in the last word, "supply"
>img = '<img src="http://matthewmoisen.com/blog/wp-content/matthew_moisen_tractor_suppl.jpg">'
>html2text.html2text(img)
u'![](http://matthewmoisen.com/blog/wp-content/matthew_moisen_tractor_suppl.jpg)\n\n'

> # Note the addition of the "y" in the last word, "supply"
>img = '<img src="http://matthewmoisen.com/blog/wp-content/matthew_moisen_tractor_supply.jpg">'
>html2text.html2text(img)
u'![](http://matthewmoisen.com/blog/wp-\ncontent/matthew_moisen_tractor_supply.jpg)\n\n'

See how a \n character has been added after wp- ?

HI, i have the same problem as you so how did you resolve it? thx

@mkmoisen
Copy link
Author

mkmoisen commented Mar 3, 2020

@JQ-K Sorry I do not remember.

@JQ-K
Copy link

JQ-K commented Mar 6, 2020

@JQ-K Sorry I do not remember.
ok thx

@durcheinandermann
Copy link

I got around this issue by avoiding wrapping altogether. Using the bodywidth argument:
html2text(html=str(soup), bodywidth=0)

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

4 participants