nteract / markdown

A package for rendering Markdown within Jupyter notebooks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Syntax highlighting works in rendered markdown not respecting theme

SpencerPark opened this issue · comments

For some languages in the markdown source editor, code fences are properly highlighted, but when rendered that syntax highlighting is lost. This is a tear off of a comment left on the related issue nteract/nteract#4445.

java is working in markdown source but not in code cells, nor in rendered markdown. Here is a screenshot:
nteract-syntax

This was on nteract desktop v0.14.3, windows 10. I'll also attach the notebook in case anything in there is interesting/helpful:

Notebook JSON
{
  "cells": [
    {
      "cell_type": "code",
      "source": [
        "for (int i = 0; i < 3; i++) {\n",
        "    System.out.println(\"i: \" + i);\n",
        "}"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "i: 0\n",
            "i: 1\n",
            "i: 2\n"
          ]
        }
      ],
      "execution_count": 2,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "```java\n",
        "for (int i = 0; i < 3; i++) {\n",
        "    System.out.println(\"i: \" + i);\n",
        "}\n",
        "```\n",
        "```python\n",
        "for i in range(0, 3):\n",
        "    print('i:', i)\n",
        "```\n",
        "```go\n",
        "package main\n",
        "```"
      ],
      "metadata": {}
    },
    {
      "cell_type": "markdown",
      "source": [],
      "metadata": {}
    }
  ],
  "metadata": {
    "kernel_info": {
      "name": "java"
    },
    "language_info": {
      "name": "Java",
      "version": "9+181",
      "mimetype": "text/x-java-source",
      "file_extension": ".jshell",
      "pygments_lexer": "java",
      "codemirror_mode": "java"
    },
    "kernelspec": {
      "name": "java",
      "language": "java",
      "display_name": "Java"
    },
    "nteract": {
      "version": "0.14.3"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}

The interesting information being:

"language_info": {
  "name": "Java",
  "version": "9+181",
  "mimetype": "text/x-java-source",
  "file_extension": ".jshell",
  "pygments_lexer": "java",
  "codemirror_mode": "java"
}

Re-opening this again.

We've leveled up from the previous scenario because rendered markdown now shows proper syntax highlighting for code.

However, it looks like the themes we are using from react-syntaxhighlighter don't get updated appropriately when the app theme changes. My suspicion is that this has something to do with the way the theme prop is propagated from the Source component to the syntax highlighter.