简体   繁体   English

Asciidoc角色和gitbook

[英]Asciidoc roles and gitbook

I'm trying to use Gitbook with AsciiDoc (running Win10x64, NodeJS 6.9.1 and Gitbook v3.2.2) — I'm new to both of them. 我正在尝试将Gitbook与AsciiDoc(运行Win10x64,NodeJS 6.9.1和Gitbook v3.2.2)一起使用-我对两者都是陌生的。

The Gitbook documentation says AsciiDoc is supported since v2.0.0 and links to the AsciiDoctor documentation — I've checked the node packages, gitbook depends on gitbook-asciidoc which in turn depends on asciidoctor.js . Gitbook文档说从 v2.0.0开始支持AsciiDoc并链接到AsciiDoctor文档 -我已经检查了节点包, gitbook依赖gitbook-asciidoc ,而gitbook-asciidoc依赖于asciidoctor.js

According to the documentation, AsciiDoc roles can be used to style both images and tables. 根据文档,AsciiDoc角色可用于设置图像和表格的样式。 They refer to classes that are applied to the HTML element, these classes being defined in the default AsciiDoctor sytlesheet. 它们引用应用于HTML元素的类,这些类在默认的AsciiDoctor sytlesheet中定义。

But no matter how I try to apply a role, for example to an image (the [.text-center] shorthand or [role="text-center"] , I don't get the expected output (ie the image horizontally centered). The only way I can make it work for the image is by setting an attribute align="center", which is even not documented. 但是,无论我如何尝试将角色应用于图像(例如[.text-center]简写形式或[role="text-center"] ,我都无法获得预期的输出(即,图像水平居中)。使它适用于图像的唯一方法是设置属性align =“ center”,甚至没有记录。

By inspecting the output in my browser I can see that classes are applied to the HTML elements but there's no matching CSS rules — the same goes for table styling as far as I've tried. 通过查看浏览器中的输出,我可以看到将类应用于HTML元素,但是没有匹配的CSS规则-就我尝试过的表样式而言,同样如此。

What am I missing here about the AsciiDoctor roles and stylesheets? 我在这里缺少有关AsciiDoctor角色和样式表的信息吗?

EDIT : asciidoctor.js is a devDependency of gitbook and is actually not installed with gitbook . 编辑asciidoctor.js是gitbook的gitbook ,实际上并未与gitbook安装。 The align="center" is documented in the AsciiDoc documentation but other features like table styling (at least the frame="none" and grid="none" ) don't seem to work with gitbook . align="center"已在AsciiDoc文档中进行了说明,但其他功能(如表格样式)(至少是frame="none"grid="none" )似乎不适用于gitbook

I still don't get why Gitbook documentation links back to the AsciiDoctor's one if it's not supported… 我仍然不明白为什么如果不支持Gitbook文档会链接回AsciiDoctor的文档……

When you use AsciiDoc syntax in GitBook, AsciiDoctor is used to transform the AsciiDoc syntax into HTML. 在GitBook中使用AsciiDoc语法时,AsciiDoctor用于将AsciiDoc语法转换为HTML。 The HTML then uses GitBook CSS, because you're using a GitBook theme rather than an AsciiDoctor theme. 然后,HTML使用GitBook CSS,因为您使用的是GitBook主题而不是AsciiDoctor主题。 That means that you don't get the default AsciiDoctor styling. 这意味着您不会获得默认的AsciiDoctor样式。

It's easy to add your own styles in GitBook. 在GitBook中添加自己的样式很容易。 In your book.json , specify an additional stylesheet: book.json ,指定其他样式表:

"styles": {
  "website": "styles/mystyles.css"
},

Then, create styles/mystyles.css so that it contains the CSS styles that you want to use: 然后,创建styles/mystyles.css ,使其包含您要使用的CSS样式:

.text-center {
  text-align: center;
}

You can copy styles from the AsciiDoctor stylesheet into styles/mystyles.css , but be prepared to tweak the styles and classes to work within the GitBook theme that you're using. 您可以将样式从AsciiDoctor样式表复制到styles/mystyles.css ,但要做好调整样式和类的准备,以便在您使用的GitBook主题中使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM