1

可以将特定的类添加到 asciidoc 中的表中,如下所示:

ASCIIDOC

[.custom]
[cols="40a,80a",options="header"]
|===

|First Name
|Family Name

|John
|Smith

|==

HTML(在 Antora 运行之后)

<table class="tableblock frame-all grid-all stretch custom">
..
..
<thead>
<tr>
<th class="tableblock halign-left valign-top"><strong>First Name</strong></th>
<th class="tableblock halign-left valign-top"><strong>Family Name</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph"><p>John</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph"><p>Smith</p></div></div></td>
</tr>

因此,“自定义”的“角色”已应用于 <table> 元素。但是,我还想为 <th>、<tr> 和 <td> 元素指定特定属性。我该怎么做呢 ?

我尝试过:

|[.custom]First Name

对于第一个元素,并且:

|[.custom]John

对于 td 元素

但这只会在转换为 html 时给我以下信息:

<th class="tableblock halign-left valign-top"><strong class="custom">First Name</strong> 
</th>
..
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph"><p>[.custom]John</p></div></div></td>

我如何实现以下目标:

<th class="tableblock halign-left valign-top custom"><strong>First Name</strong></th>

<tr class="tableblock halign-left valign-top custom"><div class="content"><div class="paragraph"><p>John</p></div></div></td>
4

1 回答 1

0

您应该为内联角色使用分隔符,以确保它们的解析一致。例如:

| [.custom]*John*
| [.specific]`Woo`

分隔符会影响生成的 HTML,因此第一个实例生成一个<strong>标记,第二个实例生成一个<code>块。两者都有指定的类。

不幸的是,该角色适用于文本内容,而不是<th>or <td>。目前无法为单元格本身指定角色。

为了实现您想要的展示,您必须使用基于表格类的 CSS 选择器。这需要将自定义 CSS 添加到您的 Antora UI。也许是这样的:

table.custom th, table.custom td {
 /* appropriate styles */
}
于 2021-06-10T23:43:17.137 回答