Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Поддержка языка разметки Markdown #84 #93

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
21 changes: 20 additions & 1 deletion classes/modules/text/Text.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public function VideoParser($sText)
}

/**
* Парсит текст, применя все парсеры
* Парсит текст, применяя все парсеры
*
* @param string $sText Исходный текст
* @return string
Expand All @@ -242,12 +242,31 @@ public function Parser($sText)
return '';
}
$sResult = $this->FlashParamParser($sText);
$sResult = $this->MarkdownParser($sResult);
$sResult = $this->JevixParser($sResult);
$sResult = $this->VideoParser($sResult);
$sResult = $this->CodeSourceParser($sResult);
return $sResult;
}

/**
* Обработка текста на помощью облегченного языка разметки Markdown
*
* @param string $sText Исходный текст
* @return string
*/
public function MarkdownParser($sText)
{
if (Config::Get('module.text.use_markdown')) {
Engine::AddAutoloaderNamespace('Michelf',
Config::Get('path.framework.libs_vendor.server') . '/php-markdown/Michelf');
$parser = new Michelf\MarkdownExtra();
// TODO: настройка парсера - https://michelf.ca/projects/php-markdown/configuration/
$sText = $parser->transform($sText);
}
return $sText;
}

/**
* Заменяет все вхождения короткого тега <param/> на длиную версию <param></param>
* Заменяет все вхождения короткого тега <embed/> на длиную версию <embed></embed>
Expand Down
2 changes: 2 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@
/**
* Настройки модулей
*/
// Модуль Text
$config['module']['text']['use_markdown'] = false; // Если установлена true, текст будет обрабатываться как Markdown
// Модуль Lang
$config['module']['lang']['delete_undefined'] = true; // Если установлена true, то модуль будет автоматически удалять из языковых конструкций переменные вида %%var%%, по которым не была произведена замена
// Для совместимости со старыми версиями
Expand Down
36 changes: 36 additions & 0 deletions libs/vendor/php-markdown/License.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
PHP Markdown Lib
Copyright (c) 2004-2015 Michel Fortin
<https://michelf.ca/>
All rights reserved.

Based on Markdown
Copyright (c) 2003-2006 John Gruber
<http://daringfireball.net/>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

* Neither the name "Markdown" nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.

This software is provided by the copyright holders and contributors "as
is" and any express or implied warranties, including, but not limited
to, the implied warranties of merchantability and fitness for a
particular purpose are disclaimed. In no event shall the copyright owner
or contributors be liable for any direct, indirect, incidental, special,
exemplary, or consequential damages (including, but not limited to,
procurement of substitute goods or services; loss of use, data, or
profits; or business interruption) however caused and on any theory of
liability, whether in contract, strict liability, or tort (including
negligence or otherwise) arising in any way out of the use of this
software, even if advised of the possibility of such damage.
10 changes: 10 additions & 0 deletions libs/vendor/php-markdown/Michelf/Markdown.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

# Use this file if you cannot use class autoloading. It will include all the
# files needed for the Markdown parser.
#
# Take a look at the PSR-0-compatible class autoloading implementation
# in the Readme.php file if you want a simple autoloader setup.

require_once dirname(__FILE__) . '/MarkdownInterface.php';
require_once dirname(__FILE__) . '/Markdown.php';
Loading