Comments (8)
Actually this might be my own fault. I'm using a Trait to override some behavior, and I think it might not be taking into account all the changes you made in 1.2.0. Debugging deeper now...
from parsedown-extra.
Nope, it's not me, it's caused by the separation of links and images into two methods. Basically the class is found but its lost in the chain of parent calls.
from parsedown-extra.
Ok, i attempted to fix this but reached an impasse.
First I had to create an inlineImage()
method in ParsedownExtra as it was missing. However that is not the real issue...
The problem really occurs when things trickle back to Parsedown::inlineImage()
and the $Inline
element comes back from inlineLink()
with the class attribute intact. However, this being the non-extra class, manually rebuilds the $Inline
element ignoring the class attribute. It is at this point the class is lost.
So when $Inline
is eventually returned to ParsedownExtra::inlineImage()
, the class is gone, so there's no extra elements found to add.
Maybe it's a Saturday, maybe i've spent too long in front of the computer today, but i'm stuck here, and can see no simple way to resolve short of putting logic into the Parsedown::inlineImage()
method to add attributes if they exist. Any resolution to this would be welcome.
from parsedown-extra.
Ok, so i have a fix that doesn't rebuild the Inline Image element, it merely manipulates it. This way anything extra is not lost. I don't find it particulary 'pretty', but it does work and maintains the class attributes for ParsedownExtra:
It is a change for the Parsedown::inlineImage()
method.
Parsedown.php
protected function inlineImage($excerpt)
{
if ( ! isset($excerpt[1]) or $excerpt[1] !== '[')
{
return;
}
$excerpt = substr($excerpt, 1);
$Inline = $this->inlineLink($excerpt);
$backup = $Inline;
if ($Inline === null)
{
return;
}
$Inline['extent'] ++;
$Inline['element']['name'] = 'img';
$Inline['element']['attributes']['src'] = $Inline['element']['attributes']['href'];
unset($Inline['element']['attributes']['href']);
$Inline['element']['attributes']['alt'] = $Inline['element']['text'];
unset($Inline['element']['text']);
return $Inline;
}
I hesitate to submit a pull request because I'm sure there's a nicer way to handle this.
from parsedown-extra.
For completeness here are my changes:
Parsedown.php - https://github.com/rhukster/parsedown/commit/03ff22c7df8e4aac3a5a309df5f6edb0685b6e0b
ParsedownExtra.php - rhukster@41dd6f7
from parsedown-extra.
That's an impressive piece of work.
I believe that the changes in Parsedown.php are sufficient .
I'm merging the pull request.
from parsedown-extra.
p.s. I'm adding Grav to Parsedown's README.
from parsedown-extra.
Great Thanks!
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.