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

[gatsby-transformer-remark] [Migration from 0.x to 1.0] Add CSS class to markdown elements #2322

Closed
JLongley opened this issue Oct 3, 2017 · 9 comments
Labels
type: documentation An issue or pull request for improving or updating Gatsby's documentation type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@JLongley
Copy link
Contributor

JLongley commented Oct 3, 2017

I'm working on migrating my site from 0.x to 1.0. On many of my markdown pages, I've annotated the text with css classes using the syntax supported by the markdown-it-attrs plugin.

I see that gatsby has switched over to using remark for markdown parsing, and I've started reemplementing some of the features I lost as plugins. As far as I can tell, however, there is no existing remark plugin for adding CSS classes. Is there a plan for implementing this feature?

@KyleAMathews
Copy link
Contributor

Someone else mentioning needed this. Not sure if they added a plugin. Try searching npm? If it doesn't exist, it'd be great to have it!

@JLongley
Copy link
Contributor Author

JLongley commented Oct 3, 2017

If I find some time, I may pick this up soon.

FWIW, for the time being, I've gone back through and replaced the styled markdown tags with HTML spans.

@sebastienfi sebastienfi changed the title Add CSS class to markdown elements [gatsby-transformer-remark] [Migration from 0.x to 1.0] Add CSS class to markdown elements Oct 4, 2017
@sebastienfi sebastienfi added API/Plugins type: documentation An issue or pull request for improving or updating Gatsby's documentation type: question or discussion Issue discussing or asking a question about Gatsby labels Oct 4, 2017
@VinSpee
Copy link
Contributor

VinSpee commented Nov 11, 2017

I'd love a way to handle this feature in a remark plugin or somehow at the configuration level

@KyleAMathews
Copy link
Contributor

It'd be great to have a Gatsby remark plugin that wraps this https://github.com/sethvincent/remark-bracketed-spans

@KyleAMathews
Copy link
Contributor

Due to the high volume of issues, we're closing out older ones without recent activity. Please open a new issue if you need help!

@vadimshvetsov
Copy link
Contributor

vadimshvetsov commented Sep 8, 2018

@KyleAMathews I'm trying to implement gatsby-remark-bracketed-spans. Is it sufficient to have a code like that?

const remarkBracketedSpans = require('remark-bracketed-spans')
module.exports = () => ({})
module.exports.setParserPlugins = () => [remarkBracketedSpans]

Or maybe I can remove default export?

@KyleAMathews
Copy link
Contributor

Have you checked out other remark plugins?

@vadimshvetsov
Copy link
Contributor

vadimshvetsov commented Sep 8, 2018

I've thought about gatsby-remark-katex as example. There are some processing with nodes for getting done with katex.

module.exports.setParserPlugins = () => [remarkMath]

But below we add a markdown plugin remark-math, which would be used within gatsby-tranformer-remark.
for (let parserPlugin of requiredPlugin.setParserPlugins(
plugin.pluginOptions
)) {
if (_.isArray(parserPlugin)) {
const [parser, options] = parserPlugin
remark = remark.use(parser, options)
} else {
remark = remark.use(parserPlugin)

I thought its sufficient, isn't?
But plugin with only setParserPlugins exports looks strange 😄

@vadimshvetsov
Copy link
Contributor

@KyleAMathews I've made a PR #8044 with adding remark-bracketed-spans parser plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation An issue or pull request for improving or updating Gatsby's documentation type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests

6 participants