使用 asciidoc 时,有什么方法可以更改特定块的文本大小(字体大小)?
Is there any way to change the text size (font size) of specific blocks when you using asciidoc?
我需要你的帮助。
现在我正在使用 AsciiDoc 和 AsciiDoctor 创建一些手册。
我希望某些特定块上的文本更小,例如宽 table、宽列表等,但不希望主文本更小。
特别是我需要根据客户的要求将宽 table 的文本变小。
有什么办法吗?
我读了一些关于
- [small] 和 [%autofit] 选项 https://github.com/asciidoctor/asciidoctor-pdf/issues/185 我从来不需要它,也许你可以试一试。
示例代码
[small]
----
should be rendered in smaller font.
----
[%autofit]
----
really long text that doesn't want to fit on a single line with the default font size, so we'll make it shrink to fit.
----
您提到列表和 tables...
关于列表,不能像AsciiDoctor Documentation:
中说的那样做
Unsupported
Complex AsciiDoc markup is not permitted in attribute values, such as:
lists
multiple paragraphs
other whitespace-dependent markup types
如您所见,它提到了多个段落,因此虽然@EhmKah 的回答是设置自定义样式块的正确方法,但它不会在 table/list 中按预期呈现,因为它是多段的-段落。
内置 CSS class 语法 是要走的路 [small]#any phrases#
但是 为了在 table 中工作,您必须使用 说明符 设置单元格类型,在这种情况下,AsciiDoc 说明符 表示为 a
这意味着单元格(或列)将呈现支持的 AsciiDoc 语句、属性等。
这是一个工作示例:
[frame="none",grid="none"]
|====
a| image::images\logo.png[] a|[.small]#Autor: {author}#
|====
如果您有大量 rows/columns,则不必手动将 a
应用到所有这些。您可以通过这种方式设置您需要此行为的列:
[cols="1a,2a",frame="none",grid="none"]
|====
| image::images\logo.png[] |[.small]#Autor: {author}#
|====
您可以查看其文档以获取更多关于 Column Formatting 的信息,您可以查看 Rendered table with variable widths and alignments 子部分以获取有关 AsciiDoc 的更多信息(a
) 和其他说明符。
docinfo.html
+ --attribute docinfo=shared
您可以将 CSS 修改放入名为 docinfo.html
:
的文件中
<style>
/* Your custom CSS. */
</style>
然后构建:
asciidoctor --attribute docinfo=shared README.adoc
这使得 Asciidoctor 2.0.10 将 docinfo.html
放在 <head>
元素的底部。
因此您可以从那里覆盖大部分默认的 Asciidoctor 样式。
那么只需要了解生成的 HTML 和以前的样式定义即可覆盖它们。
对于 image
具体而言,另请参阅:How to set a custom image height for an image in Asciidoctor?
当你使用一个主题文件时,你可以像这样给它添加一个角色:
role:
mycustomfont:
font-color: #333
font-size: 10
现在您可以直接从 table 单元格引用您新创建的角色:
a|[.mycustomfont]# some text #
我需要你的帮助。
现在我正在使用 AsciiDoc 和 AsciiDoctor 创建一些手册。
我希望某些特定块上的文本更小,例如宽 table、宽列表等,但不希望主文本更小。 特别是我需要根据客户的要求将宽 table 的文本变小。
有什么办法吗?
我读了一些关于
- [small] 和 [%autofit] 选项 https://github.com/asciidoctor/asciidoctor-pdf/issues/185 我从来不需要它,也许你可以试一试。
示例代码
[small]
----
should be rendered in smaller font.
----
[%autofit]
----
really long text that doesn't want to fit on a single line with the default font size, so we'll make it shrink to fit.
----
您提到列表和 tables... 关于列表,不能像AsciiDoctor Documentation:
中说的那样做Unsupported Complex AsciiDoc markup is not permitted in attribute values, such as:
lists
multiple paragraphs
other whitespace-dependent markup types
如您所见,它提到了多个段落,因此虽然@EhmKah 的回答是设置自定义样式块的正确方法,但它不会在 table/list 中按预期呈现,因为它是多段的-段落。
内置 CSS class 语法 是要走的路 [small]#any phrases#
但是 为了在 table 中工作,您必须使用 说明符 设置单元格类型,在这种情况下,AsciiDoc 说明符 表示为 a
这意味着单元格(或列)将呈现支持的 AsciiDoc 语句、属性等。
这是一个工作示例:
[frame="none",grid="none"]
|====
a| image::images\logo.png[] a|[.small]#Autor: {author}#
|====
如果您有大量 rows/columns,则不必手动将 a
应用到所有这些。您可以通过这种方式设置您需要此行为的列:
[cols="1a,2a",frame="none",grid="none"]
|====
| image::images\logo.png[] |[.small]#Autor: {author}#
|====
您可以查看其文档以获取更多关于 Column Formatting 的信息,您可以查看 Rendered table with variable widths and alignments 子部分以获取有关 AsciiDoc 的更多信息(a
) 和其他说明符。
docinfo.html
+ --attribute docinfo=shared
您可以将 CSS 修改放入名为 docinfo.html
:
<style>
/* Your custom CSS. */
</style>
然后构建:
asciidoctor --attribute docinfo=shared README.adoc
这使得 Asciidoctor 2.0.10 将 docinfo.html
放在 <head>
元素的底部。
因此您可以从那里覆盖大部分默认的 Asciidoctor 样式。
那么只需要了解生成的 HTML 和以前的样式定义即可覆盖它们。
对于 image
具体而言,另请参阅:How to set a custom image height for an image in Asciidoctor?
当你使用一个主题文件时,你可以像这样给它添加一个角色:
role:
mycustomfont:
font-color: #333
font-size: 10
现在您可以直接从 table 单元格引用您新创建的角色:
a|[.mycustomfont]# some text #