html - 为什么 div 标签会破坏 github-pages 中的 Markdown

标签 html jekyll github-pages

使用带有 github-pages 的 jekyll

我在 index.md 中有这个:

<div class="grey-box">
  GET /projects/<span class="variable project_id">{Project ID}</span>/codes/<span class="variable code_id">{Code ID}</span>/download
</div>

它在编译时破坏了 Markdown ,所以我将 div 更改为这样的跨度:

<span class="grey-box">
  GET /projects/<span class="variable project_id">{Project ID}</span>/codes/<span class="variable code_id">{Code ID}</span>/download
</span>

CSS:

.grey-box {
   background: #EEE;
   padding: 5px 10px;
}

现在一切都是肉汁。知道 div 导致此错误的原因吗?

最佳答案

Markdown 不解析 block 级 HTML 元素,其中 <div>是一个。

来自 the documentation :

Note that Markdown formatting syntax is not processed within block-level HTML tags. E.g., you can’t use Markdown-style *emphasis* inside an HTML block.

这不仅仅是 GitHub Pages 的情况,绝大多数 Markdown 解析器也是如此。

关于html - 为什么 div 标签会破坏 github-pages 中的 Markdown ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21589441/

相关文章:

reactjs - 为什么 Github 页面 url 在加载时发生变化,导致公共(public)资源路径不正确?

html - 如何在 GitHub 上托管我的作品集网站?

html - Firefox 6 Windows 上的白色纯 CSS 三 Angular 形错误

javascript - React json渲染猫图像

Jekyll 错误 uri 错误请求行

jekyll - 如何删除 "Powered by Jekyll with Chirpy theme."

github-pages - GitHub Pages 博客和 Google Search Console : Is it safe to follow these steps for a public repo?

html - 固定导航栏

javascript - 将鼠标悬停/单击 DIV 列表

html - Jekyll 不显示 GIF