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

Remove overtyping of existing code? #6

Closed
Lextuga007 opened this issue Jun 8, 2023 · 7 comments
Closed

Remove overtyping of existing code? #6

Lextuga007 opened this issue Jun 8, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@Lextuga007
Copy link
Contributor

Not sure how feasible this is but if there is code already written, like for the incremental bullets, then if that code is highlighted and Insert incremental list is selected it would be magical if it surrounded the text and didn't overtype it.

The reason why this is so useful is if you've (as in I've!) written ::: incremental instead of ::: {.incremental} multiple times!

@matt-dray
Copy link
Owner

Oh yeppers, this is doable. In fact, {snorkel} has this behaviour.

Stretch goal: in theory there could be some input checks too. Like a warning() if you've asked for incremental but your text doesn't appear to be bullet points.

You also just reminded me re ::: {.notes} vs ::: notes, so I've added #7.

@matt-dray matt-dray added the enhancement New feature or request label Jun 8, 2023
@matt-dray
Copy link
Owner

matt-dray commented Jun 17, 2023

Hullo @Lextuga007, I've now done this in the branch md-overwrite. Would you like to guinea-pig it for me? You can install like:

remotes::install_github("matt-dray/quartostamp@md-overwrite")

So, as before: if you don't highlight any text, you'll get this generic thing inserted when you use the addin for 'Insert Incremental List':

::: {.incremental}
- List element A
- List element B
:::

But let's say you have the following text:

- I'm going to build tension...
- By revealing incrementally until...
- BOO!

If you highlight that and then use the addin, you'll get this instead:

::: {.incremental}
- I'm going to build tension...
- By revealing incrementally until...
- BOO!
:::

Another thing I'd be interested to hear about it footnotes. I decided to drastically improve the 'Insert Footnote' one as well. Before it just inserted '[^A footnote]' inline where your cursor was. It will still do that if you don't select any text, but if you do select some text, it will generate the footnote label by taking the first 10 non-space, non-punctuation characters (e.g. select 'NHS-R Community' and you'll get 'NHS-R Community [^nhsrcommun]' inserted). Additionally, it will generate a footnote string ('[^nhsrcommun]: Insert description.' in this case), copy it to the clipboard and prompt you in the console to paste it at the bottom of the document. (I tried to automatically insert the footnote in a new row at the bottom of the document, but that involves first resaving the user's document with a new blank row at the end and then pasting into it. It doesn't feel right to manipulate the user's file like that).

Happy to explain more if that doesn't make sense!

@Lextuga007
Copy link
Contributor Author

Tested the incremental and all works 😃

@Lextuga007
Copy link
Contributor Author

With the footnote I accidentally (but luckily perhaps!) highlighted the incremental text before using the footnote and that produced:

::: {.incremental}
- I'm going to build tension...
- By revealing incrementally until...
- BOO!
::: [^incrementa]

Highlighting some text gave:

This is text [^Thisistext]

and adding just a footnote with no highlighted gives:

This is text  [^footnote]

I did get this in the console:

The footnote '[^Thisistext]: Insert description.' was added to the clipboard. Paste it at the bottom of your document.

I totally agree with not saving a user's document first - good call 😃

@matt-dray
Copy link
Owner

Smashing, thank you for taking a look.

And whoops, yes, 'NHS-R Community' actually becomes [^NHSRCommun] rather than [^nhsrcommun]. I thought I'd put in a call to tolower(), but turns out that I didn't.

In retrospect, I might change the labelling system so the 'NHS-R Community' label would be [^nhsr-community]. This should be more readable.

Initially I wanted to keep the footnote labels short, but I think it's better to have 'This bit of text' become [^this-bit-of-text] rather than [^thisbitoft]. Downside is that you could end up with a really long footnote label if you select a lot of text, but I think the user can deal with that.

Also, I think that the message in the console should be slightly different if the user simply inserts a footnote. I think it should also say 'You may need to change the footnote label if it isn't unique' or something. Otherwise there'll be several conflicting [^footnote] labels.

@Lextuga007
Copy link
Contributor Author

I like having a bit of text and sometimes it will work brilliantly, often not. Getting it right for all circumstances may take too much work?

matt-dray added a commit that referenced this issue Jun 19, 2023
Allow user text selection, not just simple insertion, close #6.
@matt-dray
Copy link
Owner

Okey doke, I merged this branch and bumped to v0.1, so the 'overtyping' thing is solved. Thanks Zoë! The (opinionated) footnotes addin now does what I think it should; happy to receive a new issue for any improvements.

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

No branches or pull requests

2 participants