-
-
Notifications
You must be signed in to change notification settings - Fork 298
Each line wrapped in a div? #44
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
Comments
I believe the way the AST is provided by lowlight makes this more difficult then it would seem but i'll try to take a look if i get some time this weekend. Agree that it would definitely be nice |
Here's an idea piggy-backing off the LineNumber functionality. Work could be done in this library to make this easier and more dynamic with inline styles, obviously. This method wouldn't ever support line wrapping though, so hooking into the AST (if possible) would be the ideal solution. http://www.webpackbin.com/VkOyz_MQG <SyntaxHighlighter
language='javascript'
showLineNumbers
customStyle={{position: 'relative'}}
lineNumberStyle={{ position: 'absolute', left: '.5em', right: '.5em' }}
codeTagProps={{style: {position: 'relative'}}}
>
{`
function () { alert('wow!'); }
function () { alert('wowwww!'); }
`}
</SyntaxHighlighter> <style>
.react-syntax-highlighter-line-number {
display: block;
width: 100%;
}
.react-syntax-highlighter-line-number:nth-child(2n) {
background: rgba(0,0,0,.1);
}
</style> |
@bmathews I like this idea, one potential thing we could do is making lineNumberStyle optionally a function where we could provide arguments such as the line number allowing it to return a differnt style for each number? |
Quick example: http://www.webpackbin.com/E13xANNmM |
going to close for similar reasons as #48 , we simply don't get enough information to do this. |
Would it make sense to wrap each line in a
div
? My use case is that I'll be using this to highlight code coverage, so I'd like to have some lines with a different background color than other lines. I think this could also be useful for allowing people to highlight line ranges or click on the line number gutter to link to lines of code, like how GitHub does in source view.The text was updated successfully, but these errors were encountered: