【翻譯】The DOT Language

原文參考:https://graphviz.gitlab.io/_pages/doc/info/lang.html

學習神器:http://magjac.com/graphviz-visual-editor/

有些地方若翻譯得不夠好,請多多賜教啊,謝謝啦!

目錄

1、DOT語法

1.1 DOT代碼結構

1.2 語句(體)類型

1.3 屬性聲明語句

1.4 屬性列表

1.5 屬性列表項

1.6 邊語句

1.7 節點語句與子圖語句

1.8 “=”語句

2、子圖與圖羣

3、詞法&語義註解

4、字符編碼


1、DOT語法

The following is an abstract grammar defining the DOT language. Terminals are shown in bold font and nonterminals in italics. Literal characters are given in single quotes. Parentheses ( and ) indicate grouping when needed. Square brackets [ and ] enclose optional items. Vertical bars | separate alternatives.

下面是一個抽象的DOT語言語法定義。語法要素用粗體表示,而語法要素的組織方式則用斜體表示。元字符放在單引號對中。括號“(”和“)”表示需要的分組。中括號“[”“]”括入可選項。垂直線“|”分隔可替代選項。

譯註:語法解析

語法要素是指DOT語言最終定義的對象,包括(嚴格)(有向、無向)圖、邊、節點、子圖,以及節點間連接方向。非語法要素是指語法要素的組織、構成規則。在語法定義中,這二者實際就如同數據結構中數據與結構的關係。

1.1 DOT代碼結構

graph:[ strict ] (graph | digraph) [ ID ] '{' stmt_list '}'

定義整個圖,以graph(無向圖)或digraph(有向圖)開始,前面可以有strict(嚴格),後面可接圖ID。具體定義放在一對大括號中。如:

digraph {

     A -> B

     A -> B

}

strict digraph {

     A -> B

     A -> B

}

 

1.2 語句(體)類型

 

stmt_list:[ stmt [ ';' ] stmt_list ]

在大括號中的是實際定義圖的語句體。由若干條語句組成,語句之間用“;”(可選)隔開。

stmt:node_stmt|edge_stmt|attr_stmt|ID '=' ID|subgraph

語句體中每條語句所屬的語句類型:節點語句node_stmt,邊語句edge_stmt,屬性聲明語句attr_stmt,“=”號語句ID’=’ID和子圖定義語句subgraph。

1.3 屬性聲明語句

attr_stmt:(graph | node | edgeattr_list

屬性聲明語句以graph、node、edge開始,指明聲明的是圖、節點、邊的屬性,後必須接屬性聲明列表attr_list,如(符號“//”“/**/”表示註釋,後同):

digraph action {

    node [shape = record,color=green,height=.1]; //node屬性聲明

    edge[color=red]//edge屬性聲明,可以不用分號結尾

    node0/*node語句,定義一個節點,可省略屬性聲明(此時整個node語句可省略),使用默認或最近的一個node語句聲明的屬性。*/

    node2

    node0->node2/*edge語句,定義一條邊,沒有屬性聲明時,使用默認或最近的一個edge聲明語句聲明的屬性。*/

}

 

上面這個例子等同於:

digraph action {

    node [shape = record,color=green,height=.1];

    edge[color=red]

    node0->node2

}

1.4 屬性列表

attr_list:'[' [ a_list ] ']' [ attr_list ]

屬性聲明列表,用中括號“[”“]”將具體的屬性聲明a_list括起來。注意此時的中括號是元字符,不表示語法結構中的可選項。屬性列表後可以再接屬性列表(可選)。後面的attr_list意義同此。

1.5 屬性列表項

a_list:ID '=' ID [ (';' | ',') ] [ a_list ]

屬性列表中括號中具體的屬性聲明。形式上由一個或多個“屬性名ID=值ID”組成,多個屬性聲明間用分號“;”或逗號“,”隔開(可選),如。

digraph action {                                                                                     

    node [shape = record,color=green;height=.1];

    edge[color=red]

    node0->node2

}

屬性列表和聲明可分開寫:

digraph action {

    node [shape = record;color=green][height=.1];

    edge[color=red]

    node0->node2

}

1.6 邊語句

 

edge_stmt:(node_id | subgraphedgeRHS [ attr_list ]

邊語句,定義一條邊,以一個節點ID或一個子圖(非語法要素,滿足subgraph定義即可,後同)開始,後接edgeRHS和該(組)邊的屬性聲明列表(無此列表則與默認或最近的edge屬性聲明一致)。若節點ID未用節點語句定義,則其屬性與默認或最近的node屬性聲明保持一致。

edgeRHS:edgeop (node_id | subgraph) [ edgeRHS ]

首先是邊操作符“->”或“--”,然後是一個節點ID或子圖,edgeRHS可出現一次或多次,即可連續定義,如:

digraph action {

    node [shape = record;color=green][height=.1];

    edge[color=red]

    A->B

    node0->node2->{ C ->D }[color=blue]

}

digraph action {

    node [shape = record,color=red][height=.1];

    node0->node2->{

        node [style=filled color=green]

        C ->D [color=blue]

    } [color=red]

}

要注意區分節點,邊,圖與子圖對象以及它們的層次。

1.7 節點語句與子圖語句

node_stmt:node_id [ attr_list ]

節點語句,由節點ID開始,後接一個屬性聲明列表(可選)。注意,邊語句中節點ID處可以是一個子圖(但不能是子圖ID)。

digraph action {

    node [shape = record,color=red][height=.1];

    node0

    node2

    node0->node2->tt

}

digraph action {

    node [shape = record,color=red][height=.1];

    node0

    node2

    subgraph tt{

        node [style=filled color=green]

        C ->D [color=blue]

    }

    node0->node2->tt

}

subgraph:[ subgraph [ ID ] ] '{' stmt_list '}'

子圖語句,由一個可選的subgraph ID開始(ID也可選),後接大括號“{”“}”,大括號中的內容同前面的stmt_list。子圖可單獨定義,也可以出現在邊語句中,此時不用subgraph ID。

node_id:ID [ port ]

節點ID,由ID名開始,後面可以接一個“port”(可選)。注意,節點ID可以出現在任何節點語句,也可以出現在任何邊語句。

port:':' ID [ ':' compass_pt ]|':' compass_pt

port以一個冒號“:”開始,後跟一個其他ID名和可選的方向指南,或者以一個冒號“:”開始,直接跟一個方向指南,如:

digraph action {

    node [shape = record,height=.1];

    node0 [label = "<head> head|<body> body|<foot> foot", height=.5]

    node2 [shape = box label="mind"]

    node0:body[color=green]

}

digraph action {

    node [shape = record,height=.1];

    node0 [label = "head", height=.5] //節點語句中的節點ID

    node2 [shape = box label="mind"]

    node0:head:n -> node2:n [label = "n"]//邊語句中的節點ID

    node0:head:ne -> node2:ne [label = "ne"]

    //ID:ID:compass_ptàID:compass_pt

    node0:head-> node2:e [label = "e"]

    node0:head:se -> node2:se [label = "se"]

    node0:head:s -> node2:s [label = "s"]

    node0:head:sw -> node2:sw [label = "sw"]

    node0:head:w -> node2:w [label = "w"]

    node0:head:nw -> node2:nw [label = "nw"]

    node0:c -> node2:c [label = "c"]

    node0:_ -> node2:_ [label = "_"]

    node0[style=filled color=orange]//節點語句

}

digraph action {

    node [shape = record,height=.1];

    node0 [label = "<head>head", height=.5]

    node2 [shape = box label="mind"]

    node0:head:n -> node2:n [label = "n"]

    node0:head:ne -> node2:ne [label = "ne"]

    node0:head-> node2:e [label = "e"]

    node0:head:se -> node2:se [label = "se"]

    node0:head:s -> node2:s [label = "s"]

    node0:head:sw -> node2:sw [label = "sw"]

    node0:head:w -> node2:w [label = "w"]

    node0:head:nw -> node2:nw [label = "nw"]

    node0:c -> node2:c [label = "c"]

    node0:_ -> node2:_ [label = "_"]

    node0:head[style=filled color=orange]//這裏的:ID可選,甚至任意

}

compass_pt:(n | ne | e | se | s | sw | w | nw | c | _)

具體的方向指南,如前例所示。

1.8 “=”語句

“=”語句ID '=' ID,類似賦值語句,如:

digraph action {

    //rankdir = LR,此時被註釋

    node [shape=box color=blue]

    edge [color=red]

    node1 // 默認節點屬性

    node2 [color=lightblue] // 定義節點的顏色屬性

    node1 -> node2 // 默認邊屬性

    node2 -> node1 [color=green] // 屬於該邊的屬性

}

digraph action {

    rankdir = LR //“=”語句

    node [shape=box color=blue]

    edge [color=red]

    node1

    node2 [color=lightblue]

    node1 -> node2

    node2 -> node1 [color=green]

}

此例參考文檔:https://www.cnblogs.com/shuqin/p/11897207.html

The keywords node, edge, graph, digraph, subgraph, and strict are case-independent. Note also that the allowed compass point values are not keywords, so these strings can be used elsewhere as ordinary identifiers and, conversely, the parser will actually accept any identifier.

關鍵字node,edge,graph,digraph,subgraph和strict都是case-independent(譯註:具體繪製對象無關的,一個語義對象)。也要注意到可用的方向指南值(譯註:如n、ne、e等)並非關鍵字,所以這些字符串可在其他地方像普通標識符一樣使用,同樣地,在使用它們的地方解析器實際上能接受任意標識符。

An ID is one of the following:

Any string of alphabetic ([a-zA-Z\200-\377]) characters, underscores ('_') or digits ([0-9]), not beginning with a digit;

a numeral [-]?(.[0-9]+ | [0-9]+(.[0-9]*)? );

any double-quoted string ("...") possibly containing escaped quotes (\")[1];

an HTML string (<...>).

一個ID可以是下列形式之一:

由字母[a-zA-Z\200-\377]、下劃線“_”、數字[0-9]構成的字符串,但不能以數字開頭;

 [-]?(.[0-9]+ | [0-9]+(.[0-9]*)? )形式的數字;譯註:?表示0個或1個,+表示1個或多個,*表示0個或多個,如:

digraph numID {

    .3

    -.3456

    -3

    -3456

    3452.

    3452.343

}

任意雙引號字符串,雙引號中可包含轉義引號(“\””)本身 [1];

一個HTML字符串。譯註:如:

digraph structs {

    node[shape=record]

   <html>-><head>

}

雙引號字符串中的HTML串:

digraph structs {

    node[shape=record]

    struct1 [label="<f0> left|<f1> mid\ dle|<f2> right"];

    struct2 [label="{<f0> one|<f1> two\n\n\n}" shape=Mrecord];

    struct3 [label="hello\nworld |{ b |{c|<here> d|e}| f}| g | <f1>h"];

    struct1:f1 -> struct2:f0;

    struct1:f0 -> struct3:f1;

}

此例參考文檔:https://casatwy.com/shi-yong-dotyu-yan-he-graphvizhui-tu-fan-yi.html

An ID is just a string; the lack of quote characters in the first two forms is just for simplicity. There is no semantic difference between abc_2 and "abc_2", or between 2.34 and "2.34". Obviously, to use a keyword as an ID, it must be quoted. Note that, in HTML strings, angle brackets must occur in matched pairs, and newlines and other formatting whitespace characters are allowed. In addition, the content must be legal XML, so that the special XML escape sequences for ", &, <, and > may be necessary in order to embed these characters in attribute values or raw text. As an ID, an HTML string can be any legal XML string. However, if used as a label attribute, it is interpreted specially and must follow the syntax for HTML-like labels.

一個ID就像一個字符串,爲了簡便,前兩種形式的ID不要引號。像abc_2和”abc_2”,2.34和”2.34”之間並沒有語義差別。很明顯,將關鍵字作爲ID,必須加引號。要注意,HTML字符串中尖括號必須成對出現,尖括號中允許換行符或其他格式的空白。此外,HTML串中的內容必須是合法的XML,所以對特定的XML符號如”、&、<、>轉義可能是必須的,以便這些字符能作爲屬性值或原始文本。作爲一個ID,HTML字符串可以任意合法的XML字符串。不管怎樣,如果它用於label屬性,它將被一種特殊方式解析,且必須遵循HTML-like標籤語法。

Both quoted strings and HTML strings are scanned as a unit, so any embedded comments will be treated as part of the strings.

引號字符串和HTML字符串被視爲一個單元,所以其中的任何註釋符將作爲字符串的一部分。

An edgeop is -> in directed graphs and -- in undirected graphs.

一個edgeop(邊操作符)在有向圖中爲“->”,而在無向圖中爲“--”。

The language supports C++-style comments: /* */ and //. In addition, a line beginning with a '#' character is considered a line output from a C preprocessor (e.g., # 34 to indicate line 34 ) and discarded.

DOT語言支持C++風格的註釋“/**/”和“//”。此外,以字符“#”開始的行被視爲C預處理程序輸出行(譯註:如C語言預處理語句)(例如,#34表示內容爲34的行),這樣的行將被丟棄。

Semicolons and commas aid readability but are not required. Also, any amount of whitespace may be inserted between terminals.

分號和逗號增加可讀性但不是必須的。同時,可以在語法要素之間插入任意數量的空白。

As another aid for readability, dot allows double-quoted strings to span multiple physical lines using the standard C convention of a backslash immediately preceding a newline character[2]. In addition, double-quoted strings can be concatenated using a '+' operator. As HTML strings can contain newline characters, which are used solely for formatting, the language does not allow escaped newlines or concatenation operators to be used within them.

作爲另一種可讀性的增強形式,DOT允許雙引號字符串通過在換行符之前使用符合C語言標準語法的反斜線來實現跨行[2]。此外,雙引號字符串可以使用操作符“+”進行連接。由於HTML字符串能包含換行符,這已成單獨成爲一種使用格式,DOT語言不允許在其中使用轉義換行符或連接操作符[3]。

[1]In quoted strings in DOT, the only escaped character is double-quote ("). That is, in quoted strings, the dyad \" is converted to "; all other characters are left unchanged. In particular, \\ remains \\. Layout engines may apply additional escape sequences.

[1]DOT引號字符串中唯一的轉義字符是雙引號(”)。這就是,引號字符串中的連續兩個字符\”將被轉換爲”;所有其他字符保持不變。此外,\\還是\\。佈局引擎可能使用一些其他轉義字符。

[2]Previous to 2.30, the language allowed escaped newlines to be used anywhere outside of HTML strings. The new lex-based scanner makes this difficult to implement. Given the perceived lack of usefulness of this generality, we have restricted this feature to double-quoted strings, where it can actually be helpful.

[2]在2.30版本之前,DOT允許轉義換行符用於HTML字符串之外的任何地方。新的lex-based scanner使這變得難以實現。鑑於察覺到大多數轉義換行符缺乏用處,我們已經將這種特性限制在雙引號字符串,在這裏它將變得更有實效。

[3]譯註:在當前版本中,如http://magjac.com/graphviz-visual-editor/編輯器,關於雙引號字符串與HTML字符串中轉義符的使用見以下例子:

strict digraph {

    //一個HTML字符串作爲ID的節點語句,看左圖

    <ht     //字符t後有隱式換行符,代碼中不能有此註釋

    ml\na+  //顯式換行符\n,+號後有隱式換行符,同上,不能有此註釋

    a>

    //一個雙引號字符串作爲ID的節點語句,看右圖

    "b\+\

    a" /*雙引號字符串隱式換行符之前出現的\是續行符而非轉義符,所以圖中“b…a”在同一行,a前面的空白是代碼中因對齊而出現的空白。b後面的\對符號+轉義的結果仍是+號,說明+是一個普通字符。*/

}

strict digraph {

    //一個html字符串作爲ID的節點語句,看左圖

    <ht

    ml\\na+\

    a>

    //一個雙引號字符串作爲ID的節點語句,看右圖

    "b\n\\\

    a"

}

左圖中,\n這個換行符被轉義,直接顯示,所以不換行,並且+號後的隱式換行符同樣被\(不同於雙引號字符串中的續行符\)轉義不換行。

右圖中,在b號面有一個顯式換行符(可被轉義),接着一個轉義後的符號\,最後的\是續行符。所以第二行是“\  a”。

2、子圖與圖羣

Subgraphs play three roles in Graphviz. First, a subgraph can be used to represent graph structure, indicating that certain nodes and edges should be grouped together. This is the usual role for subgraphs and typically specifies semantic information about the graph components. It can also provide a convenient shorthand for edges. An edge statement allows a subgraph on both the left and right sides of the edge operator. When this occurs, an edge is created from every node on the left to every node on the right. For example, the specification

在graphviz中子圖扮演三種角色。第一,一個子圖用於表徵圖的結構,表明應該組在一起的邊和節點。這是子圖的常見用法,通常用於指明圖各組成部分的語義。這也爲邊提供一種簡便定義。一條邊語句允許邊操作符左右兩邊都是子圖。當這種情形出現時,將會從左子圖每個節點到右子圖每個節點之間創建一條邊。例如,如下說明:

A -> { B C }

is equivalent to

等同於

A -> B

A -> C

 

In the second role, a subgraph can provide a context for setting attributes. For example, a subgraph could specify that blue is the default color for all nodes defined in it. In the context of graph drawing, a more interesting example is:

第二,一個子圖能夠提供一個屬性設置語境。例如,一個子圖可以指定藍色是所有定義於其中的節點默認顏色。在子圖繪製語境中,一個更有趣的例子是:

subgraph {

rank = same; A; B; C;

}

This (anonymous) subgraph specifies that the nodes A, B and C should all be placed on the same rank if drawn using dot.

這個(匿名,沒有名稱ID的)子圖指定節點A,B和C將被放置在同一級,如果使用dot繪圖的話。

譯註:擴展應用,原因後面有介紹

strict digraph {

   A -> { B C }

   subgraph {

    rank = same; A; B; C;

   }

}

strict digraph {

   A -> { B C }

   subgraph {

    rank = same; AA; BB; CC;

   }

}

 

The third role for subgraphs directly involves how the graph will be laid out by certain layout engines. If the name of the subgraph begins with cluster, Graphviz notes the subgraph as a special cluster subgraph. If supported, the layout engine will do the layout so that the nodes belonging to the cluster are drawn together, with the entire drawing of the cluster contained within a bounding rectangle. Note that, for good and bad, cluster subgraphs are not part of the DOT language, but solely a syntactic convention adhered to by certain of the layout engines.

第三,一個子圖直接關係到圖是怎樣被某種佈局引擎排列布置的。如果子圖ID名以cluster開始,graphviz解析它爲特殊的圖羣(cluster subgraph)。如果支持圖羣,佈局引擎將做出所有屬於同一個圖羣的節點被繪製在一起的安排,整個圖羣繪製在一個帶邊矩形中。要注意的是,不管是好是壞,圖羣並不是DOT語言的一部分,而是一種依附於某種佈局引擎的單獨語法規定。

譯註:

strict digraph {

   A -> { B C }

   subgraph cluster123{

    rank = same; A; B; C;

   }

}

3、詞法&語義註解

A graph must be specified as either a digraph or a graph. Semantically, this indicates whether or not there is a natural direction from one of the edge's nodes to the other. Lexically, a digraph must specify an edge using the edge operator -> while a undirected graph must use --. Operationally, the distinction is used to define different default rendering attributes. For example, edges in a digraph will be drawn, by default, with an arrowhead pointing to the head node. For ordinary graphs, edges are drawn without any arrowheads by default.

一個圖必須用digraph或graph聲明。這語義地表明從一條邊的節點到該邊另一個節點是否會有一個自然的方向。從詞法講,有向圖在定義邊的時候用的邊操作符是“à”,而無向圖使用“--”。在操作上這種區別用於定義不同的默認(提供的)屬性。例如,有向圖的邊在繪製時,默認會有一個箭頭指向頭節點。對於普通的無向圖,默認情況下繪製的邊沒有箭頭。

A graph may also be described as strict. This forbids the creation of multi-edges, i.e., there can be at most one edge with a given tail node and head node in the directed case. For undirected graphs, there can be at most one edge connected to the same two nodes. Subsequent edge statements using the same two nodes will identify the edge with the previously defined one and apply any attributes given in the edge statement. For example, the graph

一個圖也可能被描述爲“strict”。這可禁止一條邊的多次重繪。換句話說,有向圖中給定尾節點和頭節點的邊最多隻有一條。對於無向圖,在相同的兩個節點間最多隻有一條邊相連。後面使用相同兩節點的邊語句將會把定義的邊視爲前面定義的那條,並將其中設定的屬性應用其上。例如有一個strict無向圖:

strict graph {

  a -- b

  a -- b

  b -- a [color=blue]

}

will have a single edge connecting nodes a and b, whose color is blue.

這樣的圖在節點a和b之間只有單一的一條邊相連,顏色爲藍色。

If a default attribute is defined using a node, edge, or graph statement, or by an attribute assignment not attached to a node or edge, any object of the appropriate type defined afterwards will inherit this attribute value. This holds until the default attribute is set to a new value, from which point the new value is used. Objects defined before a default attribute is set will have an empty string value attached to the attribute once the default attribute definition is made.

如果用node、edge、graph屬性定義語句定義一個默認屬性,或者通過與節點、邊無關的屬性賦值定義一個默認屬性,那麼後面定義的任何相應類型對象都將繼承這一屬性值。這一直保持到默認屬性被一種新值設置,之後將應用新屬性。在默認屬性被設置之前定義的對象在該默認屬性上的值爲空串,其屬性取決於曾經的默認屬性定義。

Note, in particular, that a subgraph receives the attribute settings of its parent graph at the time of its definition. This can be useful; for example, one can assign a font to the root graph and all subgraphs will also use the font. For some attributes, however, this property is undesirable. If one attaches a label to the root graph, it is probably not the desired effect to have the label used by all subgraphs. Rather than listing the graph attribute at the top of the graph, and the resetting the attribute as needed in the subgraphs, one can simply defer the attribute definition in the graph until the appropriate subgraphs have been defined.

此外還要注意,一個子圖在它定義的時候其屬性來自父圖的屬性設置。這很有用處。例如,一個人可爲根圖指定字體,該圖的所有子圖將使用相同字體。對於一些屬性,不管怎樣,這種特性不是它們需要的。如果爲根圖添加一個label,影響到所有子圖都使用相同標籤可能就並不是需要的。不要在頂層圖設置圖屬性,而是在子圖需要的時候重新設置屬性,能夠很簡單地延遲圖中屬性定義直到相應子圖的出現。

If an edge belongs to a cluster, its endpoints belong to that cluster. Thus, where you put an edge can effect a layout, as clusters are sometimes laid out recursively.

如果一條邊屬於一個圖羣,那麼它的端節點也屬於該圖羣。這樣,一條邊的旋轉能影響一個版面佈置,這是因爲圖羣有時是遞歸佈局的。

There are certain restrictions on subgraphs and clusters. First, at present, the names of a graph and it subgraphs share the same namespace. Thus, each subgraph must have a unique name. Second, although nodes can belong to any number of subgraphs, it is assumed clusters form a strict hierarchy when viewed as subsets of nodes and edges.

子圖和圖羣有一些限制。首先,在當前,圖和子圖共享相同的名稱空間。這樣,每個子圖必須有一個唯一的名字。第二,雖然節點可以屬於任意數量的子圖,當瀏覽節點和邊的子集時圖羣形成一個嚴格等級是要想到的。

4、字符編碼

The DOT language assumes at least the ascii character set. Quoted strings, both ordinary and HTML-like, may contain non-ascii characters. In most cases, these strings are uninterpreted: they simply serve as unique identifiers or values passed through untouched. Labels, however, are meant to be displayed, which requires that the software be able to compute the size of the text and determine the appropriate glyphs. For this, it needs to know what character encoding is used.

DOT語言(本身被)認爲至少是ASCII字符集。引號字符串,無論普通的還是HTML-like的,可能會包含非ASCII字符。大多數情況下,這些字符串將不被解析:它們簡單地充當唯一標識符或值不受影響地被通過。無論怎樣,標籤意味着被顯示,這要求軟件能夠計算文本的尺寸大小並確定相應的字形。爲此,軟件需要知道使用的是哪種字符編碼。

By default, DOT assumes the UTF-8 character encoding. It also accepts the Latin1 (ISO-8859-1) character set, assuming the input graph uses the charset attribute to specify this. For graphs using other character sets, there are usually programs, such as iconv, which will translate from one character set to another.

默認情況下,DOT假定是UTF-8字符編碼。它也接受Latin1 (ISO-8859-1)字符集,可通過輸入圖時使用charset屬性指明該編碼。對於使用其他字符集的圖而言,有一些常用程序,比如iconv,可以將一種字符集轉換成另一種字符集。

Another way to avoid non-ascii characters in labels is to use HTML entities for special characters. During label evaluation, these entities are translated into the underlying character. This table shows the supported entities, with their Unicode value, a typical glyph, and the HTML entity name. Thus, to include a lower-case Greek beta into a string, one can use the ascii sequence &beta;. In general, one should only use entities that are allowed in the output character set, and for which there is a glyph in the font.

在標籤中避免使用非ASCII字符的另一種方式是爲特殊字符使用HTML實體字符。在對標籤處理時,這些實體字符被轉換成基本字符。下面這張表顯示出受支持的實體字符,包括它們的Unicode值,常見字形,以及HTML實體字符名。

爲此,要使字符串包含小寫希臘字符β,可以使用ASCII序列&beta;。一般來講,只能使用輸出字符集中允許的實體字符,並且該實體字符在字體中有相應字形。

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章