jasonwilliams / anki

Anki VSCode Plugin
MIT License
278 stars 32 forks source link

Update markdown when creating new cards #108

Closed benjamin-weller closed 1 year ago

benjamin-weller commented 1 year ago

I'm looking for a strong/less brittle way of matching the front of the card to what actually exists in the markdown. Right now bold ** or other markdown formatting breaks the line matching I have. What I really want is any easy way to reverse engineer a given HTML string into markdown and use that for the line matching. Do you know of any good packages for this?

jasonwilliams commented 1 year ago

Do you know of any good packages for this?

https://github.com/jasonwilliams/anki/issues/31#issuecomment-1372690732

benjamin-weller commented 1 year ago

I have a preliminary solution. I'm open to hearing any thoughts on how testing should work here such that this is easily maintainable.

I've tested locally, and works on my machine™:

No cards in deck prior to run: image

Testing String:

# YOLO

## SOLO **BOBO**

NOLO

Completed run: image

Note ID matches: image

jasonwilliams commented 1 year ago

Good work, ive tested it and I can see the noteIds being added. The solution does feel a bit messy though, I can't help but wonder if there's a more clean way to achieve this.

dennis-akar commented 1 year ago

Hi! Would it be possible to merge this for the time being so users can have this feature?

benjamin-weller commented 1 year ago

Good work, ive tested it and I can see the noteIds being added. The solution does feel a bit messy though, I can't help but wonder if there's a more clean way to achieve this.

I want you to be comfortable with maintaining this project (it's an amazing resource), but @denizhanakar does have a point.

Would you feel more comfortable with this change of I:

Would you be willing to accept that as a follow on PR, or would you be uncomfortable checking in this PR without those changes?

jasonwilliams commented 1 year ago

This PR is ok minus the console logs. I believe the noteIDs may need to be opt in for now and not on by default.

Those follow ups sound great but I won’t let them block this.

benjamin-weller commented 1 year ago

I've removed console logs and made the changes opt-in. Please let me know what else is required to check in this change.

jasonwilliams commented 1 year ago

LGTM, thanks @benjamin-weller

dennis-akar commented 1 year ago

Apologies for the spam, but would it be possible to push this to VSCode extension marketplace?

dennis-akar commented 1 year ago

Really really sorry for spam, but generally wondering still if this is possible. I've tried for hours trying to get vsce working with my M1 to no avail, so I can't package and use the extension. I'm already using the 1.2.7 published on vscode marketplace and even in that state it's amazing as long as I don't update my cards, but it will be perfect if I can get the update feature as well. Thank you!

jasonwilliams commented 1 year ago

Sorry for the delay. This has now been released now https://github.com/jasonwilliams/anki/releases/tag/v1.3.0

Please let me know how its going and report any feedfback

benjamin-weller commented 1 year ago

Ok so it doesn't seem like this was pushed to the extension repository, what am I missing?

If this is intentional, is there some install from source method you recommend, something like this?

jasonwilliams commented 1 year ago

Yeah the release didn’t happen due to some validation issues, I will look today