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

code and codespan elements #38

Closed
usulpro opened this issue Aug 19, 2017 · 4 comments
Closed

code and codespan elements #38

usulpro opened this issue Aug 19, 2017 · 4 comments

Comments

@usulpro
Copy link
Member

usulpro commented Aug 19, 2017

Hi! Thank you for this project!

I tried to override code and codespan elements and found out only this workaround:

const compile = marksy({
  createElement: React.createElement,
  highlight(language, code) {
    return hljs.highlight(language, code).value;
  },
  elements: {
    code({ language, children, code }) {
      return (
        children ? // render inline code:
          <code>
            {children}
          </code> : // render block code:
        <div>
          <span>
          language: {language}
          </span>
          <pre>
            <code>
              {code}
            </code>
          </pre>
        </div>
      );
    },
  },
})

Is it intended behavior and maybe it worth to update readme in this case?

@christianalfoni
Copy link
Collaborator

@usulpro Sorry for very late response here. You mean to handle inline and block code? Yeah, not tried it, but makes sense to do it like this. Maybe you want to create a PR for it? :)

@Hypnosphi
Copy link
Member

I believe this isn't fixed: renderer.code doesn't use addElement, so there's actually no way to override it via options
https://github.com/cerebral/marksy/blob/master/src/createRenderer.js#L52-L67

@Hypnosphi
Copy link
Member

Now, when I look to the tests, I see that there's one for "components" version, but none for "default" version. So is there a chance that this intentionally doesn't work in "default"?

https://github.com/storybooks/marksy/blob/master/src/index.test.js#L383

@Hypnosphi
Copy link
Member

Bu the way, looks like codespan element is never actually used (renderer.codespan uses code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants