Compare commits

..

No commits in common. "4342526f6d60fe72c87f7c2fd02c0b9bf4513db5" and "344e486bbc483006512d971f4982e08b49f48560" have entirely different histories.

4 changed files with 26 additions and 32 deletions

View File

@ -31,12 +31,12 @@
"source": "https://github.com/picocms/Pico"
},
"require": {
"php": "^7.0.8 || ^8.0",
"php": "^7.0.8",
"ext-mbstring": "*",
"twig/twig": "^2.12",
"symfony/yaml" : "^3.4",
"erusev/parsedown": "^2.0.0-beta-1",
"erusev/parsedown-extra": "^2.0.0-beta-1"
"erusev/parsedown": "1.7.4",
"erusev/parsedown-extra": "0.8.1"
},
"suggest": {
"picocms/pico-theme": "Pico requires a theme to actually display the contents of your website. This is Pico's official default theme.",

View File

@ -1,5 +1,5 @@
---
Logo: '%theme_url%/img/pico-white.svg'
Logo: %theme_url%/img/pico-white.svg
Tagline: Making the web easy.
Social:
- title: Visit us on GitHub

View File

@ -42,12 +42,6 @@
* @license http://opensource.org/licenses/MIT The MIT License
* @version 3.0
*/
use Erusev\Parsedown\Configurables\Breaks;
use Erusev\Parsedown\Parsedown;
use Erusev\Parsedown\State;
use Erusev\ParsedownExtra\ParsedownExtra;
class Pico
{
/**
@ -69,7 +63,7 @@ class Pico
*
* @var int
*/
const API_VERSION = 4;
const API_VERSION = 3;
/**
* Sort files in alphabetical ascending order
@ -654,7 +648,7 @@ class Pico
{
// scope isolated require()
$includeClosure = function ($pluginFile) {
require_once($pluginFile);
require($pluginFile);
};
if (PHP_VERSION_ID >= 50400) {
$includeClosure = $includeClosure->bindTo(null);
@ -1567,13 +1561,12 @@ class Pico
public function getParsedown()
{
if ($this->parsedown === null) {
$state = new State([
new Breaks((bool) $this->config['content_config']['breaks'])
]);
if ($this->config['content_config']['extra']){
$state = new ParsedownExtra($state);
}
$this->parsedown = new Parsedown($state);
$className = $this->config['content_config']['extra'] ? 'ParsedownExtra' : 'Parsedown';
$this->parsedown = new $className();
$this->parsedown->setBreaksEnabled((bool) $this->config['content_config']['breaks']);
$this->parsedown->setMarkupEscaped((bool) $this->config['content_config']['escape']);
$this->parsedown->setUrlsLinked((bool) $this->config['content_config']['auto_urls']);
$this->triggerEvent('onParsedownRegistered', array(&$this->parsedown));
}
@ -1673,13 +1666,14 @@ class Pico
* @see Pico::getFileContent()
*
* @param string $markdown Markdown contents of a page
* @param bool $singleLine whether to parse just a single line of markup
*
* @return string parsed contents (HTML)
*/
public function parseFileContent($markdown)
public function parseFileContent($markdown, $singleLine = false)
{
$markdownParser = $this->getParsedown();
return @$markdownParser->toHtml($markdown);
return !$singleLine ? @$markdownParser->text($markdown) : @$markdownParser->line($markdown);
}
/**
@ -2108,12 +2102,12 @@ class Pico
if ($this->twig === null) {
$twigConfig = $this->getConfig('twig_config');
$twigLoader = new \Twig\Loader\FilesystemLoader($this->getThemesDir() . $this->getTheme());
$this->twig = new \Twig\Environment($twigLoader, $twigConfig);
$twigLoader = new Twig_Loader_Filesystem($this->getThemesDir() . $this->getTheme());
$this->twig = new Twig_Environment($twigLoader, $twigConfig);
$this->twig->addExtension(new PicoTwigExtension($this));
if (!empty($twigConfig['debug'])) {
$this->twig->addExtension(new Twig\Extension\DebugExtension());
$this->twig->addExtension(new Twig_Extension_Debug());
}
// register content filter
@ -2121,7 +2115,7 @@ class Pico
// this is the reason why we can't register this filter as part of PicoTwigExtension
$pico = $this;
$pages = &$this->pages;
$this->twig->addFilter(new \Twig\TwigFilter(
$this->twig->addFilter(new Twig_SimpleFilter(
'content',
function ($page) use ($pico, &$pages) {
if (isset($pages[$page])) {
@ -2162,7 +2156,7 @@ class Pico
'theme_url' => $this->getConfig('themes_url') . $this->getTheme(),
'site_title' => $this->getConfig('site_title'),
'meta' => $this->meta,
'content' => new \Twig\Markup($this->content, 'UTF-8'),
'content' => new Twig_Markup($this->content, 'UTF-8'),
'pages' => $this->pages,
'previous_page' => $this->previousPage,
'current_page' => $this->currentPage,

View File

@ -67,20 +67,20 @@ class PicoTwigExtension extends Twig_Extension
*
* @see Twig_ExtensionInterface::getFilters()
*
* @return \Twig\TwigFilter[] array of Pico's Twig filters
* @return Twig_SimpleFilter[] array of Pico's Twig filters
*/
public function getFilters()
{
return array(
'markdown' => new \Twig\TwigFilter(
'markdown' => new Twig_SimpleFilter(
'markdown',
array($this, 'markdownFilter'),
array('is_safe' => array('html'))
),
'map' => new \Twig\TwigFilter('map', array($this, 'mapFilter')),
'sort_by' => new \Twig\TwigFilter('sort_by', array($this, 'sortByFilter')),
'link' => new \Twig\TwigFilter('link', array($this->pico, 'getPageUrl')),
'url' => new \Twig\TwigFilter('url', array($this->pico, 'substituteUrl'))
'map' => new Twig_SimpleFilter('map', array($this, 'mapFilter')),
'sort_by' => new Twig_SimpleFilter('sort_by', array($this, 'sortByFilter')),
'link' => new Twig_SimpleFilter('link', array($this->pico, 'getPageUrl')),
'url' => new Twig_SimpleFilter('url', array($this->pico, 'substituteUrl'))
);
}