单元格样式及其操作符

您可以通过在单元格的描述符中添加一个样式操作符来设置单个单元格中所有内容的样式。

Unresolved directive in format-cell-content.adoc - include::partial$style-operators.adoc[]

当样式操作符没有明确分配给单元格指定器(或列指定器xref:format-column-content.adoc),单元格将回退到默认的(d)样式,并作为常规段落文本进行处理。

应用样式到表格单元格

样式运算符总是在单元格指定符中最后输入。在`|`和运算符之间不要插入任何空格。

<factor><span or duplication operator><horizontal alignment operator><vertical alignment operator><style operator>|<cell’s content>

让我们对对单元格应用样式操作符中的每个单元应用一个样式操作符。

对单元格应用样式操作符
Unresolved directive in format-cell-content.adoc - include::example$cell.adoc[tag=styles]

来自对单元格应用样式操作符的表格如下所示。

Unresolved directive in format-cell-content.adoc - include::example$cell.adoc[tag=styles]

覆盖单元格上的列样式

当你把样式操作符赋予一个单元格时,它将覆盖列的样式操作符。在使用单元格样式操作符覆盖列样式中,分配给第一列的样式操作符在两个单元格上被覆盖。标题行也会覆盖样式操作符。然而,内联格式化标记会另外被应用,作为操作符指定样式的补充。

使用单元格样式操作符覆盖列样式
|===
[cols="m,m"] (1)
|Column 1, header row |Column 2, header row (2)

|This content is rendered using a monospace font because the column's specifier includes the `m` operator.
|This content is rendered using a monospace font because the column's specifier includes the `m` operator.

s|This content is rendered as bold paragraph text because the `s` operator in the cell's specifier overrides the style operator in the column specifier. (3)
|*This content is rendered using a monospace font because the column's specifier includes the `m` operator.
It's also bold because it's marked up with the inline syntax for bold formatting.* (4)

d|This content is rendered as regular paragraph text because the `d` operator in the cell's specifier overrides the style operator in the column specifier. (5)
|This content is rendered using a monospace font because the column's specifier includes the `m` operator.
|===
  1. 单间距操作符(m)被分配给了这两列。

  2. 表头行会忽略通过列或单元格指定的任何样式操作符。

  3. 强调操作符(s)被分配给该单元格的指定符,覆盖了列的单间距样式。

  4. 内联格式化将应用于通过列指定符分配的样式之上。

  5. 默认操作符(d)被分配给了该单元格的指定符,将其重置为默认文本样式。

.Result of 使用单元格样式操作符覆盖列样式 [cols="m,m"]

Column 1, header row

Column 2, header row

This content is rendered using a monospace font because the column’s specifier includes the m operator.

This content is rendered using a monospace font because the column’s specifier includes the m operator.

This content is rendered as bold paragraph text because the s operator in the cell’s specifier overrides the style operator in the column specifier.

This content is rendered using a monospace font because the column’s specifier includes the m operator. It’s also bold because it’s marked up with the inline syntax for bold formatting.

This content is rendered as regular paragraph text because the d operator in the cell’s specifier overrides the style operator in the column specifier.

This content is rendered using a monospace font because the column’s specifier includes the m operator.

在表格单元格中使用AsciiDoc块元素

要在单元格中使用AsciiDoc块元素,例如限定的源代码块和列表,请直接在单元格的分隔符 (|) 前放置 a 运算符。不要在 | 和运算符之间插入任何空格。

应用AsciiDoc块样式操作符到两个单元格。
Unresolved directive in format-cell-content.adoc - include::example$cell.adoc[tag=adoc]

Unresolved directive in format-cell-content.adoc - include::example$cell.adoc[tag=adoc]

AsciiDoc表格单元实际上创建了一个嵌套文档。因此,它从父文档继承属性。如果父文档中设置或明确取消了某个属性,那么在AsciiDoc表格单元中就_无法_修改该属性。有少数例外可以违反这一规则,包括doctype、toc、notitle(及其补充,showtitle)和compat-mode。在AsciiDoc表格中新定义的任何属性不会影响父文档中的属性。相反,这些属性仅限于表格单元的范围内。