Giter Site home page Giter Site logo

discord-markdown's People

Contributors

brussell98 avatar galarzaa90 avatar kneemund avatar lioness100 avatar marvin-roesch avatar matthew0x40 avatar realalphabet avatar sawa-ko avatar sorunome avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

discord-markdown's Issues

toHTML Error CustomOutput

It seems that the package contains an error in the transcription to TypeScript, I have been investigating and the problem seems to be another package installed in the same simple-markdown@latestversion
Generic type 'Output' requires 1 type argument (s)
document: node_modules/simple-markdown/simple-markdown.d.ts
line: 64

    node: ASTNode,
    state?: OptionalState
) => Result;

Thanks a lot.
image

HTML in Multi-line code blocks is not escaped

HTML in multi-line code blocks is not escaped, even with the escapeHTML option set.
Ex:

```
<div style="background: blue">Hello World</div>
```

Will not have the </> signs HTML escaped within the code block.

Spoilers

Spoilers are wrapped with {{ and }}. More details on how this works will follow as it releases.

discord mentioning

i just noticed how all the discord-specific mentions are always wrapped in <span> now, which might be unwanted behaviour for the user. Maybe they just want e.g. the plaintext name, not wrapped into a span.

This is conflicting at least with where we use this package, as we are only working with a limited subset of HTML and try to keep things as minimal as possible

This could be e.g. toggle-able behaviour with the default being on

EDIT: or maybe if all things mapped in cssModuleNames are empty strings it doesn't wrap it in a <span>? just tossing around ideas

Support quotes

Discord quotes use a single > to create a blockquote for the current line. >>> creates a blockquote which contains all text after it.

Add new parser.

It's not parsing hyperlinks, it should be added. It's a basic Markdown feature

Update for new Discord Markdown spec

Discord has updated their Markdown spec to include headings and (un)ordered + nested lists -- would love to see this get support for the new stuff.

Time parsing possibility

I cannot find a possibility to add specific or completely external custom parser for elements(Like regex-defined) such as time like <t:1666821660:F>.

Did I oversee it or any idea how to bring this functionality to live?

feature: markdown to JSX

The title is self explanatory, it would be great if the package could parse markdown directly into JSX

Nested ems are parsed wrong

Input:

_this *is* a test_

Discord:

<em>this is a test</em>

discord-markdown:

<em>this <em>is</em> a test</em>

Random Unicode char coming up.

Italics *italics* or _italics_Underline italics __*underline italics*__
Bold **bold**Underline bold __**underline bold**__
Bold Italics ***bold italics***underline bold italics
 __***underline bold italics***__
Underline __underline__
Strikethrough ~~Strikethrough~~
```py
if print("hello",5)
```
> hello
> hi

Goes to:

<br>Italics <em>italics</em> or _italics_Underline italics <u><em>underline italics</em></u><br>Bold <strong>bold</strong>Underline bold <u><strong>underline bold</strong></u><br>Bold Italics <em><strong>bold italics</strong></em>underline bold italics<br> <u><em><strong>underline bold italics</strong></em></u><br>Underline <u>underline</u><br>Strikethrough <del>Strikethrough</del><br><pre><code class="hljs py"><span class="hljs-keyword">if</span> <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;hello&quot;</span>,<span class="hljs-number">5</span>)</code></pre><br><blockquote>hello<br>hi<br></blockquote>

Why is there all these Unicode Â's?

How to add `markdown.defaultRules.paragraph`?

I've tried adding:

paragraph: markdown.defaultRules.paragraph,

to the list of rules, but it doesn't seem to be doing anything, despite a lot of tinkering. I've been able to add other rules in from markdown.defaultRules, but not this one. Any idea how to get it working?

Italics not being formatted.

In discord, you can format your text in italics like so, *hello*, but this does not get parsed properly in discord-markdown - it comes out just as it went in.

DiscordCallback typings incorrect

Here is the interface for DiscordCallback

interface DiscordCallback {
  user?: (id: number) => string;
  channel?: (id: number) => string;
  role?: (id: number) => string;
  everyone?: () => string;
  here?: () => string;
}

However, this is incorrect. None of the first three actually take an id as a parameter. user takes a user object, channel takes a channel object, and role takes a role object. See:

const discordCallbackDefaults = {
	user: node => '@' + markdown.sanitizeText(node.id),
	channel: node => '#' + markdown.sanitizeText(node.id),
	role: node => '&' + markdown.sanitizeText(node.id),
	everyone: () => '@everyone',
	here: () => '@here'
};

Could these typings be fixed to reflect the actual usage for the callback?

Unusable with typescript

As this lib does not provide any .d.ts file or @types/discord-markdown package, it is unusable with typescript.

Custom Emoji Callback Removed?

The call to discordCallback.emoji was completely removed in favor of custom emoji image generation (I assume).

Can the call be restored in the event it is provided, please?

The current implementation is significantly less flexible, and also seems to be generating stray img end tag errors in HTML validators.

FR: Reverse functionality HTML -> Markdown

Normally markdown processors have the functionality to transform MD to HTML and vice versa. I think that it would be great if that were to be implemented here and that is the reason behind this feature request.

Such functionality, in particular, would help me a great deal in an extensive array of projects and I'm sure many others would feel the same. Some of the probable use-case scenarios:

  • display content from web pages (such as from online docs, blogs, et cetera) in embeds for webhooks and bot applications
  • parse websites to cleanly include important content

Having done something similar to this myself using basic regular expressions and JavaScript, I have stumbled upon the following issues, so I'm gonna share them here for you to consider:

  • some websites, e.g. MDN docs use tags like <code><strong> which would not work on Discord. This would have to be converted to <strong><code> to avoiding showing ** in the monospaced block,
  • combinations of multiple tags in Markdown are sometimes a single one, e.g. <pre><code> is simply ```. For this in particular, it would be great if the library can detect highlight.js (hljs) code blocks and use the language defined therewithin.
  • things like <div>, <span> etc. would have to be removed altogether
  • Discord markdown has no support for headings, therefore just using bold might be most appropriate
  • some HTML links will have relative paths; when used Discord, these will need to be actual links with a protocol, FQDN, and optionally: path, query arguments, hash

All of this is probably already possible with existing libraries by tweaking them, but I thought this would be very appropriate for this repository.

Many thanks.

links are unpercise

When using the following [Link](https://discord.gg/Jpu---------) the expected output would be a blue font paragraph, with the content Link:
image
This just doesn't happen at all. Insted, this is the result:
image

Embed option

I don't really understand what the "embed" option does. Could you explain that one?

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.