Giter Club home page Giter Club logo

html2text's People

Contributors

andrewnicols avatar dsas avatar dvdoug avatar ianhk avatar mario-kinesissurvey-com avatar mtibben avatar nyholm avatar pstast avatar pwillcode avatar scaytrase avatar scrutinizer-auto-fixer avatar synchro avatar voku avatar wolfwolker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

html2text's Issues

Undefined index: mbstring

I am getting this error:

  • Undefined index: mbstring.

captura de pantalla 2019-02-04 a la s 11 21 08

The way I fixed was adding:

self::checkForSupport();

at the beginning of html_entity_decode function (line 2444 of the UTF8.php file).

Is this the best way to fix?

thanks!

thank you!

thank you for your libraries! just awesome

Ordered list handling

Hi,

Firstly wanted to say thanks for your great work in extending the use of this library!

My question is about ordered lists: I would like to be able to display them as follows:

  1. Item one
  2. Item two
  3. Item three

instead of using asterisks for each list item. Is this possible?

What happened to the LICENSE?

There is a LICENSE file, which is a GPL v. 2, plus some badly formatted extra advertising clause talking about commands and stuff.

Looks like something got very badly copy-pasted carelessly.

I strongly suggest against any of that:

  1. Adding clauses to the GPL is strongly against both the spirit of the GPL itself, and senseless, because it will make your software incompatible with the real GPL (so why use it in the first place)
  2. Why version 2? Why not "or any later version"? Is that intentional? I assume that's another mistake.
  3. Why the GPL in the first place? It's an extremely poor choice for such a library. Just go with a permissive license instead, such as MS-PL or BSD. Or, if you really want to be a pain, AGPL is what you want. GPL is just senseless for something meant to run on a server.
  4. Are you sure you have the right to re-license the original software? It wasn't licensed at all, AFAIK. Which is already a non trivial problem.

html2text does not work with uppercase html tags

print (new Html2Text('<P>Test string</P>'))->getText();

prints nothing while

print (new Html2Text('<p>Test string</p>'))->getText()

prints Test string as expected.

The reason for that is in \voku\Html2Text\Html2Text::pregCallback.
$matches['element'] is initially converted to lowercase with

$element = \strtolower($matches['element']);

but the lowercase version is not used in the switch statement or to match headings:

protected function pregCallback(array $matches): string
    {
        // init
        $element = \strtolower($matches['element']);

        switch ($matches['element']) { // Case sensitive
            case 'p':
                // Replace newlines with spaces.
                $para = \str_replace("\n", ' ', $matches['value']);

                // Add trailing newlines for this paragraph.
                return "\n\n" . $para . "\n\n";
                ...
                ...
        }

        // h1 - h6
        if (\preg_match('/h[123456]/', $matches['element'])) {  // Case sensitive
            return $this->convertElement($matches['value'], $matches['element']);
        }

I don't understand why pregCallback returns an empty string as last line.
Shouldn't the code always know how to handle the $matches['element'] that ends up in pregCallback?
Wouldn't it be better to throw an exception in case there is no handling available for a match $matches['element']
or return $matches['value'] ?? ''?

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.