Skip to content
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

Add option to new-note-namer, to underline the heading instead of highlighting it with # #249

Merged
merged 5 commits into from
Nov 28, 2024

Conversation

Mystechry
Copy link
Contributor

The script new-note-namer deviates from how QOwnNotes highlights the automatically created heading. Instead of underlining the first line with ======, it precedes it with #.

I prefer the way how QOwnNotes highlights the first line, so I added a checkbox to new-note-namer's settings that restores the default behavior.

I have done some testing and did not notice any regression. Please let me know, if anything looks suspicious.

I do not have any particular preference for which heading style shall be used as the default. I suggest to default to my style and underline the first line with =====, so that it matches QOwnNotes default aesthetics. However, I do not have a strong opinion on this and respect the author's preference to default to #, so I use that for default. Feel free, to reject the PR, if I shall use ===== as default.

if (underlineHeading){
return newName + "\n========================"
} else {
return "# " + newName;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please adapt the amount of whitespace?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed my portion of the code. The original script is not properly consistent with its use of whitespace in the first place. Please let me know if I shall unify the whitespacing throughout the whole script.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole script is a mess, you are right. Please do so in another PR.

@@ -41,7 +49,11 @@ QtObject {
script.log(note.fileCreated)
script.log(note.fileLastModified)

return "# " + newName;
if (underlineHeading){
return newName + "\n========================"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you rather want to count how many = you need according to the name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a great idea. The updated file contains that feature.

@@ -2,9 +2,9 @@
"name": "New note namer",
"identifier": "new-note-namer",
"script": "new-note-namer.qml",
"authors": ["@diegovskytl"],
"authors": ["@diegovskytl,@Mystechry"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use " for strings, and add a space before the string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -41,7 +49,11 @@ QtObject {
script.log(note.fileCreated)
script.log(note.fileLastModified)

return "# " + newName;
if (underlineHeading){
Copy link
Member

@pbek pbek Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a space, like ) {.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

1. Count heading length and adapt the number of '=' characters used for underlining the heading
2. Fixed bug where the first 2 characters were cut from the file name when using '=' to highlight the heading
3. Unified some whitespaces
@Mystechry
Copy link
Contributor Author

  1. Both files got updated. All your suggestions and requests are in.
  2. Fixed a bug I introduced that cuts the first two characters if underlining the heading was checked.

Let me know if there are any further issues or suggestions.

@pbek pbek merged commit 0fd5681 into qownnotes:master Nov 28, 2024
1 check passed
@pbek
Copy link
Member

pbek commented Nov 28, 2024

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants