Skip to content

Commit

Permalink
fixed issue Some links are breaking the page for no apparent reason #128
Browse files Browse the repository at this point in the history
 and added m4a support
  • Loading branch information
secure-77 committed Sep 23, 2024
1 parent c5eb84d commit e281683
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
- fixed kartex problem PR [#131](https://github.com/secure-77/Perlite/pull/131) thanks to @Yaro2709
- fixed obsidian edit link thanks to klgzzz
- changed site title to use the env. variable site_title
- fixed issue [#128](https://github.com/secure-77/Perlite/issues/128) thanks to @rgaricano
- added m4a support thanks to @rgaricano



Expand Down
6 changes: 6 additions & 0 deletions perlite/Demo/Demo Documents/Links and Embedded.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Link to another markdown file: [[Markdown Samples]]

Link to another markdown file with a custom linke name: [[Markdown Samples|Custom Link Name]]

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.

## Links to Headings

Expand All @@ -32,6 +34,10 @@ Youtube embedded:

![Making a Minecraft Obsidian Block in Real Life Using Astro Tech Resin](https://www.youtube.com/watch?v=NnTvZWp5Q7o)

## Audio

![[docs/sample3.m4a]]

## PDF

Link to internal stored PDF: [[pdf-test.pdf]]
Expand Down
Binary file added perlite/Demo/Demo Documents/docs/sample3.m4a
Binary file not shown.
14 changes: 13 additions & 1 deletion perlite/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ function parseContent($requestFile)
$pattern = array('/(\!\[\[)(.*?.(?:mp4))(\]\])/');
$content = preg_replace($pattern, $replaces, $content);


// 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 audio tag: Download \\2</a>
</video>';
$pattern = array('/(\!\[\[)(.*?.(?:m4a))(\]\])/');
$content = preg_replace($pattern, $replaces, $content);


// links to other files with Alias
$replaces = '<a class="internal-link" target="_blank" rel="noopener noreferrer" href="' . $path . '/' . '\\2">\\3</a>';
$pattern = array('/(\[\[)(.*?.(?:' . $linkFileTypes . '))\|(.*)(\]\])/');
Expand All @@ -142,6 +152,8 @@ function parseContent($requestFile)
// img links with size
$replaces = '<p><a href="#" class="pop"><img class="images" width="\\4" height="\\5" alt="image not found" src="' . $path . '/\\2\\3' . '"/></a></p>';
$pattern = array('/(\!?\[\[)(.*?)'.$allowedImageTypes.'\|?(\d*)x?(\d*)(\]\])/');


$content = preg_replace($pattern, $replaces, $content);

// centerise or right align images with "center"/"right" directive
Expand All @@ -166,7 +178,7 @@ function parseContent($requestFile)

// img links with captions
$replaces = '<p><a href="#" class="pop"><img class="images" alt="\\4" src="' . $path . '/\\2\\3' . '"/></a></p>';
$pattern = array('/(\!?\[\[)(.*?)'.$allowedImageTypes.'\|?(.*)(\]\])/');
$pattern = array('/(\!?\[[)(.*?)'.$allowedImageTypes.'|?(.+|)(]\])/');
$content = preg_replace($pattern, $replaces, $content);


Expand Down

0 comments on commit e281683

Please sign in to comment.