-
-
Notifications
You must be signed in to change notification settings - Fork 400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
YAML Headlines #929
Comments
You can turn off that the first line has to be the filename in the settings. |
Yes, but in this case, you have to rename the files one by one... |
There is a hook to set the filename: http://docs.qownnotes.org/en/develop/scripting/README.html#handlenotetextfilenamehook |
I'm +1 for @bepolymathe request. And I have another use case for it. My case is that Epsilon Notes and some other markdown editors can't handle spaces in file names well. So if I use file names as note names I should rename my notes to something like If there'd be some hook that asks for each note name to fill note list I could make it replace Having more control over note list item appearance can open the door to some experiments like note YAML/tags/content changing color/text of note list items, and by text changes order of notes could be changed too. Something like this feature of Wikidpad. For example I had some script that pinned notes to the top of the list by renaming a note file so it would start from some special symbol. Using such hook it can be done on the note content level, without messing with file system. |
I'll put that on my list. |
That's great news ! This would really make QON my default text editor for scientifics articles ;-) |
There are some troubles with this. One of them is that the list of files will not (and should not) be redrawn every time a note is edited (editing could lead to a possible note name change with this hook)... |
18.06.1
|
I hope there are not too many side effects, I already had to take care of some things... Please use and test the new hook and report back... |
There now is a new release, could you please test it and report if it works for you? |
Works as expected for me, even with enabled file name as note name. By the way could you clarify why it's bad with this hook. I quickly found out that this new hook should be paired with one to handle note renaming by UI like the one for in-text tagging. Without one renaming is absolutely nontransparent. Also it would be cool to have more attributes of note list item to control, like text colour and icon. |
too many things might still rely on the note name and I had to go through some hoops to kill the performance for everyone that doesn't use this hook (because of extensive hook checking)
I'm not sure yet, might be complicated |
I first want to see a script that uses the hook... |
Here is my dirty scratch one: import QtQml 2.0
import com.qownnotes.noteapi 1.0
QtObject {
function getNoteYAML(note) {
const noteText = note.noteText
if (noteText.substring(0, 4) == '---\n') {
var yamlEndIndex = noteText.indexOf('\n...\n')
// If there's no proper "..." YAML ending "---" is recognized as one
if (yamlEndIndex == -1)
yamlEndIndex = noteText.indexOf('\n---\n')
if (yamlEndIndex != -1)
return noteText.substring(0, yamlEndIndex)
}
}
function handleNoteNameHook(note) {
const noteYaml = getNoteYAML(note)
if (noteYaml == null)
return ''
return noteYaml.match(/^title: *(.*)/m)[1]
}
function onNoteStored(note) {
mainWindow.buildNotesIndexAndLoadNoteDirectoryList(true, false)
}
} Refresh part should be much more than that, it will check if title actually changed before rebuilding. |
yes, it will be something I have to do in QOwnNotes. |
I thought about implementing refresh logic in a script but app code can do it better. I haven't tested new notes yet. |
I'd rather only want to refresh that one item in the list then reloading and parsing all notes again... |
For the new notes, it is true that the ideal choice (for the variety of uses) would be :
I need to go back to my script self-study to try to help you. |
@Maboroshy does filtering by tag and sub-folders still work with the new hook? |
Seems work. |
Nice |
Currently I work with this simple "template" and I wonder how to combine the two? Or rather keep two scripts?
|
You can but multiple functions into one QtObject. If some of these functions are scripting hooks all of them will work. For example my script above has |
Ok, i will try it. thanks |
I tried adding your script to mine to test it. I have"[warning] Invalid version or not a cyphertext." in a mess...
|
One question. How is your "allow file name to differ from title" option set? |
There's a checkbox for that in "General" section of options. |
Also my script is does not fully work. It's a scratch to test a hook, nothing more. I'll make something more complete when note renaming hook come. |
Yeah, I know. But is it checked or not at for you to make it work? |
I have it checked all the time. |
Ok thanks. |
@Maboroshy, are we talking about "altering the name in the note list" or actual modifying the filename of the note. By the way, isn't something bad happening when the user actually tries to rename the note in the note list if I alter the name there? |
As of now renaming note list item renames the file, showing new name in the list until note list rebuild. I'm waiting for a hook for renaming note in the notes list. Something like one for renaming the tag, with |
Hm, so the user can't manually rename the file any more? |
For now renaming note list item renames the file. But that doesn't change YAML title in note text. So YAML title come back on note list refresh. Note file keeps new name - the one input by user at renaming. |
Currently the name in the note list was the filename of the note, I guess I will just disable note renaming if a hook to alter the name in the list is present. |
I agree. Since the hook is about control on note title, note file name should also be controlled by a script. That makes such hook a third mode, besides note title as file name and as headline. |
Hello to both of you @pbek and @Maboroshy It's been a long time since I've been through this ;-)
I find the idea of YALM header integration excellent in order to export with Pandoc more customized.
The problem is that the script only works if the document starts like this:
But Qownnotes uses the first line to give the title to the document in the list of notes. Would it be possible to allow to choose the first title ( #) or the field "title" of YALM rather than the first line to give the title. On a more complete document it would look like:
What do you think of that ?
The text was updated successfully, but these errors were encountered: