npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

obsidian-callouts-markdown

v1.0.5

Published

Library for parsing blockquote in mdxProvider into obsidian callout grammar

Downloads

18

Readme

obsidian-callouts-markdown

en ko

Try the library at playground site 🚀 2024-03-039 39 59-ezgif com-video-to-gif-converter

This library is for parsing Obsidian callout syntax in MDX. Transform your markdown syntax into callouts just like in Obsidian!

What is this library?

I write blog posts using Obsidian, and analyze markdown syntax using @mdx-js/react to operate my personal blog with Gatsby. Writing markdown posts with Obsidian allows you to post conveniently as if you were using services like velog or tistory. However, since Obsidian's callout syntax is not standard markdown syntax, callouts written in Obsidian just get parsed as blockquotes in the Gatsby blog. To alleviate this inconvenience, I created a library to help use the same callout syntax as Obsidian in Markdown.

Quick Start

  1. Install the obsidian-callouts-markdown package.
npm install obsidian-callouts-markdown
yarn add obsidian-callouts-markdown
  1. In the MDXProvider's components setting, map blockquote to ObsidianCallout.

It can be used in the same way in react-markdown. However, an additional rehype-raw plug-in is required to recognize the html tag inside the markdown.

import Post from '@/tests/posts.mdx';
import {MDXProvider} from '@mdx-js/react';
import {ObsidianCallout} from '@/package';

function App() {
  return (
    <MDXProvider
      components={{
        blockquote: ObsidianCallout,
      }}>
      <Post />
    </MDXProvider>
  );
}
  1. You can now use callouts in markdown with the same syntax as in Obsidian. result

Configuration

Types of Callouts

callout list

Types of Callout
normal ,note, abstract, summary, tldr, info, todo, tip, hint, important, success, check, done, question, help, faq, warning, caution, attention, danger, error, bug, example, quote, cite, normal

Supports all types of callouts that can be used in Obsidian. If you have not created a callout type, it is recognized as a normal type.

Customizing Callout Options

  const components = {
    blockquote: (props: HTMLAttributes<HTMLElement>) => (
      <ObsidianCallout
        {...props}
        options={{
          note: {
            icon: ErrorIcon,
            backgroundColor: '#fff',
            color: '#000',
          },
        }}
      />
    ),
  };

You can customize the icon, background color, and title text color of the callout using ObsidianCallout's options. The icon type is React.SVGProps<SVGSVGElement>.

Customizing Callout Components

  const components = {
    blockquote: (props: HTMLAttributes<HTMLElement>) => (
      <ObsidianCallout
        {...props}
        components={{
          note: CustomCallout,
        }}
      />
    ),
  };

You can define custom callout components using ObsidianCallout's components. Callout components can receive the following props.

| props | type | require | description | |----------|-----------|---------|------------------------------------------------------------| | type | string | false | The string in the [!type] part when writing a callout. | | title | string | false | The title string written next to the type ([!type] title). | | children | ReactNode | true | The main body of the callout. | |

Additional explanation image for props

callout props

Custom Callout Example

  • code
const CustomCallout: React.FC<CustomCalloutComponentProps> = ({
                                                               type,
                                                               title,
                                                               children,
                                                            }) => {
   return (
           <div className="bg-teal-100 p-4 rounded-md">
              <div className="flex gap-2 text-teal-700 font-semibold mb-4">
                 <p>
                    [{type}] {title}
                 </p>
              </div>
              {children}
           </div>
   );
};
  • result custom callout result

Adding Custom Callout Types

  const components = {
    blockquote: (props: HTMLAttributes<HTMLElement>) => (
      <ObsidianCallout
        {...props}
        components={{
          black: CustomCallout,
        }}
        options={{
           bigError: {
            icon: ErrorIcon,
            backgroundColor: 'red',
            color: 'yellow',
          },
        }}
      />
    ),
  };

When defining components or options, specifying a type key that does not exist adds that type of callout. In the code example above, new callout formats of type black and bigError are added. For callout types, any string except newline characters (\n) can be specified. If you customize the same callout type in both components and options, the settings applied in components will take effect.

Support

If you encounter any issues with the library, feel free to open an issue.