secure-77 / Perlite

A web-based markdown viewer optimized for Obsidian
https://perlite.secure77.de/
MIT License
1.06k stars 92 forks source link

Some links are breaking the page for no apparent reason #128

Closed codergoblin closed 1 week ago

codergoblin commented 3 months ago

I have many instances in my wiki where links break the page in a strange way.

image

root@vultr:/opt/Perlite# cat /data/perlite/Sif/Kugelglobe.md 

A strange cubic object that irradiates light.
Found by [[Triya]] on a beach in [[Synthea]]. LPH later discovered that the globe was probably from [[Phanes]] since it fits perfectly in an artifact stand that the party found in an underground [[Antediluvians]] ossuary underneath [[Sif]]. LPH got a confirmation of this theory when the [[Antediluvians]] ([[Stargazers]]) that [[Triya]] faced in the [[Temple of Bes]] performed the same type of magic that [[Triya]] does. 

it looks like in this case [[Triya]] breaks the link, but not sure why, it does not seem to be any different to other links that function correctly. It happens in different pages with different links but I can't see any pattern.

rgaricano commented 3 weeks ago

Yes, it happend to me too, It happend if the name of the link have some image extension on it, as tif gif tiff bmp .... I solved changing regexpression of line 152 of perlite/content.php as follow: $pattern = array('/(!?[[)(.*?)(.png|.jpg|.jpeg|.svg|.gif|.bmp|.tif|.tiff)|?(.+|)(]])/'); (it's noted under //img link with captions replace block ) and restart server: systemctl restart php8.3-fpm nginx

by the way i add a block for embed m4a links, adding this lines between embedded blocks:


     // embedded m4a links
        $replaces = '
        <video controls src="' . $path . '/\\2" type="audio/x-m4a">
                <a class="internal-link" target="_blank" rel="noopener noreferrer" href="' . $path . '/' . '\\2">Your browser does not support the video tag: Download \\2</a>
        </video>';
        $pattern = array('/(\!\[\[)(.*?.(?:m4a))(\]\])/');
        $content = preg_replace($pattern, $replaces, $content);
secure-77 commented 1 week ago

fixed in release 1.5.9

rgaricano commented 1 week ago

thx, I hope in a future propose changes through pull requests.

secure-77 commented 1 week ago

of course, Im always open to PRs! thanks for your contribution!