Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M3P2 HTML Generator
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
12
Issues
12
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
M3P2
M3P2 HTML Generator
Commits
528fa9cb
Commit
528fa9cb
authored
Mar 20, 2019
by
Administrator
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prepare support for per-page override.
parent
e9ae9816
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
6 deletions
+28
-6
markdown-underline.php
user/plugins/markdown-underline/markdown-underline.php
+28
-6
No files found.
user/plugins/markdown-underline/markdown-underline.php
View file @
528fa9cb
...
...
@@ -6,12 +6,20 @@ use Grav\Common\Plugin;
use
RocketTheme\Toolbox\Event\Event
;
/**
* Customize the HTML tags to use with the usual inline emphasis and strong blocks.
*
* - *
* - **
* - _
* - __
*
*
* __some text__ => <u>some text</u>
*
* Use with caution, as underlining makes text harder to read.
* If you don't think so, please be thankful for your great sight and ortholexia.
*
* Not sure how this will fare with multibyte strings. P
roba
bly badly.
* Not sure how this will fare with multibyte strings. P
ossi
bly badly.
* Try mb_strlen ?
*
* Class MarkdownUnderlinePlugin
...
...
@@ -41,13 +49,14 @@ class MarkdownUnderlinePlugin extends Plugin
*/
public
function
onPluginsInitialized
()
{
// Don't proceed if we are in the admin plugin
// This check is legacy, and is perhaps not useful?
// Don't proceed if we are in the admin plugin.
// Since we don't sanitize the configuration options, this is paramount.
// This way, if the plugin breaks pages somehow, admin will still be available.
if
(
$this
->
isAdmin
())
{
return
;
}
//
Enable the main event we are interested in
//
*Subscribe* to the main event we are interested in.
$this
->
enable
([
'onMarkdownInitialized'
=>
[
'onMarkdownInitialized'
,
0
],
]);
...
...
@@ -56,8 +65,21 @@ class MarkdownUnderlinePlugin extends Plugin
public
function
onMarkdownInitialized
(
Event
$event
)
{
$markdown
=
$event
[
'markdown'
];
$mu_config
=
$this
->
config
->
get
(
'plugins.markdown-underline'
);
$config
=
$this
->
config
;
$mu_config
=
$config
->
get
(
'plugins.markdown-underline'
);
// This feature depends on the page being provided in onMarkdownInitialized event.
// There may be a PR for this in the future. Not sure about the implications.
if
(
isset
(
$event
[
'page'
]))
{
$config
=
$this
->
mergeConfig
(
$event
[
'page'
]);
// Merging works but changes paths
$mu_config
=
array
(
'*'
=>
$config
->
get
(
'*'
),
'**'
=>
$config
->
get
(
'**'
),
'_'
=>
$config
->
get
(
'_'
),
'__'
=>
$config
->
get
(
'__'
),
);
}
// Add our parser right before the Emphasis one.
// See vendor/erusev/parsedown/Parsedown.php#L977
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment