Giter Club home page Giter Club logo

markdown-it-prism's People

Contributors

catnose99 avatar dependabot[bot] avatar iktakahiro avatar jgleitz avatar renovate-bot avatar renovate[bot] avatar semantic-release-bot avatar straicat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

markdown-it-prism's Issues

Highlight Inline Code Blocks

Hi, the default language works well for normal code blocks (triple ```).

However, for

`inline code`

the code is rendered as

<code>...</code>

instead of

<code class="language-default">...</code>

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

Does Not Work Well With Webpack Applications

This plugin does not work on webpack applications. After doing some testing and looking into the source code of this project, Prism themselves say that this is because you should not call loadLanguages() in a webpack application, and that a babel plugin should be used instead. That plugin seems to be integral to this plugin, and so I was getting the same errors using this plugin that I was when I was simply using Prism without the plugin, but attempting to use loadLanguages().

I am using this plugin on a node.js express application, and it renders server-side with no issues (no webpack). However, when I am building my vue.js app and need to add preview functionality, it does not work, probably because I am using webpack.

If there would be any way to fix it so others could avoid the trouble of having to manually add prism to markdown, that would be great.

I am including source code below that I am using that is based off of the official markdown-it docs using highlight-js here https://markdown-it.github.io/markdown-it/, but instead using Prismjs. I hope this helps anyone who is trying to accomplish what I was. This is the code I'll be using for now.

import markdownit from "markdown-it"; 

let md = markdownit({
  highlight: (str, lang) => {
   if (lang) {
        let langObject = Prism.languages[lang]
      try {
        return (
            `<pre class="language-${lang}"><code>` + 
            Prism.highlight(str, langObject, lang) + 
            '</code></pre>'
        ) 
      } catch (__) {}
    }
    return `<pre class="language-${lang}><code>` + md.utils.escapeHtml(str) + "</code></pre>"
  }
});

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


No npm token specified.

An npm token must be created and set in the NPM_TOKEN environment variable on your CI environment.

Please make sure to create an npm token and to set it in the NPM_TOKEN environment variable on your CI environment. The token must allow to publish to the registry https://registry.npmjs.org/.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

how to fix Error in render "TypeError: (0 , _components.default) is not a function"

I'm using Vuejs & webpack. I installed markdown-it.js & markdown-it-prism together and use them inside MEditor.vue
Inside MEditor.vue I have like this:

<script>
 import MarkdownIt from 'markdown-it'
 import prism from 'markdown-it-prism'
 import AutoSize from 'autosize'
 import "prismjs/components/prism-clike"
 import "prismjs/components/prism-java"
 import "prismjs/components/prism-php"
 import "prismjs/components/prism-javascript"
 const md = new MarkdownIt();
 md.use(prism);
 export default {
  // ...
  computed: {
       preview() {
         return md.render(this.body)
       }
 }

when I write php public function foo() { return false; } I get errors below:
[Vue warn]: Error in render: "TypeError: (0 , _components.default) is not a function"
at loadPrismLang (app.js:36167)
at selectLanguage (app.js:36206)
at highlight (app.js:36232)
at Object.markdownit.options.highlight (app.js:36280)
at Object../node_modules/markdown-it/lib/renderer.js.default_rules.fence (app.js:38275)
at Renderer../node_modules/markdown-it/lib/renderer.js.Renderer.render (app.js:38551)
at MarkdownIt../node_modules/markdown-it/lib/index.js.MarkdownIt.render (app.js:37560)
at VueComponent.preview (app.js:16085)
at Watcher.get (app.js:63325)
at Watcher.evaluate (app.js:63430)

Possible regression in 2.0.0

Hi!

First of all, thanks alot for creating the plugin!

I have possibly stumbled upon a regression in the new major release, basically after I update from 1.1.2 to 2.0.0 (and no other changes) my build process crashes with:

/home/simon/eno/eno-lang.org/node_modules/markdown-it/lib/index.js:496
  plugin.apply(plugin, args);
         ^

TypeError: plugin.apply is not a function
    at MarkdownIt.use (/home/simon/eno/eno-lang.org/node_modules/markdown-it/lib/index.js:496:10)
    at Object.<anonymous> (/home/simon/eno/eno-lang.org/lib/loaders.js:4:12)
    at Module._compile (internal/modules/cjs/loader.js:722:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Module.require (internal/modules/cjs/loader.js:658:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/home/simon/eno/eno-lang.org/src/generators/demo.js:5:22)

This is the affected (short) file, problem happens on the call to use:

const markdownIt = require('markdown-it')({ html: true });
const markdownItPrism = require('markdown-it-prism');

markdownIt.use(markdownItPrism);

exports.markdown = ({ value }) => markdownIt.render(value);

My version of markdown-it in use is 8.4.2, node is at v11.3.0.

I've set up a branch in my repository for you where you can reproduce the error, switching back and forth between master and that branch (and updating the packages of course) demonstrates the regression on my machine:
https://github.com/eno-lang/eno-lang.org/tree/markdown-it-prism-reproduce

If you need more information, let me know.
Thanks!

Set default language?

Hey :)

I'm probably missing something simple here: How would I set a default or fallback language to be passed if the used language is not detected or supported?

I've got some code blocks in markdown that either don't have a specific language defined or that have vue defined. I'd like to fall back to javascript for both cases.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

markdown-it-prism: after importing Critical dependency issues come out

WARNING in ./node_modules/prismjs/components/index.js 42:23-54
Critical dependency: the request of a dependency is an expression

My code part that causing the problem while using with WebPack
import prism from 'markdown-it-prism';

farther code lines:

const md = new MarkdownIt();
md.use(prism);

I tried changing versions for different laravel mix, vue, and markdown-it-prism packages. But nothing changed. This problem only omitted when I remove the markdown-it-prism import.

It doesn't work with PHP for some reason

Having

<?php
print('Hello world!');
?>

in Markdown results in

Unhandled Rejection (TypeError): Cannot read property 'buildPlaceholders' of undefined

Could you help, if possible?

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): lock file maintenance

