jekyll / jekyll-gist

:page_with_curl: Liquid tag for displaying GitHub Gists in Jekyll sites.
https://rubygems.org/gems/jekyll-gist
MIT License
263 stars 40 forks source link

noscript output seems to break sometimes when using Commonmark #82

Closed 0xdevalias closed 3 years ago

0xdevalias commented 4 years ago

This plugin seems to break it's output when attempting to embed the following gist when noscript is enabled, and jekyll-commonmark is used as the markdown renderer

_config.yml

markdown: CommonMark

commonmark:
  options: ["UNSAFE", "FOOTNOTES", "STRIKETHROUGH_DOUBLE_TILDE", "VALIDATE_UTF8", "GITHUB_PRE_LANG", "HARDBREAKS"]
  extensions: ["autolink", "strikethrough", "table", "tasklist"]

Rendered snippet ~~~

# Dogedraw, now with more Nyaan!

Paste these functions into the js console on https://dogedraw.firebaseapp.com and run them to nyaan nyaan nyaan..

Developed at http://hs.hact.io 2015!!

function clearScreen(w, h, color) {
  var pixelDataRef = new Firebase('https://dogedraw.firebaseio.com/pixels');
  for (var i = 0; i < h; i++) {
    for (var j = 0; j < w; j++) {
      pixelDataRef.child(j + ":" + i).set(color);
    }
  }
}

function nyaan(startX, startY) {
  function rpt(value, times) {
    var arr = [];
    for (rpti = 0; rpti < times; rpti++) {
      arr[rpti] = value;
    }
    return arr;
  }

  function cc(arr) {
    var joined = [];
    for (cci = 0; cci < arr.length; cci++) {
      joined = joined.concat(arr[cci]);
    }
    return joined;
  }

  var nyaanHax = new Firebase('https://dogedraw.firebaseio.com/pixels');

  var w = "fff" // white
  var bl = "00f" // blue
  var k = "000" // black
  var r = "f00" // red
  var gy = "333" // grey
  var gr = "0f0" // green
  var y1 = "FFFFE0" // pale yellow
  var y2 = "FFFF00" // yellow
  var o = "FF4500" // orange
  var p1 = "FFC0CB" // pink
  var p2 = "9370DB" //purple
  var p3 = "800080" // dark purple

  var nyaan = []
  nyaan[0] = rpt(w, 38)
  nyaan[1] = cc([rpt(w, 3), rpt(r, 6), rpt(w, 7), rpt(k, 14), rpt(w, 8)])
  nyaan[2] = cc([[w], rpt(r, 14), [k], rpt(y1, 14), [k], rpt(w, 7)])
  nyaan[3] = cc([[w], rpt(r, 3), rpt(o, 5), rpt(r, 5), [k, y1, y1], rpt(p1, 4), [p2, p1, p1, p2], rpt(p1, 3), rpt(y1, 3), [k], rpt(w, 6)])
  nyaan[4] = cc([[w], rpt(o, 13), [k, y1], rpt(p1, 2), [p2], rpt(p1, 4), [k, k], rpt(p1, 5), [y1, k, w, k, k], rpt(w, 3)])
  nyaan[5] = cc([[w], rpt(o, 3), rpt(y2, 4), rpt(k, 4), rpt(o, 2), [k, y1], rpt(p1, 6), [k, gy, gy, k], [p1, p1, p2, p1, y1, k, k, gy, gy, k], rpt(w, 2)])
  nyaan[6] = cc([[w], rpt(y2, 6), [k, gy, gy, gy], rpt(k, 4), [y1], rpt(p1, 6), [k, gy, gy, gy, k], rpt(p1, 3), [y1, k, gy, gy, gy, k], rpt(w, 2)])
  nyaan[7] = cc([[w], rpt(y2, 3), rpt(gr, 3), [k, k], rpt(gy, 5), [k, y1], rpt(p1, 3), [p2], rpt(p1, 2), [k], rpt(gy, 4), rpt(k, 4), rpt(gy, 4), [k], rpt(w, 2)])
  nyaan[8] = cc([[w], rpt(gr, 8), rpt(k, 4), [gy, k, y1], rpt(p1, 6), [k], rpt(gy, 12), [k], rpt(w, 2)])
  nyaan[9] = cc([[w], rpt(gr, 3), rpt(bl, 8), rpt(k, 3), [y1], rpt(p1, 4), [p2, k], rpt(gy, 3), [w, k], rpt(gy, 5), [w, k, gy, gy, k, w]])
  nyaan[10] = cc([[w], rpt(bl, 13), [k, y1, p1, p2], rpt(p1, 3), [k], rpt(gy, 3), [k, k], rpt(gy, 3), [k, gy, k, k, gy, gy, k, w]])
  nyaan[11] = cc([[w], rpt(bl, 3), rpt(p3, 5), rpt(bl, 5), [k, y1], rpt(p1, 3), [p2, p1, k, gy, p1 ,p1], rpt(gy, 9), [p1, p1, k, w]])
  nyaan[12] = cc([[w], rpt(p3, 12), [k, k, y1, y1, p1, p2, p1, p1, k, gy, p1, p1, gy, k, gy, gy, k, gy, gy, k, gy, p1, p1, k, w]])
  nyaan[13] = cc([[w], rpt(p3, 3), rpt(w, 5), rpt(p3, 2), rpt(k, 4), rpt(y1, 3), rpt(p1, 4), [k], rpt(gy, 3), rpt(k, 7), rpt(gy, 2), [k, w, w]])
  nyaan[14] = cc([rpt(w, 10), [k, gy, gy, gy, k, k], rpt(y1, 7), [k], rpt(gy, 10), [k], rpt(w, 3)])
  nyaan[15] = cc([rpt(w, 10), [k, gy, gy, k, w], rpt(k, 19), rpt(w, 4)])
  nyaan[16] = cc([rpt(w, 10), rpt(k, 3), rpt(w, 3), [k, gy, gy, k, w, w, w, k, gy, gy, k, w, k, gy, gy, k], rpt(w, 6)])
  nyaan[17] = cc([rpt(w, 17), rpt(k, 3), rpt(w, 4), rpt(k, 3), rpt(w, 2), rpt(k, 3), rpt(w, 6)])
  nyaan[18] = rpt(w, 38)

  for (var i = 0; i < nyaan.length; i++) {
    for (var j = 0; j < nyaan[i].length; j++) {
      nyaanHax.child(parseInt(startX+j) + ":" + parseInt(startY+i)).set(nyaan[i][j]);
    }
  }

  return "I drew a cat!"
}
```</pre></noscript><script src="https://gist.github.com/0xdevalias/e8bb28726a37854606ad.js"> </script>
~~~

In particular, the end part of the rendered noscript seems to be getting itself confused, and then ends up breaking the output:

```&lt;/pre&gt;&lt;/noscript&gt;&lt;script src=&quot;https://gist.github.com/0xdevalias/e8bb28726a37854606ad.js&quot;&gt; &lt;/script&gt;
</code></pre>

This doesn't appear to happen on other posts where I have gists embedded.

My theory is that maybe because the gist ends in a triple backtick codeblock (possibly with no newline?), that that may be breaking something within this plugin, that then flows on to breaking how commonmark parses/renders things?

jekyllbot commented 4 years ago

This issue has been automatically marked as stale because it has not been commented on for at least two months.

The resources of the Jekyll team are limited, and so we are asking for your help.

If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, please consider whether it can be accomplished in another way. If it cannot, please elaborate on why it is core to this project and why you feel more than 80% of users would find this beneficial.

This issue will automatically be closed in two months if no further activity occurs. Thank you for all your contributions.