Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use spring-asciidoctor-backends

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article focuses on "how to use spring-asciidoctor-backends". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use spring-asciidoctor-backends.

Functional highlight

Spring official product, easy to use

Responsive design to support computer / mobile phone

Dark mode

Other extended features such as Tabs / Code Folding / Code Chomping

Introduction to Asciidoc

Use AsciiDoc for document markup. Really. It's actually readable by humans, easier to parse and way more flexible than XML. -Linus Torvalds

To put it simply, Asciidoc can be understood as an enhanced version of Markdown.

Asciidoctor is responsible for parsing Asciidoc documents and finally generating documents in HTML 5, DocBook 5, manual pages, PDF, and EPUB 3 and other formats.

It has automatic TOC, complex tables (cell merging), cross references cross-article anchor references, footnotes, Document Attributes document variables and other functions.

Using Asciidoc in Java projects, you can better combine document files with code files, and through Asciidoctor Maven/Gradle plug-ins, you can better integrate with CI/CD.

Getting Started

Take the Gradle project as an example. Refer to spring-asciidoctor-backends document and Asciidoctor Gradle Plugin document for specific parameters.

Add Asciidoctor plug-in plugins {id 'java' id' java-library' id 'org.asciidoctor.jvm.convert' version' 3.3.0' id 'org.asciidoctor.jvm.pdf' version' 3.3.0' id 'org.asciidoctor.jvm.epub' version' 3.3.0'} add spring repo

So far, spring-asciidoctor-backends is still in the spring milestone warehouse.

Repositories {maven {url 'https://maven.aliyun.com/repository/central'} mavenCentral () maven {url "https://repo.spring.io/milestone"} maven {url" https://repo.spring.io/release"}} configure asciidoctorExtensionsext {indexFileName =' index.adoc' springAsciidoctorVersion = '0.0.1 Murray M1'} configurations {asciidoctorExtensions} dependencies {asciidoctorExtensions "io.spring.asciidoctor.backends:spring-asciidoctor-backends:$ {springAsciidoctorVersion} "} configure asciidoctor taskasciidoctor {baseDirFollowsSourceDir () sources {include project.ext.indexFileName} resources {from (sourceDir) {include 'images/**'}} outputDir file (" $buildDir/asciidoc ") configurations" asciidoctorExtensions "outputOptions {backends" spring-html "}}

Sources {} configures the files to be converted, which can be adjusted by yourself.

Replace html document logo

The default logo is Spring and cannot be directly configured and modified. For more information, please see issue

We can use Gradle task to replace the pictures after packing.

Add your own svg picture, src/docs/asciidoc/images/banner-logo.svg

Configure Gradle for picture replacement

Asciidoctor.doLast {delete file ("$buildDir/asciidoc/img/banner-logo.svg") copy {from file ("$buildDir/asciidoc/images/banner-logo.svg") into file ("$buildDir/asciidoc/img")}} configure pdf output

Download ttf font, using Sarasa-Gothic boldface and JetBrainsMono font

Put it in the src/docs/asciidoc/fonts directory

Custom pdf theme src/docs/asciidoc/themes/sc-theme.yml

Add pdf related document parameters to the document, where: pdf-theme: sc corresponds to the sc-theme.yml name

: pdf-theme: sc:pdf-fontsdir: fonts:pdf-themesdir: themes

Configure asciidoctorPdf task

AsciidoctorPdf {baseDirFollowsSourceDir () sources {include project.ext.indexFileName} resources {from (sourceDir) {include 'images/**'}} outputDir file ("$buildDir/asciidoc")} package

Customize task and package resources

Task tarIndexPage (type: Tar) {description 'package html and pdf' dependsOn asciidoctor, asciidoctorPdf archiveFileName = "index.tar.gz" destinationDirectory = file ("$buildDir/dist") compression = Compression.GZIP from "$buildDir/asciidoc"}

Packing

. / gradlew clean tarIndexPage at this point, I believe you have a deeper understanding of "how to use spring-asciidoctor-backends". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report