Skip to content

Commit

Permalink
markdown: setBreaksEnabled( ) einstellbar machen (#3885)
Browse files Browse the repository at this point in the history
  • Loading branch information
christophboecker committed Oct 2, 2020
1 parent c7d98d1 commit 33e09bd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Expand Up @@ -12,6 +12,7 @@ indent_size = 4

[*.md]
max_line_length = 80
trim_trailing_whitespace = false

[COMMIT_EDITMSG]
max_line_length = 0
2 changes: 1 addition & 1 deletion redaxo/src/core/lib/be/controller.php
Expand Up @@ -437,7 +437,7 @@ public static function includeCurrentPageSubPath(array $context = [])
$path = $languagePath;
}

[$toc, $content] = rex_markdown::factory()->parseWithToc(rex_file::get($path));
[$toc, $content] = rex_markdown::factory()->parseWithToc(rex_file::get($path), 2, 3, false);
$fragment = new rex_fragment();
$fragment->setVar('content', $content, false);
$fragment->setVar('toc', $toc, false);
Expand Down
8 changes: 4 additions & 4 deletions redaxo/src/core/lib/util/markdown.php
Expand Up @@ -31,10 +31,10 @@ public static function factory()
*
* @return string HTML code
*/
public function parse($code)
public function parse($code, bool $softLineBreaks = true)
{
$parser = new ParsedownExtra();
$parser->setBreaksEnabled(true);
$parser->setBreaksEnabled($softLineBreaks);

return rex_string::sanitizeHtml($parser->text($code));
}
Expand All @@ -48,10 +48,10 @@ public function parse($code)
*
* @return array tupel of table-of-content and content
*/
public function parseWithToc($code, $topLevel = 2, $bottomLevel = 3)
public function parseWithToc($code, $topLevel = 2, $bottomLevel = 3, bool $softLineBreaks = true)
{
$parser = new rex_parsedown_with_toc();
$parser->setBreaksEnabled(true);
$parser->setBreaksEnabled($softLineBreaks);
$parser->topLevel = $topLevel;
$parser->bottomLevel = $bottomLevel;

Expand Down
4 changes: 2 additions & 2 deletions redaxo/src/core/pages/packages.php
Expand Up @@ -26,13 +26,13 @@
$package->includeFile('help.php');
$content .= ob_get_clean();
} elseif (is_readable($package->getPath('README.'. rex_i18n::getLanguage() .'.md'))) {
[$readmeToc, $readmeContent] = rex_markdown::factory()->parseWithToc(rex_file::get($package->getPath('README.'. rex_i18n::getLanguage() .'.md')));
[$readmeToc, $readmeContent] = rex_markdown::factory()->parseWithToc(rex_file::get($package->getPath('README.'. rex_i18n::getLanguage() .'.md')), 2, 3, false);
$fragment = new rex_fragment();
$fragment->setVar('content', $readmeContent, false);
$fragment->setVar('toc', $readmeToc, false);
$content .= $fragment->parse('core/page/docs.php');
} elseif (is_readable($package->getPath('README.md'))) {
[$readmeToc, $readmeContent] = rex_markdown::factory()->parseWithToc(rex_file::get($package->getPath('README.md')));
[$readmeToc, $readmeContent] = rex_markdown::factory()->parseWithToc(rex_file::get($package->getPath('README.md')), 2, 3, false);
$fragment = new rex_fragment();
$fragment->setVar('content', $readmeContent, false);
$fragment->setVar('toc', $readmeToc, false);
Expand Down

0 comments on commit 33e09bd

Please sign in to comment.