Giter Club home page Giter Club logo

rehype-github-alerts's People

Contributors

chrisweb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rehype-github-alerts's Issues

Support for custom alert titles

Thanks for this library Chris!
It would be great if we allowed custom titles like Obsidian does.

> [!INFO] Why **CDK**?
> AWS CDK (Cloud Development Kit) is the easiest and faster way to get your AWS Lambda code up and running

Right now it gets rendered as a quote only instead of the alert:

[!INFO] Why CDK?
AWS CDK (Cloud Development Kit) is the easiest and faster way to get your AWS Lambda code up and running

This is how it looks in obsidian:
image

rehype-github-alerts test

rehype-github-alerts test

Note

this is an example "note" (with two spaces after "[!NOTE]")

> [!NOTE]  
> this is an example "note" (with two spaces after "[!NOTE]")

Important

this is an example "important" (with NO spaces after "[!IMPORTANT]")

> [!IMPORTANT]
> this is an example "important" (with NO spaces after "[!IMPORTANT]")

Note

this is an example "note" (with two spaces after "[!NOTE]") and a second line of content, containing a "strong" element and a link
foo top

> [!NOTE]  
> this is an example "note" (with two spaces after "[!NOTE]") and a second line of content, containing a "strong" element and a link
> **foo** [top](#rehype-github-alerts-test)

Important

this is an example "important" (with NO spaces after "[!IMPORTANT]") and a second line of content, containing a "strong" element and a link
foo top

> [!IMPORTANT]
> this is an example "important" (with NO spaces after "[!IMPORTANT]") and a second line of content, containing a "strong" element and a link
> **foo** [top](#rehype-github-alerts-test)

Warning

[!IMPORTANT]
test for nested alerts

> [!WARNING]  
>> [!IMPORTANT]  
>> test for nested alerts

NOTE
test for legacy alerts

> **NOTE**
> test for legacy alerts

NOTE
test for legacy alerts with second line
foo top

> **NOTE**
> test for legacy alerts with second line
> **foo** [top](#rehype-github-alerts-test)

[!NOTE]
test for nested blockquotes

>>> [!NOTE]
>>> test for nested blockquotes

[!INVALID]
test for invalid alert type

> [!INVALID]
> test for invalid alert type

remarkBreaks

Thanks for this repo!

It Might be worth updating the readme to specify /why/ you need remarkBreaks.... because otherwise it wont work unless you put two spaces.

I Spent some time (10 mins) trying to debug this, downloading and testing the example repo, assuming the parser wasnt working properly before I went back and understood exactly why your test code has 2 spaces in it.

Problem trying to make it work

Hi, I'm having troubles making your plugin work, here is a screenshot of what's the result:

image

As you can see it gets rendered as a blockquote

Where the markdown code is the following:

Explanation:

In the given sentence, унитазу refers to toilet.

Transliteration:

Type Transliteration
Cyrillic унитаз
Latin unitazu

Possible Meanings:

The word унитаз generally means toilet or lavatory. It specifically refers to the fixture used for urination and defecation.

Examples of Usage:

  1. Я купил новый унитаз для ванной комнаты.
    I bought a new toilet for the bathroom.

  2. Унитаз засорился, и нам пришлось вызвать сантехника.
    The toilet got clogged, and we had to call a plumber.

  3. Перед тем как покрасить ванную комнату, нам нужно снять крышку унитаза.
    Before painting the bathroom, we need to remove the toilet seat.

Note

In Russian, nouns have cases. The word "унитаз" in this context is in the Dative case due to its prepositional use with "к" (to, towards), indicating direction or proximity.

Cas Singular
Nominative унитаз (unitaz)
Accusative унитаз (unitaz)
Genitive унитаза (unitaza)
Dative унитазу (unitazu)
Instrumental унитазом (unitazom)
Prepositional об унитазе (o unitaze)

Here is the tsx code:

import type { TranslationPopoverProps } from '@common/components/word/translation-popover.component'
import { useExplanationRequestStore } from '@common/stores/explanation-request.store'
import Markdown from 'react-markdown'
import remarkGfm from 'remark-gfm'
import { rehypeGithubAlerts } from 'rehype-github-alerts'

export function ExplanationComponent(props: TranslationPopoverProps) {
  const explanationRequest = useExplanationRequestStore((state) =>
    state.requests.get(props.requestID),
  )
  const explanation = explanationRequest?.explanation
  if (explanation?.length === 0 || !explanation) {
    return null
  }
  return (
    <div className="markdown-body size-full overflow-y-auto rounded-md p-1  px-2.5 text-left font-fluent text-base text-white">
      <Markdown remarkPlugins={[rehypeGithubAlerts, remarkGfm]}>
        {explanation}
      </Markdown>
    </div>
  )
}

and my style.css:

@import 'github-markdown-css/github-markdown.css';

@tailwind base;
@tailwind components;
@tailwind utilities;

@layer Components {

    :root {
        --blue: #4285f4;
        --purple: #9b72cb;
        --red: #d96570;
        --input: 214.3 31.8% 91.4%;
        --ring: 215 20.2% 65.1%;
        --github-alert-default-color: rgb(175, 184, 193);
        --github-alert-note-color: rgb(9, 105, 218);
        --github-alert-important-color: rgb(130, 80, 223);
        --github-alert-warning-color: rgb(154, 103, 0);
    }


    .markdown-alert {
        padding: 0 1em;
        margin-bottom: 16px;
        border-left: 0.25em solid var(--github-alert-default-color);
    }

    .markdown-alert-note {
        border-left-color: var(--github-alert-note-color);
    }

    .markdown-alert-important {
        border-left-color: var(--github-alert-important-color);
    }

    .markdown-alert-warning {
        border-left-color: var(--github-alert-warning-color);
    }

    .markdown-alert-header {
        display: inline-flex;
        margin-bottom: 4px;
        align-items: center;
    }

    .markdown-alert-header > svg {
        margin-right: 8px;
    }
    ```
    

Thanks a lot in advance for your help !!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.