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

Feat #879: Note Embedding Syntax #1281

Merged

Conversation

badsketch
Copy link
Contributor

@badsketch badsketch commented Sep 1, 2023

Addresses #879

  • deprecates foam.preview.noteEmbedInContainer
  • adds syntax discussed. I added comments in the code, but basically the regex plugin for markdown-it only supports one group, which is currently just the wikilink. Therefore I need to capture the entire wikilink item (all of content-card![[note-a]]), and then have another regex that does the parsing and grouping to extract the modifier and the wikilink. This leads to a bit of messy regexes, but I added tests to try to confirm their validity.
  • is not order agnostic, so full-card![[note]] would match both modifiers, whereas card-full![[note]] wouldn't recognize the card portion and just parse the full part. 🫤 I could make it recognize both, but it would require expanding the existing regex, which could get ugly. Then again, the existing behavior might confuse users.

Let me know if this is what you had in mind!

Testing

Given we have content-inline as the user setting

given

Case 1: no type modifiers should just default to the user setting
1-b
1-res

Case 2: adding a type modifier content should not have an effect since it's already the default

4-b
4-res

Case 3: adding one modifier card should override inline resulting in card-inline style
2-b
2-res

Case 4: adding two modifiers full-card should override both default style and scope resulting in full-card style
3-b
3-res

@badsketch badsketch marked this pull request as ready for review September 1, 2023 05:00
Copy link
Collaborator

@riccardoferretti riccardoferretti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! Only thing I would ask is to add documentation for the feature in the docs folder

@badsketch
Copy link
Contributor Author

Updated docs, so lemme know your thoughts on wording, formatting, etc.!

Copy link
Collaborator

@riccardoferretti riccardoferretti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks amazing!

@riccardoferretti riccardoferretti merged commit e327115 into foambubble:master Sep 5, 2023
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