Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "parsedown"]
path = parsedown
url = https://github.com/erusev/parsedown.git
15 changes: 15 additions & 0 deletions diary/Markdown is supported now.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
We are glad to announce that ...

# Markdown Supported

``` javascript
for (var i = 0; i < 10; i++) {
document.write("Hello from Inndy (" + i + ")<br>");
}
```

~~Line-through test~~ *Italic* **Bold** ***ItalicBold***

---

Markdown renderer takes from [parsedown](https://github.com/erusev/parsedown).
28 changes: 23 additions & 5 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
include("parsedown/Parsedown.php");
date_default_timezone_set('Asia/Taipei');

/** The array which we'll store the diays later */
Expand Down Expand Up @@ -43,22 +44,39 @@ function Diary($SingleDiary)
}



$markdown_parser = new Parsedown();

/**
* Scan
*
* Get all the diary files
*/

foreach(glob(__DIR__ . '/diary/*.txt') as $Diary)
foreach(glob(__DIR__ . '/diary/*') as $Diary)
{
/** The file name is the title of this diary */
/** Now we remove the path first, then we remove the file extension */
$Title = preg_replace('/\.\w*$/', '', preg_replace('/^.+[\\\\\\/]/', '', $Diary));
$info = pathinfo($Diary);
$extension = $info['extension'];

$Title = $info['filename'];

$Content = null;

/** Get the content */
$Content = nl2br(file_get_contents($Diary));
switch ($extension) {
case 'md':
case 'markdown':
$Content = $markdown_parser->text(file_get_contents($Diary));
break;
case 'txt':
case 'text':
$Content = nl2br(file_get_contents($Diary));
break;
}

if ($Content === null) {
continue; // Skip invalid file type
}

/** Get the unix timestramp of the file */
$Date = filemtime($Diary);
Expand Down
1 change: 1 addition & 0 deletions parsedown
Submodule parsedown added at 65116c