-
Notifications
You must be signed in to change notification settings - Fork 3
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
[Request]: Highlight pre- and post-context #50
Comments
Hi @jez Did I understand you correctly that your idea is to basically highlight the {{highlightWithinContext highlight contextualText}} The helper function would look like this: Handlebars.registerHelper('highlightWithinContext', (highlight: string, contextualText: string) => {
// there must always be a highlight within the contextual text
// so it is possible to wrap that portion with <mark> tag and return it
const highlightWithinContext = contextualText.replace(highlight, `<mark>${highlight}</mark>`);
return highlightWithinContext;
}); I should also mention that the |
@bandantonio The difference between the solution you propose and the one I propose is that in mine, the choice of mark is configurable. Continuing with your solution, it would be possible to accept
Yep, understood, that's fine. I'm personally just trying to recreate this effect from the Books app: So if the |
I have no strong opinion about either solution (one helper or two) in so far as it supports choosing what to use for the begin and end marker. |
@jez Thanks for the explanation, now this makes more sense. |
Thanks but I’m really hoping for arbitrary markers. My intention is to use markup like <span style="color: red;">red</span> with custom inline CSS to recreate the highlights with the same colors as used by the Books app. There is even an example of doing so in the documentation, except it doesn’t support showing the contextual text before and after the highlight: There’s also the question of how some people might want to use markdown markers ( In my opinion, it’s not sufficient to artificially restrict the markers. |
This looks exactly like what I need. Thank you. Please add also an option to increase the context: +2 sentences at each side, +100 words at each side, the whole paragraph, etc. Books.app also supports different colors and underlining. Hope this will be supported too! |
Feature Request Checklist
What feature would you like to request?
What I'd really like is some way to take input like this:
and produce this:
One way I can think to achieve this would be if there were a Handlebars helper function to get the contextual text before and after the highlighted text (or, to have two additional template variables,
contextualTextPre
andcontextualTextPost
, which achieve the same thing).If there's already a way to achieve this with functionality built into this plugin or Handlebars itself, I'd love to learn about it.
Code of Conduct
The text was updated successfully, but these errors were encountered: