Giter Club home page Giter Club logo

Comments (14)

jerry1970 avatar jerry1970 commented on July 18, 2024 1

Another difference between Markdown Extra and Parsedown Extra when you have a fenced block with just "someclass" following it (I can't finish the example since GFM doesn't like nested blocks; not sure how Lakhman did it!):

   ~~~ someclass

ME:

<pre><code class="someclass">code</code></pre>

PE:

<pre><code class="language-someclass">code</code></pre>

I hope there will be a difference between a fenced block with a language type (class="language-someclass") and an extra class (class="someclass") so I could even have class="language-html best-example".

from parsedown-extra.

aidantwoods avatar aidantwoods commented on July 18, 2024 1

I don't foresee any issues with supporting this for fenced code blocks, I'll have a go later today. As @lakhman points out, this is something that should work per the extra spec, so it should probably be supported here :)

from parsedown-extra.

willstocks avatar willstocks commented on July 18, 2024 1

@tovic whilst I agree with you that they like to keep things simple, Parsedown Extra (which is, in itself, an extension of Parsedown) adds support for Markdown Extra, which includes this functionality (https://michelf.ca/projects/php-markdown/extra/#fenced-code-blocks) for code blocks therefore in theory this should be supported as standard within PE?

Markdown Extra example (from link above):

You can specify a class name that will apply to a code block. This is useful if you want to style differently code blocks depending on the language. Or you could also use it to tell a syntax highlighter what syntax to use.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .html
<p>paragraph <b>emphasis</b>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The class name is placed at the end of the first fence. It can be preceded by a dot, but this is not a requirement. You can also use a special attribute block:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.html #example-1}
<p>paragraph <b>emphasis</b>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

from parsedown-extra.

tomturton avatar tomturton commented on July 18, 2024

+1

from parsedown-extra.

willstocks avatar willstocks commented on July 18, 2024

@erusev - do you know if this is/will be fixed? I recently started using OctoberCMS and realised Parsedown + Parsedown Extra are included by default, but noticed that adding a class/ID to a code block doesn't work when writing either markdown page content or a blog post using rainlab's blog plugin (please see rainlab/blog-plugin#457)

from parsedown-extra.

erusev avatar erusev commented on July 18, 2024

@aidantwoods do you have any thoughts on this

from parsedown-extra.

willstocks avatar willstocks commented on July 18, 2024

Thanks @aidantwoods 😁 Looking forward to it!

from parsedown-extra.

taufik-nurrohman avatar taufik-nurrohman commented on July 18, 2024

@lakhman Read this section to add custom classes without language- prefix in Markdown Extra using my extension. Currently compatible for Parsedown Extra 0.7.0.

Update: #133

from parsedown-extra.

willstocks avatar willstocks commented on July 18, 2024

@aidantwoods / @erusev - is @tovic's solution a viable solution that will be backed into PE or will you guys have an alternate/formal solution for this?

I only ask because obviously Parsedown + Parsedown Extra are bundled into October and it'd be great to not have to fudge something together 😁

from parsedown-extra.

willstocks avatar willstocks commented on July 18, 2024

Any luck with this one @aidantwoods?

from parsedown-extra.

willstocks avatar willstocks commented on July 18, 2024

Hey @aidantwoods / @erusev
Don't suppose you happen to have any update on this one? Or maybe is it worth @tovic putting in a PR for this functionality? Would be nice to see this "native" in October/in other places PE is used :)

from parsedown-extra.

taufik-nurrohman avatar taufik-nurrohman commented on July 18, 2024

@willstocks I could, but looking at the philosophy of Parsedown, they seem to prefer simplicity. That is to simply process Markdown input to HTML according to the CommonMark specs without providing many complicated options. So, it would still be better if the advanced configuration is available as a separate plugin.

from parsedown-extra.

taufik-nurrohman avatar taufik-nurrohman commented on July 18, 2024

From this commit, I can see that @aidantwoods is deliberately limiting the class names that are allowed in the code block attribute to just one class name. Somehow, maybe to prevent XSS.

from parsedown-extra.

willstocks avatar willstocks commented on July 18, 2024

@aidantwoods is there a reason for this restriction? Would you be open to @tovic submitting a PR (if he's happy to that is!!!) considering he has already extended this functionality externally or would you prefer to handle extending class/id's to code blocks within existing PE contributors?

from parsedown-extra.

Related Issues (20)

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.