-
Notifications
You must be signed in to change notification settings - Fork 13
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
Toggle bold, italic, and strike styling #101
Comments
Ahh yeah, I figured this one would pop up someday :) The thing here is that figuring out the boundaries is sometimes quite tough to do, depending on wether or not a certain applied style (bold / italic) spans multiple lines. That said one can always I think it's worth a shot, cheers for the suggestion 👍 though as it may be more difficult than expected it may take some time for me to implement, with that I thank you for your patience in advance :) |
Will it be possible to toggle between selected text maybe? Just a thought... |
@samarulmeu I think it would be more effort to first have to select the text and then unmark it, as opposed to just unmarking stuff around the cursor directly. This is only the case for unmarking though, since it does make sense to start a selection and later figure out where you want it to end, and apply stuff around it after you've selected what you want. In any case I think basic toggling of say bold/italic/bold-italic using normal mode should be possible and will allow me to stay in the realm of sanity while at it :) As usual thanks for joining in on the convo, please keep sharing your thoughts if you have them, always appreciated 👍 |
@SidOfc Thank you for your kind words. I really like the plugin and it replaced some other markdown plugins for me, that is way I am following all the issues trying to help in making it better. My latest suggestion was based on what I considered to be easier. I think is easy to select text betweend bold or italic mark amd then just toggle them. Having the plugin do the switch in normal mode will ne great, but as I already noted it will be a lot of work. Anyhow, you have the knife and the knowledge to do it. |
Thanks @SidOfc and @samarulmeu for the comments! I believe the behavior of this feature could be rather simple (using bold as an example).
What do you think? Does that make sense? Am I forgetting some edge cases or missing anything? |
@victorkristof indeed that is an amazing suggestion, I never thought about using the syntax highlighting group to detect the boundaries of bold marks! In my mind I was already traversing the file left / right and up / down in order to find boundaries, but this seems like it could make life a whole lot easier and less bug riddled, I will give that a shot hopefully this week as well! |
Did some more research, while I can actually identify the highlighting group below the cursor, the start / end positions of the highlighting group the cursor is on are not in the results. I've checked Had some high hopes for that information being given to me by Vim/Nvim but it seems like traversing current line and possibly up/down as well will be the only way to achieve what we want here. I'll see what I can come up with, but it may take a bit longer because of this 😅 |
I've got a crude working implementation of it now, but because of the way vim applies highlighting (it's inconsistent, ugh) there are some edge cases that need to be taken care of... basically, given: Aside from that I'm a bit worried about single-character wrapped texts such as For today though, I think I'll leave it at what it is :) |
Alright, actually pushed through a bit and got it working, this one is also in master now, you can update mkdx normally. Let me know if anything breaks for you, otherwise I think we can also close this one :) The only thing it doesn't do is handle bold+italic mappings since these are essentially "composite" of a bold+italic marker and the syntax highlighting mkdx applies doesn't respect them as individual parts but rather as a whole, perhaps changing the way its highlighted will fix it though, but I think this can wait until it pops up as a feature request :) |
That's really great! I have some errors unfortunately :/
and then
|
@victorkristof hmmn that is quite interesting, can you provide a case to reproduce this issue? It could be because I am safeguarding Just opened vim and indeed marking text there doesn't work at the momoent. in Neovim this does work however... I'm on it! |
hmmn, regular vim (at least mine) refuses to load mkdx all-together now... interesting indeed |
@victorkristof I reset master to an earlier point in time, does it restore "old" functionality for you? |
@victorkristof I've reset master back to before any feature merges (so even further than my last message), seems regular vim now works again but holy freaking hell... I usually develop in neovim and usually, neovim and vim aren't too different. In this case however, I have no idea what causes this issue at all... Unfortunately the error messages are harder to decipher than chinese. It is complaining about not being able to modify count, which I am never modifying anywhere. The artefact you are seeing may be an internal vim function since that code does not exist within mkdx source code. edit: back to the drawing board to make vim also play nice |
@victorkristof figured it out... It seems that, if you use I fixed it and added a note in the code to clarify: I don't like bashing on vim, but that was indeed rediculous 😓 edit: upon further investigation it makes more "sense", apparently using |
Well done! It works smoothly :) I found another (smaller) bug though...with a potential solution. If I toggle bold on a snake-cased word, I get two different results:
and
The second instance is broken I guess. I think I suggested in #103 to wrap around So my suggestion would to revert the behavior of bold/italics/... to wrap around Unless you can come up with a resilient behavior for these cases? What do you think? :) |
Ahh nice catch @victorkristof this should be easy to fix actually, I use regular motions to move cursor around so all I had to do is replace |
Should be working now actually :) |
|
Ahh cool cool! Does this mean we can close this one? :) |
Ok one last thing. You were right about punctuation. If there is punctuation right after the
Any chance to exclude the last character of the |
Yeah was just typing this one out in a message actually, I haven't found a way to "change" the definition of a WORD ( I think it'll be easier to move the punctuation out manually in this edge case, because otherwise I'd have to reimplement how wrapping works entirely, is that something you can live with? |
Alternatively, I could provide a setting which would allow wrapping to occur per WORD or word, since as you mentioned before, wrap mappings may now be prefixed with count, which could solve it that way. |
Alright I see, I don't have a strong opinion right now, I guess I'll have to use the plugin for a few days in real situation to make my mind. If this turns out to be a problem, I can open a bug issue later so that you can close this one :) Anyways, thank you for the reactivity and implementing the feature so quickly! [Edit] Just saw your second comment, yes that could be a potential workaround. But don't want to overload your plugin with rather "small" options though! |
Alright, that sounds good to me! As for the option, I believe mkdx already has 40+ settings so another one won't do harm, perhaps the default could be changed back to "word" wrapping etcetera but this is something we can discuss later. Give it a test drive and let me know what you think if indeed it bothers you, your input has been valuable and useful for other users (though we won't hear about it from them easily hehe). Thank you for the compliments, I do my best to keep everyone happy while retaining the quality of the plugin, it is getting a bit hairy lately though but still doable :) With that I'll close this one for now and I may hear from you again quite soon, thanks for all the feedback so far (now onto #100) 👍 |
just in case you're wondering about the I also found a setting which I can use with One edge case I found is while the cursor is on the punctuation it will not do the right thing currently, not yet sure how to figure that one out either but figured I'd keep you up-to-date here :) |
Ok, interesting. Actually setting
This works majestically! (I don't why you have it by default. Did you set it explicitly as well? Do you have Anyway, problem solved - thanks! |
Actually don't have either I can add a mention in the README, glad this worked for you as well! |
A bug I discovered today, when writing: if the word is the last one, without any space after it and you try to toggle it will also take the space before Example:
Trying to bold words I get
Instead of
Italic shows the same behavior. |
Please see my edited last comment. I accidentally added a dot at the end of the example. |
Alright, reopening, may take a few more days since I already planned a bit ahead this week, cheers @samarulmeu 👍 |
No problem. Take your time. |
After some quick checking, it is an issue in vim only, neovim handles it properly (this is just a note to self) |
Nevermind above comment, I performed a slightly different check in neovim where it did work (having cursor on last char of last word) both are equally broken. |
Alright, should now also work properly @samarulmeu although I did find a new issue whereby if you try to quote an actual punctuation mark:
I doubt anyone really wants to do this though however, if it does pop up, let's not reopen this anymore since this one is getting quite long now :) |
Thank you again. You've made my day! I think that the issue with the dot mark is strange and will not be encountered. How I've stumble upon the issue I've mentioned: I was writing something and then I thought I should emphasize this so Great job! You can close this as I am not able to. |
Cheers for detailing this, there's probably some more edge cases lurking in the dark with text wrapping (especially multi-line which I did end up writing some traversal logic for). In any case will close this one permanently now, new issues are welcome as usual samarulmeu 👍 Note: I honestly thought this one would be more difficult, but I keep finding new ways to fix these things lately 😅 |
Hi!
I really like to be able to toggle quotes and list types.
Would it make sense to also enable
<Plug>(mkdx-text-bold-n)
(and its italic and strike counterpart) to toggle between**text**
andtext
?Currently, <MAP_PREFIX>b performed on
**text**
gives****text****
, which isn't really useful.The text was updated successfully, but these errors were encountered: