备注:
   次文档参考github 例子
 
1.环境准备
node npm (yarn) java  KindleGen
备注: 具体的安装可以参考网上相关文档,KindleGen 下载地址:https://www.amazon.com/gp/feature.html?docId=1000765211
2. 代码&&运行
a. git clone code
git clone https://github.com/mraible/infoq-mini-book.git
修改build.sh 中 KindleGen 位置比如我的在 /opt/kind/kindlegen
b. build
./build.sh //epub html
./generate-pdf.sh pdf
3. 构建结果
build
└── asciidoc
├── epub3
│ └── images
└── html5
└── images
4. 效果
 
5. 代码结构解析
备注: 主要说明asciidoc 代码
src/docs 主要是文档以及需要的图片资源 └── asciidoc
├── chapters
├── images
└── styles
├── epub
│   └── fonts
└── pdf
└── fonts
build.gradle gradle 构建 task buildscript {
repositories {
jcenter()
} dependencies {
classpath 'com.github.ben-manes:gradle-versions-plugin:0.15.0'
classpath 'com.bluepapa32:gradle-watch-plugin:0.1.5'
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.3'
classpath 'org.asciidoctor:asciidoctorj-epub3:1.5.0-alpha.7'
classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.16'
classpath 'org.jruby:jruby-complete:9.1.12.0'
}
} apply plugin: 'java'
apply plugin: 'org.asciidoctor.convert'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'com.bluepapa32.watch' version = '4.1.0-SNAPSHOT' asciidoctorj {
version = '1.5.6'
} import org.asciidoctor.gradle.AsciidoctorTask def attrs = ['sourcedir' : '../../../main/webapp',
'source-highlighter': 'coderay',
'epub3-stylesdir' : './styles/epub',
// NOTE don't include leading ./ because it messes up paths in the epub files
'imagesdir' : 'images',
'toc' : 'left',
'icons' : 'font',
'sectanchors' : '',
'idprefix' : '',
'idseparator' : '-'] tasks.withType(AsciidoctorTask) { task ->
attributes attrs
sources {
include 'index.adoc'
}
} task html(type: AsciidoctorTask, description: 'Generates single page HTML') {
backends 'html5'
} // NOTE please use ./generate-pdf.sh instead of this task for now
task prepress(type: AsciidoctorTask, description: 'Generates PDF for prepress printing') {
attributes attrs + ['media' : 'prepress', 'pdfmarks': '', 'pdf-theme': 'infoq-prepress']
attrs.remove('source-highlighter')
requires file('src/main/ruby/asciidoctor-pdf-extensions.rb')
backends 'pdf'
outputDir "$buildDir/asciidoc/pdf-prepress"
separateOutputDirs false
} // NOTE please use ./generate-pdf.sh screen instead of this task for now
task pdf(type: AsciidoctorTask, description: 'Generates PDF') {
attributes attrs + ['pdfmarks': '']
requires file('src/main/ruby/asciidoctor-pdf-extensions.rb')
backends 'pdf'
} task epub(type: AsciidoctorTask, description: 'Generates EPUB3') {
backends 'epub3'
} task mobi(type: AsciidoctorTask, description: 'Generates MOBI') {
backends 'epub3'
attrs.put('ebook-format', 'kf8')
attributes attrs
} pdf.shouldRunAfter html
epub.shouldRunAfter pdf //task all(dependsOn: ['html', 'pdf', 'epub', 'mobi'])
task all(dependsOn: ['html', 'epub', 'mobi']) defaultTasks 'all' watch {
asciidoc {
files fileTree(dir: 'src/docs/asciidoc', include: '**/*.adoc')
tasks 'asciidoctor'
}
}
6. 参考资料
https://www.amazon.com/gp/feature.html?docId=1000765211
http://asciidoctor.org/docs/asciidoctor-gradle-plugin/
https://github.com/asciidoctor/asciidoctor-maven-plugin
 
 
 
 

