GithubHelp home page GithubHelp logo

spatie / commonmark-highlighter Goto Github PK

View Code? Open in Web Editor NEW
133.0 4.0 9.0 58 KB

Highlight code blocks with league/commonmark

Home Page: https://spatie.be/open-source

License: MIT License

PHP 100.00%
commonmark highlight

commonmark-highlighter's Issues

Add .hljs class to all blocks

Hi
Is it possible to add .hljs class even to blocks with unsupported languages. Currently, unsupported languages (like blade, vue ..etc) display without a background when applying a theme. This will confuse the reader as they appear just like a regular text.

This is without apply the class:
image

This is with the class applied:
image

Highlight line in combination with emojis

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');
    ```

Screen Shot 2020-08-26 at 20 14 51

Without the {2} the emoji is shown correctly:

    ```php
    // ✅ ...
    $isUserPending = $user->isStatus('pending');
    ```

image

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);

highlighting script tag

hi there,
I don't know if it's package related, but any idea why the "script" tag isn't highlighted correctly?

Screenshot 2021-05-25 at 17 01 27

The code for this (picture):
Screenshot 2021-05-25 at 17 06 20

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.