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

Feature Request: Allow many styles #7

Closed
muescha opened this issue Jun 15, 2020 · 11 comments
Closed

Feature Request: Allow many styles #7

muescha opened this issue Jun 15, 2020 · 11 comments
Labels
🙋 no/question This does not need any changes

Comments

@muescha
Copy link

muescha commented Jun 15, 2020

Subject of the feature

we can also allow style: ['github', 'twitter', customRegEx]

#6 (comment)

Problem

if you have GitHub and Twitter mentions in the docs then it would be nice to have both to check

Expected behavior

use many styles from the settings

Alternatives

        .use(require("retext-syntax-mentions"), { style: 'github'})
        .use(require("retext-syntax-mentions"), { style: 'twitter'})

call the retext-syntax-mentions 2x times with different options

EDIT: this is not possible, the last option wins in this case and only the test for twitter is run :(

@muescha muescha added 🙉 open/needs-info This needs some more info 🦋 type/enhancement This is great to have labels Jun 15, 2020
@wooorm
Copy link
Member

wooorm commented Jun 15, 2020

@muescha
Copy link
Author

muescha commented Jun 15, 2020

no it not used the sames, because there are some @component/something-different in the code and then they are errors :(

for example also in mdx files with an import this also get ignored :/

import VisuallyHidden from "@components/visually-hidden"

@wooorm
Copy link
Member

wooorm commented Jun 15, 2020

Well, @component/something-different is a valid GitHub mention: it mentions the something-different team in the component organization, so if that behavior is not what you want, then I’d suggest using twitter or a custom regex.

If you want to check MDX files: those are fundamentally different than Markdown, and becoming more so in MDX@2. You may want use remark-mdx to support the MDX-only/non-Markdown syntax as syntax. But you may need to use separate processors: one for regular Markdown, that doesn‘t support imports, and one for MDX!

@muescha
Copy link
Author

muescha commented Jun 15, 2020

it is used here: gatsbyjs/gatsby#24372 but the docs are mixed normal markdown and some mdx (but same ending)

@wooorm
Copy link
Member

wooorm commented Jun 16, 2020

For the original question: I view “Many styles” as technically a new style, and that can be done with a regex. I believe I can close this?


For your other question:

The docs are mixed normal markdown and some mdx (but same ending)

When you say “same ending”, I understand that as the same extension (.md), correct? If that is the case, I would strongly suggest using .mdx as an extension (see jshttp/mime-db#160). That may be a big task for Gatsby, so you may want to talk to other Gatsby folks about that. But by using the same extension for different content types, tools can’t understand that the content is different (and it fundamentally is, especially with the upcoming MDX@2).

@muescha
Copy link
Author

muescha commented Jun 17, 2020

yes - for markdown files and mdx files are used the same file extension .md

is it possible to process all files with remark-mdx with no problems?

@wooorm
Copy link
Member

wooorm commented Jun 17, 2020

is it possible to process all files with remark-mdx with no problems?

It is somewhat possible currently, in a couple of weeks with MDX@2 it definitely isn’t. See my earlier reply:

But by using the same extension for different content types, tools can’t understand that the content is different (and it fundamentally is, especially with the upcoming MDX@2).

@wooorm
Copy link
Member

wooorm commented Jun 17, 2020

Alright, I’ll close this as different styles can be achieved with a custom regex. As you don‘t care for GH teams, I’d suggest:

  .use(syntaxMentions, {style: /^@\w{1,40}$/})

@wooorm wooorm closed this as completed Jun 17, 2020
@wooorm wooorm added 🙋 no/question This does not need any changes and removed 🙉 open/needs-info This needs some more info 🦋 type/enhancement This is great to have labels Jun 17, 2020
@muescha
Copy link
Author

muescha commented Jun 18, 2020

thats not include the - for example: @m-allanson

@ChristianMurphy
Copy link
Member

then add - to the custom regex 🙂
here's a resource to help with creating regexs https://regexr.com

@muescha
Copy link
Author

muescha commented Jun 18, 2020

thx for the link :)

 .use(syntaxMentions, {style: /^@[\w-]{1,40}$/})

i was not aware that i can put \w inside brackets :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 no/question This does not need any changes
Development

No branches or pull requests

3 participants