lochmueller / sourceopt
最终页面的优化:重新格式化(x)HTML输出,移除换行符、注释和生成器信息,包括使用正则表达式的搜索和替换字符串。此外,将内容元素内选定的所有SVG合并成一个<symbol>文件,并用<use>替换<img>。
资助包维护!
lochmueller
paypal.me/lochmueller
Requires
- php: ^7.4||^8.0
- typo3/cms-core: ^9.5||^10.4||^11.5||^12.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.3
- phpmd/phpmd: ^2.10
- typo3/testing-framework: ^6.4
Replaces
- maxserv/replacecontent: *
- typo3-ter/replacecontent: *
- typo3-ter/sourceopt: 5.1.2
README
- SourceOpt : 重新格式化(x)HTML输出,移除换行符、注释和生成器信息
- RegExRep : 使用您的正则表达式进行搜索和替换字符串;拥抱正则表达式和立即迁移
- SVGstore : 将元素内选定的所有SVG合并成一个<symbol>文件,并用<use>替换<img>
安装
在2346673中的第19到20行
| "php": "^7.4||^8.0", | |
| "typo3/cms-core": "^9.5||^10.4||^11.5||^12.0" |
composer require lochmueller/sourceopt
-
通过TypoScript
[constants]@import 'EXT:sourceopt/Configuration/TypoScript/constants'[setup]@import 'EXT:sourceopt/Configuration/TypoScript/setup' -
通过输入设备
- 将
[EXT:sourceopt/Configuration/TypoScript]添加到Template中的Includes下的Include static
- 将
配置
包含扩展并转到模板的常量编辑器,您将在PLUGIN下找到所有选项
性能
PHP进程需要服务器性能,因为在逻辑中有多个搜索/替换操作
参考
注意:以下功能按相反顺序执行
SourceOpt
TypoScript [constants] || 在[setup]前添加config.
RegEx 替换
TypoScript [setup] 包含 stdWrap
config.replacer {
search {
1 = /(?<="|')\/?(fileadmin|typo3temp|uploads)/
give-me-cherries = /fruit/
wrapBoldly < tmp.find
wrapBoldly.wrap = /|/
}
replace {
1 = //cdn.tld/$1
give-me-cherries = cherry
wrapBoldly < tmp.repl
wrapBoldly.wrap = <b>|</b>
}
}
如何迁移
从 jweiland/replacer : 1.4 - 2.x
1.4 - 2.x- regex replace
config\.tx_(?:\w*replace\w*)toconfig.replacer - 删除
config.tx_replacer.enable_regex = 1
从 maxserv/replacecontent 2013 - 2017
- regex replace
config\.tx_(?:\w*replace\w*)toconfig.replacer
从 typo3-ter/ja_replacer 2009 - 2013 || phorax/ja-replacer 2016
composer install jweiland/replacer
将 config.tx_ja_replacer 替换为 config.tx_replacer
从 typo3-ter/n84_contentreplacer 2016
- regex replace
config\.tx_(?:\w*replace\w*)toconfig.replacer
来自 typo3-ter/fereplace 2011
composer install jweiland/replacer
& 将 plugin.fereplace.pairs 替换为 config.tx_replacer .. ah .. 并使用一个正则表达式
- 搜索
(\n\s*)(\d+)(?:{\s+|\.)old\s*=\s*([^\n]+).+?new\s*=\s*([^\n]+) - 替换
$1search.$2 = $3\n$1replace.$2 = $4
来自 typo3-ter/regex 2009
- 正则替换
config\.regex为config.replacer - 正则替换
(?:\s)(\w+)\s*=\s*为search.$1 = - 正则替换
(\w+)\.replacement\s*=\s*为replace.$1 =
SVGstore
TypoScript [constants] || 在[setup]前添加config.