From 9945c2a19e05e2b298754747ea595dd47c8fbf33 Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Fri, 11 Aug 2023 15:09:48 +0200 Subject: [PATCH] Update league/commonmark to version 2.4.0 (#3028) --- composer.json | 2 +- composer.lock | 142 +++++++++--------- config/vufind/markdown.ini | 35 +++-- .../src/VuFind/Service/MarkdownFactory.php | 32 ++-- .../Service/MarkdownFactoryTest.php | 21 +++ 5 files changed, 136 insertions(+), 96 deletions(-) diff --git a/composer.json b/composer.json index 5a63a4a8347..a5ab92026a2 100644 --- a/composer.json +++ b/composer.json @@ -70,7 +70,7 @@ "laminas/laminas-text": "2.10.0", "laminas/laminas-validator": "2.30.1", "laminas/laminas-view": "2.27.0", - "league/commonmark": "2.3.9", + "league/commonmark": "2.4.0", "league/oauth2-server": "8.5.3", "lm-commons/lmc-rbac-mvc": "3.3.2", "matthiasmullie/minify": "1.3.70", diff --git a/composer.lock b/composer.lock index e0479495a2f..d3d45e42cab 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7d1e0767aa822831d6aaa829873b1a0e", + "content-hash": "055167e8b8194d6891e199153fbf423b", "packages": [ { "name": "ahand/mobileesp", @@ -4569,16 +4569,16 @@ }, { "name": "league/commonmark", - "version": "2.3.9", + "version": "2.4.0", "source": { "type": "git", "url": "https://github.com/thephpleague/commonmark.git", - "reference": "c1e114f74e518daca2729ea8c4bf1167038fa4b5" + "reference": "d44a24690f16b8c1808bf13b1bd54ae4c63ea048" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/c1e114f74e518daca2729ea8c4bf1167038fa4b5", - "reference": "c1e114f74e518daca2729ea8c4bf1167038fa4b5", + "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/d44a24690f16b8c1808bf13b1bd54ae4c63ea048", + "reference": "d44a24690f16b8c1808bf13b1bd54ae4c63ea048", "shasum": "" }, "require": { @@ -4614,7 +4614,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "2.4-dev" + "dev-main": "2.5-dev" } }, "autoload": { @@ -4671,7 +4671,7 @@ "type": "tidelift" } ], - "time": "2023-02-15T14:07:24+00:00" + "time": "2023-03-24T15:16:10+00:00" }, { "name": "league/config", @@ -5277,21 +5277,21 @@ }, { "name": "nette/schema", - "version": "v1.2.3", + "version": "v1.2.4", "source": { "type": "git", "url": "https://github.com/nette/schema.git", - "reference": "abbdbb70e0245d5f3bf77874cea1dfb0c930d06f" + "reference": "c9ff517a53903b3d4e29ec547fb20feecb05b8ab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/schema/zipball/abbdbb70e0245d5f3bf77874cea1dfb0c930d06f", - "reference": "abbdbb70e0245d5f3bf77874cea1dfb0c930d06f", + "url": "https://api.github.com/repos/nette/schema/zipball/c9ff517a53903b3d4e29ec547fb20feecb05b8ab", + "reference": "c9ff517a53903b3d4e29ec547fb20feecb05b8ab", "shasum": "" }, "require": { "nette/utils": "^2.5.7 || ^3.1.5 || ^4.0", - "php": ">=7.1 <8.3" + "php": "7.1 - 8.3" }, "require-dev": { "nette/tester": "^2.3 || ^2.4", @@ -5333,26 +5333,26 @@ ], "support": { "issues": "https://github.com/nette/schema/issues", - "source": "https://github.com/nette/schema/tree/v1.2.3" + "source": "https://github.com/nette/schema/tree/v1.2.4" }, - "time": "2022-10-13T01:24:26+00:00" + "time": "2023-08-05T18:56:25+00:00" }, { "name": "nette/utils", - "version": "v4.0.0", + "version": "v4.0.1", "source": { "type": "git", "url": "https://github.com/nette/utils.git", - "reference": "cacdbf5a91a657ede665c541eda28941d4b09c1e" + "reference": "9124157137da01b1f5a5a22d6486cb975f26db7e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/cacdbf5a91a657ede665c541eda28941d4b09c1e", - "reference": "cacdbf5a91a657ede665c541eda28941d4b09c1e", + "url": "https://api.github.com/repos/nette/utils/zipball/9124157137da01b1f5a5a22d6486cb975f26db7e", + "reference": "9124157137da01b1f5a5a22d6486cb975f26db7e", "shasum": "" }, "require": { - "php": ">=8.0 <8.3" + "php": ">=8.0 <8.4" }, "conflict": { "nette/finder": "<3", @@ -5360,7 +5360,7 @@ }, "require-dev": { "jetbrains/phpstorm-attributes": "dev-master", - "nette/tester": "^2.4", + "nette/tester": "^2.5", "phpstan/phpstan": "^1.0", "tracy/tracy": "^2.9" }, @@ -5420,9 +5420,9 @@ ], "support": { "issues": "https://github.com/nette/utils/issues", - "source": "https://github.com/nette/utils/tree/v4.0.0" + "source": "https://github.com/nette/utils/tree/v4.0.1" }, - "time": "2023-02-02T10:41:53+00:00" + "time": "2023-07-30T15:42:21+00:00" }, { "name": "nikic/php-parser", @@ -8076,16 +8076,16 @@ }, { "name": "symfony/string", - "version": "v5.4.22", + "version": "v5.4.26", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "8036a4c76c0dd29e60b6a7cafcacc50cf088ea62" + "reference": "1181fe9270e373537475e826873b5867b863883c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/8036a4c76c0dd29e60b6a7cafcacc50cf088ea62", - "reference": "8036a4c76c0dd29e60b6a7cafcacc50cf088ea62", + "url": "https://api.github.com/repos/symfony/string/zipball/1181fe9270e373537475e826873b5867b863883c", + "reference": "1181fe9270e373537475e826873b5867b863883c", "shasum": "" }, "require": { @@ -8142,7 +8142,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.22" + "source": "https://github.com/symfony/string/tree/v5.4.26" }, "funding": [ { @@ -8158,7 +8158,7 @@ "type": "tidelift" } ], - "time": "2023-03-14T06:11:53+00:00" + "time": "2023-06-28T12:46:07+00:00" }, { "name": "symfony/yaml", @@ -11193,16 +11193,16 @@ }, { "name": "sebastian/global-state", - "version": "5.0.5", + "version": "5.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2" + "reference": "bde739e7565280bda77be70044ac1047bc007e34" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2", - "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bde739e7565280bda77be70044ac1047bc007e34", + "reference": "bde739e7565280bda77be70044ac1047bc007e34", "shasum": "" }, "require": { @@ -11245,7 +11245,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.6" }, "funding": [ { @@ -11253,7 +11253,7 @@ "type": "github" } ], - "time": "2022-02-14T08:28:10+00:00" + "time": "2023-08-02T09:26:13+00:00" }, { "name": "sebastian/lines-of-code", @@ -11772,16 +11772,16 @@ }, { "name": "symfony/config", - "version": "v5.4.21", + "version": "v5.4.26", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "2a6b1111d038adfa15d52c0871e540f3b352d1e4" + "reference": "8109892f27beed9252bd1f1c1880aeb4ad842650" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/2a6b1111d038adfa15d52c0871e540f3b352d1e4", - "reference": "2a6b1111d038adfa15d52c0871e540f3b352d1e4", + "url": "https://api.github.com/repos/symfony/config/zipball/8109892f27beed9252bd1f1c1880aeb4ad842650", + "reference": "8109892f27beed9252bd1f1c1880aeb4ad842650", "shasum": "" }, "require": { @@ -11831,7 +11831,7 @@ "description": "Helps you find, load, combine, autofill and validate configuration values of any kind", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/config/tree/v5.4.21" + "source": "https://github.com/symfony/config/tree/v5.4.26" }, "funding": [ { @@ -11847,20 +11847,20 @@ "type": "tidelift" } ], - "time": "2023-02-14T08:03:56+00:00" + "time": "2023-07-19T20:21:11+00:00" }, { "name": "symfony/css-selector", - "version": "v5.4.21", + "version": "v5.4.26", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "95f3c7468db1da8cc360b24fa2a26e7cefcb355d" + "reference": "0ad3f7e9a1ab492c5b4214cf22a9dc55dcf8600a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/95f3c7468db1da8cc360b24fa2a26e7cefcb355d", - "reference": "95f3c7468db1da8cc360b24fa2a26e7cefcb355d", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/0ad3f7e9a1ab492c5b4214cf22a9dc55dcf8600a", + "reference": "0ad3f7e9a1ab492c5b4214cf22a9dc55dcf8600a", "shasum": "" }, "require": { @@ -11897,7 +11897,7 @@ "description": "Converts CSS selectors to XPath expressions", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/css-selector/tree/v5.4.21" + "source": "https://github.com/symfony/css-selector/tree/v5.4.26" }, "funding": [ { @@ -11913,20 +11913,20 @@ "type": "tidelift" } ], - "time": "2023-02-14T08:03:56+00:00" + "time": "2023-07-07T06:10:25+00:00" }, { "name": "symfony/dependency-injection", - "version": "v5.4.25", + "version": "v5.4.26", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "f0410c30a6c86bbce6c719c2b5cfc343362b982e" + "reference": "6736a10dcf724725a3b1c3b53e63a9ee03b27db9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/f0410c30a6c86bbce6c719c2b5cfc343362b982e", - "reference": "f0410c30a6c86bbce6c719c2b5cfc343362b982e", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/6736a10dcf724725a3b1c3b53e63a9ee03b27db9", + "reference": "6736a10dcf724725a3b1c3b53e63a9ee03b27db9", "shasum": "" }, "require": { @@ -11986,7 +11986,7 @@ "description": "Allows you to standardize and centralize the way objects are constructed in your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/dependency-injection/tree/v5.4.25" + "source": "https://github.com/symfony/dependency-injection/tree/v5.4.26" }, "funding": [ { @@ -12002,20 +12002,20 @@ "type": "tidelift" } ], - "time": "2023-06-24T09:45:28+00:00" + "time": "2023-07-19T20:11:33+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v5.4.22", + "version": "v5.4.26", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "1df20e45d56da29a4b1d8259dd6e950acbf1b13f" + "reference": "5dcc00e03413f05c1e7900090927bb7247cb0aac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/1df20e45d56da29a4b1d8259dd6e950acbf1b13f", - "reference": "1df20e45d56da29a4b1d8259dd6e950acbf1b13f", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/5dcc00e03413f05c1e7900090927bb7247cb0aac", + "reference": "5dcc00e03413f05c1e7900090927bb7247cb0aac", "shasum": "" }, "require": { @@ -12071,7 +12071,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v5.4.22" + "source": "https://github.com/symfony/event-dispatcher/tree/v5.4.26" }, "funding": [ { @@ -12087,7 +12087,7 @@ "type": "tidelift" } ], - "time": "2023-03-17T11:31:58+00:00" + "time": "2023-07-06T06:34:20+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -12234,16 +12234,16 @@ }, { "name": "symfony/finder", - "version": "v5.4.21", + "version": "v5.4.27", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "078e9a5e1871fcfe6a5ce421b539344c21afef19" + "reference": "ff4bce3c33451e7ec778070e45bd23f74214cd5d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/078e9a5e1871fcfe6a5ce421b539344c21afef19", - "reference": "078e9a5e1871fcfe6a5ce421b539344c21afef19", + "url": "https://api.github.com/repos/symfony/finder/zipball/ff4bce3c33451e7ec778070e45bd23f74214cd5d", + "reference": "ff4bce3c33451e7ec778070e45bd23f74214cd5d", "shasum": "" }, "require": { @@ -12277,7 +12277,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v5.4.21" + "source": "https://github.com/symfony/finder/tree/v5.4.27" }, "funding": [ { @@ -12293,7 +12293,7 @@ "type": "tidelift" } ], - "time": "2023-02-16T09:33:00+00:00" + "time": "2023-07-31T08:02:31+00:00" }, { "name": "symfony/options-resolver", @@ -12445,16 +12445,16 @@ }, { "name": "symfony/process", - "version": "v5.4.24", + "version": "v5.4.26", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "e3c46cc5689c8782944274bb30702106ecbe3b64" + "reference": "1a44dc377ec86a50fab40d066cd061e28a6b482f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/e3c46cc5689c8782944274bb30702106ecbe3b64", - "reference": "e3c46cc5689c8782944274bb30702106ecbe3b64", + "url": "https://api.github.com/repos/symfony/process/zipball/1a44dc377ec86a50fab40d066cd061e28a6b482f", + "reference": "1a44dc377ec86a50fab40d066cd061e28a6b482f", "shasum": "" }, "require": { @@ -12487,7 +12487,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v5.4.24" + "source": "https://github.com/symfony/process/tree/v5.4.26" }, "funding": [ { @@ -12503,7 +12503,7 @@ "type": "tidelift" } ], - "time": "2023-05-17T11:26:05+00:00" + "time": "2023-07-12T15:44:31+00:00" }, { "name": "symfony/stopwatch", @@ -12683,5 +12683,5 @@ "platform-overrides": { "php": "8.0" }, - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.3.0" } diff --git a/config/vufind/markdown.ini b/config/vufind/markdown.ini index fb0d052b3d6..b962f700a30 100644 --- a/config/vufind/markdown.ini +++ b/config/vufind/markdown.ini @@ -1,6 +1,6 @@ ; This file could be used to define configuration of markdown to HTML converter. ; More detailed configuration documentation could be found here: -; https://commonmark.thephpleague.com/2.3/configuration/ +; https://commonmark.thephpleague.com/2.4/configuration/ [Markdown] ; How to handle HTML input. Options are: strip, allow, escape. Defaults to strip ;html_input = allow @@ -18,11 +18,11 @@ ;max_nesting_level = 10 ; Which extension you want to activate. List of extension names separated by comma. -; Available extensions as of league/commonmark version 2.3: +; Available extensions as of league/commonmark version 2.4: ; Attributes, Autolink, DefaultAttributes, DescriptionList, DisallowedRawHtml, ; ExternalLink, Footnote, FrontMatter, HeadingPermalink, Mention, SmartPunct, ; Strikethrough, Table, TableOfContents, TaskList. -; More about extensions: https://commonmark.thephpleague.com/2.3/extensions/overview/ +; More about extensions: https://commonmark.thephpleague.com/2.4/extensions/overview/ ; Some of them could have a configuration, see sections below. ; Note: FrontMatter does enable to inject the title other then main heading. Just add ; something like this at the very beginning of your markdown file: @@ -30,7 +30,7 @@ ;title: "Some specific title" ;--- ; See more about FrontMatter extension here: -; https://commonmark.thephpleague.com/2.3/extensions/front-matter/ +; https://commonmark.thephpleague.com/2.4/extensions/front-matter/ ; ; You can also use own extensions, just address it using fully qualified class name ; like 'VuFindLocalModule\Markdown\ExampleExtension'. If your extension is @@ -38,7 +38,7 @@ ; qualified name. For example: '[VuFindLocalModule\Markdown\ExampleExtension]', and ; with 'config_key' with value of configuration key, in which your extension expects ; its configuration. More about custom extension configuration: -; https://commonmark.thephpleague.com/2.3/customization/configuration/ +; https://commonmark.thephpleague.com/2.4/customization/configuration/ extensions = Autolink,DisallowedRawHtml,Strikethrough,Table,TaskList ; CommonMarkCore extension is always enabled by default @@ -57,13 +57,13 @@ extensions = Autolink,DisallowedRawHtml,Strikethrough,Table,TaskList ;unordered_list_markers[] = "*" ;unordered_list_markers[] = "+" -; See https://commonmark.thephpleague.com/2.3/extensions/default-attributes/ +; See https://commonmark.thephpleague.com/2.4/extensions/default-attributes/ [DefaultAttributes] ; Example configuration: ;League\CommonMark\Extension\Table\Table[class] = 'table' ;League\CommonMark\Extension\CommonMark\Node\Inline\Link[target] = '_blank' -; See https://commonmark.thephpleague.com/2.3/extensions/disallowed-raw-html/ +; See https://commonmark.thephpleague.com/2.4/extensions/disallowed-raw-html/ [DisallowedRawHtml] ; Default configuration, to enable any tag, just comment out the appropriate line disallowed_tags[] = "title" @@ -76,7 +76,7 @@ disallowed_tags[] = "noframes" disallowed_tags[] = "script" disallowed_tags[] = "plaintext" -; See https://commonmark.thephpleague.com/2.3/extensions/external-links/ +; See https://commonmark.thephpleague.com/2.4/extensions/external-links/ [ExternalLink] ; This should be always set, if you want to use this extension. You can use regular ; expressions to match group of hosts @@ -87,7 +87,7 @@ internal_hosts[] = www.example.com ;noopener = external ;noreferrer = external -; See https://commonmark.thephpleague.com/2.3/extensions/footnotes/ +; See https://commonmark.thephpleague.com/2.4/extensions/footnotes/ [Footnote] ;backref_class = footnote-backref ;backref_symbol = '↩' @@ -98,7 +98,7 @@ internal_hosts[] = www.example.com ;footnote_class = footnote ;footnote_id_prefix = 'fn:' -; See https://commonmark.thephpleague.com/2.3/extensions/heading-permalinks/ +; See https://commonmark.thephpleague.com/2.4/extensions/heading-permalinks/ [HeadingPermalink] ; There is also 'slug_normalizer' options, which should be set to an object ; implementing League\CommonMark\Normalizer\TextNormalizerInterface @@ -113,22 +113,25 @@ internal_hosts[] = www.example.com ;title = Permalink ;symbol = '¶' ;aria-hidden = false +;apply_id_to_heading = true +;heading_class = 'heading' +;insert = 'none' -; See https://commonmark.thephpleague.com/2.3/extensions/mentions/ +; See https://commonmark.thephpleague.com/2.4/extensions/mentions/ [Mention] ; This is an example of configuration, see more details in original documentation ;github_handle[prefix] = '@' ;github_handle[pattern] = '/^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}(?!\w)/' ;github_handle[generator] = 'https://github.com/%s' -; See https://commonmark.thephpleague.com/2.3/extensions/smart-punctuation/ +; See https://commonmark.thephpleague.com/2.4/extensions/smart-punctuation/ [SmartPunct] ;double_quote_opener = '“' ;double_quote_closer = '”' ;single_quote_opener = '‘' ;single_quote_closer = '’' -; See https://commonmark.thephpleague.com/2.3/extensions/table-of-contents/ +; See https://commonmark.thephpleague.com/2.4/extensions/table-of-contents/ [TableOfContents] ;html_class = table-of-contents ;position = top @@ -138,7 +141,7 @@ internal_hosts[] = www.example.com ;normalize = relative ;placeholder = -; See https://commonmark.thephpleague.com/2.3/extensions/tables/ +; See https://commonmark.thephpleague.com/2.4/extensions/tables/ [Table] ;wrap[enabled] = true ;wrap[tag] = 'div' @@ -146,3 +149,7 @@ internal_hosts[] = www.example.com ; to define it in ini file, so this is fixed later in code. More attributes ; definitions need to separated by coma ;wrap[attributes] = 'class:table-responsive,title:table' +; Works similarly to wrap[attributes] configuration +;alignment_attributes[left] = 'align:left' +;alignment_attributes[center] = 'align:center' +;alignment_attributes[right] = 'align:right' diff --git a/module/VuFind/src/VuFind/Service/MarkdownFactory.php b/module/VuFind/src/VuFind/Service/MarkdownFactory.php index 1cf8ea9cd0d..2480a635d81 100644 --- a/module/VuFind/src/VuFind/Service/MarkdownFactory.php +++ b/module/VuFind/src/VuFind/Service/MarkdownFactory.php @@ -269,6 +269,7 @@ protected function sanitizeConfig(array $config): array ['external_link', 'open_in_new_window'], ['footnote', 'container_add_hr'], ['heading_permalink', 'aria_hidden'], + ['heading_permalink', 'apply_id_to_heading'], ]; foreach ($boolSettingKeys as $key) { if (isset($config[$key[0]][$key[1]])) { @@ -290,20 +291,31 @@ protected function sanitizeConfig(array $config): array $config[$key[0]][$key[1]] = (int)$config[$key[0]][$key[1]]; } } - $tableWrapAttributes = []; - if (isset($config['table']['wrap']['attributes'])) { - $tableWrapAttributes = array_map( + + $parseAttributes = function (string $attributes): array { + $attributes = array_map( 'trim', - explode(',', $config['table']['wrap']['attributes']) + explode(',', $attributes) ); - $config['table']['wrap']['attributes'] = []; - } - foreach ($tableWrapAttributes as $attribute) { - $parts = array_map('trim', explode(':', $attribute)); - if (2 === count($parts)) { - $config['table']['wrap']['attributes'][$parts[0]] = $parts[1]; + $attributesArray = []; + foreach ($attributes as $attribute) { + $parts = array_map('trim', explode(':', $attribute)); + if (2 === count($parts)) { + $attributesArray[$parts[0]] = $parts[1]; + } } + return $attributesArray; + }; + $attributesConfigKeys = [ + ['wrap', 'attributes'], + ['alignment_attributes', 'left'], + ['alignment_attributes', 'center'], + ['alignment_attributes', 'right'], + ]; + foreach ($attributesConfigKeys as $keys) { + $config['table'][$keys[0]][$keys[1]] = $parseAttributes($config['table'][$keys[0]][$keys[1]] ?? ''); } + return $config; } diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Service/MarkdownFactoryTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Service/MarkdownFactoryTest.php index a33b57cbea1..bd05827138f 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Service/MarkdownFactoryTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Service/MarkdownFactoryTest.php @@ -138,6 +138,11 @@ public function testConfig(): void 'tag' => 'div', 'attributes' => 'class:table-responsive,title:table', ], + 'alignment_attributes' => [ + 'left' => 'class:left,align:left', + 'center' => 'class:center, align: center', + 'right' => 'class:right', + ], ], 'VuFindTest\Markdown\ExampleExtension' => [ 'config_key' => 'example', @@ -150,6 +155,7 @@ public function testConfig(): void 'HeadingPermalink' => [ 'min_heading_level' => '3', 'max_heading_level' => '4', + 'apply_id_to_heading' => 'true', ], ]; $customEnvironment2 = [ @@ -172,6 +178,19 @@ public function testConfig(): void 'title' => 'table', ], ], + 'alignment_attributes' => [ + 'left' => [ + 'class' => 'left', + 'align' => 'left', + ], + 'center' => [ + 'class' => 'center', + 'align' => 'center', + ], + 'right' => [ + 'class' => 'right', + ], + ], ], 'example' => [ 'example' => 'example', @@ -200,6 +219,8 @@ public function testConfig(): void 'title' => 'Permalink', 'symbol' => '¶', 'aria_hidden' => true, + 'apply_id_to_heading' => true, + 'heading_class' => '', ], ];