问题
I have a problem with inline HTML in a github page, where inline HTML bullet lists are escaped in tables. The rows of the following table:
| Name | Value |
|------|-----------------------|
| one | <i>foo</i> |
| two | <ul><li>bar</li></ul> |
is rendered as:
<tr>
<td>one</td>
<td><i>foo</i></td>
</tr>
<tr>
<td>two</td>
<td><ul><li>bar</li></ul></td>
</tr>
The bullet list is rendered as expected by the GitHub UI, but in gh-pages, the <ul>
is escaped. Why?
回答1:
This is by design as implemented by Kramdown, which is the Markdown processor that renders Markdown in GitHub pages.
Kramdown treats each new line as a row and doesn't render Markdown bullet lists inside table cells, and instead of rendering HTML, it is escaped and outputted as a single line of text.
You can tell Kramdown to leave the HTML alone and output as is, with the nomarkdown extension. Just wrap the HTML code with {::nomarkdown}
... {:/}
e.g.
| Name | Value |
|------|-----------------------------------------|
| one | {::nomarkdown}<i>foo</i>{:/} |
| two | {::nomarkdown}<ul><li>bar</li></ul>{:/} |
回答2:
The way I did it (works for GitHub markdown and GitHub Pages (Jekyll)):
<!-- {% raw %} -->
```html
<div no-ui-slider
slider-options="{{ optionsWithoutStart }}"
ng-model="sliderPositions"></div>
```
<!-- {% endraw %}) -->
The <!-- -->
is seen by GitHub as a comment and the {% raw %} {% endraw %}
prevents Jekyll from parsing the curly braces.
On both GitHub and Jekyll (GitHub Pages), the output is:
<div no-ui-slider
slider-options="{{ optionsWithoutStart }}"
ng-model="sliderPositions"></div>
回答3:
I have this three tables as a markdown
file. Inside the table there a no HTML elements
but HTML encoding
.
## Special Symbols
| Symbol | Unicode | HTML |
| :----: | ------- | ------- |
| ™ | 2122 | ™ |
| © | 00A9 | © |
| ♻ | 267B | ♻ |
## Special Symbols (nomarkdown-wrapped)
| Symbol | Unicode | HTML |
| :----: | ------- | ------------------------- |
| ™ | 2122 | {::nomarkdown}™{:/} |
| © | 00A9 | {::nomarkdown}©{:/} |
| ♻ | 267B | {::nomarkdown}♻{:/} |
## Special Symbols (raw-wrapped)
| Symbol | Unicode | HTML |
| :----: | ------- | ---------------------------- |
| ™ | 2122 | {% raw %}™{% endraw %} |
| © | 00A9 | {% raw %}©{% endraw %} |
| ♻ | 267B | {% raw %}♻{% endraw %} |
I tried it with {::nomarkdown} ... {:/}
and {% raw %} ... {% endraw %}
both shows still the symbol and not the HTML as plain text. How can I enforce the plain HTML.
I know that is NOT an answer, but it is to complicated for a comment.
来源:https://stackoverflow.com/questions/47262698/inline-html-is-escaped-by-jekyll