2020-09-17 02:51:57 +08:00
|
|
|
const repository = require('../../src/services/repository');
|
|
|
|
|
|
|
|
module.exports = () => {
|
|
|
|
for (const note of repository.getEntities("SELECT * FROM notes WHERE type = 'text' AND isProtected = 0")) {
|
|
|
|
try {
|
2020-10-04 02:51:14 +08:00
|
|
|
let origContent = note.getContent();
|
2020-09-17 02:51:57 +08:00
|
|
|
|
2020-10-04 02:51:14 +08:00
|
|
|
const newContent = origContent
|
2020-09-17 02:51:57 +08:00
|
|
|
.replace(/<h1/ig, "<h2")
|
|
|
|
.replace(/<\/h1/ig, "</h2");
|
|
|
|
|
2020-10-04 02:51:14 +08:00
|
|
|
if (newContent !== origContent) {
|
|
|
|
note.setContent(newContent);
|
|
|
|
}
|
2020-09-17 02:51:57 +08:00
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
console.log(`Changing note content for note ${note.noteId} failed with: ${e.message} ${e.stack}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|