GithubHelp home page GithubHelp logo

Error during cleanup about php-readability HOT 3 CLOSED

j0k3r avatar j0k3r commented on May 28, 2024
Error during cleanup

from php-readability.

Comments (3)

techexo avatar techexo commented on May 28, 2024

Here is some more information about the issue:

  1. It occurs only when a header element is empty. Even a space between the tags "fixes" the issue.
  2. It occurs with every header element >= h2 (i.e. h3, h4 etc.). (I suppose h1 are interpreted by default in graby as containing the title of the article, thus are stripped.)
  3. If the element has no class attribute, the following elements of same level (with or without class) are stripped from the code! (i.e. a <h2></h2> instruction will strip all following <h2> markups, even not empty!)
<h2></h2>
<p>Lorem ipsum.</p>
<h2 class="truc">Truc</h2>
<p>Lorem ipsum 2.</p>

<!-- will give -->

<p>Lorem ipsum.</p>
<p>Lorem ipsum 2.</p>
  1. It is not "class" dependant (i.e. <h2 id="truc"></h2> will give the same issue)
<h2 id="truc"></h2>
<p>Lorem ipsum.</p>
<h2 id="truc">Truc</h2>
<p>Lorem ipsum 2.</p>

<!-- will give -->

<h2>Lorem ipsum.
Truc</h2>
<p>Lorem ipsum 2.</p>
  1. The issue only appears up to the next occurrence of a header of same level:
<h2 class="truc"></h2>
<p>Lorem ipsum.</p>
<h2 class="truc">Truc</h2>
<h2 class="truc">Truc 2</h2>
<p>Lorem ipsum 3.</p>

<!-- will give -->

<h2>Lorem ipsum.
Truc</h2>
<h2 class="truc">Truc2</h2>
<p>Lorem ipsum 2.</p>
  1. Interestingly however, the problem disappears when the next header is not at the same level
<h2 class="truc"></h2>
<p>Lorem ipsum.</p>
<h3 class="truc">Truc</h3>
<p>Lorem ipsum 2.</p>

<!-- will give -->

<p>Lorem ipsum.</p>
<h3>Truc</h3>
<p>Lorem ipsum 2.</p>

It seems to be an issue finding the closing HTML markup when the markups are empty.

from php-readability.

techexo avatar techexo commented on May 28, 2024

New test: Using Tidy to clean the examples above with the options specified in php-readability doesn't fail.

from php-readability.

Kdecherf avatar Kdecherf commented on May 28, 2024

@j0k3r this issue can be closed as per j0k3r/graby#178

from php-readability.

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.