Comments (6)
I don't think this is a big bug.
Spaces and half-spaces should be preserved for some formatting reasons.
I'll leave this issue here for now, but It shouldn't be considered as a bug.
Although formatting options/flags are welcome.
half-spaces: In Persian based languages such as Arabic, Farsi, Dari, etc is a must. Words like می باشد and میباشد are such examples.
from html2text.
I do not understand the issue? Is the preservation of spaces the bug in question?
from html2text.
I had to work aroud this bug in another project, as the text version was showing two spaces where the HTML version (in an email) was showing only one space as intended.
As an additional argument, when the spaces are at one side of the link tag, html2text only outputs one space:
>>> h.handle('foo <a href="/">bar</a>')
u'foo [bar](/)\n\n'
>>> h.handle('foo<a href="/"> bar</a>')
u'foo[ bar](/)\n\n'
>>> h.ignore_links = True
>>> h.handle('foo <a href="/">bar</a>')
u'foo bar\n\n'
>>> h.handle('foo<a href="/"> bar</a>')
u'foo bar\n\n'
Just like browsers do:
Note that the space in the second example is part of the link (in Chrome).
I don't know how non-Latin-based languages do this formatting.
@theSage21 the problem is that there are two spaces rendered where there should be (in my opinion and as browsers indicate) only one.
from html2text.
A browser renders one space irrespective of how many spaces are there between two words.
Creating a file sample.html
or testing here with the following html
<p>arjoonn sharma
<br>
arjoonn sharma</p>
shows that the spaces do not matter and only one space is rendered even though the html is evidently not the same.
@aykevl My point being that html2text preserves information from the original html and translates that to text.
edit
Maybe we should be stripping the link texts? @Alir3z4 your take on this?
from html2text.
As @mcepl once mentioned can we transform the data to its original form or we gonna loose the format of the original.
We're fine with any implementations as long as the text can keep it's original form after parsing to html by python markdown parser.
@mcepl do you have any input on this?
from html2text.
Not a bug
and based on #58 (comment) I'll close this.
from html2text.
Related Issues (20)
- Semicolon in Text with &#. HOT 1
- 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
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.