-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
feat(notes): add marked options #3225
feat(notes): add marked options #3225
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3225 +/- ##
==========================================
- Coverage 35.74% 35.63% -0.11%
==========================================
Files 472 472
Lines 10134 10122 -12
Branches 1196 928 -268
==========================================
- Hits 3622 3607 -15
- Misses 5784 5935 +151
+ Partials 728 580 -148
Continue to review full report at Codecov.
|
@aymeric-duchein how do you pass the prism theme (css) to the notes panel? |
@aymeric-duchein here is what i tried
but i dont see Prism tokenizing my input. currently using a work around as follows <link rel="stylesheet" href="assets/prismjs/themes/prism.css"> //helper.js
import marked from "marked";
import Prism from "prismjs";
const mdToHTML = (md) => {
marked.setOptions({
...marked.defaults,
highlight: function (code, lang) {
return Prism.highlight(code, Prism.languages[lang], lang);
}
});
const HTML = marked(md);
return HTML;
};
export default mdToHTML;
//some where inside index.stories.ts
import mdToHTML from "./helper/mdToHTML";
import * as buttonMarkdown from "./button.md";
//.....
notes: {
text: mdToHTML(buttonMarkdown)
} |
It seems that the code changed a lot since the last time I used storybook. From what I can gather maybe @tmeasday could help you on this one. |
@anoopsinghbayes that code looks like it should work: I'm not sure exactly why it not work -- perhaps we should add an example to the official storybook that uses the option? |
Although, shouldn't it be I haven't tested this directly, I just converted the old code. @anoopsinghbayes if you wanted to send a PR with an example it would be awesome. I bet you'd be able to fix the issue too, the code isn't too complicated! Let me know I can help. |
@tmeasday ,I was struggling to get the storybook application setup(proxy and other yarn related issues) |
Oh! Sure, the best way is to just run the storybook and take a look. You can do (from the top-level of the project):
and then browse to the official storybook (I think it's http://localhost:9011), and look at the addon/notes stories within it. The files for those stories are here: https://github.com/storybooks/storybook/blob/master/examples/official-storybook/stories/addon-notes.stories.js |
@anoopsinghbayes, Are you going to create a PR for that? |
I think it'd be great! |
Issue:
Hi all,
I don't think there where any way to enable code syntax highlight when using
withMarkdownNotes
using it like that:So we currently have something like this:
I haven't found any PR or Issue addressing this issue except maybe this closed one: #951
What I did
I came up with the following solution that solves this issue while allowing backward-compatibility.
changing above code snippet to this: (I'm using Prism but that's only a personnal preference)
You should now be able (with a bit of css, i.e. a prism theme) to obtain this:
If you think this need some testing I'll gladly add them or if there is anything that I missed feel free to tell me.