Gatsby-theme-novela: Only JavaScript Syntax is getting highlighted

Created on 15 Aug 2019  路  12Comments  路  Source: narative/gatsby-theme-novela

Version of Novela you are using
0.2.0
Number of posts you have and which data source
8 and local
Describe the bug
A clear and concise description of what the bug is.
I use bash scripts and dart language, but only javascript code blocks get syntax highlighting
To Reproduce
Steps to reproduce the behavior:

  1. Use any language other than javascript
    Expected behavior
    Should highlight code blocks of any language

Screenshots
image

Most helpful comment

Just confirming that I'd love to take a look and help out where possible.

All 12 comments

Thanks for creating the issue. Sounds like we should switch from prism
https://github.com/narative/gatsby-theme-novela/issues/51

Will bump the priority of that.

Feel free to follow along on the PR: https://github.com/narative/gatsby-theme-novela/pull/66
Right now ran into an external bug that's blocking progress. Hopefully we'll be able to solve it soon and get this feature shipped in Novela.

Sure thanks for the quick update

@chakrihacker You need to specify the language after the three backticks. Using your example:

```java
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Text("Example")
  }
}
``` // this comment needed to force GitHub to render these backticks properly

you'll get:
Screen Shot 2019-08-17 at 4 03 59 PM

Hope that helps!

Ah, yes. I assumed he was specifying the language in his post.
Thanks so much for clarifying @AryanJ-NYC :)

Hey, I am specifying language with backticks

@chakrihacker could you share the code you're writing? It looks like Aryan was able to get it done.

Just confirming that I'd love to take a look and help out where possible.

I have the same issue with Kotlin. Presumably this is because dart and Kotlin are not specified as default language in prism-react-renderer? See includeLangs.js
https://github.com/FormidableLabs/prism-react-renderer/blob/master/src/vendor/prism/includeLangs.js

Although Java works, I think that's included in Prisms default set of languages? I'm trying to figure out how I can enable Kotlin.

```kotlin
override fun onCreateView(
    inflater: LayoutInflater,
    container: ViewGroup?,
    savedInstanceState: Bundle?
): View? {
    return inflater.inflate(R.layout.fragment_new_blog_post, container, false)
}
``` //

image

Now, I've seen this Issue in prism-react-renderer where someone is including an extra language. I've tried adding kotlin as extra language by shadowing Code.Prims.tsx or Code.Pre.tsx but both say they can't find the kotlin-prism file.

Do you have any idea or pointers how I can add Kotlin support?

Nevermind! I just got it working.

I first had to run yarn add prismjs and then shadow Code.Prism.tsx. In this file you add the lines from the issue here https://github.com/FormidableLabs/prism-react-renderer/issues/53

import Prism from "prism-react-renderer/prism";
(typeof global !== "undefined" ? global : window).Prism = Prism;
require("prismjs/components/prism-kotlin");

And then it works 馃檪

image

Nevermind! I just got it working.

I first had to run yarn add prismjs and then shadow Code.Prism.tsx. In this file you add the lines from the issue here FormidableLabs/prism-react-renderer#53

import Prism from "prism-react-renderer/prism";
(typeof global !== "undefined" ? global : window).Prism = Prism;
require("prismjs/components/prism-kotlin");

And then it works 馃檪

image

do we need to add the code inside @narative/gatsby-theme-novela/components/Code.Prisme.tsx like this ?

I did put the following inside @narative/gatsby-theme-novela/components/Code/Code.Prisme.tsx

import Prism from "prism-react-renderer/prism";
(typeof global !== "undefined" ? global : window).Prism = Prism;
require("prismjs/components/prism-ruby");

I get this error in the page of the post:

TypeError: Cannot read property 'getElementsByTagName' of null

I get this warnings:

warn "export 'default' (imported as 'CodeBlock') was not found in './Code.Prism'
warn "export 'default' (imported as 'Prism') was not found in './Code.Prism'
Was this page helpful?
0 / 5 - 0 ratings

Related issues

jorgeorejas picture jorgeorejas  路  3Comments

devanSAGA picture devanSAGA  路  4Comments

MartinRosenberg picture MartinRosenberg  路  3Comments

alfieqashwa picture alfieqashwa  路  4Comments

mwood23 picture mwood23  路  4Comments