Giter Site home page Giter Site logo

Comments (6)

Alir3z4 avatar Alir3z4 commented on May 16, 2024

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.

theSage21 avatar theSage21 commented on May 16, 2024

I do not understand the issue? Is the preservation of spaces the bug in question?

from html2text.

aykevl avatar aykevl commented on May 16, 2024

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:

foo bar
foo bar

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.

theSage21 avatar theSage21 commented on May 16, 2024

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.

Alir3z4 avatar Alir3z4 commented on May 16, 2024

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.

Alir3z4 avatar Alir3z4 commented on May 16, 2024

Not a bug and based on #58 (comment) I'll close this.

from html2text.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.