spatie / commonmark-highlighter Goto Github PK
View Code? Open in Web Editor NEWHighlight code blocks with league/commonmark
Home Page: https://spatie.be/open-source
License: MIT License
Highlight code blocks with league/commonmark
Home Page: https://spatie.be/open-source
License: MIT License
There's an issue for it, but the bottom line is new installations of this library will pull in a version of the highlighter which has an infinite loop when rendering JS code blocks.
I have a branch that fixes it, which I have submitted as a PR; but you might want to tag an older version in the meantime...
The CommonMark spec allows for any arbitrary content to exist in the info string of a code block. Would you be open to adding support for highlighting specific lines of code within said code block?
```html{2}
<div>
<p>I wish I wish I was a fish</p>
</div>
```
Proposed Syntax
html{4}
- highlight the 4th line of the code blockhtml{4-5}
- highlight the 4th through 5th lines of codehtml{1,4-5}
- highlight the 1st and 4th through 5th line of code separatelyhi there,
I don't know if it's package related, but any idea why the "script" tag isn't highlighted correctly?
I save the textarea directly to the db from SimpleMde with markdown data, and on frontend I use github.css
style for this example, and use {!! !!} tags to render.
With php I don't have any problem, fully colorize the opening tag.
If you try to highlight a specific line in combination with an emoji, the emoji will not be shown anymore:
```php{2}
// ✅ ...
$isUserPending = $user->isStatus('pending');
```
Without the {2}
the emoji is shown correctly:
```php
// ✅ ...
$isUserPending = $user->isStatus('pending');
```
Have you an idea what this is about @allejo?
PS: Here some info about how I set up the converter:
$environment = Environment::createCommonMarkEnvironment();
$languages = ['html', 'php', 'js', 'shell', 'shell'];
$environment->addBlockRenderer(FencedCode::class, new FencedCodeRenderer($languages));
$environment->addBlockRenderer(IndentedCode::class, new IndentedCodeRenderer($languages));
$commonMarkConverter = new CommonMarkConverter([], $environment);
return $commonMarkConverter->convertToHtml($codeExample);
Commonmark v1.0.0 changes the League\CommonMark\Block\Renderer\FencedCodeRenderer
to be a final
class, so it can’t be extended anymore.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.