Skip to content
Snippets Groups Projects
Commit 6eca2130 authored by Josef Moravec's avatar Josef Moravec Committed by Robert Lange
Browse files

Add configuration for markdown processing (#1601)

parent 1efca9eb
No related merge requests found
; This file could be used to define configuration of markdown to HTML converter.
; More detailed configuration documentation could be found here:
; https://github.com/thephpleague/commonmark/blob/master/docs/1.0/configuration.md
[Markdown]
; How to handle HTML input. Options are: strip, allow, escape. Defaults to strip
;html_input = allow
; Remove risky link and image URLs by setting this to false. Defaults to false
;allow_unsafe_links = true
; String to use for separating renderer block elements
;renderer[block_separator] = "\n"
; String to use for separating inner block contents
;renderer[inner_separator] = "\n"
; String to use for rendering soft breaks
;renderer[inner_separator] = "\n"
; Enable or disable <em> parsing. Enabled by default
;enable_em = false
; Enable or disable <strong> parsing. Enabled by default
;enable_strong = false
; Enable or disable parsing of '*' for emphasis. Enabled by default
;use_asterisk = false
; Enable or disable parsing of '_' for emphasis. Enabled by default
;use_underscore = false
; Array of characters that can be used to indicated a bulleted list (default:
; ["-", "*", "+"])
;unordered_list_markers[] = "-"
;unordered_list_markers[] = "*"
;unordered_list_markers[] = "+"
; The maximum nesting level for blocks (default: infinite). Setting this to a
; positive integer can help protect against long parse times and/or segfaults if
; blocks are too deeply-nested.
;max_nesting_level = 10
...@@ -63,10 +63,28 @@ class MarkdownFactory implements FactoryInterface ...@@ -63,10 +63,28 @@ class MarkdownFactory implements FactoryInterface
public function __invoke( public function __invoke(
ContainerInterface $container, $requestedName, array $options = null ContainerInterface $container, $requestedName, array $options = null
) { ) {
$config = $container->get(\VuFind\Config\PluginManager::class)
->get('markdown')->Markdown;
return new GithubFlavoredMarkdownConverter( return new GithubFlavoredMarkdownConverter(
[ [
'html_input' => 'strip', 'html_input' => $config->html_input ?? 'strip',
'allow_unsafe_links' => false, 'allow_unsafe_links' => $config->allow_unsafe_links ?? false,
'enable_em' => $config->enable_em ?? true,
'enable_strong' => $config->enable_strong ?? true,
'use_asterisk' => $config->use_asterisk ?? true,
'use_underscore' => $config->use_underscore ?? true,
'unordered_list_markers' => isset($config->unordered_list_markers)
&& $config->unordered_list_markers instanceof \ArrayAccess
? $config->unordered_list_markers->toArray()
: ['-', '*', '+'],
'max_nesting_level' => $config->max_nesting_level ?? \INF,
'renderer' => [
'block_separator'
=> $config->renderer['block_separator'] ?? "\n",
'inner_separator'
=> $config->renderer['inner_separator'] ?? "\n",
'soft_break' => $config->renderer['soft_break'] ?? "\n",
],
] ]
); );
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment