lumeland / lume

🔥 Static site generator for Deno 🦕
https://lume.land
MIT License
1.85k stars 84 forks source link

Prism breaks JavaScript highligting using code_highligt #497

Open Hexagon opened 11 months ago

Hexagon commented 11 months ago

Version

v1.19.1

Platform

deno 1.37.1 (release, x86_64-unknown-linux-gnu)

What steps will reproduce the bug?

This could very well be a wontfix, i got here by accident... But it could be a symptom of something else going wrong:

Setup a fresh lume project, include code_highlight and prism:

@Hexagon ➜ /workspaces/lumebug (master) $ deno run -Ar https://deno.land/x/lume/init.ts
Warning Implicitly using latest version (v1.19.1) for https://deno.land/x/lume/init.ts
 ? Choose the configuration file format › _config.ts (TypeScript)
 ? Do you want to install some plugins now? › Yes
 ? Select the plugins to install › code_highlight, prism

Change _config.yaml so that prism is used before code_highlight

// ...
site.use(prism());
site.use(code_highlight());
// ...

Create index.md, include a javascript code block

# Hello Bug!

\`\`\`javascript
const a = 1;
\`\`\`

^ Had to escape the backticks, unescape them

Build site

deno task lume

How often does it reproduce? Is there a required condition?

Every time

What is the expected behavior?

Success!

What do you see instead?

Pages and pages of:

          mode: ""
        },
        [Symbol("[[webidl.brand]]")]: Symbol("[[webidl.brand]]")
      },
      _ancestors: Set(3) {
        <ref *18> HTMLDocument [EventTarget] {
          nodeName: "#document",
          nodeType: 9,
          childNodes: [NodeList],
          parentNode: null,
          parentElement: null,
          _ancestors: Set(0) {},
          head: [Element [EventTarget]],
          body: [Element [EventTarget]],
          implementation: DOMImplementation {},
          [Symbol()]: [Object],
          [Symbol("[[webidl.brand]]")]: Symbol("[[webidl.brand]]")
        },
        <ref *20> Element [EventTarget] {
          nodeName: "HTML",
          nodeType: 1,
          childNodes: [NodeList],
          parentNode: [HTMLDocument [EventTarget]],
          parentElement: null,
          _ancestors: [Set],
          tagName: "HTML",
          localName: "html",
          attributes: NamedNodeMap {},
          [Symbol()]: [Object],
          [Symbol("[[webidl.brand]]")]: Symbol("[[webidl.brand]]")
        },
        <ref *15> Element [EventTarget] {
          nodeName: "BODY",
          nodeType: 1,
          childNodes: [NodeList],
          parentNode: [Element [EventTarget]],
          parentElement: [Element [EventTarget]],
          _ancestors: [Set],
          tagName: "BODY",
          localName: "body",
          attributes: NamedNodeMap {},
          [Symbol()]: [Object],
          [Symbol("[[webidl.brand]]")]: Symbol("[[webidl.brand]]")
        }
      },
      tagName: "PRE",
      localName: "pre",
      attributes: NamedNodeMap {},
      [Symbol()]: {
        assignedSlot: false,
        hasActivationBehavior: false,
        host: null,
        listeners: [Object: null prototype] {},
        mode: ""
      },
      [Symbol("[[webidl.brand]]")]: Symbol("[[webidl.brand]]")
    }
  },
  tagName: "CODE",
  localName: "code",
  attributes: NamedNodeMap {},
  [Symbol()]: {
    assignedSlot: false,
    hasActivationBehavior: false,
    host: null,
    listeners: [Object: null prototype] {},
    mode: ""
  },
  [Symbol("[[webidl.brand]]")]: Symbol("[[webidl.brand]]")
}

Additional information

No response

oscarotero commented 11 months ago

Hmm, why are you using prism and code_highlight? Both plugins are mutually exclusive because they do the same things but with different libraries.

Hexagon commented 11 months ago

Yes, it was by accident, but it took way to long to figure out what was going wrong as i didn't get any clue from the error message.

Maybe a warning if they both are activated at the same time, if someone else is careless enough to activate them both? :)

oscarotero commented 11 months ago

Ah, ok, got it. Good idea, I'll think something.