Enable or disable Markdown parser for #980

This commit is contained in:
Diego Najar 2019-03-09 18:53:03 +01:00
parent 185ae09393
commit 3ab8c4c0a6
4 changed files with 30 additions and 13 deletions

View File

@ -179,6 +179,17 @@
'placeholder'=>'https://'
));
echo Bootstrap::formTitle(array('title'=>$L->g('Page content')));
echo Bootstrap::formSelect(array(
'name'=>'markdownParser',
'label'=>$L->g('Markdown parser'),
'options'=>array('true'=>$L->g('Enabled'), 'false'=>$L->g('Disabled')),
'selected'=>($site->markdownParser()?'true':'false'),
'class'=>'',
'tip'=>$L->g('Enable the markdown parser for the content of the page.')
));
echo Bootstrap::formTitle(array('title'=>$L->g('URL Filters')));
echo Bootstrap::formInputText(array(

View File

@ -208,6 +208,9 @@ define('IMAGE_RESTRICT', $site->imageRestrict());
// TRUE to convert relatives images to absoultes, FALSE No changes apply
define('IMAGE_RELATIVE_TO_ABSOLUTE', $site->imageRelativeToAbsolute());
// TRUE if the markdown parser is enabled
define('MARKDOWN_PARSER', $site->markdownParser());
// --- PHP paths with dependency ---
// This paths are absolutes for the OS
define('THEME_DIR', PATH_ROOT.'bl-themes'.DS.$site->theme().DS);

View File

@ -76,8 +76,10 @@ class Page {
$content = $this->contentRaw();
// Parse Markdown
if (MARKDOWN_PARSER) {
$parsedown = new Parsedown();
$content = $parsedown->text($content);
}
// Parse img src relative to absolute (with domain)
if (IMAGE_RELATIVE_TO_ABSOLUTE) {

View File

@ -43,7 +43,8 @@ class Site extends dbJSON {
'thumbnailWidth'=> 400, // px
'thumbnailHeight'=> 400, // px
'thumbnailQuality'=> 100,
'logo'=> ''
'logo'=> '',
'markdownParser'=> true
);
function __construct()
@ -68,8 +69,9 @@ class Site extends dbJSON {
// Check values on args or set default values
foreach ($this->dbFields as $field=>$value) {
if (isset($args[$field])) {
// Sanitize if will be stored on database
$finalValue = Sanitize::html($args[$field]);
if ($finalValue==='false') { $finalValue = false; }
elseif ($finalValue==='true') { $finalValue = true; }
settype($finalValue, gettype($value));
$this->db[$field] = $finalValue;
}
@ -138,6 +140,11 @@ class Site extends dbJSON {
return $this->getField('extremeFriendly');
}
public function markdownParser()
{
return $this->getField('markdownParser');
}
public function twitter()
{
return $this->getField('twitter');
@ -168,12 +175,6 @@ class Site extends dbJSON {
return $this->getField('gitlab');
}
// DEPRECATED since v3.5
public function googlePlus()
{
return $this->getField('googlePlus');
}
public function linkedin()
{
return $this->getField('linkedin');