Markup: Consider having a whitelist of CSS classes

Created on 22 Jun 2016  ·  6Comments  ·  Source: github/markup

I can understand the reasoning behind filtering out class attributes. Rather than strip them entirely, could we have a whitelist of classes instead?

I just finished writing this on another issue, so I'm just going to copy+paste my own words:


I feel GitHub should have a whitelist of CSS classes to apply basic inline formatting. This would permit users to use <pre><code> … </code></pre> blocks to establish the same look as fenced code-blocks, but have proper control over the syntax highlighting.

E.g., this:

# Ignore the fact this is Perl, and pretend it's some unheard-of language
our $site = "needs this";

... might be implemented like this:

<pre><code>
<span class="code-comment"># Ignore the fact this is Perl, and pretend it's some unheard-of language</span>
<span class="code-keyword">our</span> <span class="code-variable">$site</span> = <span class="code-string">"needs this"</span>;
</code></pre>

Yes, this is cumbersome to write. But for authors who're serious about having code presented readably and cleanly, it's better than absolutely nothing.

This would also allow true diff-style highlighting within GitHub-flavoured Markdown (green and red backgrounds, etc).

Some possible suggestions:

code-keyword
code-number
code-string
code-modifier
code-constant
…
diff-changed-line  (light green)
diff-changed       (darker green for parts that actually changed)
diff-removed-line
diff-removed

Most helpful comment

I would already be happy if at least well-known rST admonition classes (sidebar, info, warning, …) would not be filtered, or else prefixed into their own namespace and then left alone (user-content-rst-sidebar, …).

Right now, rendering of rST admonitions is plain broken, and only epitaph is actually usable.

All 6 comments

I like this idea! 🎉

I think the whitelist should at least include all of GitHub's primer class name definitions. This would cover a basic range of styles, but more colors would need to be included. One idea for more colors would be to copy the "lighten-#" and "darken-#" definitions provided by the materialize framework.

I would already be happy if at least well-known rST admonition classes (sidebar, info, warning, …) would not be filtered, or else prefixed into their own namespace and then left alone (user-content-rst-sidebar, …).

Right now, rendering of rST admonitions is plain broken, and only epitaph is actually usable.

I like the idea proposed in this issue. Any progress on this? I traced the similar requests all the way back to #68 , it seems there was no visible progress in the past 7 years (at least for rst admonitions rendering, correct me if I'm wrong). This should be a simple but really amazing feature.

👍

See https://github.com/github/markup/issues/1246#issuecomment-439259382 -- there's no official support behind this, so I'm not moving it anywhere more permanent/visible for the time being.

+1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

doggy8088 picture doggy8088  ·  4Comments

petrdvorak picture petrdvorak  ·  6Comments

zoffixznet picture zoffixznet  ·  6Comments

daenney picture daenney  ·  3Comments

Istiakmorsalin picture Istiakmorsalin  ·  4Comments