Other Branches

These updates are pending. To force PRs open, click the checkbox below.

  • chore(deps): update dependency marked to 4.0.10 [security]

  • Check this box to trigger a request for Renovate to run again on this repository

v2.0.4 should be a new major release

v2.0.4 seems to bump compatibility from node LTS version 12.x to 13.x

I believe this should constitute bump in major semver since it's a breaking change requiring to install a new node version

DOM-Based Plugins won't work (notably `line-numbers`)

The line-numbers plugin (and all the other plugins I have checked so far) won't work.

This is due to a statement in every of them:

if (typeof self === 'undefined' || !self.Prism || !self.document) {
	return;
}

which prevents anything from being registered. Further, most of them use the document and browser-only methods.

I guess the only way to make them work would be to rewrite all of them to make them work...

If i add languages, everything stop working.

I do not know if there's compatibility bugs.

i do a king of chatGPT bot and after adding makdown-it-prism, it will work for javascritp and html. if i try to add languages, it break the code and my chat bubble disappear.

import "prismjs/components/prism-clike"
import "prismjs/components/prism-java"

It's like, it will install prism.js or there's some incompatibility, i don't know.

I have to uninstall prismjs and comment these languages imports to make it work again.

P.S. I also use Svelte to render the @html and until i do not import code languages it work.

Plugins loaded but now working

Following is the input js file:

const prism = require('markdown-it-prism');
const options = {
	plugins: ["line-highlight","show-language"]
};
md.use(prism, options);

console.log(md.render(`
\`\`\`python {3,5}
import os
import sys
\`\`\`
`
)); 

output file is following:

<pre class="language-python"><code class="language-python"><span class="token keyword">import</span> os
<span class="token keyword">import</span> sys

</code></pre>

It looks like the two plugins do not has any effects.

Clarify license terms - what is a derived work?

This project is GPL3 licensed. With a strict reading of that license, code that is linked must also be released under a GPL3-compatible license.

Can you clarify what is a "derived work" when code uses (links to) this software?

Would you consider re-licensing under the LGPL?

I ask because this code is the only GPL-licensed code in a project we are building.

`loadPrismLang` doesn't handle dependencies

Hi!
I'm one of the maintainers of PrismJS and we had this issue here.
The cause of the problem is that loadPrismLang doesn't handle languages dependencies, e.g. C++ requiring C.

This should be quite easy to fix however as Prism provides a loadLanguages function which handles all dependencies for you. The usage of this function is described here under "Usage with Node".

How to use ?

Hi, I want to use this plugin in my code , but it seems not work, my code :

const prism = require('markdown-it-prism')
var md = require('markdown-it')({
  html: true,
  linkify: true,
}).use(prism)

....

and I use md.render(text) to insert into span as innerHTML

but it doesn't hightlight, is that something I doesn't do ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.