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 custom templates for cite action #2226

Merged
merged 1 commit into from
Apr 10, 2024

Conversation

duydl
Copy link
Contributor

@duydl duydl commented Mar 13, 2024

I would like to add an option to selection-bar to copy highlight information using a template. This way user could easily define a template and paste their highlights into a markdown for example with readily available links to the source.

The behavior is as follow:
calibre-custom-hl

@duydl
Copy link
Contributor Author

duydl commented Mar 17, 2024

I understand it kind of overlaps with the citation action. If a new action is not welcomed, would it possible to extend the highlight action instead? Like an option to copy info of a highlight into clipboard when it is created.

Thank you for your consideration.

@kovidgoyal
Copy link
Owner

I am travelling for a few days will looka t this when I have a moment.

@kovidgoyal
Copy link
Owner

I am OK with adding an option to specify a template for the existing cite action. This is implemented around line 1150 in selection-bar.pyj

@duydl
Copy link
Contributor Author

duydl commented Apr 9, 2024

test

Would this behavior be acceptable? Cite would behave the same as before with unhighlighted text and use the template with highlighted text.

@kovidgoyal
Copy link
Owner

Couple of comments:

  1. Move the setting below Quick highlights as it is not a commonly used
    setting

  2. Might make more sense to have just a single template that applies
    always. When the selected text is not highlighted {notes}, etc. can simply
    return the empty string. The default value of the template should be the
    current format.

Or if you really want the template specially for highlights, then create
two templates one for selected and one for highlighted.

@duydl
Copy link
Contributor Author

duydl commented Apr 10, 2024

I adjusted the location to follow your first comment. For the second, I would like to use two templates. I also added the vars into session for restore_default.

@duydl duydl changed the title feat: functional custom hl-info copy feat: Custom templates for cite action Apr 10, 2024
@duydl duydl changed the title feat: Custom templates for cite action Add custom templates for cite action Apr 10, 2024
@kovidgoyal kovidgoyal merged commit 2fa7a1f into kovidgoyal:master Apr 10, 2024
3 checks passed
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