5

On the GitHub repo the README, the markdown inside the collapsible section renders as desired.

enter image description here

But on GitHub Pages the markdown is not rendered, just literal.

enter image description here

The _config.yml is essentially empty.

In the issue is mentioned Markdown inside and not being processed, and the suggested fix is:

markdown: kramdown
kramdown:
  parse_block_html: true

That does indeed fix the rendering of the content, and I am fine with switching to kramdown, but it breaks the rendering of <details> and <summary> and the twirl-down. (So I rolled it back.)

The relevant HTML and markdown is:

<details><summary><strong>About transliteration</strong></summary>

About half of the billions of internet users speak languages written in non-Latin alphabets, like Russian, Arabic, Hebrew, Chinese, Greek, Armenian and Hindi.  Very often, they haphazardly use the Latin alphabet to write those languages.

`Привет`: `Privet`, `Privyet`, `Priwjet`, ...  
`كيف حالك`: `kayf halk`, `keyf 7alek`, ...  
`Բարև Ձեզ`: `Barev Dzez`, `Barew Dzez`, ...  

... ... ...

</details>

Is there a way to force the rendering without kramdown (and without using raw HTML)? Or is there a way to make a collapsible section with kramdown?

The full repo is of course up at github.com/deepchar/deepchar.github.io.

Adam Bittlingmayer
  • 1,169
  • 9
  • 22
  • The GitHub Pages docs for [Configuring Jekyll](https://help.github.com/articles/configuring-jekyll/) list the default used, some of which you can override and some you can't. Note that Kramdown's `parse_block_html` setting is not on that list. But then it is only available on Kramdown's [kramdown](https://kramdown.gettalong.org/parser/kramdown.html) parser, not the [GFM](https://kramdown.gettalong.org/parser/gfm.html) parser which GitHub Pages uses. – Waylan Oct 24 '18 at 01:50
  • And then [since March 14, 2017](https://blog.github.com/2017-03-14-a-formal-spec-for-github-flavored-markdown/) everything on GitHub.com is now parsed by GitHub's [extended Commonmark parser](https://github.com/github/cmark-gfm) which handles [HTML Blocks](https://github.github.com/gfm/#html-blocks) differently than traditional Markdown implementations (including the old GitHub Flavored Markdown implementation). In other words, you may never get matching behavior between GitHub Pages and GitHub.com as they use different implementations based on different sets of rules. – Waylan Oct 24 '18 at 01:55
  • @Waylan Thank you, this helped, I will post the answer. – Adam Bittlingmayer Oct 24 '18 at 06:28

1 Answers1

5

As noted in the comments by Waylan, markdown in GitHub repos like a README.md are rendered with Commonmark.

The repo github.com/github/jekyll-commonmark-ghpages#installation mentions that support for GitHub Pages is on the way and gives some instructions.

Installation

Add the following to your Gemfile:

group :jekyll_plugins do
  gem 'jekyll-commonmark-ghpages'
end

and modify your _config.yml to use CommonMarkGhPages as your Markdown converter:

markdown: CommonMarkGhPages

This processor is currently in testing for use in GitHub Pages.

To specify extensions and options for use in converting Markdown to HTML, supply options to the Markdown converter:

commonmark:
  options: ["SMART", "FOOTNOTES"]
  extensions: ["strikethrough", "autolink", "tables"]

To make it work (as of October 2018), all I had to do was add markdown: CommonMarkGhPages to the _config.yml. (There is no Gemfile in the repo.)

Adam Bittlingmayer
  • 1,169
  • 9
  • 22
  • 3
    It seems to me there is a little error in the answer. Should be "table", not "tables" in the last part. `commonmark: options: ["SMART", "FOOTNOTES"] extensions: ["strikethrough", "autolink", "table", "tagfilter"]` – 黄锐铭 May 18 '19 at 20:00
  • Thanks, I just copied their instructions verbatim. – Adam Bittlingmayer May 20 '19 at 02:44
  • 1
    As of July 2020, I added this to my gemfile, but I get an error when running `Jekyll serve`: "Could not find gem 'jekyll-commonmark-ghpages'". Does this gem still exist? I'm not good when it comes to Ruby, so I don't know where to see if it still exists. – Damian Jul 12 '20 at 18:13
  • 1
    @Damian `bundle install` shows me (Ubuntu) `Using jekyll-commonmark-ghpages 0.1.6` – Fuhrmanator Jan 06 '21 at 19:58