From: Michael Wallner Date: Tue, 9 Sep 2014 09:35:19 +0000 (+0200) Subject: fix markdown in descriptions X-Git-Url: https://git.m6w6.name/?p=mdref%2Fmdref;a=commitdiff_plain;h=e95ff5f1866c75b3d1d63d640324af3f6c3f87b9 fix markdown in descriptions --- diff --git a/mdref/Markdown.php b/mdref/Markdown.php index 6d761c2..e8c5cb6 100644 --- a/mdref/Markdown.php +++ b/mdref/Markdown.php @@ -12,7 +12,7 @@ class Markdown /** * @param \mdref\Path $path */ - function __construct(Path $path) { + function __construct(Path $path = null) { $this->path = $path; } @@ -20,6 +20,9 @@ class Markdown * @return string */ function __toString() { + if (!$this->path) { + return ""; + } try { $r = fopen($this->path->getFullPath(".md"), "r"); $md = \MarkdownDocument::createFromStream($r); @@ -31,4 +34,10 @@ class Markdown } return $html; } + + function quick($string) { + $md = \MarkdownDocument::createFromString($string); + $md->compile(\MarkdownDocument::AUTOLINK); + return $md->getHtml(); + } } diff --git a/mdref/RefEntry.php b/mdref/RefEntry.php index 2ad3d27..6c54674 100644 --- a/mdref/RefEntry.php +++ b/mdref/RefEntry.php @@ -114,7 +114,7 @@ class RefEntry function readTitle() { $this->openFile(); fseek($this->file, 1, SEEK_SET); - return htmlspecialchars(fgets($this->file)); + return fgets($this->file); } /** @@ -126,7 +126,7 @@ class RefEntry fseek($this->file, 0, SEEK_SET); fgets($this->file); fgets($this->file); - return htmlspecialchars(fgets($this->file)); + return fgets($this->file); } /** diff --git a/mdref/RefListing.php b/mdref/RefListing.php index 3816be2..4c3b629 100644 --- a/mdref/RefListing.php +++ b/mdref/RefListing.php @@ -71,7 +71,7 @@ class RefListing implements \Countable, \Iterator * @return \mdref\RefEntry */ function current() { - return new RefEntry($this->path, $this->key());//$this->format($this->key()); + return new RefEntry($this->path, $this->key()); } /** diff --git a/views/index.phtml b/views/index.phtml index dbd3017..417419d 100644 --- a/views/index.phtml +++ b/views/index.phtml @@ -10,8 +10,13 @@ recurse($refs, "/*.md", function($entry, $pattern, callable $recursor) { ?> diff --git a/views/mdref.phtml b/views/mdref.phtml index 5cec21d..08df2e1 100644 --- a/views/mdref.phtml +++ b/views/mdref.phtml @@ -6,8 +6,8 @@
  • formatLink(true)?>

    -

    readDescription()?>

    -

    readTitle()?>

    +

    quick($entry->readDescription())?>

    +

    esc($entry->readTitle())?>