Skip to content
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

Line Numbers Missing #1

Closed
tatiana-perry opened this issue May 14, 2019 · 8 comments
Closed

Line Numbers Missing #1

tatiana-perry opened this issue May 14, 2019 · 8 comments
Labels
question Further information is requested

Comments

@tatiana-perry
Copy link

tatiana-perry commented May 14, 2019

I added the class line-numbers to my shortcode and the line numbers do not appear.

[prism classes="language-php line-numbers" highlight="2,4"] 
        <?php
        namespace Grav\Plugin;
        
        use \Grav\Common\Plugin;
        use \Grav\Common\Grav;
        use \Grav\Common\Page\Page;
        
        class PrismHighlightPlugin extends Plugin
        {
            /**
            * @return array
            */
            public static function getSubscribedEvents()
            {
                return [
                    'onPageInitialized' => ['onPageInitialized', 0],
                    'onShortcodeHandlers' => ['onShortcodeHandlers', 0],
                    'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0],
                ];
            }
        }
[/prism]

Screen Shot 2019-05-14 at 3 00 14 PM

enabled: true
theme: prism-base16-ocean.dark.css
all-pre-blocks: true
plugins:
    line-numbers: true
    command-line: false
    command-line-prompt: '$'
@rhukster
Copy link
Member

It might be related to the combination of your indented code, and the use of all-pre-blocks: true.

Try removing that indented code as that could conflict with the shortcode (indented code converts to pre in markdown). Also if that make no diff, set all-pre-blocks: false, see if that makes a difference.

@rhukster rhukster added the question Further information is requested label May 14, 2019
@tatiana-perry
Copy link
Author

tatiana-perry commented May 14, 2019

I removed all-pre-blocks: false and unindented my code.
The line numbers are still not showing.

prism-highlight.yaml

enabled: true
theme: prism-base16-ocean.light.css
plugins:
    line-numbers: true
    command-line: false
    command-line-prompt: '$'
title: API
taxonomy:
    tag: [article]
related_pages:
    - /tutorials
    - /reference
plugins:
    line-numbers: true
---

# API Page


[prism classes="language-php line-numbers" highlight="2,4"] 
<?php
namespace Grav\Plugin;

use \Grav\Common\Plugin;
use \Grav\Common\Grav;
use \Grav\Common\Page\Page;

class PrismHighlightPlugin extends Plugin
{
/**
* @return array
*/
public static function getSubscribedEvents()
{
return [
'onPageInitialized' => ['onPageInitialized', 0],
'onShortcodeHandlers' => ['onShortcodeHandlers', 0],
'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0],
];
}
}
[/prism]

Example of generated HTML after changes:

Screen Shot 2019-05-14 at 3 56 27 PM

@rhukster
Copy link
Member

Do you have latest shortcode-core installed? Also is this a modular page?

@rhukster
Copy link
Member

You know you might have highlight plugin installed that is picking this up. If so, please disable that and let prism handle the code rendering.

@tatiana-perry
Copy link
Author

tatiana-perry commented May 15, 2019

The page is regular. default.html.md This is the base quark theme.

I also installed grav, prisim, and shortcode-core yesterday, so it is the most recent. I am using shortcode-ui without any issues.

Is there a list of types this works on?

I also don't have highlight.js installed.

In the README it lists this as a command to have line numbers appear:

[prism classes="language-twig line-numbers"] {% set payload = {frontmatter: page.header, content: page.content} %} {{ payload|json_encode|raw }} [/prism]

{% set payload = {frontmatter: page.header, content: page.content} %} {{ payload|json_encode|raw }} Where is this supposed to go?

@tatiana-perry
Copy link
Author

tatiana-perry commented May 17, 2019

In case anyone else has this issue:
Quark is rendering the code as a div, but another theme I installed learn2 is rendering it as code. I have not been able to figure out why the base theme does this.
Even when toggling this setting all-pre-blocks: true

@rhukster
Copy link
Member

Fixed in quark develop.

pre[class*="language-"] {
  code {
    border-radius: inherit;
    padding: 0 !important;
    overflow-x: initial;
  }
}

pre {
  code:not(.hljs):not([class*="language-"]) {
    background: #f8f8f8;
  }
}

@rhukster
Copy link
Member

FYI with fix:

Image 2019-05-17 at 6 13 44 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants