在博客園的markdow編輯器中使用SVG


[comment]: # 在博客園的markdow編輯器中使用SVG

SVG

SVG 意為可縮放矢量圖形(Scalable Vector Graphics)。 SVG 使用 XML 格式定義圖像。

問題

如果在博客園的markdow編輯器中直接使用SVG,由於保存時,markdown引擎會插入一些html標簽,導致看不到圖像。

解決方案

可以使用div標簽或者table標簽來解決這個問題。

  • 使用div
<div width="100%" style="overflow-x: auto;"> 
  <svg width="140" height="170">
    <title>SVG Sample</title>
    <desc>This is a sample to use SVG in markdown on the website cnblogs.</desc>
    <circle cx="70" cy="95" r="50" style="stroke: black; fill: none;"/>
  </svg>
</div>

示例:注意:在div前要有一個空行。

SVG Sample This is a sample to use SVG in markdown on the website cnblogs.
  • 使用table
<table>
  <tr>
    <td>
      <svg width="140" height="170">
        <title>SVG Sample</title>
        <desc>This is a sample to use SVG in markdown on the website cnblogs.</desc>
        <circle cx="70" cy="95" r="50" style="stroke: black; fill: none;"/>
      </svg>
    </td>
  </tr>
</table>

示例:注意:在table前要有一個空行。

SVG Sample This is a sample to use SVG in markdown on the website cnblogs.

graphviz: 一個可以通過文本產生圖片的工具

訪問: http://graphviz.org/

  • 編輯一個test.dot文件
digraph G {
    bgcolor="cornsilk"
    splines="FALSE";
	size="6,6";
    label="Spark Cluster + AKKA"
	node [colorscheme=paired12, color=1, style=filled];
    
    akka_client     [label="AKKA Client", color=1]
    akka_server     [label="AKKA Server (Spark)", color=2]
    spark_master    [label="Spark Master", color=3]
    spark_slave1    [label="Spark Slave", color=4]
    spark_slave2    [label="Spark Slave", color=4]
    spark_slave3    [label="Spark Slave", color=4]
    akka_client -> akka_server -> spark_master -> spark_slave1 [dir=both color=cadetblue]
    spark_master -> spark_slave2 [dir=both color=cadetblue] 
    spark_master -> spark_slave3 [dir=both color=cadetblue]
}
  • 運行命令:
C:\Tools\graphviz\bin\dot.exe test.dot -T svg -o test.svg
  • 生成以下圖片:
G Spark Cluster + AKKA akka_client AKKA Client akka_server AKKA Server (Spark) akka_client->akka_server spark_master Spark Master akka_server->spark_master spark_slave1 Spark Slave spark_master->spark_slave1 spark_slave2 Spark Slave spark_master->spark_slave2 spark_slave3 Spark Slave spark_master->spark_slave3

References


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM