covid19-hg / covid19hg

Home Page:https://www.covid19hg.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Underscores inadvertently substituted for italics using admin console.

mattsolo1 opened this issue · comments

Bug report

What is the current behavior?

Text containing underscores is interpreted as italic formatting -- in particular filenames on the in silico page. It's possible to escape the underscores when editing a page in raw markdown, but as soon as someone edits the page using the Admin UI, the escape characters are removed and the text is displayed in italic.

If the current behavior is a bug, please provide the steps to reproduce.

e.g. on the in silico page, COVID19HGIANAB2V2_20200629 should be COVID19_HGI_ANA_B2_V2_20200629

image

What is the expected behavior?

Ideally when the page is edited through the admin console, the escape characters would not be removed. Not sure if there is an easy way to fix this.

I did some investigation by adding escaped and unescaped underscores into various types of Markdown content in the site and found that there seems to be a difference between how underscores are handled when they appear in frontmatter fields and in the body.

In 5763235, I added test phrases to the frontmatter and body fields:

Screen Shot 2020-09-11 at 6 35 47 PM

and the the rendered results look different:

Screen Shot 2020-09-11 at 6 33 10 PM

A possible reason for the discrepancy is that the Markdown content in the Projects page's frontmatter is rendered at run time by ReactMarkdown:

<ReactMarkdown source={description} />

whereas the Markdown in the body of a blog post is statically rendered into HTML by gatsby-transformer-remark.

I also found that when switching from "rich text" to "markdown" modes, Netlify CMS's markdown widget does not escape underscores entered in "rich text" mode even though their markdown escaping unit test passes when provided with the phrase I used for testing. I suspect that the switch from "rich text" to "markdown" modes doesn't trigger escaping as it should.

@huy-nguyen, based on your last message, the takeaway is there is no way to fix this? Should this issue be closed?

The takeaway is that Netlify CMS' markdown editor doesn't escape underscores properly when switching from rich text mode to markdown mode, even though their own test suites do not reveal any problem. The solution is that writers should manually escape underscores in both rich text and markdown modes. I can close the issue.