3
4

2 回答 2

5

In your _config.yml you can configure kramdown to leave html entities as they are written in your code with :

kramdown:
  entity_output: :as_input

See documentation.

于 2016-05-21T01:10:07.657 回答
3

As the docs state:

    --entity-output ARG
     Defines how entities are output

     The possible values are :as_input (entities are output in the same
     form as found in the input), :numeric (entities are output in numeric
     form), :symbolic (entities are output in symbolic form if possible) or
     :as_char (entities are output as characters if possible, only available
     on Ruby 1.9).

     Default: :as_char
     Used by: HTML converter, kramdown converter

So lets try those options:

$ kramdown --version
1.11.1 
$ kramdown
‘foo’
<p>‘foo’&lt;/p>
$ kramdown --entity-output=as_input
&lsquo;foo&rsquo;
<p>&lsquo;foo&rsquo;</p>
$ kramdown --entity-output=symbolic
&lsquo;foo&rsquo;
<p>&lsquo;foo&rsquo;</p>
$ kramdown --entity-output=numeric
&lsquo;foo&rsquo;
<p>&#8216;foo&#8217;</p>
$ kramdown --entity-output=as_char
&lsquo;foo&rsquo;
<p>‘foo’&lt;/p>
$ ruby --version
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]

Notice that I have Kramdown version 1.11 and Ruby version 1.9. if you have earlier versions, then things may not work properly.

于 2016-05-20T23:09:56.673 回答