-
Notifications
You must be signed in to change notification settings - Fork 6
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
Obsidian style callouts #141
Comments
Is this a full superset of GitHub alert blocks? I.e. if we EDIT: Ah, by the way, I think the person who replied to that discussion is on windows so Vivify is not (yet) applicable for them. The OP I haven't seen before, but I would wait until we hear from them here that they would want this here before adding it :) |
That's what I was looking at. How deep do you want to go implementing stuff like this, obsidian on its own is a whole massive rabbit hole. |
Yep, exactly. That's why I would only do it if people ask for it explicitly. Also, I'm not familiar with Obsidian, but when I opened their page for a second it looked like a huge thing including the editor and viewer and all that so I don't know if people even have files from that laying around that they would want to look at in Vivify/edit in Vim |
Then lets close for now as not planned? and revisit if there's demand for it. |
Yes sounds good! We can reopen if @ Praczet stops by and/or someone else wants it as well. |
I'm also very interested, hopefully it will be implemented one day 🙂. |
Also looking for this feature 👍 |
Fair to say it's a popular request, reopening But I have the same question as @jannis-baum above: Is this similar to Github Style Alerts? The biggest functional difference I can see is foldability And another one is nestability, it apparently doesn't work with our github alert plugin, but I'd be interested in 'fixing' that. i.e.: Other than that it looks like something that could be achieved through theming the github alerts. |
Oh hold on, there's mention about Obsidian callout syntax support in the Github alert plugin's readme: https://github.com/antfu/markdown-it-github-alerts?tab=readme-ov-file#customization
So.. if we simply enable that, how much would that solve? |
If no one specifies what exactly they are looking for maybe let's just do this, make a release and then see if anyone complains?🙈 |
So hmm I'm not quite sure how useful this is: > [!note]
> hi
> [!info]
> jajdjdj So it allows to give any id like First thing I notice is we need a generic styling for alert of any 'id' So it would be easy to allow to customize any arbitrary alert type, but with a bit of effort because a custom icon would need to be provided too. Also note that this is already possible:
But again info for people who request this: we aren't familiar with Obsidian usage and currently may have a severe lack of understanding what the expectation is here :) |
Hi,
When I was looking today in your source code to check why my question-callout is not rendered I noticed that you use markdown-it-github-alert. The md.use md.use(MarkdownItGitHubAlerts, {
markers: '*'
}) would work if in neovim you could in config (setup) add styling something like this: { "jannis-baum/vivify.vim"
config = function()
require("vivify").setup({
"markdown-alerts = {
"question" = {
css={},
icon ={},
-- etc
}
}
})
end,
}, But this is what I would like to have, since I am using vivify-server only with neovim. Did I thank you for a help with |
Hey thanks for the input Ok so as far as I understand the main thing would be to be able to use any custom It would be probably better to do the user customization on main Vivify's side so it will work both for standalone So makes me wonder if it's enough to set the
{
"styles": "~/.vivify/styles.css"
}
.markdown-alert-foo {
/* Set any CSS you want */
} ^ This is generally what I'd suggest at this point, there's a couple more details:
If you've got some objections to this approach due to me missing something, let us know 😄 @jannis-baum What do you think? |
Also I might take a closer look at the markdown-it plugin markdown-it-obsidian-callouts that you mentioned in the original discussion, if that gives some ideas as well |
Hi, And about icons you could use icons from https://lucide.dev/ I think. When I am exporting MD file to PDF. I am using fancyicon. for a callouts icons. It goes thru LaTeX and filters like this: % Success Callout
\newtcolorbox{callout-success}{
colback=calloutBackground, % Dark background for the content area
colframe=calloutSuccess, % Green left border and title color
fonttitle=\bfseries, % Title font color same as pageFontColor
coltitle=calloutSuccess, % Title color matching the left border
colbacktitle=calloutBackground, % Title background matches the content area
coltext=pageFontColor,
boxrule=0.5mm, % Thin border
arc=4mm, % Rounded corners
leftrule=2mm, rightrule=0mm, toprule=0mm, bottomrule=0mm, % Only left border
left=2mm, right=2mm, top=2mm, bottom=2mm, % Padding inside the box
before skip=10pt, after skip=10pt, % Vertical space before and after the box
sharp corners, % Optional: to have sharp inner corners
titlerule=0mm, % No title underline or border
title=\faCheck\ Success, % Title with icon
} and lua script: function BlockQuote(el)
local first = el.content[1]
if first and first.t == "Para" then
local text = pandoc.utils.stringify(first.content[1])
local callout_type = text:match("%[!(%u+)%]")
if callout_type then
-- Remove the callout marker from the text
el.content[1].content[1].text = first.content[1].text:gsub("%[!%u+%]%s*", "")
-- Define the callout styles
local blocks = pandoc.List()
if FORMAT:match("html") then
local icon_html = ""
if callout_type == "NOTE" then
icon_html = "" -- info-circle
elseif callout_type == "TIP" then
icon_html = "" -- lightbulb
elseif callout_type == "IMPORTANT" then
icon_html = "" -- exclamation-triangle
elseif callout_type == "WARNING" then
icon_html = "" -- exclamation-circle
elseif callout_type == "CAUTION" then
icon_html = "" -- exclamation-triangle
elseif callout_type == "ABSTRACT" then
icon_html = "" -- book
elseif callout_type == "TODO" then
icon_html = "" -- check-square
elseif callout_type == "SUCCESS" then
icon_html = "" -- check
elseif callout_type == "QUESTION" then
icon_html = "" -- question-circle
elseif callout_type == "FAILURE" then
icon_html = "" -- times-circle
elseif callout_type == "DANGER" then
icon_html = "" -- bomb
elseif callout_type == "BUG" then
icon_html = "" -- bug
elseif callout_type == "EXAMPLE" then
icon_html = "" -- code
elseif callout_type == "QUOTE" then
icon_html = "" -- quote-left
end
local start_html = string.format(
'<div class="callout callout-%s"><strong>%s %s</strong>',
callout_type:lower(),
icon_html,
callout_type
)
blocks:insert(pandoc.RawBlock("html", start_html))
blocks:extend(el.content)
blocks:insert(pandoc.RawBlock("html", "</div>"))
return blocks
elseif FORMAT:match("latex") then
-- Map callout types to LaTeX tcolorbox environments
local env_name = "callout-" .. callout_type:lower()
local start_latex = string.format("\\begin{%s}", env_name)
blocks:insert(pandoc.RawBlock("latex", start_latex))
blocks:extend(el.content)
blocks:insert(pandoc.RawBlock("latex", "\\end{" .. env_name .. "}"))
return blocks
end
end
end
end
return {
{ BlockQuote = BlockQuote },
} |
@tuurep sounds good what you said! The configuration should definitely happen on main Vivify as you said, editor plugin config only makes sense for things specific to the editor. This is viewer-topic. About the icons, I would strongly prefer to avoid introducing a second source of icons. The Octicons probably have something suitable. If not, I'd rather switch to whatever new source for everything instead of having two. In case the icons need to be accessible from CSS, we could consider symlinking the Octicon SVGs from the Node plugin into our static assets to compile them into the executable the way I recently did it for KaTeX and Mermaid. Just have to keep an eye on how much bigger this makes the executable, but I'd guess it'll be fine |
Yeah as I imagine it right now, they'd need to be Note that also what we were talking about here #162 (comment) is always possible by either inlining the whole svg or putting it as a file in your configs or something I definitely have enough to start making a PR in the not too distant future, but think I need help with this part:
:) |
Yes, true, I had already forgotten about this again haha. This is a great option for custom configs. For Vivify itself I think we should always try to go for the symlinking approach so that things keep themselves up to date and we don't have manual copies laying around. I'll help with that :) |
Returning to this issue/draft PR lately!
We had a change of plan about this, CSS is not a good place to add/specify the SVG icons so this will most likely be configured in The idea is to give the options as seen here: .. in Line 69 in 0e10b2e
^ |
…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
As per iamcco/markdown-preview.nvim#682
Feature requested on iamcco plugin by 2 recent users.
OP @Praczet
The text was updated successfully, but these errors were encountered: