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

Need example for CDN hosted on html #257

Closed
reflexdemon opened this issue Apr 26, 2024 · 3 comments
Closed

Need example for CDN hosted on html #257

reflexdemon opened this issue Apr 26, 2024 · 3 comments
Labels
question Further information is requested

Comments

@reflexdemon
Copy link

I was trying to add code highlighting to a static html file and this does not seem to be working for me. Can you please add a Browser example like this? https://github.com/bent10/marked-extensions/tree/main/packages/code-format#browser

@UziTech
Copy link
Member

UziTech commented Apr 26, 2024

Here is an example:

<html>
<head>
</head>
<body>

<script src="https://cdn.jsdelivr.net/npm/marked/lib/marked.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/marked-highlight/lib/index.umd.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/styles/default.min.css">
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/highlight.min.js"></script>

<script>
const { Marked } = window.marked;
const { markedHighlight } = window.markedHighlight;

const marked = new Marked(
  markedHighlight({
    langPrefix: 'hljs language-',
    highlight(code, lang, info) {
      const language = hljs.getLanguage(lang) ? lang : 'plaintext';
      return hljs.highlight(code, { language }).value;
    }
  })
);


const div = document.createElement("div");
div.innerHTML = marked.parse(`
\`\`\`javascript
const highlight = "code";
\`\`\`
`);
document.body.append(div);
</script>

</body>
</html>

@UziTech UziTech added the question Further information is requested label Apr 26, 2024
@LBASD
Copy link

LBASD commented May 7, 2024

Does IE 11 10 not support?

@UziTech
Copy link
Member

UziTech commented May 7, 2024

No, Microsoft doesn't even support them anymore.

@UziTech UziTech closed this as completed May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants