fusuma icon indicating copy to clipboard operation
fusuma copied to clipboard

Code "lang", which is part of a list, is not considered

Open szotsaki opened this issue 3 years ago • 0 comments

Type

  • [X] bug
  • [ ] feature request

When we have a list and inside it a Prism.js code section (```) fusuma doesn't add its language to the loadable list of languages.

Here is an example:

# Header

* First line
* Second line
    ```
    Code without language
    ```
    ```diff
    --- file1.txt   2018-01-11 10:39:38.237464052 +0000
    +++ file2.txt   2018-01-11 10:40:00.323423021 +0000
    @@ -1,4 +1,4 @@
    cat
    -mv
    -comm
    cp
    +diff
    +comm
    ```
* Third line
    * Fourth line
        ```diff
        --- file1.txt   2018-01-11 10:39:38.237464052 +0000
        +++ file2.txt   2018-01-11 10:40:00.323423021 +0000
        @@ -1,4 +1,4 @@
        cat
        -mv
        -comm
        cp
        +diff
        +comm
        ```

This is valid markdown where code sections are indented to the list level. Rendered by github:

  • First line
  • Second line
    Code without language
    
    --- file1.txt   2018-01-11 10:39:38.237464052 +0000
    +++ file2.txt   2018-01-11 10:40:00.323423021 +0000
    @@ -1,4 +1,4 @@
    cat
    -mv
    -comm
    cp
    +diff
    +comm
    
  • Third line
    • Fourth line
      --- file1.txt   2018-01-11 10:39:38.237464052 +0000
      +++ file2.txt   2018-01-11 10:40:00.323423021 +0000
      @@ -1,4 +1,4 @@
      cat
      -mv
      -comm
      cp
      +diff
      +comm
      

The problem is that diff is not syntax coloured on the slide (but it is here above).

The reason is in mdx-loader/src/mdxPlugin.js tree.children.forEach() only processes top-most code types but doesn't descent deeper (e.g. into a list type).

szotsaki avatar Nov 16 '21 16:11 szotsaki