在Github README.md上显示ANSI颜色

时间:2015-07-19 16:28:58

标签: github markdown github-flavored-markdown ansi-colors

我想转换这个丑陋的字符串......

"\e[0;92;49mGroup::Item\e[0m | \e[0;35;49mgender\e[0m\n  \e[0;92;49mGroup::SubItem\e[0m | \e[0;36;49mage=22 \e[0m\e[0;94;49mfirst_name=\"Juan Manuel\" \e[0m\e[0;36;49msite_id=1 \e[0m\e[0;94;49mstore_id=1 \e[0m\e[0;36;49mgender=\"M\" \e[0m\e[0;94;49msavings=20.5 \e[0m\n    \e[0;93;49mSource::Item\e[0m | \e[0;36;49mage=22 \e[0m\e[0;94;49mfirst_name=\"Juan Manuel\" \e[0m\e[0;36;49msite_id=1 \e[0m\e[0;94;49mstore_id=1 \e[0m\e[0;36;49mgender=\"M\" \e[0m\e[0;94;49msavings=20.5 \e[0m\n    \e[0;93;49mSource::Item\e[0m | \e[0;36;49mage=31 \e[0m\e[0;94;49mfirst_name=\"Leandro\" \e[0m\e[0;36;49msite_id=1 \e[0m\e[0;94;49mstore_id=1 \e[0m\e[0;36;49mgender=\"M\" \e[0m\e[0;94;49msavings=15.5 \e[0m\n    \e[0;93;49mSource::Item\e[0m | \e[0;36;49mage=65 \e[0m\e[0;94;49mfirst_name=\"Rodolfo\" \e[0m\e[0;36;49msite_id=2 \e[0m\e[0;94;49mstore_id=2 \e[0m\e[0;36;49mgender=\"M\" \e[0m\e[0;94;49msavings=50.2 \e[0m\n    \e[0;93;49mSource::Item\e[0m | \e[0;36;49mage=8 \e[0m\e[0;94;49mfirst_name=\"Francisco\" \e[0m\e[0;36;49msite_id=2 \e[0m\e[0;94;49mstore_id=3 \e[0m\e[0;36;49mgender=\"M\" \e[0m\e[0;94;49msavings=2.5 \e[0m\n    \e[0;93;49mSource::Item\e[0m | \e[0;36;49mage=31 \e[0m\e[0;94;49mfirst_name=\"Gustavo\" \e[0m\e[0;36;49msite_id=3 \e[0m\e[0;94;49mstore_id=4 \e[0m\e[0;36;49mgender=\"M\" \e[0m\e[0;94;49msavings=40.5 \e[0m\n    \e[0;93;49mSource::Item\e[0m | \e[0;36;49mage=35 \e[0m\e[0;94;49mfirst_name=\"Javier\" \e[0m\e[0;36;49msite_id=3 \e[0m\e[0;94;49mstore_id=5 \e[0m\e[0;36;49mgender=\"M\" \e[0m\e[0;94;49msavings=25.5 \e[0m\n  \e[0;92;49mGroup::SubItem\e[0m | \e[0;36;49mage=64 \e[0m\e[0;94;49mfirst_name=\"Susana\" \e[0m\e[0;36;49msite_id=2 \e[0m\e[0;94;49mstore_id=2 \e[0m\e[0;36;49mgender=\"F\" \e[0m\e[0;94;49msavings=30.0 \e[0m\n    \e[0;93;49mSource::Item\e[0m | \e[0;36;49mage=64 \e[0m\e[0;94;49mfirst_name=\"Susana\" \e[0m\e[0;36;49msite_id=2 \e[0m\e[0;94;49mstore_id=2 \e[0m\e[0;36;49mgender=\"F\" \e[0m\e[0;94;49msavings=30.0 \e[0m\n    \e[0;93;49mSource::Item\e[0m | \e[0;36;49mage=33 \e[0m\e[0;94;49mfirst_name=\"Virginia\" \e[0m\e[0;36;49msite_id=2 \e[0m\e[0;94;49mstore_id=3 \e[0m\e[0;36;49mgender=\"F\" \e[0m\e[0;94;49msavings=70.1 \e[0m\n    \e[0;93;49mSource::Item\e[0m | \e[0;36;49mage=33 \e[0m\e[0;94;49mfirst_name=\"Gabriela\" \e[0m\e[0;36;49msite_id=3 \e[0m\e[0;94;49mstore_id=4 \e[0m\e[0;36;49mgender=\"F\" \e[0m\e[0;94;49msavings=45.5 \e[0m\n"

进入这个美丽而有光泽的桌子

enter image description here

  

显然,我不想使用图片......

我该怎么做?

1 个答案:

答案 0 :(得分:2)

这是不可能的。 GitHub Markup使用html-pipeline sanitize any HTML,删除您可能用于为文字添加颜色的任何内容, 包括:

  • style元素
  • style属性
  • font元素

请注意,color属性仍然可用,但这并不多 很好,因为它需要font元素。

如果您想添加颜色支持,请发表对open issue的支持 html-pipeline repo。