@haxcms/migrate-regex
v0.0.13
Published
Search and replace regex patterns in a HAXcms site.
Downloads
11
Readme
@haxcms/migrate-regex
Install
$ npm install -g @haxcms/migrate-regex
$ migrate-regex COMMAND
running command...
$ migrate-regex (-v|--version|version)
@haxcms/migrate-regex/0.0.13 darwin-x64 node-v12.13.0
$ migrate-regex --help [COMMAND]
USAGE
$ migrate-regex COMMAND
...
$ npm install -g @haxcms/migrate-regex
$ migrate-regex COMMAND
running command...
$ migrate-regex (-v|--version|version)
@haxcms/migrate-regex/0.0.0 darwin-x64 node-v10.12.0
$ migrate-regex --help [COMMAND]
USAGE
$ migrate-regex COMMAND
...
Usage
Define patterns and replacements
In your HAXcms site, create a file called migrate.json
. By default migrate-regex
will assume this file is a sibling of site.json
.
Define your patterns in the regex
property. Example:
{
"regex": [
{
"pattern": "<",
"replacement": "<"
},
{
"pattern": ">",
"replacement": ">"
},
{
"pattern": """,
"replacement": "\""
},
{
"pattern": "(\\$\\$(?:(?!\\$\\$)[\\s\\S])*?)(<\/?em>)([\\s\\S]*?\\$\\$)",
"replacement": "$1_$3"
},
{
"pattern": "(\\$\\$)([^\\$\\$]*)(\\$\\$)",
"replacement": "<lrn-math>$2</lrn-math>"
}
]
}
Run regex migration
$ migrate-regex run -j site.json