Repository navigation
Format examples with Prettier too - #331
Conversation
|
Deploy preview ready! Built with commit f0f3753 |
|
I think we should change how highlighting is done since Prettier now can change line numbers. function() {
something(); // highlight
somethingElse(); // highlight
}in the code that gets stripped out and is parsed by the code frame display. It'll also be much easier to maintain in general. |
|
I'm working on the plug-in for embedding now FWIW, trying to figure out the syntax for line-highlights. At first I thought "formatting will mostly remain stable so line highlighting really won't be any tricker than before" - but if we change our Prettier config, or it makes changes to its own defaults, that could cause a lot of headache updating all of the places we reference line numbers Also it's just kind of a hassle anyway to figure them out. So yeah, I agree that specifying in-line would be nicest. Not sure yet of the best way to do this though. Will give it some thought. (Inline comments sound nice from a maintenance perspective but Prettier might move a comment to a different line depending on the line-length.) |
|
FWIW, the current line-highlighting syntax is part of Gatsby's built-in Prism plug-in. I could probably update that plug-in to support a different syntax though. I think the inline comment would work fine for embedded/inline snippets. It's just a bit trickier with Prettier-formatted ones. But it's still better than the |
|
Currently I'm thinking of the following... Here's what the markdown syntax for an embed would look like: ```embed:path/to/file.js```This creates an We can infer the Prism language from the file extension (eg Then we can load the file in question, extract the line-highlight indicators, and convert the node to one that will use Prism for markdown highlighting. I think the plug-in could support the following line-highlight formats: <!-- highlight-line -->
<!-- highlight-next-line -->/* highlight-line */
/* highlight-next-line */// highlight-line
// highlight-next-line |
|
I think I have a good proposal for this now, with gatsbyjs/gatsby/pull/3012 Build-time code embedding. Line-highlighting supported for various common language comment formats (eg JavaScript, CSS, HTML, YAML). etc. |
|
I'm going to merge this and follow up with a PR that uses my new |
* Update 2019-08-15-new-react-devtools.md * Apply suggestions from code review Co-Authored-By: Júlio Campos <jcserracampos@gmail.com> * Apply suggestions from code review reactjs#2 Co-Authored-By: Jhon Mike <developer@jhonmike.com.br>
docs(en): merge reactjs.org into zh-hans @ bbea522
As we migrate example code from Dan's Codepen into the repo, let's run it through Prettier too for consistency. This will also help with issues like #310, if we start embedding these examples within markdown.
I created a custom Prettier config for code in the examples directory for 2 reasons:
<code>blocks are narrower too.)