gradle asciidoc 使用的更多相关文章

  1. Gradle环境下导出Swagger为PDF

    更多精彩博文,欢迎访问我的个人博客 说明 我个人是一直使用Swagger作为接口文档的说明的.但是由于在一些情况下,接口文档说明需要以文件的形式交付出去,如果再重新写一份文档难免有些麻烦.于是在网上看 ...

  2. 在gradle中构建java项目

    目录 简介 构建java项目的两大插件 管理依赖 编译代码 管理resource 打包和发布 生成javadoc 简介 之前的文章我们讲到了gradle的基本使用,使用gradle的最终目的就是为了构 ...

  3. Gradle配置APK自动签名完整流程

    转载请注明出处:http://www.cnblogs.com/LT5505/p/6256683.html 一.生成签名 1.命令行生成签名,输入命令keytool -genkey -v -keysto ...

  4. gradle学习笔记(1)

    1. 安装     (1) 下载最新gradle压缩包,解压到某处.地址是:Gradle web site:     (2) 添加环境变量:             1) 变量名:GRADLE_HOM ...

  5. Gradle 实现 Android 多渠道定制化打包

    Gradle 实现 Android 多渠道定制化打包 版权声明:本文为博主原创文章,未经博主允许不得转载. 最近在项目中遇到需要实现 Apk 多渠道.定制化打包, Google .百度查找了一些资料, ...

  6. 解决 Could not find com.android.tools.build:gradle 问题

    今天拉同事最新的代码,编译时老是报如下错误: Error:Could not find com.android.tools.build:gradle:2.2.0.Searched in the fol ...

  7. React Native Android gradle下载慢问题解决

    很多人会遇到 初次运行 react-native run android的时候 gradle下载极慢,甚至会失败的问题 如下图 实际上这个问题好解决的 首先 把对应版本的gradle下载到本地任意一个 ...

  8. Android studio使用gradle动态构建APP(不同的包,不同的icon、label)

    最近有个需求,需要做两个功能相似的APP,大部分代码是一样的,只是界面不一样,以前要维护两套代码,比较麻烦,最近在网上找资料,发现可以用gradle使用同一套代码构建两个APP.下面介绍使用方法: 首 ...

  9. 对Maven、gradle、svn、spring 3.0 fragment、git的想法

    1.Maven Maven可以构建项目,采用pom方式配置主项目和其他需要引用的项目.同时可结合spring3.0的新特性web  fragment. 从现实出发,特别是对于管理不到位,程序员整体素质 ...

随机推荐

  1. Angular----安置物流项目前端框架经验总结

    一.架构方面 (一) Angular框架有service .controller层: 在Angular里面,services作为单例对象在需要到的时候被创建,只有在应用生命周期结束的时候(关闭浏览器) ...

  2. Graphviz(转载)

    简述 原文: http://www.tuicool.com/articles/vy2Ajyu 本文翻译自 Drawing Graphs using Dot and Graphviz 1. 许可 Cop ...

  3. JAVA常用数据结构API

    Quene

  4. VS2013 VC++的.cpp文件调用CUDA的.cu文件中的函数

    CUDA 8.0在函数的调用中方便的让人感动.以下是从网上学到的VC++的.cpp文件调用CUDA的.cu文件中的函数方法,和一般的VC++函数调用的方法基本没差别. 使用的CUDA版本为CUDA 8 ...

  5. 二十、dbms_stats(用于搜集,查看,修改数据库对象的优化统计信息)

    1.概述 作用:用于搜集,查看,修改数据库对象的优化统计信息. 2.包的组成 1).get_column_stats作用:用于取得列的统计信息语法:dbms_stats.get_column_stat ...

  6. Linux下使用Opencv打开笔记本摄像头

    新建test文件夹,文件夹存在test.cpp和CMakeLists.txt test.cpp#include <iostream> #include <string> #in ...

  7. 哈工大LTP语言分析:分词、词性标注、句法分析等

    1. LTP介绍和安装 LTP语言云官网  在线演示 | 语言云(语言技术平台云 LTP-Cloud) 安装LTP的python接口包 $ sudo pip install pyltp 模型文件下载 ...

  8. python常用模块之json、pickle模块

    python常用模块之json.pickle模块 什么是序列化? 序列化就是把内存里的数据类型转换成字符,以便其能存储到硬盘或者通过网络进行传输,因为硬盘或网络传输时只接受bytes. 为什么要序列化 ...

  9. runtime 知识点

    demo https://github.com/ZOYOOPlus/runtime2 // //  ViewController.m //  runtime //  Copyright © 2017年 ...

  10. iOS9的新特性以及适配方案-----转载

    2015年9月8日,苹果宣布iOS 9操作系统的正式版在太平洋时间9月16日正式推出,北京时间9月17日凌晨1点推送. 新的iOS 9系统比iOS8更稳定,功能更全面,而且还更加开放.iOS 9加入了 ...