Comments (14)
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.
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.
@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.
+1
from parsedown-extra.
@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.
@aidantwoods do you have any thoughts on this
from parsedown-extra.
Thanks @aidantwoods 😁 Looking forward to it!
from parsedown-extra.
@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.
@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.
Any luck with this one @aidantwoods?
from parsedown-extra.
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.
@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.
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.
@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)
- Undefined index: text HOT 4
- Paragraphs/HTML blocks may disappear in HTML block with markdown="1" HOT 3
- ParsedownExtra.php and tests classes are declared as psr-0 in composer.json but are not compliant with psr-0 HOT 11
- Bug: Uninitialized string offset: 1
- Footnote HTML is double-escaped when safe mode is on HOT 1
- Can't embed video HOT 1
- The Footnotes stop working
- I'm getting this while composer update/install HOT 2
- Multiline blockquotes not rendering correctly in multiline footnotes
- Multiple blockquotes HOT 1
- Video HTML tag does not work
- Parsing special attributes {lang=fr} are not parsed HOT 1
- List Item is dropping text that follows a custom tag HOT 2
- PHP 8.2: mb_convert_encoding(): Handling HTML entities via mbstring is deprecated HOT 2
- Wrap image inside div - not working
- Demo broken? HOT 5
- Add support for PHP 8.2 HOT 2
- Deprecated: Use of "self" in callables is deprecated HOT 1
- Should we start looking for alternatives? Is this repo alive? HOT 1
- Deprecated: Use of "self" in callables is deprecated
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parsedown-extra.