Skip to content

Commit

Permalink
option to control supported attributes in markdown links
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Miller <rhuk@mac.com>
  • Loading branch information
rhukster committed Jun 4, 2020
1 parent aaa636f commit bfbe4ce
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# v1.6.26
## mm/dd/2020

1. [](#improved)
* Added new configuration option to control the supported attributes in markdown links [#2882](https://github.com/getgrav/grav/issues/2882)
1. [](#bugfix)
* Fixed blueprint for `system.pages.hide_empty_folders` [#1925](https://github.com/getgrav/grav/issues/2925)

Expand Down
10 changes: 10 additions & 0 deletions system/blueprints/config/system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,16 @@ form:
validate:
type: bool

pages.markdown.valid_link_attributes:
type: selectize
size: large
label: PLUGIN_ADMIN.VALID_LINK_ATTRIBUTES
help: PLUGIN_ADMIN.VALID_LINK_ATTRIBUTES_HELP
placeholder: "rel, target, id, class, classes"
classes: fancy
validate:
type: commalist

caching:
type: tab
title: PLUGIN_ADMIN.CACHING
Expand Down
6 changes: 6 additions & 0 deletions system/config/system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ pages:
special_chars: # List of special characters to automatically convert to entities
'>': 'gt'
'<': 'lt'
valid_link_attributes: # Valid attributes to pass through via markdown links
- rel
- target
- id
- class
- classes
types: [html,htm,xml,txt,json,rss,atom] # list of valid page types
append_url_extension: '' # Append page's extension in Page urls (e.g. '.html' results in /path/page.html)
expires: 604800 # Page expires time in seconds (604800 seconds = 7 days)
Expand Down
3 changes: 2 additions & 1 deletion system/src/Grav/Common/Page/Markdown/Excerpts.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static function ($carry, $item) {
);

// Valid attributes supported.
$valid_attributes = ['rel', 'target', 'id', 'class', 'classes'];
$valid_attributes = Grav::instance()['config']->get('system.pages.markdown.valid_link_attributes');

// Unless told to not process, go through actions.
if (array_key_exists('noprocess', $actions)) {
Expand Down Expand Up @@ -232,6 +232,7 @@ public function processMediaActions($medium, $url)
$url_parts = is_string($url) ? $this->parseUrl($url) : $url;
$actions = [];


// if there is a query, then parse it and build action calls
if (isset($url_parts['query'])) {
$actions = array_reduce(
Expand Down

0 comments on commit bfbe4ce

Please sign in to comment.