Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    @kerbymart
    @kerbymart
    +1 to prism, we are to release an app using prism at its core
    while we are using prism on the client side, it possible to have prism usable for server side rendering?
    Tzu-ping Chung
    @uranusjr
    I think Prism works on Node. I have built an Objective-C binding for Prism using WebKit’s JavaScriptCore, too.
    Can’t be 100% sure but it’d be a good bet that it should work for you.
    Arafat Hussain
    @rftHss
    Hello I am @rftHss
    Patrick-Jeffrey Pollo Guilbert
    @epatpol
    Anyone using Prism with the Monaco editor?
    Patrick-Jeffrey Pollo Guilbert
    @epatpol
    I'm trying to use prismjs in our typescript project to highlight monaco's content, however I'm not exactly sure how I can use prismjs.tokenize
    Golmote
    @Golmote
    Hi @epatpol! I'm not familiar with the Monaco editor. Can you explain your issue with the tokenize() function in more details?
    Patrick-Jeffrey Pollo Guilbert
    @epatpol
    I was trying to use tokenize from the npm package and it didn't work, I think I misunderstoof how to use it
    I ended up adding the prismjs.js and prismjs.css to my frontend without prismjs/@types/prismjs dependencies, referring to Prism as a global variable of type any and called tokenize() on it and it works
    I don't have types though :/
    Golmote
    @Golmote
    What "types" are you talking about? Is it something specific to the Monaco editor? Your message implies that you managed to make it work. Is there still an issue to fix?
    Patrick-Jeffrey Pollo Guilbert
    @epatpol
    Sorry it's not very clear, because we use typescript to do all of the front end stuff, so I had to declare the Prism variable as any (because all objects must have a type in ts) and use it there. The thing is you don't get any completion from the ts-server, and you can't tell from vscode from instance what types you get from the tokenize function, so the workaround was to just cast as any and debug with chrome to see what objects I was getting
    So yea I managed to get it to work, now the issue is more monaco specific you're right (applying the token classes to the elements in the editor)
    Golmote
    @Golmote
    @epatpol Someone wrote a ts definition for Prism on DefinitelyTyped, but I'm not sure it's accurate anymore. https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/prismjs
    Also, keep in mind that the tokens may vary a lot from one language to another, and there is no actual warranty they will stay the same from one version of Prism to another. So you must be careful there.
    If you encounter a specific issue related to using tokenize(), feel free to open an issue on Prism's Github.
    Patrick-Jeffrey Pollo Guilbert
    @epatpol
    Yea I think the types are also not to date, seeing as the Token object doesn't have length property on it, even though it has it when I debug in chrome
    Thanks for the tips @Golmote
    Also is it normal that calling tokenize return some tokens with nothing/no properties
    Patrick-Jeffrey Pollo Guilbert
    @epatpol
    I get some tokens with type: comment, content, length, greedy etc. attributes
    but some with empty objects
    (maybe it's okay though, and it's the client's role to use these tokens accordingly)
    1, 3, 5, 7 for instance
    Patrick-Jeffrey Pollo Guilbert
    @epatpol
    Looking at some other project also using monaco and prismjs it seems it might be normal https://github.com/supnate/rekit/blob/master/packages/rekit-studio/src/features/common/monaco/workers/syntaxHighlighter.js#L227
    Patrick-Jeffrey Pollo Guilbert
    @epatpol
    nvm it totally makes sense, you want to be able to calculate the position of a token , and without line/column you need to iterate through all tokens with length
    Golmote
    @Golmote
    @epatpol Yes, tokenize can return Token objects, but also raw string items for parts that were not tokenized, like whitespaces in your example.
    Ghost
    @ghost~559d399815522ed4b3e3a63a
    Hi. Could you tell me why prism has :not(pre) in :not(pre) > code[class*="language-"] { background: ... }?
    my markdown-generator generates exactly <pre><code> blocks
    Oleg Dutchenko
    @dutchenkoOleg
    my first theme for prism
    https://dutchenkooleg.github.io/prismjs-material-theme/
    maybe someone will come in handy