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

Minimal example with CDN? #13

Closed
EdAyers opened this issue Jan 26, 2023 · 5 comments
Closed

Minimal example with CDN? #13

EdAyers opened this issue Jan 26, 2023 · 5 comments

Comments

@EdAyers
Copy link
Member

EdAyers commented Jan 26, 2023

What's a full minimal example of using this package with a CDN? The static page below gets a TypeError in registerLanguage, but the go example works fine.

<!DOCTYPE html>
<html>

<head>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/default.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
    <script src="https://unpkg.com/highlightjs-lean/dist/lean.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/languages/go.min.js"></script>
    <script type="text/javascript">
        hljs.initHighlightingOnLoad();
    </script>

</head>

<body>
    <pre><code class="language-lean">def well_founded_tactics.process_lex :
        tactic unit → tactic unit </code></pre>

    <pre><code class="language-go">
package main

import "fmt"

type rect struct {
    width, height int
}
</code></pre>
</body>

</html>
@EdAyers
Copy link
Member Author

EdAyers commented Jan 26, 2023

I get the same error if I replace 11.7.0 with 10.4.1 so I'm not sure it's a versioning thing.

@rzeta0
Copy link

rzeta0 commented Jun 28, 2024

This issue is still not resolved over a year later.

I am using the following as part of a blogger template:

<link href='https://unpkg.com/@highlightjs/[email protected]/styles/default.min.css' rel='stylesheet'/>
<script src='https://unpkg.com/@highlightjs/[email protected]/highlight.min.js'/>
<script src='https://unpkg.com/highlightjs-lean/dist/lean.min.js' type='text/javascript'/>
<script>hljs.highlightAll();</script>

and in the content I am using:

<pre><code class="language-lean">
-- 01 - First Proof

import Mathlib.Tactic

example {a : ℕ} (h1: a = 4) : a &gt; 1 :=
  calc
    a = 4 := by rw [h1]
    _ &gt; 1 := by norm_num
</code></pre>

This fails with the console showing:

Uncaught TypeError: "name" is read-only
    registerLanguage https://unpkg.com/@highlightjs/[email protected]/highlight.min.js:295
    <anonymous> https://unpkg.com/highlightjs-lean/dist/lean.min.js:1
highlight.min.js:295:1

It fails in updated Firefox and Safari browsers.

@bryangingechen
Copy link
Collaborator

Apologies for taking so long to get to this. If I understand highlightjs/highlight.js#3363 correctly, this is due to a change in rollup which broke all CDN builds of highlightjs extra packages (including highlightjs-lean) which were built using versions of highlightjs before version 11.3.1.

I think what I'll need to do is to upgrade highlightjs-lean to the latest version 11, then rebuild it and publish to npm, and then hopefully unpkg will pick it up soon afterwards and then things will work again.

I'll try to get to this sometime tonight 🤞

@rzeta0
Copy link

rzeta0 commented Jun 29, 2024

Thanks - I appreciate your help. I wish I was capable of helping in some way.

@bryangingechen
Copy link
Collaborator

bryangingechen commented Jun 30, 2024

I think this should be fixed now. This file now highlights properly for me in the VS Code Live Preview: https://github.com/leanprover-community/highlightjs-lean/blob/c9b83e8791d015df75d3ee4358e72ffbd648def6/test/cdn_test.html

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

No branches or pull requests

3 participants