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

Custom alert markers (for Obsidian Callout style alert) #185

Closed

Conversation

tuurep
Copy link
Collaborator

@tuurep tuurep commented Sep 18, 2024

Issue: #141

  • Enable markers: '*'
  • Make svg icon configurable
    • the plugin allows setting the icons in the initialization like
      mdit.use(githubAlerts, {
        ...
        icons: {
          custom1: svgTag1,
          custom2: svgTag2,
          ...
        } 
        ...
      });
    • Make a new option for vivify's config.json, where you can set either octicon by name or svg by path
    • Allow overriding the default GH icons in the same option
  • Color configuration
    • To be decided... Setting it via custom stylesheets always works but is it too annoying to configure a marker in 2 separate places?

Limitation of plugin:

Using a custom marker with spaces doesn't work, such as:

> [!Pay Attention]
> Hey

@Tweekism tested that on Obsidian this does work (thanks!), and I think it makes a lot of sense so I'd wish it worked here too.

This however works of course:

> [!custom] Pay Attention
> Hey

Feels like more work though.

Consider sending PR to the plugin if it's easy to add.

@tuurep tuurep force-pushed the issue/141-obsidian-style-callouts branch from 6d06a12 to 9e6350d Compare September 18, 2024 15:11
> Something more special

> [!fOoBaR]
> The marker is case-insensitive and turns into Title Case
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Check if it actually is "Title Case",
However since multi-word markers don't currently work in the plugin, it's not super relevant at the moment

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Confirmed that in Obsidian it's like this:

> [!hello world]

gives Hello world so first letter capitalized only

…dian

On Obsidian, if a custom marker is not defined

e.g.

> [!fooooobarrrrr]

It's styled the same as [!NOTE] (icon and color)

Thanks @Tweekism for confirming
@luposmi
Copy link
Contributor

luposmi commented Jan 22, 2025

About custom style classes, I think the option where you do not directly give the color option, but a class name as a good option:
I personally use custom callouts in neovim for studying and, to keep it very simple, I did not use custom icons or colors directly, but just used built in one.

For example, this is my renderer-markdown.nvim settings:

``` {
        checkbox = {
            custom = {
                todo = { raw = '[-]', rendered = '', highlight = 'RenderMarkdownTodo', scope_highlight = nil },
                rightarrow = { raw = '[>]', rendered = '󰧛', highlight = 'RenderMarkdownRightArrow', scope_highlight = nil },
                tilde = { raw = '[~]', rendered = '󰰱', highlight = 'RenderMarkdownTilde', scope_highlight = nil },
                important = { raw = '[!]', rendered = '', highlight = 'RenderMarkdownImportant', scope_highlight = nil },
            },
        },
        callout = {
            note = { raw = '[!NOTE]', rendered = '󰋽 Note ', highlight = 'RenderMarkdownInfo' },
            tip = { raw = '[!TIP]', rendered = '󰌶 Tip ', highlight = 'RenderMarkdownSuccess' },
            definition = { raw = '[!DEF]', rendered = '󰌶 Definition', highlight = 'RenderMarkdownInfo' },
            important = { raw = '[!IMPORTANT]', rendered = '󰅾 Important ', highlight = 'RenderMarkdownHint' },
            warning = { raw = '[!WARNING]', rendered = '󰀪 Warning ', highlight = 'RenderMarkdownWarn' },
            caution = { raw = '[!CAUTION]', rendered = '󰳦 Caution ', highlight = 'RenderMarkdownError' },
            -- Obsidian: https://help.obsidian.md/Editing+and+formatting/Callouts
            abstract = { raw = '[!ABSTRACT]', rendered = '󰨸 Abstract ', highlight = 'RenderMarkdownInfo' },
            summary = { raw = '[!SUMMARY]', rendered = '󰨸 Summary ', highlight = 'RenderMarkdownInfo' },
-- snip, and more!
        },

    }

I think it's more convenient to just use the colors of other callouts, rather than needing to provide your own RGB value

The built-in color classes should just be written somewhere in the documentation.

edit: PS, if you are unfamiliar with nvim, "highlight" is basically a name for a color option and the provided ones are those who are built in.

@tuurep
Copy link
Collaborator Author

tuurep commented Jan 22, 2025

Hey, thanks for your input.

When I have the time, I'll take a good look at what you're saying, and maybe whether the way render-markdown.nvim does it can help as a reference.

A little pinched at the moment though sorry 😄

@tuurep tuurep closed this Feb 9, 2025
@tuurep tuurep deleted the issue/141-obsidian-style-callouts branch February 9, 2025 15:52
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