Processor allows you to modify new title in a way you want to. By default, processor is disabled.
In this mode processor will use RegExp to modify title.
Plugin uses the following template:
title.replace(new RegExp("#pattern#", "#flags#"), "#relacement#");
Where:
title
- resolved title by settings. Not original filename.replace
- Docnew Regexp
- Doc#pattern#
- value fromPattern
setting inside Processor#flags#
- value fromFlags
setting inside Processor#replacement#
- value fromReplacement
setting inside Processor
For example, you have set up plugin to pull new title from new_title
path and this key has foo
value.
After plugin resolves foo
title it will execute the following construction:
//It will return "bar" as new value
'foo'.replace(new RegExp('foo'), 'bar');
In this case bar
value will be used as shown title
In this mode processor will use custom function you write inside text area:
You can read more about this
logic here
Inside your function you will be able to use title
variable which contains resolved title.
A value returned by your function will be used as shown title
Works same as Function, but the argument is the object instead of string; Object your function will give an argument:
// Object that will be given into FunctionV2 processor as an "obj" argument
import {TFile} from "obsidian";
export type FunctionV2ObjArg = {
// New file title
title: string;
// Path to file
path: string;
// Obisian's TFile
file: TFile | null;
};
Example of text area:
//just for debugging
console.debug(obj)
return obj.title + '-title-in-' + obj.path