Comments (15)
Also occurs when there is nbsp (u+a0) at the end of the line.
<div></div>
Google is eaten
It seems only block elements do this. Inline elems are unaffected. Only Parsedown Extra is affected.
from parsedown-extra.
I can confirm that this is a serious issue. What makes this a particularly nasty bug is that it results in a complete loss of the data as it was originally intended.
<div>1</div><p>2</p>
The p tag (and contents), along with this line are eaten.
from parsedown-extra.
I left a small donation hoping that it helps others resolve this.
from parsedown-extra.
I'll see what I can do. It might take some time, though. I'll be quite busy over the next couple of weeks.
from parsedown-extra.
It might take some time, though.
Copy that :-) I'm a veteran with PHP, but new to Parsedown. Any ideas where I might start debugging this? If so I might be able to submit a PR for this.
from parsedown-extra.
Sure,
It's in the blockMarkup
methods in Parsedown.php
.
Parsedown does supports one line block-level elements, but it looks for a closing tag at the end of the line. It doesn't consider the element closed when it doesn't find a closing tag at the end of the line.
You could give it a shot, but it might take me much less time to fix. Unless it's urgent, it might make more sense to wait.
from parsedown-extra.
@erusev writes...
blockMarkup methods in Parsedown.php
Thank you :-) I'll take a look at this in the next day or so and see what I can make of it. Otherwise, I'll wait patiently as suggested.
from parsedown-extra.
I noticed an issue with a self closing element which ended in an endless loop. If an element doesn't have any children, the html should be appended directly and not through processText().
I've fixed this in:
storeman@ddd0d0b
from parsedown-extra.
@storeman Can you provide an example that I can use to reproduce the issue?
from parsedown-extra.
First,I have to say it only occurs in the fix from @acmitch. The block element problem seems to be resolved.
Just process '<iframe />' gave me this issue.
I wanted to notify you about this, in case you wanted to merge the fix from @acmitch.
from parsedown-extra.
@storeman Ah, I see, thanks, I appreciate it.
from parsedown-extra.
Had more issues today with the solution from @acmitch. I deleted my fork because i could not find the clear edge case where his solution was breaking my html. One of the issues was, textareas were replicated and the dom-structure was altered. For example:
<textarea></textarea>
<label><input type="checkbox"> <a href="#">Some test</a></label>
Became
<textarea><textarea></textarea></textarea>
<label><input type="checkbox"></label> <a href="#">Some test</a>
It was caused by the surrounding html, but those 13000 lines were to hard to walk through.
from parsedown-extra.
@storeman thanks for the feedback! Found a few issues related to the code block you provided.
<textarea></textarea>
<label><input type="checkbox"> <a href="#">Some test</a></label>
The first issue, as you mentioned above, was that specific elements were causing endless loops. This has been fixed in my latest commit acmitch@468ecc6
It is important to note that all inline or voided HTML elements must be within the $this->textLevelElements
and $this->voidElements
arrays located within the parsedown library for my fix to work properly.
Therefore, to fix the textarea
issue you must add the textarea
value to the $this->voidElements
array, like such:
protected $voidElements = array(
'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'textarea'
);
Once, that has been added you should be good to go (I've already tested and works like a charm)! Maybe @erusev can add the textarea
permanently if he gets a chance. FYI: I plan to do a little more work to this library over the next few months. I can't seem to get the script
tags working as well as a few small things. I will likely have to change the saveXML
back to saveHTML
once my PHP is updated to a newer version. You might even want to make that change if your PHP version is 5.3.6 or greater.
from parsedown-extra.
Here is a failing testcase if it would be of help:
public function testStripping()
{
$expectedMarkup = '<p><strong>Contact Method:</strong> email</p><p>Test</p><p><em>Some italic text.</em></p>';
$actualMarkup = (new ParsedownExtra())->text($expectedMarkup);
$this->assertEquals($expectedMarkup, $actualMarkup);
}
Results:
1) ParsedownExtraTest::testStripping
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<p><strong>Contact Method:</strong> email</p><p>Test</p><p><em>Some italic text.</em></p>'
+'<p><strong>Contact Method:</strong> email</p>'
from parsedown-extra.
@ericbarnes Thanks, Eric, I appreciate it, hopefully, I'll have some time later this month to address the issue.
from parsedown-extra.
Related Issues (20)
- Undefined index: text HOT 4
- Paragraphs/HTML blocks may disappear in HTML block with markdown="1" HOT 3
- ParsedownExtra.php and tests classes are declared as psr-0 in composer.json but are not compliant with psr-0 HOT 11
- Bug: Uninitialized string offset: 1
- Footnote HTML is double-escaped when safe mode is on HOT 1
- Can't embed video HOT 1
- The Footnotes stop working
- I'm getting this while composer update/install HOT 2
- Multiline blockquotes not rendering correctly in multiline footnotes
- Multiple blockquotes HOT 1
- Video HTML tag does not work
- Parsing special attributes {lang=fr} are not parsed HOT 1
- List Item is dropping text that follows a custom tag HOT 2
- PHP 8.2: mb_convert_encoding(): Handling HTML entities via mbstring is deprecated HOT 2
- Wrap image inside div - not working
- Demo broken? HOT 5
- Add support for PHP 8.2 HOT 2
- Deprecated: Use of "self" in callables is deprecated HOT 1
- Should we start looking for alternatives? Is this repo alive? HOT 1
- Deprecated: Use of "self" in callables is deprecated
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 parsedown-extra.