Unicode characters escaped with JsonLexer and HtmlFormatter

Issue #1419 new
Anonymous created an issue

Using a JsonLexer and HtmlFormatter with a non-ascii string in Python 2,7, for example:

[
  "告知書扱い対象の保険種類",
  "一般検診が必要"
]

The HtmlFormatter escapes non-ascii characters, resulting in the equivalent :

[
      "\u544a\u77e5\u66f8\u6271\u3044\u5bfe\u8c61\u306e\u4fdd\u967a\u7a2e\u985e", 
      "\u4e00\u822c\u691c\u8a3a\u304c\u5fc5\u8981"
]

..and HTML:

"<div class="highlight"><pre><span></span><span class="p">{</span>  <span class="nt">&quot;$id&quot;</span><span class="p">:</span> <span class="s2">&quot;http://example.com/example.json&quot;</span><span class="p">,</span>   <span class="nt">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;array&quot;</span><span class="p">,</span>   <span class="nt">&quot;definitions&quot;</span><span class="p">:</span> <span class="p">{},</span>   <span class="nt">&quot;$schema&quot;</span><span class="p">:</span> <span class="s2">&quot;http://json-schema.org/draft-07/schema#&quot;</span><span class="p">,</span>   <span class="nt">&quot;items&quot;</span><span class="p">:</span> <span class="p">{</span>    <span class="nt">&quot;$id&quot;</span><span class="p">:</span> <span class="s2">&quot;http://example.com/example.json/items&quot;</span><span class="p">,</span>     <span class="nt">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;string&quot;</span><span class="p">,</span>     <span class="nt">&quot;title&quot;</span><span class="p">:</span> <span class="s2">&quot;The 0th Schema&quot;</span><span class="p">,</span>     <span class="nt">&quot;default&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>     <span class="nt">&quot;examples&quot;</span><span class="p">:</span> <span class="p">[</span>      <span class="s2">&quot;\u544a\u77e5\u66f8\u6271\u3044\u5bfe\u8c61\u306e\u4fdd\u967a\u7a2e\u985e&quot;</span><span class="p">,</span>       <span class="s2">&quot;\u4e00\u822c\u691c\u8a3a\u304c\u5fc5\u8981&quot;</span>    <span class="p">]</span>  <span class="p">}</span><span class="p">}</span></pre></div>"

The exact same string with the same HtmlFormatter, but using an XmlLexer, works just fine:

<item>告知書扱い対象の保険種類</item>
<item>一般検診が必要</item>

Comments (0)

  1. Log in to comment