Comments (11)
szepeviktor:
I expected [állás: Country Manager](http://thth)
Are accents converted by default?
from html2text.
szepeviktor it's because html2text
like to see the world as ASCII only and seems to think there's only English with 26 letters only, with giving mercy to some characters too.
Well this need to be fixed, text should be be utf-8 and encoded too.
In [23]: html2text.html2text(u'<a href="go.com" class="nolink">állás: Country Manager]</a>')
Out[23]: u'[\xe1ll\xe1s: Country Manager]](go.com)\n\n'
or just simply:
In [37]: print html2text.html2text(u'<a href="go.com" class="nolink">állás: Country Manager]</a>')
[állás: Country Manager]](go.com)
I guess we need to encode the text before feeding it to html2text
, right?
from html2text.
szepeviktor:
Yes. Only a one-byte HTML entity will get outside the anchor, not an UTF-8 character.
from html2text.
I guess it should be handled by html2text, I mean encoding the input to
utf8.
Feel free to patch and make it by default.
from html2text.
This is only caused when the link text begins with a char reference.
<a href="http://thth">állás: Country Manager</a>
causes the bug.
<a href="http://thth"> állás: Country Manager</a>
translates correctly to
[ állás: Country Manager](http://thth)
This is because the first call is to handle_charref
and after that handle_data
and handle_data
is the function that adds the '['.
Fixed in #77
from html2text.
The issue is solved in #77. Can we close this?
from html2text.
Please wait till I get home, and confirm.
from html2text.
@szepeviktor sure sure. it is morning again and I have to sleep. See you on the other side of the sun. 😄
from html2text.
There is a problem:
$ echo $LANG
en_US.UTF-8
$ echo '<a href="http://thth" class="nolink" style="text-decoration:none;color:inherit;cursor:default;">állás: Country Manager</a>'| ./html2text
[allas: Country Manager](http://thth)
Shouldn't á
be á
?
from html2text.
@szepeviktor The command line by default works with ASCII. Hence they are being converted to ASCII equivalents. As of now there is no command line option for unicode
. Try this.
>>>import html2text as h2t
>>>H2T = h2t.HTML2Text()
>>>html = '<a href="http://thth" class="nolink" style="text-decoration:none;color:inherit;cursor:default;">állás: Country Manager</a>'
>>>md_ascii = H2T.handle(html)
>>>H2T.unicode_snob = True
>>>md_unicode = H2T.handle(html)
>>>print(md_ascii)
[allas: Country Manager](http://thth)
>>>print(md_unicode)
[állás: Country Manager](http://thth)
>>>
from html2text.
Thank you.
Please merge #77.
from html2text.
Related Issues (20)
- IndexError when padding nested tables HOT 2
- inline tags within strong/strike/u/i/em/... do not handle spaces correctly
- Different results when `HTML2Text` object is reused HOT 2
- Strip leading/trailing whitespace for links and inline code HOT 1
- Cannot provide space between content of <option> tag in <select>
- The export format is incorrect when the table tag contains < p > or < br >
- Featurerequest: Output without markdown HOT 3
- RE_MD_DASH_MATCHER does not exist in the HTML2TEXT() object
- Character reference replacement results in raw HTML
- Broken Images in README.md HOT 2
- How can I parse the `<pre>` tag into tri-backquote style?
- [Bug] Assumes first row is always table header even if it is not
- --ignore-links flag creates new composite words in output
- Link titles break with encoded quote
- Ignoring some elements
- HTML <picture> Element not returned as image link from srcset
- charref() maybe throw OverflowError: Python int too large to convert to C int HOT 1
- Extra "\" slashes before specific numeric
- `.handle()` w/ new text yields previous results if AssertionError is raised
- Considered using the rust library html2text under the hood? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from html2text.