├── .editorconfig ├── .github ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md ├── dependabot.yml └── workflows │ ├── build-maven-4.yaml │ ├── build.yaml │ ├── deploy-docs.yml │ └── release.yaml ├── .gitignore ├── .mvn └── wrapper │ └── maven-wrapper.properties ├── CHANGELOG.adoc ├── LICENSE.txt ├── README.adoc ├── README_zh-CN.adoc ├── asciidoctor-converter-doxia-module ├── pom.xml └── src │ ├── it │ └── maven-site-plugin │ │ ├── invoker.properties │ │ ├── pom.xml │ │ ├── src │ │ └── site │ │ │ ├── asciidoc │ │ │ ├── _include.adoc │ │ │ ├── file-with-toc.adoc │ │ │ ├── sample.asciidoc │ │ │ └── templates │ │ │ │ └── paragraph.html.slim │ │ │ └── site.xml │ │ └── validate.groovy │ ├── main │ └── java │ │ └── org │ │ └── asciidoctor │ │ └── maven │ │ └── site │ │ ├── AsciidoctorConverterDoxiaParser.java │ │ ├── AsciidoctorConverterDoxiaParserModule.java │ │ └── SiteConverterDecorator.java │ └── test │ ├── java │ └── org │ │ └── asciidoctor │ │ └── maven │ │ └── site │ │ ├── AsciidoctorConverterDoxiaParserTest.java │ │ └── SiteConverterDecoratorTest.java │ └── resources │ ├── errors │ ├── document-with-invalid-reference.adoc │ └── document-with-missing-include.adoc │ ├── includes │ ├── asciidoctor-icon.jpg │ ├── groovy-include.groovy │ └── new-include.adoc │ ├── main-document.adoc │ ├── sample.asciidoc │ ├── templates │ └── block_paragraph.html.slim │ └── with-locale │ └── en │ └── asciidoc │ ├── included.adoc │ └── sample.adoc ├── asciidoctor-maven-commons ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── asciidoctor │ │ └── maven │ │ ├── commons │ │ ├── AsciidoctorHelper.java │ │ └── StringUtils.java │ │ ├── log │ │ ├── CapturedLogRecord.java │ │ ├── FailIf.java │ │ ├── LogHandler.java │ │ ├── LogRecordFormatter.java │ │ ├── LogRecordsProcessors.java │ │ └── MemoryLogHandler.java │ │ └── site │ │ ├── HeadParser.java │ │ ├── HeaderMetadata.java │ │ ├── LogHandlerFactory.java │ │ ├── SiteBaseDirResolver.java │ │ ├── SiteConversionConfiguration.java │ │ ├── SiteConversionConfigurationParser.java │ │ └── SiteLogHandlerDeserializer.java │ └── test │ └── java │ └── org │ └── asciidoctor │ └── maven │ ├── commons │ ├── AsciidoctorHelperTest.java │ └── StringUtilsTest.java │ ├── log │ ├── CapturedLogRecordTest.java │ ├── LogRecordFormatterTest.java │ ├── LogRecordsProcessorsTest.java │ ├── MemoryLogHandlerTest.java │ ├── TestCursor.java │ └── TestLogRecords.java │ └── site │ ├── HeadParserTest.java │ ├── HeaderMetadataTest.java │ ├── SiteBaseDirResolverTest.java │ ├── SiteConversionConfigurationParserTest.java │ ├── SiteLogHandlerDeserializerTest.java │ └── Xpp3DoomBuilder.java ├── asciidoctor-maven-plugin ├── pom.xml └── src │ ├── it │ ├── article-html-command │ │ ├── invoker.properties │ │ ├── pom.xml │ │ ├── src │ │ │ └── main │ │ │ │ └── doc │ │ │ │ └── sample.asciidoc │ │ └── validate.groovy │ ├── article-html │ │ ├── invoker.properties │ │ ├── pom.xml │ │ ├── src │ │ │ └── main │ │ │ │ └── doc │ │ │ │ └── sample.asciidoc │ │ └── validate.bsh │ ├── book-html │ │ ├── invoker.properties │ │ ├── pom.xml │ │ ├── src │ │ │ └── main │ │ │ │ └── doc │ │ │ │ └── sample.asciidoc │ │ └── validate.bsh │ ├── convert-with-minimal-configuration │ │ ├── invoker.properties │ │ ├── pom.xml │ │ ├── src │ │ │ └── docs │ │ │ │ └── asciidoc │ │ │ │ └── sample.asciidoc │ │ └── validate.groovy │ ├── inject-attributes-from-maven-pom │ │ ├── invoker.properties │ │ ├── pom.xml │ │ ├── src │ │ │ └── docs │ │ │ │ └── asciidoc │ │ │ │ └── attributes-example.adoc │ │ └── validate.groovy │ ├── rendering-single-html-with-relative-outputDirectory-and-outputFile │ │ ├── invoker.properties │ │ ├── pom.xml │ │ ├── src │ │ │ └── main │ │ │ │ └── doc │ │ │ │ └── sample.asciidoc │ │ └── validate.groovy │ ├── rendering-single-html-with-relative-outputFile │ │ ├── invoker.properties │ │ ├── pom.xml │ │ ├── src │ │ │ └── main │ │ │ │ └── doc │ │ │ │ └── sample.asciidoc │ │ └── validate.groovy │ ├── spi-registered-log │ │ ├── asciidoctor-project │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── doc │ │ │ │ └── sample.asciidoc │ │ ├── invoker.properties │ │ ├── log-handler │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── java │ │ │ │ └── org │ │ │ │ │ └── asciidoctor │ │ │ │ │ └── maven │ │ │ │ │ └── test │ │ │ │ │ └── TestLogHandlerService.java │ │ │ │ └── resources │ │ │ │ └── META-INF │ │ │ │ └── services │ │ │ │ ├── _org.asciidoctor.extension.spi.ExtensionRegistry │ │ │ │ └── org.asciidoctor.log.LogHandler │ │ ├── pom.xml │ │ └── validate.groovy │ ├── thread-safe │ │ ├── asciidoctor-project-1 │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── doc │ │ │ │ └── sample.asciidoc │ │ ├── asciidoctor-project-2 │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── doc │ │ │ │ └── sample.asciidoc │ │ ├── asciidoctor-project-3 │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── doc │ │ │ │ └── sample.asciidoc │ │ ├── invoker.properties │ │ ├── pom.xml │ │ └── validate.groovy │ └── uses-html5-as-default-backend │ │ ├── invoker.properties │ │ ├── pom.xml │ │ ├── src │ │ └── docs │ │ │ └── asciidoc │ │ │ └── sample.asciidoc │ │ └── validate.groovy │ ├── main │ ├── java │ │ └── org │ │ │ └── asciidoctor │ │ │ └── maven │ │ │ ├── AsciidoctorHttpMojo.java │ │ │ ├── AsciidoctorJFactory.java │ │ │ ├── AsciidoctorMaven.java │ │ │ ├── AsciidoctorMojo.java │ │ │ ├── AsciidoctorOptionsFactory.java │ │ │ ├── AsciidoctorRefreshMojo.java │ │ │ ├── AsciidoctorZipMojo.java │ │ │ ├── extensions │ │ │ ├── AsciidoctorJExtensionRegistry.java │ │ │ ├── ExtensionConfiguration.java │ │ │ └── ExtensionRegistry.java │ │ │ ├── http │ │ │ ├── AsciidoctorHandler.java │ │ │ └── AsciidoctorHttpServer.java │ │ │ ├── io │ │ │ └── Zips.java │ │ │ ├── model │ │ │ └── Resource.java │ │ │ ├── process │ │ │ ├── CopyResourcesProcessor.java │ │ │ ├── ResourcesProcessor.java │ │ │ ├── SourceDirectoryFinder.java │ │ │ └── SourceDocumentFinder.java │ │ │ └── refresh │ │ │ ├── AbstractFileAlterationListenerAdaptor.java │ │ │ ├── AdditionalSourceFileAlterationListenerAdaptor.java │ │ │ ├── AsciidoctorConverterFileAlterationListenerAdaptor.java │ │ │ ├── ResourceCopyFileAlterationListenerAdaptor.java │ │ │ ├── ResourcesPatternBuilder.java │ │ │ └── TimeCounter.java │ └── resources │ │ └── enable_verbose.rb │ └── test │ ├── java │ └── org │ │ └── asciidoctor │ │ └── maven │ │ ├── AsciidoctorAsserter.java │ │ ├── AsciidoctorHttpMojoTest.java │ │ ├── AsciidoctorIntegrationTest.java │ │ ├── AsciidoctorMojoExtensionsTest.java │ │ ├── AsciidoctorMojoLogHandlerTest.java │ │ ├── AsciidoctorMojoTest.java │ │ ├── AsciidoctorRefreshMojoTest.java │ │ ├── AsciidoctorZipMojoTest.java │ │ ├── SourceDirectoryFinderTest.java │ │ ├── extensions │ │ └── AsciidoctorJExtensionRegistryTest.java │ │ ├── http │ │ └── AsciidoctorHttpServerTest.java │ │ ├── io │ │ ├── ConsoleHolder.java │ │ ├── DoubleOutputStream.java │ │ ├── PrefilledInputStream.java │ │ ├── StringsCollectionsInputStream.java │ │ ├── TestFilesHelper.java │ │ └── UserInputSimulator.java │ │ ├── process │ │ ├── CopyResourcesProcessorTest.java │ │ └── SourceDocumentFinderTest.java │ │ ├── refresh │ │ ├── ResourceCopyFileAlterationListenerAdaptorTest.java │ │ └── ResourcesPatternBuilderTest.java │ │ └── test │ │ ├── MojoMocker.java │ │ ├── MojoMockerTest.java │ │ ├── ParametersInitializer.java │ │ ├── ParametersInitializerTest.java │ │ ├── TestUtils.java │ │ └── processors │ │ ├── AutoregisteredProcessor.java │ │ ├── ChangeAttributeValuePreprocessor.java │ │ ├── DummyPostprocessor.java │ │ ├── DummyTreeprocessor.java │ │ ├── FailingPreprocessor.java │ │ ├── GistBlockMacroProcessor.java │ │ ├── ManpageInlineMacroProcessor.java │ │ ├── MetaDocinfoProcessor.java │ │ ├── RequireCheckerTreeprocessor.java │ │ ├── UriIncludeProcessor.java │ │ └── YellBlockProcessor.java │ └── resources │ ├── META-INF │ └── org.asciidoctor.extension.spi.ExtensionRegistry │ ├── src │ └── asciidoctor │ │ ├── attribute-missing.adoc │ │ ├── attribute-undefined.adoc │ │ ├── attributes-example.adoc │ │ ├── book.adoc │ │ ├── errors │ │ ├── document-with-invalid-reference.adoc │ │ ├── document-with-missing-include.adoc │ │ └── valid.adoc │ │ ├── file-extensions │ │ ├── sample │ │ ├── sample.ad │ │ ├── sample.adoc │ │ ├── sample.asc │ │ ├── sample.asciidoc │ │ └── sample.my-adoc │ │ ├── github-include.adoc │ │ ├── imageDir.adoc │ │ ├── includes │ │ ├── asciidoctor-icon.jpg │ │ ├── groovy-include.groovy │ │ └── new-include.adoc │ │ ├── issue-78 │ │ ├── halliburton_lab.jpg │ │ ├── image-test.adoc │ │ └── main.adoc │ │ ├── main-document.adoc │ │ ├── processors-sample.adoc │ │ ├── project-version.adoc │ │ ├── relative-path-treatment │ │ ├── .these_sources_are_not_processed │ │ │ └── ignored.adoc │ │ ├── HelloWorld.adoc │ │ ├── HelloWorld.groovy │ │ ├── _this_is_ignored │ │ │ └── ignored.adoc │ │ └── level-1-1 │ │ │ ├── .internal-dot-partial.adoc │ │ │ ├── HelloWorld2.adoc │ │ │ ├── HelloWorld2.groovy │ │ │ ├── HelloWorld22.adoc │ │ │ ├── _internal-partial.adoc │ │ │ ├── asciidoctor-icon.jpg │ │ │ ├── level-2-1 │ │ │ ├── HelloWorld3.adoc │ │ │ └── HelloWorld3.groovy │ │ │ └── level-2-2 │ │ │ ├── HelloWorld3.adoc │ │ │ ├── HelloWorld3.groovy │ │ │ ├── _this_is_ignored │ │ │ └── ignored.adoc │ │ │ └── level-3-1 │ │ │ ├── HelloWorld4.adoc │ │ │ └── HelloWorld4.groovy │ │ ├── ruby.png │ │ ├── sample-embedded.adoc │ │ ├── sample-with-doc-info-docinfo-footer.html │ │ ├── sample-with-doc-info-docinfo-footer.xml │ │ ├── sample-with-doc-info-docinfo.html │ │ ├── sample-with-doc-info-docinfo.xml │ │ ├── sample-with-doc-info.asciidoc │ │ ├── sample-with-source-highlighting.adoc │ │ ├── sample.asciidoc │ │ ├── sample.ext │ │ ├── source-finder │ │ └── _enclosing │ │ │ └── src │ │ │ └── simple.adoc │ │ └── templates │ │ └── block_paragraph.html.slim │ └── templates │ ├── erb │ └── section.html.erb │ └── slim │ ├── set-1 │ └── admonition.html.slim │ └── set-2 │ └── block_paragraph.html.slim ├── asciidoctor-parser-doxia-module ├── pom.xml └── src │ ├── it │ └── maven-site-plugin │ │ ├── invoker.properties │ │ ├── pom.xml │ │ ├── src │ │ └── site │ │ │ ├── asciidoc │ │ │ └── sample.adoc │ │ │ ├── resources │ │ │ └── images │ │ │ │ └── asciidoctor-logo.png │ │ │ └── site.xml │ │ └── validate.groovy │ ├── main │ └── java │ │ └── org │ │ └── asciidoctor │ │ └── maven │ │ └── site │ │ └── parser │ │ ├── AsciidoctorAstDoxiaParser.java │ │ ├── AsciidoctorAstDoxiaParserModule.java │ │ ├── NodeProcessor.java │ │ ├── NodeSinker.java │ │ └── processors │ │ ├── AbstractSinkNodeProcessor.java │ │ ├── DescriptionListNodeProcessor.java │ │ ├── DocumentNodeProcessor.java │ │ ├── ExampleNodeProcessor.java │ │ ├── ImageNodeProcessor.java │ │ ├── ListItemNodeProcessor.java │ │ ├── ListingNodeProcessor.java │ │ ├── LiteralNodeProcessor.java │ │ ├── NoOpNodeProcessor.java │ │ ├── OrderedListNodeProcessor.java │ │ ├── ParagraphNodeProcessor.java │ │ ├── PreambleNodeProcessor.java │ │ ├── SectionNodeProcessor.java │ │ ├── SinkAttributes.java │ │ ├── Styles.java │ │ ├── TableNodeProcessor.java │ │ ├── TitleCaptionExtractor.java │ │ └── UnorderedListNodeProcessor.java │ └── test │ ├── java │ └── org │ │ └── asciidoctor │ │ └── maven │ │ └── site │ │ └── parser │ │ ├── AsciidoctorAstDoxiaParserTest.java │ │ ├── NodeSinkerTest.java │ │ └── processors │ │ ├── DescriptionListNodeProcessorTest.java │ │ ├── DocumentNodeProcessorTest.java │ │ ├── ExampleNodeProcessorTest.java │ │ ├── ImageNodeProcessorTest.java │ │ ├── ListItemNodeProcessorTest.java │ │ ├── ListingNodeProcessorTest.java │ │ ├── LiteralNodeProcessorTest.java │ │ ├── OrderedListNodeProcessorTest.java │ │ ├── ParagraphNodeProcessorTest.java │ │ ├── PreambleNodeProcessorTest.java │ │ ├── SectionNodeProcessorTest.java │ │ ├── TableNodeProcessorTest.java │ │ ├── UnorderedListNodeProcessorTest.java │ │ └── test │ │ ├── Html.java │ │ ├── JUnitNodeProcessorExtension.java │ │ ├── NodeProcessorTest.java │ │ ├── ReflectionUtils.java │ │ ├── StringTestUtils.java │ │ └── TestNodeProcessorFactory.java │ └── resources │ ├── sample.asciidoc │ └── with-locale │ └── en │ └── asciidoc │ ├── included.adoc │ └── sample.adoc ├── docs ├── antora.yml └── modules │ ├── ROOT │ └── pages │ │ └── index.adoc │ ├── plugin │ ├── nav.adoc │ ├── pages │ │ ├── command-line-configuration.adoc │ │ ├── compatibility-matrix.adoc │ │ ├── examples.adoc │ │ ├── goals │ │ │ ├── auto-refresh.adoc │ │ │ ├── http.adoc │ │ │ └── process-asciidoc.adoc │ │ ├── introduction.adoc │ │ ├── tips-and-tricks.adoc │ │ ├── usage.adoc │ │ ├── v2-migration-guide.adoc │ │ └── v3-migration-guide.adoc │ └── partials │ │ ├── auto-refresh-mojo-parameters.adoc │ │ ├── basic-maven-setup.adoc │ │ ├── breaking-changes-warning.adoc │ │ ├── http-mojo-parameters.adoc │ │ ├── process-asciidoc-mojo-parameters.adoc │ │ └── setting-boolean-attributes.adoc │ ├── project │ ├── nav.adoc │ └── pages │ │ ├── contributing.adoc │ │ └── copyright-and-licence.adoc │ └── site-integration │ ├── nav.adoc │ └── pages │ ├── compatibility-matrix.adoc │ ├── converter-module-setup-and-configuration.adoc │ ├── exposed-metadata.adoc │ ├── introduction.adoc │ ├── parser-module-setup-and-configuration.adoc │ └── v3-migration-guide.adoc ├── mvnw ├── mvnw.cmd └── pom.xml /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | charset = utf-8 3 | end_of_line = lf 4 | indent_size = 4 5 | indent_style = space 6 | insert_final_newline = true 7 | tab_width = 4 8 | 9 | [*.java] 10 | ij_java_class_count_to_use_import_on_demand = 99 11 | ij_java_imports_layout = javax.**, java.**, |, *, |, $* 12 | 13 | [{*.yml,*.yaml}] 14 | indent_size = 2 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for taking your time to talk with us! 2 | 3 | **What is this issue about?** 4 | 5 | 6 | - [ ] Bug report 🪲 7 | - [ ] Feature request 🏎 8 | - [ ] Question ❓ Consider dropping it first in the [Project Chat](https://asciidoctor.zulipchat.com/#narrow/stream/users) 9 | 10 | 11 | **Description** 12 | 13 | 14 | 15 | **Environment information** 16 | 17 | * asciidoctor-maven-plugin version: ___ 18 | * asciidoctorj version: ___ 19 | 20 | * Maven, Java and OS version: ___ 21 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for opening a pull request and contributing to asciidoctor-maven-plugin! 2 | 3 | **What kind of change does this PR introduce?** (check at least one) 4 | 5 | 6 | - [ ] Bugfix 7 | - [ ] Feature 8 | - [ ] Documentation 9 | - [ ] Refactor 10 | - [ ] Build improvement 11 | - [ ] Other (please describe) 12 | 13 | 14 | **What is the goal of this pull request?** 15 | 16 | 17 | **Are there any alternative ways to implement this?** 18 | 19 | 20 | **Are there any implications of this pull request? Anything a user must know?** 21 | 22 | 23 | **Is it related to an existing issue?** 24 | 25 | - [ ] Yes 26 | - [ ] No 27 | 28 | *Finally, please add a corresponding entry to CHANGELOG.adoc* 29 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | labels: 8 | - "dependencies" 9 | - package-ecosystem: "maven" 10 | directory: "/" 11 | schedule: 12 | interval: "weekly" 13 | labels: 14 | - "dependencies" 15 | commit-message: 16 | prefix: "(main)" 17 | target-branch: "main" 18 | ignore: 19 | - dependency-name: org.codehaus.plexus:plexus-utils 20 | update-types: 21 | - "version-update:semver-major" 22 | - dependency-name: org.glassfish.jaxb:jaxb-runtime 23 | update-types: 24 | - "version-update:semver-major" 25 | - "version-update:semver-minor" 26 | - dependency-name: jakarta.xml.bind:jakarta.xml.bind-api 27 | update-types: 28 | - "version-update:semver-major" 29 | - "version-update:semver-minor" 30 | -------------------------------------------------------------------------------- /.github/workflows/build-maven-4.yaml: -------------------------------------------------------------------------------- 1 | name: Maven 4 2 | on: 3 | push: 4 | branches: 5 | - main 6 | paths-ignore: 7 | - '*.adoc' 8 | - docs/** 9 | pull_request: 10 | branches: 11 | - main 12 | paths-ignore: 13 | - '*.adoc' 14 | - docs/** 15 | 16 | jobs: 17 | build: 18 | name: Build 19 | strategy: 20 | fail-fast: false 21 | max-parallel: 12 22 | matrix: 23 | os: 24 | - ubuntu-latest 25 | - windows-latest 26 | - macos-latest 27 | java: 28 | - 17 29 | - 21 30 | maven: 31 | - 4.0.0-rc-3 32 | runs-on: ${{ matrix.os }} 33 | steps: 34 | - uses: s4u/setup-maven-action@v1.18.0 35 | with: 36 | java-distribution: 'temurin' 37 | java-version: ${{ matrix.java }} 38 | maven-version: ${{ matrix.maven }} 39 | - name: Maven version 40 | run: mvn -version 41 | - name: Build & Test 42 | run: mvn -B -Prun-its -Pmaven4 clean verify 43 | 44 | -------------------------------------------------------------------------------- /.github/workflows/deploy-docs.yml: -------------------------------------------------------------------------------- 1 | name: Deploy Docs 2 | on: 3 | push: 4 | branches: 5 | - main 6 | paths: [ 'docs/**' ] 7 | permissions: read-all 8 | jobs: 9 | build: 10 | if: github.repository_owner == 'asciidoctor' 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Trigger 14 | env: 15 | GH_TOKEN: ${{ secrets.GH_TOKEN_SCOPE_REPO }} 16 | run: gh workflow run trigger.yml -R asciidoctor/docs.asciidoctor.org -r main 17 | -------------------------------------------------------------------------------- /.github/workflows/release.yaml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: workflow_dispatch 4 | permissions: 5 | contents: write 6 | 7 | jobs: 8 | release: 9 | environment: release 10 | env: 11 | GPG_KEYNAME: ${{ secrets.GPG_KEYNAME }} 12 | GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} 13 | GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout repository 17 | uses: actions/checkout@v4 18 | - name: Setup Java 19 | uses: actions/setup-java@v4 20 | with: 21 | distribution: 'temurin' 22 | java-version: 11 23 | - uses: s4u/maven-settings-action@v3.1.0 24 | with: 25 | servers: | 26 | [{ 27 | "id": "ossrh", 28 | "username": "${{ secrets.OSS_SONATYPE_USERNAME }}", 29 | "password": "${{ secrets.OSS_SONATYPE_PASSWORD }}" 30 | }] 31 | - name: Configure Git user 32 | run: | 33 | git config user.email "actions@github.com" 34 | git config user.name "GitHub Actions" 35 | - name: Configure GPG key 36 | run: echo -e "${{ env.GPG_PRIVATE_KEY }}" | gpg --import --batch 37 | - name: Build artifacts 38 | run: ./mvnw clean verify -e -B -Prelease -Dmaven.test.skip 39 | - name: Publish artifacts 40 | run: ./mvnw release:prepare release:perform -e -B -Darguments="-Prelease -Dmaven.test.skip" 41 | - name: Close release 42 | run: | 43 | echo "Release completed 🎉" 44 | echo "Remember to 'Close' & 'Release' at https://oss.sonatype.org" 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | .settings 3 | .idea 4 | *.iml 5 | .classpath 6 | .project 7 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /asciidoctor-converter-doxia-module/src/it/maven-site-plugin/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=clean site:site 2 | -------------------------------------------------------------------------------- /asciidoctor-converter-doxia-module/src/it/maven-site-plugin/src/site/asciidoc/_include.adoc: -------------------------------------------------------------------------------- 1 | Content included from the file `_include.adoc`. 2 | -------------------------------------------------------------------------------- /asciidoctor-converter-doxia-module/src/it/maven-site-plugin/src/site/asciidoc/file-with-toc.adoc: -------------------------------------------------------------------------------- 1 | = File with TOC 2 | The Author 3 | :docdatetime: 2024-02-07 23:36:29 4 | :toc: 5 | 6 | [.lead] 7 | This is an example `.adoc` file that was processed by the Doxia Parser module in the Asciidoctor Maven Plugin. 8 | Version {docs-version}. 9 | 10 | == First section 11 | 12 | This is the first section of the page. 13 | 14 | include::_include.adoc[] 15 | 16 | === Sub section 17 | 18 | This is a subsection of the first section 19 | 20 | TIP: You can control the number of section levels displayed in the TOC using the `toclevels` attribute. 21 | 22 | == Second section 23 | 24 | This is the first section of the page. 25 | 26 | === Sub section 27 | 28 | This is a subsection of the second section. 29 | 30 | [source,xml,indent=0] 31 | ---- 32 | include::../../../pom.xml[tag=plugin-decl] 33 | ---- 34 | -------------------------------------------------------------------------------- /asciidoctor-converter-doxia-module/src/it/maven-site-plugin/src/site/asciidoc/sample.asciidoc: -------------------------------------------------------------------------------- 1 | Document Title 2 | ============== 3 | Doc Writer 4 | :idprefix: id_ 5 | 6 | Preamble paragraph. 7 | 8 | NOTE: This is test, only a test. 9 | 10 | == Section A 11 | 12 | *Section A* paragraph. 13 | 14 | === Section A Subsection 15 | 16 | *Section A* 'subsection' paragraph. 17 | 18 | == Section B 19 | 20 | *Section B* paragraph. 21 | 22 | .Section B list 23 | * Item 1 24 | * Item 2 25 | * Item 3 26 | -------------------------------------------------------------------------------- /asciidoctor-converter-doxia-module/src/it/maven-site-plugin/src/site/asciidoc/templates/paragraph.html.slim: -------------------------------------------------------------------------------- 1 | p class=role =content 2 | -------------------------------------------------------------------------------- /asciidoctor-converter-doxia-module/src/it/maven-site-plugin/src/site/site.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | org.apache.maven.skins 18 | maven-fluido-skin 19 | 2.0.0-M9 20 | 21 | 22 | -------------------------------------------------------------------------------- /asciidoctor-converter-doxia-module/src/main/java/org/asciidoctor/maven/site/AsciidoctorConverterDoxiaParserModule.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site; 2 | 3 | import org.apache.maven.doxia.parser.module.AbstractParserModule; 4 | import org.apache.maven.doxia.parser.module.ParserModule; 5 | import org.codehaus.plexus.component.annotations.Component; 6 | 7 | /** 8 | * This class is the entry point for integration with the Maven Site Plugin 9 | * integration since Doxia 1.6 (i.e., maven-site-plugin 3.4 and above): 10 | * it defines source directory and file extensions to be added to 11 | * Doxia provided modules. 12 | * 13 | * @author jdlee 14 | * @since 0.1.2.1 15 | */ 16 | @Component(role = ParserModule.class, hint = AsciidoctorConverterDoxiaParser.ROLE_HINT) 17 | public class AsciidoctorConverterDoxiaParserModule extends AbstractParserModule { 18 | 19 | /** 20 | * The source directory for AsciiDoc files. 21 | */ 22 | public static final String SOURCE_DIRECTORY = AsciidoctorConverterDoxiaParser.ROLE_HINT; 23 | 24 | /** 25 | * The extensions for AsciiDoc files. 26 | */ 27 | public static final String[] FILE_EXTENSIONS = new String[]{"adoc", "asciidoc"}; 28 | 29 | /** 30 | * Build a new instance of {@link AsciidoctorConverterDoxiaParserModule}. 31 | */ 32 | public AsciidoctorConverterDoxiaParserModule() { 33 | super(SOURCE_DIRECTORY, AsciidoctorConverterDoxiaParser.ROLE_HINT, FILE_EXTENSIONS); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /asciidoctor-converter-doxia-module/src/main/java/org/asciidoctor/maven/site/SiteConverterDecorator.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site; 2 | 3 | import javax.inject.Singleton; 4 | import java.util.Map; 5 | 6 | import org.asciidoctor.Asciidoctor; 7 | import org.asciidoctor.Options; 8 | import org.asciidoctor.OptionsBuilder; 9 | import org.asciidoctor.ast.Document; 10 | 11 | /** 12 | * Asciidoctor conversion wrapper for maven-site integration. 13 | * In addition to conversion, handles header metadata extraction. 14 | * 15 | * @author abelsromero 16 | * @since 3.0.0 17 | */ 18 | @Singleton 19 | class SiteConverterDecorator { 20 | 21 | Result process(Asciidoctor asciidoctor, String content, Options options) { 22 | final Document document = asciidoctor.load(content, headerProcessingMetadata(options)); 23 | final HeaderMetadata headerMetadata = HeaderMetadata.from(document); 24 | 25 | final String html = asciidoctor.convert(content, options); 26 | 27 | return new Result(headerMetadata, html); 28 | } 29 | 30 | private static Options headerProcessingMetadata(Options options) { 31 | Map optionsMap = options.map(); 32 | OptionsBuilder builder = Options.builder(); 33 | for (Map.Entry entry : optionsMap.entrySet()) { 34 | builder.option(entry.getKey(), entry.getValue()); 35 | } 36 | 37 | builder.parseHeaderOnly(Boolean.TRUE); 38 | return builder.build(); 39 | } 40 | 41 | /** 42 | * Simple tuple to return Asciidoctor extracted metadata and conversion result. 43 | */ 44 | final class Result { 45 | 46 | private final HeaderMetadata headerMetadata; 47 | private final String html; 48 | 49 | Result(HeaderMetadata headerMetadata, String html) { 50 | this.headerMetadata = headerMetadata; 51 | this.html = html; 52 | } 53 | 54 | HeaderMetadata getHeaderMetadata() { 55 | return headerMetadata; 56 | } 57 | 58 | String getHtml() { 59 | return html; 60 | } 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /asciidoctor-converter-doxia-module/src/test/resources/errors/document-with-invalid-reference.adoc: -------------------------------------------------------------------------------- 1 | = My Document 2 | 3 | == Code example 4 | 5 | Missing file reference to <<../path/some-file.adoc,the lost doc>>. 6 | 7 | Missing section reference to <>. 8 | -------------------------------------------------------------------------------- /asciidoctor-converter-doxia-module/src/test/resources/errors/document-with-missing-include.adoc: -------------------------------------------------------------------------------- 1 | = My Document 2 | 3 | include::unexistingdoc.adoc[] 4 | 5 | include::unexistingdoc.adoc[] 6 | 7 | include::https://raw.githubusercontent.com/asciidoctor/asciidoctor-maven-plugin/main/src/test/resources/src/asciidoctor/github-include.adoc[] 8 | 9 | include::unexistingdoc.adoc[] 10 | 11 | 12 | == Code example 13 | 14 | [source,java] 15 | ---- 16 | public class HelloWorld { 17 | 18 | public static void main(String[] args) { 19 | // Prints "Hello, World" to the terminal window. 20 | System.out.println("Hello, World"); 21 | } 22 | 23 | } 24 | ---- 25 | <1> Missing callout reference? 26 | -------------------------------------------------------------------------------- /asciidoctor-converter-doxia-module/src/test/resources/includes/asciidoctor-icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asciidoctor/asciidoctor-maven-plugin/fd42dbf7b2dd1fa1204962df8aa4afcb85b28cde/asciidoctor-converter-doxia-module/src/test/resources/includes/asciidoctor-icon.jpg -------------------------------------------------------------------------------- /asciidoctor-converter-doxia-module/src/test/resources/includes/groovy-include.groovy: -------------------------------------------------------------------------------- 1 | 2 | println "HelloWorld from Groovy on ${new Date()}" 3 | -------------------------------------------------------------------------------- /asciidoctor-converter-doxia-module/src/test/resources/includes/new-include.adoc: -------------------------------------------------------------------------------- 1 | This is an included file. 2 | -------------------------------------------------------------------------------- /asciidoctor-converter-doxia-module/src/test/resources/main-document.adoc: -------------------------------------------------------------------------------- 1 | = Include test 2 | 3 | This is the parent document 4 | 5 | include::includes/new-include.adoc[] 6 | 7 | == Code 8 | 9 | [source,groovy] 10 | .groovy-include.groovy 11 | ---- 12 | include::includes/groovy-include.groovy[] 13 | ---- 14 | 15 | ifdef::my-label[] 16 | == Optional section 17 | 18 | This shows how to add optional text. 19 | For example, this {my-label}. 20 | 21 | TIP: Use `ifdef` to control what is shown. 22 | 23 | endif::[] 24 | -------------------------------------------------------------------------------- /asciidoctor-converter-doxia-module/src/test/resources/sample.asciidoc: -------------------------------------------------------------------------------- 1 | Document Title 2 | ============== 3 | Doc Writer 4 | :idprefix: id_ 5 | 6 | Preamble paragraph. 7 | 8 | NOTE: This is a test, only a test. 9 | 10 | == Section A 11 | 12 | *Section A* paragraph. 13 | 14 | === Section A Subsection 15 | 16 | *Section A* 'subsection' paragraph. 17 | 18 | == Section B 19 | 20 | *Section B* paragraph. 21 | 22 | .Section B list 23 | * Item 1 24 | * Item 2 25 | * Item 3 26 | 27 | [source,ruby] 28 | require 'asciidoctor' 29 | -------------------------------------------------------------------------------- /asciidoctor-converter-doxia-module/src/test/resources/templates/block_paragraph.html.slim: -------------------------------------------------------------------------------- 1 | - if title? 2 | .title=title 3 | p id=id class="custom-template #{role}" =content 4 | -------------------------------------------------------------------------------- /asciidoctor-converter-doxia-module/src/test/resources/with-locale/en/asciidoc/included.adoc: -------------------------------------------------------------------------------- 1 | == Included section 2 | 3 | This has been included. 4 | -------------------------------------------------------------------------------- /asciidoctor-converter-doxia-module/src/test/resources/with-locale/en/asciidoc/sample.adoc: -------------------------------------------------------------------------------- 1 | = Document Title 2 | 3 | == Include 4 | 5 | include::included.adoc[] 6 | -------------------------------------------------------------------------------- /asciidoctor-maven-commons/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | 5 | org.asciidoctor 6 | asciidoctor-maven-tools 7 | 3.2.1-SNAPSHOT 8 | ../pom.xml 9 | 10 | 11 | org.asciidoctor 12 | asciidoctor-maven-commons 13 | jar 14 | 15 | Asciidoctor Maven Commons 16 | 17 | Common components for Asciidoctor Maven Plugin and Asciidoctor Doxia Module(s). 18 | These should not depend on Doxia libraries, only shared Maven dependencies used by 19 | all and provided as runtime. 20 | This is an internal library, backward compatibility is not guaranteed. 21 | 22 | https://github.com/asciidoctor/asciidoctor-maven-plugin 23 | 24 | 25 | 26 | org.asciidoctor 27 | asciidoctorj 28 | ${asciidoctorj.version} 29 | 30 | 31 | org.apache.maven 32 | maven-core 33 | ${maven.version} 34 | provided 35 | 36 | 37 | 38 | org.codehaus.plexus 39 | plexus-utils 40 | ${plexus-utils.version} 41 | compile 42 | 43 | 44 | org.apache.maven.doxia 45 | doxia-core 46 | ${doxia.version} 47 | compile 48 | 49 | 50 | org.apache.maven.doxia 51 | doxia-sink-api 52 | ${doxia.version} 53 | provided 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/commons/StringUtils.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.commons; 2 | 3 | /** 4 | * String utils method. 5 | * 6 | * @author abelsromero 7 | */ 8 | public class StringUtils { 9 | 10 | private StringUtils() { 11 | } 12 | 13 | /** 14 | * Whether a {@link CharSequence} it blank (null, empty or white characters). 15 | * 16 | * @param cs character sequence 17 | * @return {@literal true} if input is blank 18 | */ 19 | public static boolean isBlank(final CharSequence cs) { 20 | int strLen; 21 | if (cs != null && (strLen = cs.length()) != 0) { 22 | for (int i = 0; i < strLen; i++) { 23 | if (!Character.isWhitespace(cs.charAt(i))) { 24 | return false; 25 | } 26 | } 27 | } 28 | return true; 29 | } 30 | 31 | /** 32 | * Whether a {@link CharSequence} it not blank (null, empty or white characters). 33 | * 34 | * @param cs character sequence 35 | * @return {@literal true} if input is not blank 36 | */ 37 | public static boolean isNotBlank(final CharSequence cs) { 38 | return !isBlank(cs); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/log/CapturedLogRecord.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.log; 2 | 3 | import java.io.File; 4 | 5 | import org.asciidoctor.ast.Cursor; 6 | import org.asciidoctor.log.LogRecord; 7 | 8 | /** 9 | * {@link LogRecord} proxy that allows capturing the source file being 10 | * processed. 11 | * Important: the {@link #sourceFile} and the actual source where an error is present 12 | * may not be the same. For example if the source is being included. 13 | * 14 | * @since 3.2.0 15 | */ 16 | final class CapturedLogRecord extends LogRecord { 17 | 18 | private final File sourceFile; 19 | 20 | CapturedLogRecord(LogRecord record, File sourceFile) { 21 | super(record.getSeverity(), record.getCursor(), record.getMessage(), record.getSourceFileName(), record.getSourceMethodName()); 22 | this.sourceFile = sourceFile; 23 | } 24 | 25 | public Cursor getCursor() { 26 | if (super.getCursor() != null) { 27 | return super.getCursor(); 28 | } 29 | if (sourceFile != null) { 30 | return new FileCursor(sourceFile); 31 | } 32 | return null; 33 | } 34 | 35 | public File getSourceFile() { 36 | return sourceFile; 37 | } 38 | 39 | class FileCursor implements Cursor { 40 | 41 | private final File file; 42 | 43 | public FileCursor(File file) { 44 | this.file = file; 45 | } 46 | 47 | @Override 48 | public int getLineNumber() { 49 | return 0; 50 | } 51 | 52 | @Override 53 | public String getPath() { 54 | return file.getName(); 55 | } 56 | 57 | @Override 58 | public String getDir() { 59 | return file.getParent(); 60 | } 61 | 62 | @Override 63 | public String getFile() { 64 | return file.getAbsolutePath(); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/log/FailIf.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.log; 2 | 3 | import org.asciidoctor.log.Severity; 4 | 5 | /** 6 | * POJO for Maven XML mapping. 7 | * 8 | * @author abelsromero 9 | */ 10 | public class FailIf { 11 | 12 | private Severity severity; 13 | private String containsText; 14 | 15 | public Severity getSeverity() { 16 | return severity; 17 | } 18 | 19 | public void setSeverity(Severity severity) { 20 | this.severity = severity; 21 | } 22 | 23 | public String getContainsText() { 24 | return containsText; 25 | } 26 | 27 | public void setContainsText(String containsText) { 28 | this.containsText = containsText; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/log/LogHandler.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.log; 2 | 3 | 4 | import static org.asciidoctor.maven.commons.StringUtils.isNotBlank; 5 | 6 | /** 7 | * POJO for Maven XML mapping. 8 | * 9 | * @author abelsromero 10 | * @since 1.5.7 11 | */ 12 | public class LogHandler { 13 | 14 | private Boolean outputToConsole; 15 | private FailIf failIf; 16 | private Boolean failFast; 17 | 18 | public LogHandler() { 19 | outputToConsole = Boolean.TRUE; 20 | failFast = Boolean.TRUE; 21 | } 22 | 23 | public Boolean getOutputToConsole() { 24 | return outputToConsole; 25 | } 26 | 27 | public void setOutputToConsole(Boolean outputToConsole) { 28 | this.outputToConsole = outputToConsole; 29 | } 30 | 31 | public FailIf getFailIf() { 32 | return failIf; 33 | } 34 | 35 | public void setFailIf(FailIf failIf) { 36 | this.failIf = failIf; 37 | } 38 | 39 | public boolean isSeveritySet() { 40 | return failIf != null && failIf.getSeverity() != null; 41 | } 42 | 43 | public boolean isContainsTextNotBlank() { 44 | return failIf != null && isNotBlank(failIf.getContainsText()); 45 | } 46 | 47 | public Boolean getFailFast() { 48 | return failFast; 49 | } 50 | 51 | public void setFailFast(Boolean failFast) { 52 | this.failFast = failFast; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/log/LogRecordsProcessors.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.log; 2 | 3 | import java.io.File; 4 | import java.util.List; 5 | import java.util.Optional; 6 | import java.util.function.Consumer; 7 | 8 | import org.asciidoctor.log.LogRecord; 9 | import org.asciidoctor.log.Severity; 10 | 11 | public class LogRecordsProcessors { 12 | 13 | private final LogHandler logHandler; 14 | private final File sourceDirectory; 15 | 16 | private final Consumer errorMessageConsumer; 17 | 18 | public LogRecordsProcessors(LogHandler logHandler, 19 | File sourceDirectory, 20 | Consumer errorMessageConsumer) { 21 | this.logHandler = logHandler; 22 | this.sourceDirectory = sourceDirectory; 23 | this.errorMessageConsumer = errorMessageConsumer; 24 | } 25 | 26 | public void processLogRecords(MemoryLogHandler memoryLogHandler) throws Exception { 27 | if (logHandler.isSeveritySet() || logHandler.isContainsTextNotBlank()) { 28 | final Severity severity = Optional.ofNullable(logHandler.getFailIf()).map(FailIf::getSeverity).orElse(null); 29 | final String textToSearch = Optional.ofNullable(logHandler.getFailIf()).map(FailIf::getContainsText).orElse(null); 30 | 31 | final List records = memoryLogHandler.filter(severity, textToSearch); 32 | if (records.size() > 0) { 33 | for (LogRecord record : records) { 34 | errorMessageConsumer.accept(LogRecordFormatter.format(record, sourceDirectory)); 35 | } 36 | throw new Exception(getMessage(records, severity, textToSearch)); 37 | } 38 | } 39 | } 40 | 41 | private String getMessage(List records, Severity severity, String textToSearch) { 42 | if (logHandler.isSeveritySet() && logHandler.isContainsTextNotBlank()) { 43 | return String.format("Found %s issue(s) matching severity %s or higher and text '%s'", records.size(), severity, textToSearch); 44 | } else if (logHandler.isSeveritySet()) { 45 | return String.format("Found %s issue(s) of severity %s or higher during conversion", records.size(), severity); 46 | } else { 47 | return String.format("Found %s issue(s) containing '%s'", records.size(), textToSearch); 48 | } 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/site/HeadParser.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site; 2 | 3 | import java.util.Optional; 4 | 5 | import org.apache.maven.doxia.sink.Sink; 6 | 7 | /** 8 | * Injects Asciidoctor header information into Doxia's {@link Sink}. 9 | * This allows Doxia to build: 10 | * - breadcrumbs 11 | * - HTML head's meta elements 12 | * 13 | * @since 3.0.0 14 | */ 15 | public class HeadParser { 16 | 17 | private final Sink sink; 18 | 19 | public HeadParser(Sink sink) { 20 | this.sink = sink; 21 | } 22 | 23 | public void parse(HeaderMetadata headerMetadata) { 24 | sink.head(); 25 | sink.title(); 26 | sink.text(Optional.ofNullable(headerMetadata.getTitle()).orElse("[Untitled]")); 27 | sink.title_(); 28 | 29 | for (String author : headerMetadata.getAuthors()) { 30 | sink.author(); 31 | sink.text(author.toString()); 32 | sink.author_(); 33 | } 34 | 35 | sink.date(); 36 | sink.text(headerMetadata.getDateTime()); 37 | sink.date_(); 38 | sink.head_(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/site/HeaderMetadata.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | import java.util.Optional; 6 | import java.util.stream.Collectors; 7 | 8 | import org.asciidoctor.ast.Author; 9 | import org.asciidoctor.ast.Document; 10 | import org.asciidoctor.ast.RevisionInfo; 11 | 12 | /** 13 | * Extract required metadata from Asciidoctor to be used for maven-site pages. 14 | */ 15 | public class HeaderMetadata { 16 | 17 | private final String title; 18 | private final List authors; 19 | private final String dateTime; 20 | 21 | HeaderMetadata(String title, List authors, String dateTime) { 22 | this.title = title; 23 | this.authors = authors; 24 | this.dateTime = dateTime; 25 | } 26 | 27 | String getTitle() { 28 | return title; 29 | } 30 | 31 | List getAuthors() { 32 | return authors; 33 | } 34 | 35 | String getDateTime() { 36 | return dateTime; 37 | } 38 | 39 | public static HeaderMetadata from(Document document) { 40 | final String title = document.getTitle(); 41 | final List authors = extractAuthors(document); 42 | final String documentDateTime = extractDocumentDateTime(document, document.getAttributes()); 43 | return new HeaderMetadata(title, authors, documentDateTime); 44 | } 45 | 46 | private static List extractAuthors(Document document) { 47 | return document.getAuthors().stream() 48 | .map(Author::toString) 49 | .collect(Collectors.toList()); 50 | } 51 | 52 | private static String extractDocumentDateTime(Document document, Map attributes) { 53 | final RevisionInfo revisionInfo = document.getRevisionInfo(); 54 | return Optional.ofNullable(revisionInfo.getDate()) 55 | .orElse((String) attributes.get("docdatetime")); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/site/LogHandlerFactory.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site; 2 | 3 | import java.io.File; 4 | 5 | import org.asciidoctor.Asciidoctor; 6 | import org.asciidoctor.maven.log.LogHandler; 7 | import org.asciidoctor.maven.log.LogRecordFormatter; 8 | import org.asciidoctor.maven.log.MemoryLogHandler; 9 | import org.codehaus.plexus.util.xml.Xpp3Dom; 10 | import org.slf4j.Logger; 11 | 12 | /** 13 | * Factory to parse and create {@link MemoryLogHandler} in order to handle 14 | * issues during processing. 15 | * 16 | * @author abelsromero 17 | * @since 3.1.1 18 | */ 19 | public class LogHandlerFactory { 20 | 21 | public LogHandler getConfiguration(Xpp3Dom asciidocConfig) { 22 | return new SiteLogHandlerDeserializer().deserialize(asciidocConfig); 23 | } 24 | 25 | public MemoryLogHandler create(Asciidoctor asciidoctor, File siteDirectory, Logger logger) { 26 | 27 | final MemoryLogHandler memoryLogHandler = new MemoryLogHandler(false, 28 | logRecord -> logger.info(LogRecordFormatter.format(logRecord, siteDirectory))); 29 | asciidoctor.registerLogHandler(memoryLogHandler); 30 | // disable default console output of AsciidoctorJ 31 | java.util.logging.Logger.getLogger("asciidoctor").setUseParentHandlers(false); 32 | return memoryLogHandler; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/site/SiteConversionConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site; 2 | 3 | import java.io.File; 4 | import java.util.List; 5 | 6 | import org.asciidoctor.Options; 7 | import org.codehaus.plexus.util.xml.Xpp3Dom; 8 | 9 | /** 10 | * @author abelsromero 11 | * @since 3.1.1 12 | */ 13 | public final class SiteConversionConfiguration { 14 | 15 | private final Xpp3Dom asciidocConfig; 16 | private final File siteBaseDir; 17 | private final Options options; 18 | private final List requires; 19 | 20 | SiteConversionConfiguration(Xpp3Dom asciidocConfig, 21 | File siteBaseDir, 22 | Options options, 23 | List requires) { 24 | this.asciidocConfig = asciidocConfig; 25 | this.siteBaseDir = siteBaseDir; 26 | this.options = options; 27 | this.requires = requires; 28 | } 29 | 30 | public File getSiteBaseDir() { 31 | return siteBaseDir; 32 | } 33 | 34 | public Xpp3Dom getAsciidocConfig() { 35 | return asciidocConfig; 36 | } 37 | 38 | public Options getOptions() { 39 | return options; 40 | } 41 | 42 | public List getRequires() { 43 | return requires; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/commons/AsciidoctorHelperTest.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.commons; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import java.util.stream.Stream; 6 | 7 | import org.asciidoctor.Attributes; 8 | import org.asciidoctor.AttributesBuilder; 9 | import org.assertj.core.data.MapEntry; 10 | import org.junit.jupiter.params.ParameterizedTest; 11 | import org.junit.jupiter.params.provider.Arguments; 12 | import org.junit.jupiter.params.provider.MethodSource; 13 | 14 | import static org.asciidoctor.maven.commons.AsciidoctorHelper.addAttributes; 15 | import static org.assertj.core.api.Assertions.assertThat; 16 | 17 | public class AsciidoctorHelperTest { 18 | 19 | @ParameterizedTest 20 | @MethodSource("specialAttributes") 21 | void should_add_attributes_with_special_values(Object actual, String expected) { 22 | final Map attributes = new HashMap<>(); 23 | attributes.put("toc", actual); 24 | final AttributesBuilder attributesBuilder = Attributes.builder(); 25 | 26 | addAttributes(attributes, attributesBuilder); 27 | 28 | var attributesAsMap = attributesBuilder.build().map(); 29 | assertThat(attributesAsMap) 30 | .containsExactly(MapEntry.entry("toc", expected)); 31 | } 32 | 33 | private static Stream specialAttributes() { 34 | return Stream.of( 35 | Arguments.of(null, ""), 36 | Arguments.of("", ""), 37 | Arguments.of("true", ""), 38 | Arguments.of("false", null), 39 | Arguments.of(true, ""), 40 | Arguments.of(false, null) 41 | ); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/commons/StringUtilsTest.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.commons; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.junit.jupiter.params.ParameterizedTest; 5 | import org.junit.jupiter.params.provider.ValueSource; 6 | 7 | import static org.asciidoctor.maven.commons.StringUtils.isBlank; 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | class StringUtilsTest { 11 | 12 | @Test 13 | void should_detect_null_as_blank_string() { 14 | assertThat(isBlank(null)).isTrue(); 15 | } 16 | 17 | @ParameterizedTest 18 | @ValueSource(strings = { 19 | "", 20 | " ", 21 | "\t", 22 | "\n\n", 23 | " \n\t \n ", 24 | }) 25 | void should_detect_blank_string(String strings) { 26 | assertThat(isBlank(strings)).isTrue(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/log/CapturedLogRecordTest.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.log; 2 | 3 | import java.io.File; 4 | 5 | import static org.assertj.core.api.Assertions.assertThat; 6 | 7 | import org.asciidoctor.ast.Cursor; 8 | import org.asciidoctor.log.LogRecord; 9 | import org.asciidoctor.log.Severity; 10 | import org.junit.jupiter.api.Nested; 11 | import org.junit.jupiter.api.Test; 12 | 13 | class CapturedLogRecordTest { 14 | 15 | @Nested 16 | class WhenLogRecordsContainsCursor { 17 | 18 | @Test 19 | void shouldReturnCursorFile() { 20 | final var cursorFile = new File("uno", "dos"); 21 | final var recordFile = new File("tres", "quatre"); 22 | final var cursor = new TestCursor(cursorFile.getAbsolutePath(), 0, null, null); 23 | 24 | final var logRecord = new CapturedLogRecord(getLogRecord(cursor), recordFile); 25 | final var capturedLogRecord = new CapturedLogRecord(logRecord, cursorFile); 26 | 27 | assertThat(capturedLogRecord.getCursor().getFile()).isEqualTo(cursorFile.getAbsolutePath()); 28 | } 29 | 30 | } 31 | 32 | @Nested 33 | class WhenLogRecordsDoesNotContainsCursor { 34 | 35 | @Test 36 | void shouldReturnLogRecordFileWhenCursorFileIsSet() { 37 | final var cursorFile = new File("uno", "dos"); 38 | final var recordFile = new File("tres", "quatre"); 39 | 40 | final var logRecord = new CapturedLogRecord(getLogRecord(null), recordFile); 41 | final var capturedLogRecord = new CapturedLogRecord(logRecord, cursorFile); 42 | 43 | assertThat(capturedLogRecord.getCursor().getFile()).isEqualTo(recordFile.getAbsolutePath()); 44 | } 45 | 46 | @Test 47 | void shouldReturnNullWhenCursorFileIsNoSet() { 48 | final var logRecord = new CapturedLogRecord(getLogRecord(null), null); 49 | final var capturedLogRecord = new CapturedLogRecord(logRecord, null); 50 | 51 | assertThat(capturedLogRecord.getCursor()).isNull(); 52 | } 53 | 54 | } 55 | 56 | private LogRecord getLogRecord(Cursor cursor) { 57 | return new LogRecord(Severity.INFO, cursor, "a message"); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/log/TestCursor.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.log; 2 | 3 | import org.asciidoctor.ast.Cursor; 4 | 5 | class TestCursor implements Cursor { 6 | 7 | private final int lineNumber; 8 | private final String file; 9 | private final String path; 10 | private final String dir; 11 | 12 | TestCursor(String file, int lineNumber, String path, String dir) { 13 | this.file = file; 14 | this.lineNumber = lineNumber; 15 | this.path = path; 16 | this.dir = dir; 17 | } 18 | 19 | @Override 20 | public int getLineNumber() { 21 | return lineNumber; 22 | } 23 | 24 | @Override 25 | public String getPath() { 26 | return path; 27 | } 28 | 29 | @Override 30 | public String getDir() { 31 | return dir; 32 | } 33 | 34 | @Override 35 | public String getFile() { 36 | return file; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/log/TestLogRecords.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.log; 2 | 3 | import java.util.Optional; 4 | 5 | import static org.asciidoctor.log.Severity.*; 6 | 7 | import org.asciidoctor.log.LogRecord; 8 | 9 | class TestLogRecords { 10 | 11 | static LogRecord errorMessage() { 12 | return errorMessage(null); 13 | } 14 | 15 | static LogRecord errorMessage(Integer index) { 16 | LogRecord logRecord = new LogRecord(ERROR, buildMessage("error", index)); 17 | return new CapturedLogRecord(logRecord, null); 18 | } 19 | 20 | static LogRecord getInfoMessage() { 21 | return getInfoMessage(null); 22 | } 23 | 24 | static LogRecord getInfoMessage(Integer index) { 25 | LogRecord logRecord = new LogRecord(INFO, buildMessage("info", index)); 26 | return new CapturedLogRecord(logRecord, null); 27 | } 28 | 29 | static LogRecord warningMessage() { 30 | return warningMessage(null); 31 | } 32 | 33 | static LogRecord warningMessage(Integer index) { 34 | LogRecord logRecord = new LogRecord(WARN, buildMessage("warning", index)); 35 | return new CapturedLogRecord(logRecord, null); 36 | } 37 | 38 | private static String buildMessage(String type, Integer index) { 39 | return Optional.ofNullable(index) 40 | .map(i -> type + " message " + index) 41 | .orElse(type + " message"); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/site/HeadParserTest.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site; 2 | 3 | import org.apache.maven.doxia.sink.Sink; 4 | import org.junit.jupiter.api.Test; 5 | import org.mockito.Mockito; 6 | 7 | import java.util.List; 8 | 9 | import static org.mockito.Mockito.times; 10 | 11 | class HeadParserTest { 12 | 13 | @Test 14 | void should_inject_title() { 15 | final Sink sinkSpy = Mockito.spy(Sink.class); 16 | 17 | var headerMetadata = new HeaderMetadata("test title", List.of(), null); 18 | new HeadParser(sinkSpy).parse(headerMetadata); 19 | 20 | Mockito.verify(sinkSpy).head(); 21 | Mockito.verify(sinkSpy).head_(); 22 | 23 | Mockito.verify(sinkSpy).title(); 24 | Mockito.verify(sinkSpy).text("test title"); 25 | Mockito.verify(sinkSpy).title_(); 26 | 27 | Mockito.verify(sinkSpy, times(0)).author(); 28 | Mockito.verify(sinkSpy, times(1)).date(); 29 | } 30 | 31 | @Test 32 | void should_inject_author() { 33 | final Sink sinkSpy = Mockito.spy(Sink.class); 34 | 35 | var headerMetadata = new HeaderMetadata(null, List.of("an author"), null); 36 | new HeadParser(sinkSpy).parse(headerMetadata); 37 | 38 | Mockito.verify(sinkSpy).head(); 39 | Mockito.verify(sinkSpy).head_(); 40 | 41 | verifyDefaultTitle(sinkSpy); 42 | 43 | Mockito.verify(sinkSpy).author(); 44 | Mockito.verify(sinkSpy).text("an author"); 45 | Mockito.verify(sinkSpy).author(); 46 | 47 | Mockito.verify(sinkSpy, times(1)).date(); 48 | } 49 | 50 | @Test 51 | void should_inject_date() { 52 | final Sink sinkSpy = Mockito.spy(Sink.class); 53 | 54 | var headerMetadata = new HeaderMetadata(null, List.of(), "2024-11-22"); 55 | new HeadParser(sinkSpy).parse(headerMetadata); 56 | 57 | Mockito.verify(sinkSpy).head(); 58 | Mockito.verify(sinkSpy).head_(); 59 | 60 | verifyDefaultTitle(sinkSpy); 61 | 62 | Mockito.verify(sinkSpy, times(0)).author(); 63 | 64 | Mockito.verify(sinkSpy).date(); 65 | Mockito.verify(sinkSpy).text("2024-11-22"); 66 | Mockito.verify(sinkSpy).date_(); 67 | } 68 | 69 | private void verifyDefaultTitle(Sink sinkSpy) { 70 | Mockito.verify(sinkSpy).title(); 71 | Mockito.verify(sinkSpy).text("[Untitled]"); 72 | Mockito.verify(sinkSpy).title_(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/site/Xpp3DoomBuilder.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site; 2 | 3 | import org.codehaus.plexus.util.xml.Xpp3Dom; 4 | 5 | public class Xpp3DoomBuilder { 6 | 7 | private Xpp3Dom rootNode; 8 | private Xpp3Dom currentNode; 9 | private Xpp3Dom parentNode; 10 | 11 | private Xpp3DoomBuilder(String name) { 12 | rootNode = currentNode = new Xpp3Dom(name); 13 | } 14 | 15 | public static Xpp3DoomBuilder siteNode() { 16 | return new Xpp3DoomBuilder("site"); 17 | } 18 | 19 | public static Xpp3DoomBuilder asciidocNode() { 20 | return siteNode().addChild("asciidoc"); 21 | } 22 | 23 | public static Xpp3DoomBuilder logHandler() { 24 | return new Xpp3DoomBuilder("asciidoc").addChild("logHandler"); 25 | } 26 | 27 | public Xpp3DoomBuilder addChild(String name) { 28 | final Xpp3Dom newNode = new Xpp3Dom(name); 29 | currentNode.addChild(newNode); 30 | parentNode = currentNode; 31 | currentNode = newNode; 32 | return this; 33 | } 34 | 35 | public Xpp3DoomBuilder addChild(String name, String... values) { 36 | Xpp3Dom newNode = null; 37 | if (values == null) { 38 | newNode = new Xpp3Dom(name); 39 | currentNode.addChild(newNode); 40 | } else { 41 | for (String value : values) { 42 | newNode = new Xpp3Dom(name); 43 | newNode.setValue(value); 44 | currentNode.addChild(newNode); 45 | } 46 | } 47 | parentNode = currentNode; 48 | currentNode = newNode; 49 | return this; 50 | } 51 | 52 | public Xpp3DoomBuilder parent() { 53 | currentNode = parentNode; 54 | return this; 55 | } 56 | 57 | public Xpp3Dom build() { 58 | return rootNode; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/it/article-html-command/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=clean asciidoctor:process-asciidoc \ 2 | -Dasciidoctor.sourceDirectory=src/main/doc \ 3 | -Dasciidoctor.outputDirectory=target/docs \ 4 | -Dasciidoctor.attributes="toc=left source-highlighter=coderay" -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/it/article-html-command/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.asciidoctor 6 | test 7 | 1.0-SNAPSHOT 8 | 9 | Converts Asciidoctor Article to Html with command line arguments 10 | Runs asciidoctor-maven-plugin:process-asciidoc 11 | 12 | 13 | UTF-8 14 | 15 | 16 | 17 | 18 | 19 | org.asciidoctor 20 | asciidoctor-maven-plugin 21 | @project.version@ 22 | 23 | html 24 | article 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/it/article-html-command/src/main/doc/sample.asciidoc: -------------------------------------------------------------------------------- 1 | Document Title 2 | ============== 3 | Doc Writer 4 | :idprefix: id_ 5 | 6 | Preamble paragraph. 7 | 8 | NOTE: This is test, only a test. 9 | 10 | == Section A 11 | 12 | *Section A* paragraph. 13 | 14 | === Section A Subsection 15 | 16 | *Section A* 'subsection' paragraph. 17 | 18 | == Section B 19 | 20 | *Section B* paragraph. 21 | 22 | .Section B list 23 | * Item 1 24 | * Item 2 25 | * Item 3 26 | 27 | == Section C 28 | 29 | [source,java] 30 | ---- 31 | public class HelloWorld { 32 | 33 | public static void main(String[] args) { 34 | System.out.println("Hello, World!!"); 35 | } 36 | 37 | } 38 | ---- -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/it/article-html-command/validate.groovy: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | 3 | 4 | File outputDir = new File( basedir, "target/docs" ) 5 | 6 | String[] expectedFiles = ["sample.html"] 7 | 8 | for ( String expectedFile : expectedFiles ) { 9 | File file = new File( outputDir, expectedFile ) 10 | println ( "Checking for existence of " + file ) 11 | 12 | // validate that asciidoctor.attributes are processed 13 | String text = file.text 14 | if ( !text.contains('') || !text.contains('
') ) {
15 |         throw new Exception( "Attributes not processed" )
16 |     }
17 | 
18 |     if ( !file.isFile() ) {
19 |         throw new Exception( "Missing file " + file )
20 |     }
21 | }
22 | 
23 | return true;


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/article-html/invoker.properties:
--------------------------------------------------------------------------------
1 | invoker.goals=clean asciidoctor:process-asciidoc


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/article-html/pom.xml:
--------------------------------------------------------------------------------
 1 | 
 3 | 	4.0.0
 4 | 
 5 | 	org.asciidoctor
 6 | 	test
 7 | 	1.0-SNAPSHOT
 8 | 
 9 | 	Converts Asciidoctor Article to Html
10 | 	Runs asciidoctor-maven-plugin:process-asciidoc
11 | 
12 | 	
13 | 		UTF-8
14 | 	
15 | 
16 | 	
17 | 		
18 | 			
19 | 				org.asciidoctor
20 | 				asciidoctor-maven-plugin
21 | 				@project.version@
22 | 				
23 | 					src/main/doc
24 | 					target/docs
25 | 					html
26 | 					article
27 | 					
28 | 						my-theme.css
29 | 					
30 | 				
31 | 			
32 | 		
33 | 	
34 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/article-html/src/main/doc/sample.asciidoc:
--------------------------------------------------------------------------------
 1 | Document Title
 2 | ==============
 3 | Doc Writer 
 4 | :idprefix: id_
 5 | 
 6 | Preamble paragraph.
 7 | 
 8 | NOTE: This is test, only a test.
 9 | 
10 | == Section A
11 | 
12 | *Section A* paragraph.
13 | 
14 | === Section A Subsection
15 | 
16 | *Section A* 'subsection' paragraph.
17 | 
18 | == Section B
19 | 
20 | *Section B* paragraph.
21 | 
22 | .Section B list
23 | * Item 1
24 | * Item 2
25 | * Item 3
26 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/article-html/validate.bsh:
--------------------------------------------------------------------------------
 1 | import java.io.*;
 2 | 
 3 | File outputDir = new File( basedir, "target/docs" );
 4 | 
 5 | String[] expectedFiles = {
 6 | 	"sample.html"
 7 | };
 8 | 
 9 | for ( String expectedFile : expectedFiles )
10 | {
11 |     File file = new File( outputDir, expectedFile );
12 |     System.out.println( "Checking for existence of " + file );
13 |     if ( !file.isFile() )
14 |     {
15 |         throw new Exception( "Missing file " + file );
16 |     }
17 | }
18 | 
19 | return true;


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/book-html/invoker.properties:
--------------------------------------------------------------------------------
1 | invoker.goals=clean asciidoctor:process-asciidoc


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/book-html/pom.xml:
--------------------------------------------------------------------------------
 1 | 
 3 | 	4.0.0
 4 | 
 5 | 	org.asciidoctor
 6 | 	test
 7 | 	1.0-SNAPSHOT
 8 | 
 9 | 	Converts Asciidoctor Article to Html
10 | 	Runs asciidoctor-maven-plugin:process-asciidoc
11 | 
12 | 	
13 | 		UTF-8
14 | 	
15 | 
16 | 	
17 | 		
18 | 			
19 | 				org.asciidoctor
20 | 				asciidoctor-maven-plugin
21 | 				@project.version@
22 | 				
23 | 					src/main/doc
24 | 					target/docs
25 | 					html
26 | 					book
27 | 					
28 | 						my-theme.css
29 | 					
30 | 				
31 | 			
32 | 		
33 | 	
34 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/book-html/validate.bsh:
--------------------------------------------------------------------------------
 1 | import java.io.*;
 2 | 
 3 | File outputDir = new File( basedir, "target/docs" );
 4 | 
 5 | String[] expectedFiles = {
 6 | 	"sample.html"
 7 | };
 8 | 
 9 | for ( String expectedFile : expectedFiles )
10 | {
11 |     File file = new File( outputDir, expectedFile );
12 |     System.out.println( "Checking for existence of " + file );
13 |     if ( !file.isFile() )
14 |     {
15 |         throw new Exception( "Missing file " + file );
16 |     }
17 | }
18 | 
19 | return true;


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/convert-with-minimal-configuration/invoker.properties:
--------------------------------------------------------------------------------
1 | invoker.goals=clean asciidoctor:process-asciidoc


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/convert-with-minimal-configuration/pom.xml:
--------------------------------------------------------------------------------
 1 | 
 3 | 	4.0.0
 4 | 
 5 | 	org.asciidoctor
 6 | 	test
 7 | 	1.0-SNAPSHOT
 8 | 
 9 | 	Converts Asciidoctor Article to Html
10 | 	Runs asciidoctor-maven-plugin:process-asciidoc
11 | 
12 | 	
13 | 		UTF-8
14 | 	
15 | 
16 | 	
17 | 		
18 | 			
19 | 				org.asciidoctor
20 | 				asciidoctor-maven-plugin
21 | 				@project.version@
22 | 			
23 | 		
24 | 	
25 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/convert-with-minimal-configuration/src/docs/asciidoc/sample.asciidoc:
--------------------------------------------------------------------------------
 1 | Document Title
 2 | ==============
 3 | Doc Writer 
 4 | :idprefix: id_
 5 | 
 6 | Preamble paragraph.
 7 | 
 8 | NOTE: This is test, only a test.
 9 | 
10 | == Section A
11 | 
12 | *Section A* paragraph.
13 | 
14 | === Section A Subsection
15 | 
16 | *Section A* 'subsection' paragraph.
17 | 
18 | == Section B
19 | 
20 | *Section B* paragraph.
21 | 
22 | .Section B list
23 | * Item 1
24 | * Item 2
25 | * Item 3
26 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/convert-with-minimal-configuration/validate.groovy:
--------------------------------------------------------------------------------
 1 | File outputDir = new File(basedir, 'target/generated-docs');
 2 | 
 3 | def expectedFiles = ['sample.html']
 4 | 
 5 | for (String expectedFile : expectedFiles) {
 6 |     File file = new File(outputDir, expectedFile)
 7 |     if (!file.isFile())
 8 |         throw new Exception("Missing file $file")
 9 | }
10 | 
11 | return true


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/inject-attributes-from-maven-pom/invoker.properties:
--------------------------------------------------------------------------------
1 | invoker.goals=clean generate-resources


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/inject-attributes-from-maven-pom/pom.xml:
--------------------------------------------------------------------------------
 1 | 
 3 |     4.0.0
 4 | 
 5 |     org.asciidoctor
 6 |     test
 7 |     1.0-SNAPSHOT
 8 | 
 9 |     Converts Asciidoctor Article to Html
10 |     Processes attributes from different sections in the Maven pom
11 | 
12 |     
13 |         UTF-8
14 |         project property configuration
15 |     
16 | 
17 |     
18 |         
19 |             
20 |                 org.asciidoctor
21 |                 asciidoctor-maven-plugin
22 |                 @project.version@
23 |                 
24 |                     
25 |                         plugin configuration
26 |                     
27 |                 
28 |                 
29 |                     
30 |                         asciidoc-to-html
31 |                         generate-resources
32 |                         
33 |                             process-asciidoc
34 |                         
35 |                         
36 |                             
37 |                                 execution configuration
38 |                             
39 |                         
40 |                     
41 |                 
42 |             
43 |         
44 |     
45 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/inject-attributes-from-maven-pom/src/docs/asciidoc/attributes-example.adoc:
--------------------------------------------------------------------------------
 1 | Document Title
 2 | ==============
 3 | Doc Writer 
 4 | :execution.attribute: cosa
 5 | :idprefix: id_
 6 | 
 7 | Preamble paragraph.
 8 | 
 9 | NOTE: This is test, only a test.
10 | 
11 | == Section A
12 | 
13 | * This attribute is set in the plugin configuration: {plugin-configuration-attribute}
14 | * This attribute is set in the execution configuration: {execution-attribute}
15 | * This attribute is set in the project's properties: {project-property-attribute}
16 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/inject-attributes-from-maven-pom/validate.groovy:
--------------------------------------------------------------------------------
 1 | final File outputDir = new File(basedir, "target/generated-docs");
 2 | final File expectedFile = new File(outputDir, 'attributes-example.html')
 3 | 
 4 | if (!expectedFile.exists()) {
 5 |     throw new Exception("Missing file " + expectedFile)
 6 | }
 7 | 
 8 | expectedFile.text.with { outputContent ->
 9 |     assertContains(outputContent, 'This attribute is set in the plugin configuration: plugin configuration')
10 |     assertContains(outputContent, 'This attribute is set in the execution configuration: execution configuration')
11 |     assertContains(outputContent, 'This attribute is set in the project’s properties: project property configuration')
12 | }
13 | 
14 | void assertContains(String text, String expectedValueToContain) {
15 |     if (!text.contains(expectedValueToContain))
16 |         throw new Exception("Expected value '$expectedValueToContain' not found")
17 | }
18 | 
19 | return true


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/rendering-single-html-with-relative-outputDirectory-and-outputFile/invoker.properties:
--------------------------------------------------------------------------------
1 | invoker.goals=clean asciidoctor:process-asciidoc


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/rendering-single-html-with-relative-outputDirectory-and-outputFile/pom.xml:
--------------------------------------------------------------------------------
 1 | 
 3 | 	4.0.0
 4 | 
 5 | 	org.asciidoctor
 6 | 	test
 7 | 	1.0-SNAPSHOT
 8 | 
 9 | 	Converts Asciidoctor Article to Html
10 | 	Runs asciidoctor-maven-plugin:process-asciidoc
11 | 
12 | 	
13 | 		UTF-8
14 | 	
15 | 
16 | 	
17 | 		
18 | 			
19 | 				org.asciidoctor
20 | 				asciidoctor-maven-plugin
21 | 				@project.version@
22 | 				
23 | 					src/main/doc
24 | 					target/output_path
25 | 					a_path/custom-filename.html
26 | 					html
27 | 				
28 | 			
29 | 		
30 | 	
31 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/rendering-single-html-with-relative-outputDirectory-and-outputFile/src/main/doc/sample.asciidoc:
--------------------------------------------------------------------------------
 1 | Document Title
 2 | ==============
 3 | Doc Writer 
 4 | :idprefix: id_
 5 | 
 6 | Preamble paragraph.
 7 | 
 8 | NOTE: This is test, only a test.
 9 | 
10 | == Section A
11 | 
12 | *Section A* paragraph.
13 | 
14 | === Section A Subsection
15 | 
16 | *Section A* 'subsection' paragraph.
17 | 
18 | == Section B
19 | 
20 | *Section B* paragraph.
21 | 
22 | .Section B list
23 | * Item 1
24 | * Item 2
25 | * Item 3
26 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/rendering-single-html-with-relative-outputDirectory-and-outputFile/validate.groovy:
--------------------------------------------------------------------------------
1 | final File outputDir = new File(basedir, 'target/output_path')
2 | final File expectedFile = new File(outputDir, 'a_path/custom-filename.html')
3 | 
4 | if (!expectedFile.exists()) {
5 |     throw new Exception("Missing file " + file)
6 | }
7 | 
8 | return true


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/rendering-single-html-with-relative-outputFile/invoker.properties:
--------------------------------------------------------------------------------
1 | invoker.goals=clean asciidoctor:process-asciidoc


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/rendering-single-html-with-relative-outputFile/pom.xml:
--------------------------------------------------------------------------------
 1 | 
 3 | 	4.0.0
 4 | 
 5 | 	org.asciidoctor
 6 | 	test
 7 | 	1.0-SNAPSHOT
 8 | 
 9 | 	Converts Asciidoctor Article to Html
10 | 	Runs asciidoctor-maven-plugin:process-asciidoc
11 | 
12 | 	
13 | 		UTF-8
14 | 	
15 | 
16 | 	
17 | 		
18 | 			
19 | 				org.asciidoctor
20 | 				asciidoctor-maven-plugin
21 | 				@project.version@
22 | 				
23 | 					src/main/doc
24 | 					a_path/custom-filename.html
25 | 					html
26 | 				
27 | 			
28 | 		
29 | 	
30 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/rendering-single-html-with-relative-outputFile/src/main/doc/sample.asciidoc:
--------------------------------------------------------------------------------
 1 | Document Title
 2 | ==============
 3 | Doc Writer 
 4 | :idprefix: id_
 5 | 
 6 | Preamble paragraph.
 7 | 
 8 | NOTE: This is test, only a test.
 9 | 
10 | == Section A
11 | 
12 | *Section A* paragraph.
13 | 
14 | === Section A Subsection
15 | 
16 | *Section A* 'subsection' paragraph.
17 | 
18 | == Section B
19 | 
20 | *Section B* paragraph.
21 | 
22 | .Section B list
23 | * Item 1
24 | * Item 2
25 | * Item 3
26 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/rendering-single-html-with-relative-outputFile/validate.groovy:
--------------------------------------------------------------------------------
1 | final File outputDir = new File(basedir, 'target/generated-docs')
2 | final File expectedFile = new File(outputDir, 'a_path/custom-filename.html')
3 | 
4 | if (!expectedFile.exists()) {
5 |     throw new Exception("Missing file " + file)
6 | }
7 | 
8 | return true


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/spi-registered-log/asciidoctor-project/pom.xml:
--------------------------------------------------------------------------------
 1 | 
 3 |     4.0.0
 4 | 
 5 |     org.asciidoctor
 6 |     asciidoctor-project
 7 |     1.0-SNAPSHOT
 8 | 
 9 |     
10 |         org.asciidoctor
11 |         test-parent
12 |         1.0-SNAPSHOT
13 |     
14 | 
15 |     Runs asciidoctor-maven-plugin:process-asciidoc
16 | 
17 |     
18 |         UTF-8
19 |     
20 | 
21 |     
22 |         
23 |             
24 |                 org.asciidoctor
25 |                 asciidoctor-maven-plugin
26 |                 @project.version@
27 |                 
28 |                     
29 |                         html
30 |                         generate-resources
31 |                         
32 |                             process-asciidoc
33 |                         
34 |                         
35 |                             src/main/doc
36 |                             target/docs
37 |                             html
38 |                         
39 |                     
40 |                 
41 |                 
42 |                     
43 |                         org.asciidoctor
44 |                         log-handler
45 |                         1.0-SNAPSHOT
46 |                     
47 |                 
48 |             
49 |         
50 |     
51 | 
52 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/spi-registered-log/asciidoctor-project/src/main/doc/sample.asciidoc:
--------------------------------------------------------------------------------
 1 | Document Title
 2 | ==============
 3 | Doc Writer 
 4 | :idprefix: id_
 5 | 
 6 | Preamble paragraph.
 7 | 
 8 | NOTE: This is test, only a test.
 9 | 
10 | == Section A
11 | 
12 | *Section A* paragraph.
13 | 
14 | === Section A Subsection
15 | 
16 | *Section A* 'subsection' paragraph.
17 | 
18 | == Section B
19 | 
20 | *Section B* paragraph.
21 | 
22 | .Section B list
23 | * Item 1
24 | * Item 2
25 | * Item 3
26 | 
27 | == Missing include
28 | 
29 | include::something.adoc[]
30 | 
31 | // use  to show this message
32 | <>
33 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/spi-registered-log/invoker.properties:
--------------------------------------------------------------------------------
1 | invoker.goals=clean compile


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/spi-registered-log/log-handler/pom.xml:
--------------------------------------------------------------------------------
 1 | 
 3 |     4.0.0
 4 | 
 5 |     org.asciidoctor
 6 |     log-handler
 7 |     1.0-SNAPSHOT
 8 | 
 9 |     
10 |         org.asciidoctor
11 |         test-parent
12 |         1.0-SNAPSHOT
13 |     
14 | 
15 |     Implements a custom AsciidoctorJ LogHandler
16 | 
17 |     
18 |         UTF-8
19 |         1.8
20 |         3.8.1
21 |         2.5.11
22 |     
23 | 
24 |     
25 |         
26 |             
27 |                 org.apache.maven.plugins
28 |                 maven-compiler-plugin
29 |                 ${maven.compiler.plugin.version}
30 |                 
31 |                     ${project.java.version}
32 |                     ${project.java.version}
33 |                 
34 |             
35 |         
36 |     
37 | 
38 |     
39 |         
40 |             org.asciidoctor
41 |             asciidoctorj
42 |             ${asciidoctorj.version}
43 |         
44 |         
45 |         
46 |             org.apache.maven
47 |             maven-plugin-api
48 |             3.5.4
49 |             provided
50 |         
51 |     
52 | 
53 | 
54 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/spi-registered-log/log-handler/src/main/java/org/asciidoctor/maven/test/TestLogHandlerService.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.test;
 2 | 
 3 | import org.asciidoctor.log.LogHandler;
 4 | import org.asciidoctor.log.LogRecord;
 5 | 
 6 | import java.io.File;
 7 | import java.io.FileNotFoundException;
 8 | import java.io.FileOutputStream;
 9 | import java.io.IOException;
10 | import java.util.ArrayList;
11 | import java.util.List;
12 | 
13 | public class TestLogHandlerService implements LogHandler {
14 | 
15 |     public static final String CUSTOM_LOG = "custom_log.log";
16 | 
17 |     final FileOutputStream logFile;
18 | 
19 |     private static List logRecords = new ArrayList<>();
20 | 
21 |     public static List getLogRecords() {
22 |         return logRecords;
23 |     }
24 | 
25 |     public static void clear() {
26 |         logRecords.clear();
27 |     }
28 | 
29 |     public TestLogHandlerService() {
30 |         try {
31 |             logFile = new FileOutputStream(new File(CUSTOM_LOG));
32 |         } catch (FileNotFoundException e) {
33 |             throw new RuntimeException(e);
34 |         }
35 |     }
36 | 
37 |     @Override
38 |     public void log(LogRecord logRecord) {
39 |         writeLine("Logging from TestLogHandlerService: " + logRecord.getMessage());
40 |         logRecords.add(logRecord);
41 |     }
42 | 
43 |     private void writeLine(String message) {
44 |         try {
45 |             logFile.write(message.getBytes());
46 |             logFile.write("\n".getBytes());
47 |             logFile.flush();
48 |             // logFile.close();
49 |         } catch (IOException e) {
50 |             e.printStackTrace();
51 |         }
52 |     }
53 | 
54 | }


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/spi-registered-log/log-handler/src/main/resources/META-INF/services/_org.asciidoctor.extension.spi.ExtensionRegistry:
--------------------------------------------------------------------------------
1 | org.asciidoctor.maven.test.processors.AutoregisteredProcessor
2 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/spi-registered-log/log-handler/src/main/resources/META-INF/services/org.asciidoctor.log.LogHandler:
--------------------------------------------------------------------------------
1 | org.asciidoctor.maven.test.TestLogHandlerService


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/spi-registered-log/pom.xml:
--------------------------------------------------------------------------------
 1 | 
 3 |     4.0.0
 4 | 
 5 |     org.asciidoctor
 6 |     test-parent
 7 |     1.0-SNAPSHOT
 8 |     pom
 9 | 
10 |     Tests SPI registration of an AsciidoctorJ LogHandler
11 | 
12 |     
13 |         UTF-8
14 |     
15 | 
16 |     
17 |         log-handler
18 |         asciidoctor-project
19 |     
20 | 
21 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/spi-registered-log/validate.groovy:
--------------------------------------------------------------------------------
 1 | final def file = new File(basedir, "custom_log.log")
 2 | 
 3 | if (!file.exists())
 4 |     throw new Exception("Log file not initialized")
 5 | 
 6 | def text = file.text
 7 | if (!text.contains("Logging from TestLogHandlerService: include file not found:"))
 8 |     throw new Exception("Expected LogHandler message not found in log file")
 9 | 
10 | return true


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/thread-safe/asciidoctor-project-1/pom.xml:
--------------------------------------------------------------------------------
 1 | 
 4 |   4.0.0
 5 | 
 6 |   org.asciidoctor
 7 |   asciidoctor-project-1
 8 | 
 9 |   
10 |     org.asciidoctor
11 |     test-parent
12 |     1.0-SNAPSHOT
13 |   
14 | 
15 |   Runs asciidoctor-maven-plugin:process-asciidoc
16 | 
17 |   
18 |     UTF-8
19 |   
20 | 
21 |   
22 |     
23 |       
24 |         org.asciidoctor
25 |         asciidoctor-maven-plugin
26 |         @project.version@
27 |         
28 |           
29 |             html
30 |             generate-resources
31 |             
32 |               process-asciidoc
33 |             
34 |             
35 |               src/main/doc
36 |               target/docs
37 |               html
38 |               false
39 |             
40 |           
41 |         
42 |       
43 |     
44 |   
45 | 
46 | 
47 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/thread-safe/asciidoctor-project-1/src/main/doc/sample.asciidoc:
--------------------------------------------------------------------------------
 1 | Document Title
 2 | ==============
 3 | Doc Writer 
 4 | :idprefix: id_
 5 | 
 6 | Preamble paragraph.
 7 | 
 8 | NOTE: This is test, only a test.
 9 | 
10 | 
11 | 
12 | == Section A
13 | 
14 | *Section A* paragraph.
15 | 
16 | === Section A Subsection
17 | 
18 | *Section A* 'subsection' paragraph.
19 | 
20 | == Section B
21 | 
22 | *Section B* paragraph.
23 | 
24 | .Section B list
25 | * Item 1
26 | * Item 2
27 | * Item 3
28 | 
29 | == Section C
30 | 
31 | [source,java]
32 | ----
33 | public class HelloWorld {
34 | 
35 |     public static void main(String[] args) {
36 |         System.out.println("Hello, World!!");
37 |     }
38 | 
39 | }
40 | ----


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/thread-safe/asciidoctor-project-2/pom.xml:
--------------------------------------------------------------------------------
 1 | 
 4 |   4.0.0
 5 | 
 6 |   org.asciidoctor
 7 |   asciidoctor-project-2
 8 | 
 9 |   
10 |     org.asciidoctor
11 |     test-parent
12 |     1.0-SNAPSHOT
13 |   
14 | 
15 |   Runs asciidoctor-maven-plugin:process-asciidoc
16 | 
17 |   
18 |     UTF-8
19 |   
20 | 
21 |   
22 |     
23 |       
24 |         org.asciidoctor
25 |         asciidoctor-maven-plugin
26 |         @project.version@
27 |         
28 |           
29 |             html
30 |             generate-resources
31 |             
32 |               process-asciidoc
33 |             
34 |             
35 |               src/main/doc
36 |               target/docs
37 |               html
38 |               false
39 |             
40 |           
41 |         
42 |       
43 |     
44 |   
45 | 
46 | 
47 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/thread-safe/asciidoctor-project-2/src/main/doc/sample.asciidoc:
--------------------------------------------------------------------------------
 1 | Document Title
 2 | ==============
 3 | Doc Writer 
 4 | :idprefix: id_
 5 | 
 6 | Preamble paragraph.
 7 | 
 8 | NOTE: This is test, only a test.
 9 | 
10 | 
11 | 
12 | == Section A
13 | 
14 | *Section A* paragraph.
15 | 
16 | === Section A Subsection
17 | 
18 | *Section A* 'subsection' paragraph.
19 | 
20 | == Section B
21 | 
22 | *Section B* paragraph.
23 | 
24 | .Section B list
25 | * Item 1
26 | * Item 2
27 | * Item 3
28 | 
29 | == Section C
30 | 
31 | [source,java]
32 | ----
33 | public class HelloWorld {
34 | 
35 |     public static void main(String[] args) {
36 |         System.out.println("Hello, World!!");
37 |     }
38 | 
39 | }
40 | ----


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/thread-safe/asciidoctor-project-3/pom.xml:
--------------------------------------------------------------------------------
 1 | 
 4 |   4.0.0
 5 | 
 6 |   org.asciidoctor
 7 |   asciidoctor-project-3
 8 | 
 9 |   
10 |     org.asciidoctor
11 |     test-parent
12 |     1.0-SNAPSHOT
13 |   
14 | 
15 |   Runs asciidoctor-maven-plugin:process-asciidoc
16 | 
17 |   
18 |     UTF-8
19 |   
20 | 
21 |   
22 |     
23 |       
24 |         org.asciidoctor
25 |         asciidoctor-maven-plugin
26 |         @project.version@
27 |         
28 |           
29 |             html
30 |             generate-resources
31 |             
32 |               process-asciidoc
33 |             
34 |             
35 |               src/main/doc
36 |               target/docs
37 |               html
38 |               false
39 |             
40 |           
41 |         
42 |       
43 |     
44 |   
45 | 
46 | 
47 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/thread-safe/asciidoctor-project-3/src/main/doc/sample.asciidoc:
--------------------------------------------------------------------------------
 1 | Document Title
 2 | ==============
 3 | Doc Writer 
 4 | :idprefix: id_
 5 | 
 6 | Preamble paragraph.
 7 | 
 8 | NOTE: This is test, only a test.
 9 | 
10 | 
11 | 
12 | == Section A
13 | 
14 | *Section A* paragraph.
15 | 
16 | === Section A Subsection
17 | 
18 | *Section A* 'subsection' paragraph.
19 | 
20 | == Section B
21 | 
22 | *Section B* paragraph.
23 | 
24 | .Section B list
25 | * Item 1
26 | * Item 2
27 | * Item 3
28 | 
29 | == Section C
30 | 
31 | [source,java]
32 | ----
33 | public class HelloWorld {
34 | 
35 |     public static void main(String[] args) {
36 |         System.out.println("Hello, World!!");
37 |     }
38 | 
39 | }
40 | ----


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/thread-safe/invoker.properties:
--------------------------------------------------------------------------------
1 | invoker.goals=-T3 clean compile


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/thread-safe/pom.xml:
--------------------------------------------------------------------------------
 1 | 
 3 |   4.0.0
 4 | 
 5 |   org.asciidoctor
 6 |   test-parent
 7 |   1.0-SNAPSHOT
 8 |   pom
 9 | 
10 |   Tests that the plugin is thread safe by checking that the result content are not mixed.
11 | 
12 |   
13 |     UTF-8
14 |   
15 | 
16 |   
17 |     asciidoctor-project-1
18 |     asciidoctor-project-2
19 |     asciidoctor-project-3
20 |   
21 | 
22 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/thread-safe/validate.groovy:
--------------------------------------------------------------------------------
 1 | import java.nio.charset.Charset
 2 | import java.nio.file.Files
 3 | 
 4 | String fileTemplate = "asciidoctor-project-%s/target/docs/sample.html"
 5 | 
 6 | List contents = new ArrayList<>()
 7 | List files = new ArrayList<>()
 8 | for (int i = 1; i <= 3; i++) {
 9 |     File file = new File(basedir, String.format(fileTemplate, i))
10 |     println("Checking for existence of " + file)
11 |     if (!file.isFile()) {
12 |         throw new Exception("Missing file " + file)
13 |     }
14 | 
15 |     StringBuilder contentOfFile = new StringBuilder()
16 |     for (String line : Files.readAllLines(file.toPath(), Charset.forName("UTF-8"))) {
17 |         contentOfFile.append(line)
18 |     }
19 |     contents.add(contentOfFile.toString())
20 |     files.add(String.format(fileTemplate, i))
21 | 
22 | }
23 | 
24 | 
25 | if(!contents.get(0).equals(contents.get(1))) {
26 |     throw new Exception(String.format("The content of two files are different.\n\n%s: %s\n%s: %s", files.get(0), contents.get(0), files.get(1), contents.get(1) ))
27 | }
28 | 
29 | if(!contents.get(1).equals(contents.get(2))) {
30 |     throw new Exception(String.format("The content of two files are different.\n\n%s: %s\n%s: %s", files.get(1), contents.get(1), files.get(2), contents.get(2) ))
31 | }
32 | 
33 | if(!contents.get(2).equals(contents.get(0))) {
34 |     throw new Exception(String.format("The content of two files are different.\n\n%s: %s\n%s: %s", files.get(2), contents.get(2), files.get(0), contents.get(0) ))
35 | }
36 | 
37 | return true


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/uses-html5-as-default-backend/invoker.properties:
--------------------------------------------------------------------------------
1 | invoker.goals=clean asciidoctor:process-asciidoc


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/uses-html5-as-default-backend/pom.xml:
--------------------------------------------------------------------------------
 1 | 
 3 | 	4.0.0
 4 | 
 5 | 	org.asciidoctor
 6 | 	test
 7 | 	1.0-SNAPSHOT
 8 | 
 9 | 	Converts Asciidoctor Article to Html
10 | 	Runs asciidoctor-maven-plugin:process-asciidoc
11 | 
12 | 	
13 | 		UTF-8
14 | 	
15 | 
16 | 	
17 | 		
18 | 			
19 | 				org.asciidoctor
20 | 				asciidoctor-maven-plugin
21 | 				@project.version@
22 | 			
23 | 		
24 | 	
25 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/uses-html5-as-default-backend/src/docs/asciidoc/sample.asciidoc:
--------------------------------------------------------------------------------
 1 | Document Title
 2 | ==============
 3 | Doc Writer 
 4 | :idprefix: id_
 5 | 
 6 | Preamble paragraph.
 7 | 
 8 | NOTE: This is test, only a test.
 9 | 
10 | == Section A
11 | 
12 | *Section A* paragraph.
13 | 
14 | === Section A Subsection
15 | 
16 | *Section A* 'subsection' paragraph.
17 | 
18 | == Section B
19 | 
20 | *Section B* paragraph.
21 | 
22 | .Section B list
23 | * Item 1
24 | * Item 2
25 | * Item 3
26 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/it/uses-html5-as-default-backend/validate.groovy:
--------------------------------------------------------------------------------
 1 | final File outputDir = new File(basedir, "target/generated-docs");
 2 | 
 3 | final def expectedFiles = ["sample.html"]
 4 | 
 5 | expectedFiles.each { it ->
 6 |     File file = new File(outputDir, it);
 7 |     System.out.println("Checking for existence of " + file)
 8 |     if (!file.exists() || !file.isFile()) {
 9 |         throw new Exception("Missing file " + file)
10 |     }
11 |     if (!file.text.startsWith("")) {
12 |         throw new Exception("Expected file does not contain HTML: " + file)
13 |     }
14 | }
15 | 
16 | return true


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/AsciidoctorHttpMojo.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven;
 2 | 
 3 | import javax.inject.Inject;
 4 | 
 5 | import org.apache.maven.plugin.MojoExecutionException;
 6 | import org.apache.maven.plugin.MojoFailureException;
 7 | import org.apache.maven.plugins.annotations.Mojo;
 8 | import org.apache.maven.plugins.annotations.Parameter;
 9 | import org.asciidoctor.maven.http.AsciidoctorHttpServer;
10 | import org.asciidoctor.maven.process.ResourcesProcessor;
11 | import org.asciidoctor.maven.process.SourceDocumentFinder;
12 | 
13 | @Mojo(name = "http")
14 | public class AsciidoctorHttpMojo extends AsciidoctorRefreshMojo {
15 | 
16 |     public static final String PREFIX = AsciidoctorMaven.PREFIX + "http.";
17 | 
18 |     @Parameter(property = PREFIX + "port", defaultValue = "2000")
19 |     protected int port;
20 | 
21 |     @Parameter(property = PREFIX + "home", defaultValue = "index")
22 |     protected String home;
23 | 
24 |     @Inject
25 |     public AsciidoctorHttpMojo(AsciidoctorJFactory asciidoctorJFactory, AsciidoctorOptionsFactory asciidoctorOptionsFactory, SourceDocumentFinder finder, ResourcesProcessor defaultResourcesProcessor) {
26 |         super(asciidoctorJFactory, asciidoctorOptionsFactory, finder, defaultResourcesProcessor);
27 |     }
28 | 
29 |     @Override
30 |     public void execute() throws MojoExecutionException, MojoFailureException {
31 | 
32 |         final AsciidoctorHttpServer server = new AsciidoctorHttpServer(getLog(), port, outputDirectory, home);
33 | 
34 |         startPolling();
35 |         server.start();
36 |         doWork();
37 |         doWait();
38 |         server.stop();
39 |         stopMonitors();
40 |     }
41 | 
42 |     public String getHome() {
43 |         return home;
44 |     }
45 | 
46 |     public void setHome(final String home) {
47 |         this.home = home;
48 |     }
49 | }
50 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/AsciidoctorMaven.java:
--------------------------------------------------------------------------------
1 | package org.asciidoctor.maven;
2 | 
3 | public interface AsciidoctorMaven {
4 |     String PREFIX = "asciidoctor.";
5 | }
6 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/extensions/ExtensionConfiguration.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.extensions;
 2 | 
 3 | /**
 4 |  * Holds an extension's configuration parameters in the pom.xml
 5 |  *
 6 |  * @author abelsromero
 7 |  */
 8 | public class ExtensionConfiguration {
 9 | 
10 |     /**
11 |      * Fully qualified name of the extension
12 |      */
13 |     private String className;
14 | 
15 |     /**
16 |      * Optional. Block name in case of setting a Block, BlockMacro or
17 |      * InlineMacro processor
18 |      */
19 |     private String blockName;
20 | 
21 |     public ExtensionConfiguration() {
22 |     }
23 | 
24 |     public String getClassName() {
25 |         return className;
26 |     }
27 | 
28 |     public void setClassName(String className) {
29 |         this.className = className;
30 |     }
31 | 
32 |     public String getBlockName() {
33 |         return blockName;
34 |     }
35 | 
36 |     public void setBlockName(String blockName) {
37 |         this.blockName = blockName;
38 |     }
39 | 
40 | }
41 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/extensions/ExtensionRegistry.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.extensions;
 2 | 
 3 | import org.asciidoctor.extension.Processor;
 4 | 
 5 | /**
 6 |  * Base interface for registering AsciidoctorJ extension in the plugin.
 7 |  *
 8 |  * @author abelsromero
 9 |  */
10 | public interface ExtensionRegistry {
11 | 
12 |     /**
13 |      * Registers an AsciidoctorJ extension by full class name.
14 |      *
15 |      * @param extensionClassName fully qualified name of the class implementing the extension
16 |      * @param blockName          required when declaring
17 |      * @throws RuntimeException if {@code extensionClassName} belongs to a valid {@link Processor},
18 |      *                          class, or if it can be found in the classpath
19 |      */
20 |     void register(String extensionClassName, String blockName);
21 | 
22 | }
23 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/io/Zips.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.io;
 2 | 
 3 | import java.io.File;
 4 | import java.io.FileInputStream;
 5 | import java.io.FileOutputStream;
 6 | import java.io.IOException;
 7 | import java.util.zip.ZipEntry;
 8 | import java.util.zip.ZipOutputStream;
 9 | 
10 | import org.apache.commons.io.IOUtils;
11 | 
12 | public final class Zips {
13 | 
14 |     public static void zip(final File dir, final File zipName) throws IOException, IllegalArgumentException {
15 |         final String[] entries = dir.list();
16 | 
17 |         try (final ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipName))) {
18 |             String prefix = dir.getAbsolutePath();
19 |             if (!prefix.endsWith(File.separator)) {
20 |                 prefix += File.separator;
21 |             }
22 | 
23 |             for (final String entry : entries) {
24 |                 File f = new File(dir, entry);
25 |                 zip(out, f, prefix, zipName.getName().substring(0, zipName.getName().length() - 4));
26 |             }
27 |         }
28 |     }
29 | 
30 |     private static void zip(final ZipOutputStream out, final File f, final String prefix, final String root) throws IOException {
31 |         if (f.isDirectory()) {
32 |             final File[] files = f.listFiles();
33 |             if (files != null) {
34 |                 for (final File child : files) {
35 |                     zip(out, child, prefix, root);
36 |                 }
37 |             }
38 |         } else {
39 |             try (final FileInputStream in = new FileInputStream(f)) {
40 |                 final ZipEntry entry = new ZipEntry(root + "/" + f.getPath().replace(prefix, ""));
41 |                 out.putNextEntry(entry);
42 |                 IOUtils.copy(in, out);
43 |             }
44 |         }
45 |     }
46 | 
47 |     private Zips() {
48 |         // no-op
49 |     }
50 | }
51 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/model/Resource.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.model;
 2 | 
 3 | import java.util.ArrayList;
 4 | import java.util.List;
 5 | 
 6 | public class Resource {
 7 | 
 8 |     private String directory;
 9 |     private String targetPath;
10 |     private List includes;
11 |     private List excludes;
12 | 
13 |     public void setDirectory(String directory) {
14 |         this.directory = directory;
15 |     }
16 | 
17 |     public String getDirectory() {
18 |         return this.directory;
19 |     }
20 | 
21 |     public void setTargetPath(String targetPath) {
22 |         this.targetPath = targetPath;
23 |     }
24 | 
25 |     public String getTargetPath() {
26 |         return this.targetPath;
27 |     }
28 | 
29 |     public void setIncludes(List includes) {
30 |         this.includes = includes;
31 |     }
32 | 
33 |     public List getIncludes() {
34 |         if (this.includes == null) {
35 |             this.includes = new ArrayList<>();
36 |         }
37 | 
38 |         return this.includes;
39 |     }
40 | 
41 |     public void setExcludes(List excludes) {
42 |         this.excludes = excludes;
43 |     }
44 | 
45 |     public List getExcludes() {
46 |         if (this.excludes == null) {
47 |             this.excludes = new ArrayList<>();
48 |         }
49 | 
50 |         return this.excludes;
51 |     }
52 | }
53 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/process/ResourcesProcessor.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.process;
 2 | 
 3 | import java.io.File;
 4 | 
 5 | import org.asciidoctor.maven.AsciidoctorMojo;
 6 | 
 7 | /**
 8 |  * @since 2.1.0
 9 |  */
10 | public interface ResourcesProcessor {
11 | 
12 |     /**
13 |      * Identifies requires resources and prepares them based on configuration.
14 |      *
15 |      * @param sourceRootDirectory starting directory to search resources. 'configuration' may add or modify it.
16 |      * @param outputRootDirectory target directory to place final resources when copying is required.
17 |      * @param configuration       Asciidoctor conversion configuration
18 |      */
19 |     void process(File sourceRootDirectory, File outputRootDirectory, AsciidoctorMojo configuration);
20 | 
21 | }
22 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/process/SourceDirectoryFinder.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.process;
 2 | 
 3 | import java.io.File;
 4 | import java.util.Optional;
 5 | import java.util.function.Consumer;
 6 | 
 7 | /**
 8 |  * Finds the first available source directory amongst a list of possible candidates,
 9 |  * unless the initial candidate is the default value.
10 |  * In that case, it only checks availability for the value provided as initial.
11 |  *
12 |  * @author abelsromero
13 |  * @since 2.0.0
14 |  */
15 | public class SourceDirectoryFinder {
16 | 
17 |     public static final String DEFAULT_SOURCE_DIR = "src/docs/asciidoc";
18 |     public static final String[] ORDERED_CANDIDATE_PATHS = new String[]{
19 |             DEFAULT_SOURCE_DIR,
20 |             "src/asciidoc",
21 |             "src/main/asciidoc"
22 |     };
23 | 
24 |     private final String initialCandidate;
25 |     private final File baseDir;
26 |     private final Consumer notFoundAction;
27 | 
28 |     public SourceDirectoryFinder(File initialCandidate, File baseDir, Consumer notFoundAction) {
29 |         this.initialCandidate = initialCandidate.toString();
30 |         this.baseDir = baseDir;
31 |         this.notFoundAction = notFoundAction;
32 |     }
33 | 
34 |     public Optional find() {
35 | 
36 |         if (!matchesDefaultSourceDirectory(initialCandidate)) {
37 |             File filePath = resolvePath(initialCandidate);
38 |             if (filePath.exists())
39 |                 return Optional.of(filePath);
40 |             else {
41 |                 notFoundAction.accept(filePath);
42 |                 return Optional.empty();
43 |             }
44 |         }
45 | 
46 |         for (String candidatePath : ORDERED_CANDIDATE_PATHS) {
47 |             File current = resolvePath(candidatePath);
48 |             if (current.exists()) {
49 |                 return Optional.of(current);
50 |             }
51 |             notFoundAction.accept(current);
52 |         }
53 | 
54 |         return Optional.empty();
55 |     }
56 | 
57 |     private boolean matchesDefaultSourceDirectory(String path) {
58 |         return resolvePath(path).equals(new File(baseDir, DEFAULT_SOURCE_DIR));
59 |     }
60 | 
61 |     private File resolvePath(String filePath) {
62 |         final File candidate = new File(filePath);
63 |         if (candidate.isAbsolute())
64 |             return candidate;
65 |         else
66 |             return new File(baseDir, filePath);
67 |     }
68 | 
69 | }
70 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/refresh/AbstractFileAlterationListenerAdaptor.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.refresh;
 2 | 
 3 | import java.io.File;
 4 | 
 5 | import org.apache.commons.io.monitor.FileAlterationListenerAdaptor;
 6 | import org.apache.maven.plugin.logging.Log;
 7 | import org.asciidoctor.maven.AsciidoctorRefreshMojo;
 8 | 
 9 | public abstract class AbstractFileAlterationListenerAdaptor extends FileAlterationListenerAdaptor {
10 | 
11 |     private final AsciidoctorRefreshMojo mojo;
12 |     private final Runnable postAction;
13 |     private final Log log;
14 | 
15 |     public AbstractFileAlterationListenerAdaptor(AsciidoctorRefreshMojo mojo, Runnable postAction, Log log) {
16 |         this.mojo = mojo;
17 |         this.postAction = postAction;
18 |         this.log = log;
19 |     }
20 | 
21 |     @Override
22 |     public void onFileCreate(final File file) {
23 |         processFile(file, "created");
24 |         postAction.run();
25 |     }
26 | 
27 |     @Override
28 |     public void onFileChange(final File file) {
29 |         processFile(file, "updated");
30 |         postAction.run();
31 |     }
32 | 
33 |     abstract void processFile(File file, String actionName);
34 | 
35 |     public AsciidoctorRefreshMojo getMojo() {
36 |         return mojo;
37 |     }
38 | 
39 |     public Log getLog() {
40 |         return log;
41 |     }
42 | }
43 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/refresh/AdditionalSourceFileAlterationListenerAdaptor.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.refresh;
 2 | 
 3 | import java.io.File;
 4 | 
 5 | import org.apache.maven.plugin.MojoExecutionException;
 6 | import org.apache.maven.plugin.logging.Log;
 7 | import org.asciidoctor.maven.AsciidoctorRefreshMojo;
 8 | import org.asciidoctor.maven.process.ResourcesProcessor;
 9 | 
10 | public class AdditionalSourceFileAlterationListenerAdaptor extends AbstractFileAlterationListenerAdaptor {
11 | 
12 |     private static final ResourcesProcessor EMPTY_RESOURCES_PROCESSOR = (sourcesDir, outputDir, configuration) -> {
13 |     };
14 | 
15 | 
16 |     public AdditionalSourceFileAlterationListenerAdaptor(AsciidoctorRefreshMojo mojo, Runnable postAction, Log log) {
17 |         super(mojo, postAction, log);
18 |     }
19 | 
20 |     @Override
21 |     synchronized void processFile(File file, String actionName) {
22 |         getLog().info(String.format("Additional source file %s %s", file.getAbsolutePath(), actionName));
23 |         getLog().info("Full refresh");
24 |         long timeInMillis = TimeCounter.timed(() -> {
25 |             try {
26 |                 getMojo().processAllSources(EMPTY_RESOURCES_PROCESSOR);
27 |             } catch (MojoExecutionException e) {
28 |                 getLog().error(e);
29 |             }
30 |         });
31 |         getLog().info("Converted document(s) in " + timeInMillis + "ms");
32 |     }
33 | 
34 | }
35 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/refresh/AsciidoctorConverterFileAlterationListenerAdaptor.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.refresh;
 2 | 
 3 | import java.io.File;
 4 | import java.util.Collections;
 5 | 
 6 | import org.apache.maven.plugin.MojoExecutionException;
 7 | import org.apache.maven.plugin.logging.Log;
 8 | import org.asciidoctor.maven.AsciidoctorRefreshMojo;
 9 | import org.asciidoctor.maven.process.ResourcesProcessor;
10 | 
11 | public class AsciidoctorConverterFileAlterationListenerAdaptor extends AbstractFileAlterationListenerAdaptor {
12 | 
13 |     private static final ResourcesProcessor EMPTY_RESOURCES_PROCESSOR = (sourcesDir, outputDir, configuration) -> {
14 |     };
15 | 
16 | 
17 |     public AsciidoctorConverterFileAlterationListenerAdaptor(AsciidoctorRefreshMojo mojo, Runnable postAction, Log log) {
18 |         super(mojo, postAction, log);
19 |     }
20 | 
21 |     @Override
22 |     synchronized void processFile(File file, String actionName) {
23 |         getLog().info(String.format("Source file %s %s", file.getAbsolutePath(), actionName));
24 |         long timeInMillis = TimeCounter.timed(() -> {
25 |             try {
26 |                 getMojo().processSources(Collections.singletonList(file), EMPTY_RESOURCES_PROCESSOR);
27 |             } catch (MojoExecutionException e) {
28 |                 getLog().error(e);
29 |             }
30 |         });
31 |         getLog().info("Converted document in " + timeInMillis + "ms");
32 |     }
33 | 
34 | }
35 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/refresh/ResourcesPatternBuilder.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.refresh;
 2 | 
 3 | import java.util.Arrays;
 4 | import java.util.List;
 5 | import java.util.StringJoiner;
 6 | import java.util.stream.Collectors;
 7 | 
 8 | import static org.asciidoctor.maven.commons.StringUtils.isBlank;
 9 | import static org.asciidoctor.maven.process.CopyResourcesProcessor.IGNORED_FILE_NAMES;
10 | import static org.asciidoctor.maven.process.SourceDocumentFinder.ASCIIDOC_FILE_EXTENSIONS_REG_EXP;
11 | 
12 | /**
13 |  * Builds regular expression to include all valid resources, as well as exclude invalid ones
14 |  * to be copied for `auto-refresh` mojo.
15 |  *
16 |  * @author abelsromero
17 |  */
18 | public class ResourcesPatternBuilder {
19 | 
20 |     private final String sourceDocumentName;
21 |     private final List sourceDocumentExtensions;
22 | 
23 |     public ResourcesPatternBuilder(final String sourceDocumentName, final List sourceDocumentExtensions) {
24 |         this.sourceDocumentName = sourceDocumentName;
25 |         this.sourceDocumentExtensions = sourceDocumentExtensions;
26 |     }
27 | 
28 |     public String build() {
29 |         final StringJoiner filePattern = new StringJoiner("|")
30 |                 .add(ASCIIDOC_FILE_EXTENSIONS_REG_EXP);
31 |         if (!sourceDocumentExtensions.isEmpty())
32 |             filePattern.add(String.join("|", sourceDocumentExtensions));
33 | 
34 |         final String specialFiles = Arrays.stream(IGNORED_FILE_NAMES)
35 |                 .map(pattern -> pattern.replaceAll("\\*", ".*"))
36 |                 .map(pattern -> pattern.replaceAll("\\.", "\\\\."))
37 |                 .collect(Collectors.joining("|"));
38 | 
39 |         return new StringBuilder()
40 |                 .append("^")
41 |                 .append("(?!(" + specialFiles + (isBlank(sourceDocumentName) ? "" : "|" + sourceDocumentName) + "))")
42 |                 .append("[^_.].*\\.(?!(")
43 |                 .append(filePattern)
44 |                 .append(")).*$")
45 |                 .toString();
46 |     }
47 | 
48 | }
49 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/refresh/TimeCounter.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.refresh;
 2 | 
 3 | import java.util.concurrent.TimeUnit;
 4 | 
 5 | public class TimeCounter {
 6 | 
 7 |     public static long timed(Runnable runnable) {
 8 |         final long start = System.nanoTime();
 9 |         runnable.run();
10 |         final long end = System.nanoTime();
11 |         return TimeUnit.NANOSECONDS.toMillis(end - start);
12 |     }
13 | }
14 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/main/resources/enable_verbose.rb:
--------------------------------------------------------------------------------
1 | # script used to enable Asciidoctor verbose
2 | $VERBOSE=true


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorAsserter.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven;
 2 | 
 3 | import java.io.File;
 4 | import java.nio.file.Files;
 5 | 
 6 | import lombok.SneakyThrows;
 7 | import org.assertj.core.api.AbstractFileAssert;
 8 | import org.assertj.core.api.AbstractStringAssert;
 9 | import org.assertj.core.api.Assertions;
10 | 
11 | public class AsciidoctorAsserter {
12 | 
13 |     private final AbstractFileAssert fileAssert;
14 |     private final AbstractStringAssert contentAssert;
15 | 
16 |     @SneakyThrows
17 |     private AsciidoctorAsserter(File generatedFile) {
18 |         this.fileAssert = Assertions.assertThat(generatedFile);
19 |         this.contentAssert = Assertions.assertThat(Files.readString(generatedFile.toPath()));
20 |     }
21 | 
22 |     public static AsciidoctorAsserter assertThat(File file) {
23 |         return new AsciidoctorAsserter(file);
24 |     }
25 | 
26 |     public static AsciidoctorAsserter assertThat(File parentPath, String filename) {
27 |         return new AsciidoctorAsserter(new File(parentPath, filename));
28 |     }
29 | 
30 |     public AsciidoctorAsserter isNotEmpty() {
31 |         fileAssert.exists().isNotEmpty();
32 |         return this;
33 |     }
34 | 
35 |     public AsciidoctorAsserter contains(String text) {
36 |         contentAssert.contains(text);
37 |         return this;
38 |     }
39 | 
40 |     public AsciidoctorAsserter containsPattern(String regex) {
41 |         contentAssert.containsPattern(regex);
42 |         return this;
43 |     }
44 | 
45 |     public AsciidoctorAsserter containsOnlyOnce(String text) {
46 |         contentAssert.containsOnlyOnce(text);
47 |         return this;
48 |     }
49 | 
50 |     public AsciidoctorAsserter doesNotContain(String text) {
51 |         contentAssert.doesNotContain(text);
52 |         return this;
53 |     }
54 | 
55 |     public AsciidoctorAsserter startsWith(String prefix) {
56 |         contentAssert.startsWith(prefix);
57 |         return this;
58 |     }
59 | }
60 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/DoubleOutputStream.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.io;
 2 | 
 3 | import java.io.ByteArrayOutputStream;
 4 | import java.io.OutputStream;
 5 | 
 6 | import lombok.SneakyThrows;
 7 | 
 8 | public class DoubleOutputStream extends ByteArrayOutputStream {
 9 | 
10 |     final OutputStream other;
11 | 
12 |     public DoubleOutputStream(final OutputStream os) {
13 |         other = os;
14 |     }
15 | 
16 |     @SneakyThrows
17 |     @Override
18 |     public synchronized void write(final byte[] b, final int off, final int len) {
19 |         other.write(b, off, len);
20 |         super.write(b, off, len);
21 |     }
22 | }
23 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/PrefilledInputStream.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.io;
 2 | 
 3 | import java.io.ByteArrayInputStream;
 4 | import java.util.concurrent.CountDownLatch;
 5 | 
 6 | import lombok.SneakyThrows;
 7 | 
 8 | public class PrefilledInputStream extends ByteArrayInputStream {
 9 | 
10 |     final CountDownLatch latch;
11 | 
12 |     public PrefilledInputStream(final byte[] buf, final CountDownLatch latch) {
13 |         super(buf);
14 |         this.latch = latch;
15 |     }
16 | 
17 |     @SneakyThrows
18 |     @Override
19 |     public synchronized int read(final byte[] b, final int off, final int len) {
20 |         latch.await();
21 |         return super.read(b, off, len);
22 |     }
23 | }
24 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/StringsCollectionsInputStream.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.io;
 2 | 
 3 | import java.io.InputStream;
 4 | import java.util.ArrayList;
 5 | import java.util.List;
 6 | import java.util.concurrent.Semaphore;
 7 | import java.util.concurrent.atomic.AtomicInteger;
 8 | 
 9 | import lombok.SneakyThrows;
10 | 
11 | /**
12 |  * Reads from a collection of strings to simulate command line inputs.
13 |  * {@link InputStream#read(byte[], int, int)} will wait indefinitely
14 |  * until a new line is published with {@link #publishLine(String)}.
15 |  */
16 | class StringsCollectionsInputStream extends InputStream {
17 | 
18 |     private static final String LINEBREAK = "\r\n";
19 | 
20 |     private final AtomicInteger index = new AtomicInteger(0);
21 |     private final List lines = new ArrayList<>();
22 | 
23 |     private volatile Semaphore mutex = new Semaphore(1);
24 | 
25 |     @SneakyThrows
26 |     public StringsCollectionsInputStream() {
27 |         mutex.acquire();
28 |     }
29 | 
30 |     @SneakyThrows
31 |     @Override
32 |     public int read() {
33 |         mutex.acquire();
34 |         int indexValue = index.get();
35 |         return indexValue >= lines.size() ? -1 : lines.get(indexValue).charAt(0);
36 | 
37 |     }
38 | 
39 |     @SneakyThrows
40 |     @Override
41 |     public int read(byte[] b, final int off, final int len) {
42 |         mutex.acquire();
43 | 
44 |         if (lines.isEmpty()) {
45 |             return copyBytesToBuffer(LINEBREAK, b, off);
46 |         } else {
47 |             return copyBytesToBuffer(lines.get(index.getAndIncrement()), b, off);
48 |         }
49 |     }
50 | 
51 |     private int copyBytesToBuffer(String line, byte[] buffer, int off) {
52 |         byte[] bytes = (line + LINEBREAK).getBytes();
53 |         for (int i = 0; i < bytes.length; i++) {
54 |             buffer[off + i] = bytes[i];
55 |         }
56 |         return bytes.length;
57 |     }
58 | 
59 |     public void publishLine(String line) {
60 |         lines.add(line);
61 |         mutex.release();
62 |     }
63 | }
64 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/TestFilesHelper.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.io;
 2 | 
 3 | import java.io.File;
 4 | import java.nio.file.Files;
 5 | import java.util.UUID;
 6 | 
 7 | import lombok.SneakyThrows;
 8 | 
 9 | public class TestFilesHelper {
10 | 
11 |     public static final String TEST_OUTPUT_BASE_PATH = "target/test-outputs/";
12 | 
13 |     public static File newOutputTestDirectory() {
14 |         return normalize(createDirectory(TEST_OUTPUT_BASE_PATH + UUID.randomUUID()));
15 |     }
16 | 
17 |     public static File newOutputTestDirectory(String subDir) {
18 |         return normalize(createDirectory(TEST_OUTPUT_BASE_PATH + subDir + "/" + UUID.randomUUID()));
19 |     }
20 | 
21 |     // Since v3.0.0, path must be absolute https://github.com/asciidoctor/asciidoctorj/pull/1249.
22 |     // Note: in real Mojo execution, paths are always absolute.
23 |     private static File normalize(File file) {
24 |         return file.getAbsoluteFile();
25 |     }
26 | 
27 |     private static File createDirectory(String path) {
28 |         return new File(path);
29 |     }
30 | 
31 |     public static File createFileWithContent(File srcDir, String filename) {
32 |         return createFileWithContent(srcDir, filename, "Test content");
33 |     }
34 | 
35 |     @SneakyThrows
36 |     public static File createFileWithContent(File srcDir, String filename, String content) {
37 |         srcDir.mkdirs();
38 |         final File file = new File(srcDir, filename);
39 |         Files.write(file.toPath(), content.getBytes());
40 |         return file;
41 |     }
42 | }
43 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/UserInputSimulator.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.io;
 2 | 
 3 | import java.io.ByteArrayOutputStream;
 4 | import java.io.PrintStream;
 5 | import java.util.concurrent.CountDownLatch;
 6 | 
 7 | import lombok.SneakyThrows;
 8 | 
 9 | public class UserInputSimulator {
10 | 
11 |     private final CountDownLatch inputLatch;
12 |     private final PrintStream originalOut;
13 |     private final ByteArrayOutputStream newOut;
14 | 
15 |     public UserInputSimulator() {
16 |         inputLatch = new CountDownLatch(1);
17 |         originalOut = System.out;
18 |         newOut = new DoubleOutputStream(originalOut);
19 |     }
20 | 
21 |     /**
22 |      * Simulates commands inputted by an user.
23 |      */
24 |     public void type(String input) {
25 |         System.setOut(new PrintStream(newOut));
26 |         System.setIn(new PrefilledInputStream(input.getBytes(), inputLatch));
27 |     }
28 | 
29 |     public void stop() {
30 |         System.setOut(originalOut);
31 |         inputLatch.countDown();
32 |     }
33 | 
34 |     @SneakyThrows
35 |     public void waitForCompletion() {
36 |         while (!new String(newOut.toByteArray()).contains("Type ")) {
37 |             Thread.sleep(200);
38 |         }
39 |     }
40 | }
41 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/refresh/ResourcesPatternBuilderTest.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.refresh;
 2 | 
 3 | import java.util.Arrays;
 4 | import java.util.Collections;
 5 | 
 6 | import org.junit.jupiter.api.Test;
 7 | 
 8 | import static org.assertj.core.api.Assertions.assertThat;
 9 | 
10 | class ResourcesPatternBuilderTest {
11 | 
12 |     private static final String DOC_INFO_FILES = "docinfo\\.html|docinfo-header\\.html|docinfo-footer\\.html|\\.*-docinfo\\.html|\\.*-docinfo-header\\.html|\\.*-docinfo-footer\\.html|docinfo\\.xml|docinfo-header\\.xml|docinfo-footer\\.xml|\\.*-docinfo\\.xml|\\.*-docinfo-header\\.xml|\\.*-docinfo-footer\\.xml";
13 |     private static final String ASCIIDOC_SOURCES = "(a((sc(iidoc)?)|d(oc)?))";
14 | 
15 |     @Test
16 |     void should_build_default_pattern() {
17 |         // given
18 |         ResourcesPatternBuilder patternBuilder = new ResourcesPatternBuilder("", Collections.emptyList());
19 |         // when
20 |         final String pattern = patternBuilder.build();
21 |         // then
22 |         assertThat(pattern)
23 |                 .isEqualTo("^(?!(" + DOC_INFO_FILES + "))[^_.].*\\.(?!" + ASCIIDOC_SOURCES + ").*$");
24 |     }
25 | 
26 |     @Test
27 |     void should_build_pattern_with_sourceDocumentName() {
28 |         // given
29 |         ResourcesPatternBuilder patternBuilder = new ResourcesPatternBuilder("fixed-source.name", Collections.emptyList());
30 |         // when
31 |         final String pattern = patternBuilder.build();
32 |         // then
33 |         assertThat(pattern)
34 |                 .isEqualTo("^(?!(" + DOC_INFO_FILES + "|fixed-source.name))[^_.].*\\.(?!" + ASCIIDOC_SOURCES + ").*$");
35 |     }
36 | 
37 |     @Test
38 |     void should_build_pattern_with_sourceDocumentExtensions() {
39 |         // given
40 |         ResourcesPatternBuilder patternBuilder = new ResourcesPatternBuilder("", Arrays.asList("my-docs", "md"));
41 |         // when
42 |         final String pattern = patternBuilder.build();
43 |         // then
44 |         assertThat(pattern)
45 |                 .isEqualTo("^(?!(" + DOC_INFO_FILES + "))[^_.].*\\.(?!(a((sc(iidoc)?)|d(oc)?)|my-docs|md)).*$");
46 |     }
47 | }
48 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/MojoMocker.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.test;
 2 | 
 3 | import java.io.File;
 4 | import java.util.Map;
 5 | import java.util.Properties;
 6 | 
 7 | import lombok.SneakyThrows;
 8 | import org.apache.maven.plugin.logging.SystemStreamLog;
 9 | import org.apache.maven.project.MavenProject;
10 | import org.asciidoctor.maven.AsciidoctorJFactory;
11 | import org.asciidoctor.maven.AsciidoctorMojo;
12 | import org.asciidoctor.maven.AsciidoctorOptionsFactory;
13 | import org.asciidoctor.maven.log.LogHandler;
14 | import org.asciidoctor.maven.process.CopyResourcesProcessor;
15 | import org.asciidoctor.maven.process.SourceDocumentFinder;
16 | import org.mockito.Mockito;
17 | 
18 | import static org.codehaus.plexus.util.ReflectionUtils.setVariableValueInObject;
19 | import static org.mockito.Mockito.when;
20 | 
21 | class MojoMocker {
22 | 
23 |     private static final ParametersInitializer parametersInitializer = new ParametersInitializer();
24 | 
25 |     @SneakyThrows
26 |     @SuppressWarnings("unchecked")
27 |      T mock(Class clazz, Map mavenProperties, LogHandler logHandler) {
28 | 
29 |         final AsciidoctorMojo mojo = (AsciidoctorMojo) clazz.getConstructors()[0].newInstance(new Object[]{
30 |             new AsciidoctorJFactory(),
31 |             new AsciidoctorOptionsFactory(),
32 |             new SourceDocumentFinder(),
33 |             new CopyResourcesProcessor()
34 |         });
35 | 
36 |         parametersInitializer.initialize(mojo);
37 |         setVariableValueInObject(mojo, "log", new SystemStreamLog());
38 |         setVariableValueInObject(mojo, "project", mockMavenProject(mavenProperties));
39 | 
40 |         if (logHandler != null)
41 |             setVariableValueInObject(mojo, "logHandler", logHandler);
42 | 
43 |         return (T) mojo;
44 |     }
45 | 
46 |     private MavenProject mockMavenProject(Map mavenProperties) {
47 |         final MavenProject mavenProject = Mockito.mock(MavenProject.class);
48 |         when(mavenProject.getBasedir()).thenReturn(new File("."));
49 |         if (mavenProperties != null) {
50 |             final Properties properties = new Properties();
51 |             properties.putAll(mavenProperties);
52 |             when(mavenProject.getProperties()).thenReturn(properties);
53 |         }
54 |         return mavenProject;
55 |     }
56 | }
57 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/MojoMockerTest.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.test;
 2 | 
 3 | import java.util.Map;
 4 | 
 5 | import org.asciidoctor.maven.AsciidoctorMojo;
 6 | import org.asciidoctor.maven.log.LogHandler;
 7 | import org.junit.jupiter.api.Test;
 8 | 
 9 | import static org.assertj.core.api.Assertions.assertThat;
10 | 
11 | class MojoMockerTest {
12 | 
13 |     private final MojoMocker mojoMocker = new MojoMocker();
14 | 
15 |     @Test
16 |     void should_mock_mojo() {
17 |         AsciidoctorMojo mock = mojoMocker.mock(AsciidoctorMojo.class, null, null);
18 | 
19 |         assertThat(mock).isNotNull();
20 |     }
21 | 
22 |     @Test
23 |     void should_mock_mojo_with_properties() {
24 |         Map properties = Map.of("a-key", "a-value");
25 |         AsciidoctorMojo mock = mojoMocker.mock(AsciidoctorMojo.class, properties, null);
26 | 
27 |         assertThat(mock).isNotNull();
28 |     }
29 | 
30 |     @Test
31 |     void should_mock_mojo_with_logHandler() {
32 |         AsciidoctorMojo mock = mojoMocker.mock(AsciidoctorMojo.class, null, new LogHandler());
33 | 
34 |         assertThat(mock).isNotNull();
35 |     }
36 | }
37 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/AutoregisteredProcessor.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.test.processors;
 2 | 
 3 | import org.asciidoctor.Asciidoctor;
 4 | import org.asciidoctor.jruby.extension.spi.ExtensionRegistry;
 5 | 
 6 | public class AutoregisteredProcessor implements ExtensionRegistry {
 7 | 
 8 |     @Override
 9 |     public void register(Asciidoctor asciidoctor) {
10 |         asciidoctor.javaExtensionRegistry()
11 |                 .preprocessor(ChangeAttributeValuePreprocessor.class);
12 |     }
13 | }
14 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/ChangeAttributeValuePreprocessor.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.test.processors;
 2 | 
 3 | import java.util.Map;
 4 | 
 5 | import org.asciidoctor.ast.Document;
 6 | import org.asciidoctor.extension.Preprocessor;
 7 | import org.asciidoctor.extension.PreprocessorReader;
 8 | import org.asciidoctor.extension.Reader;
 9 | 
10 | public class ChangeAttributeValuePreprocessor extends Preprocessor {
11 | 
12 |     public static final String AUTHOR_NAME = "ThisIsMe";
13 | 
14 |     public ChangeAttributeValuePreprocessor(Map config) {
15 |         super(config);
16 |         System.out.println(String.format("%s(%s) initialized", this.getClass().getSimpleName(), this.getClass().getSuperclass().getSimpleName()));
17 |     }
18 | 
19 |     @Override
20 |     public Reader process(Document document, PreprocessorReader reader) {
21 |         System.out.println("Processing " + this.getClass().getSimpleName());
22 |         System.out.println("Processing: blocks found: " + document.getBlocks().size());
23 |         document.getAttributes().put("author", AUTHOR_NAME);
24 |         return reader;
25 |     }
26 | }
27 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/DummyPostprocessor.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.test.processors;
 2 | 
 3 | import java.util.Map;
 4 | 
 5 | import org.asciidoctor.ast.Document;
 6 | import org.asciidoctor.extension.Postprocessor;
 7 | 
 8 | public class DummyPostprocessor extends Postprocessor {
 9 | 
10 |     public DummyPostprocessor(Map config) {
11 |         super(config);
12 |         System.out.println(String.format("%s(%s) initialized", this.getClass().getSimpleName(), this.getClass().getSuperclass().getSimpleName()));
13 |     }
14 | 
15 |     @Override
16 |     public String process(Document document, String output) {
17 |         System.out.println("Processing " + this.getClass().getSimpleName());
18 |         System.out.println("Processing: blocks found: " + document.getBlocks().size());
19 |         System.out.println("Processing: output size: " + output.length());
20 |         return output;
21 |     }
22 | }
23 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/DummyTreeprocessor.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.test.processors;
 2 | 
 3 | import java.util.HashMap;
 4 | import java.util.Map;
 5 | 
 6 | import org.asciidoctor.ast.Document;
 7 | import org.asciidoctor.extension.Treeprocessor;
 8 | 
 9 | public class DummyTreeprocessor extends Treeprocessor {
10 | 
11 |     public DummyTreeprocessor() {
12 |         super(new HashMap<>());
13 |     }
14 | 
15 |     public DummyTreeprocessor(Map config) {
16 |         super(config);
17 |         System.out.println(String.format("%s(%s) initialized", this.getClass().getSimpleName(), this.getClass().getSuperclass().getSimpleName()));
18 |     }
19 | 
20 |     @Override
21 |     public Document process(Document document) {
22 |         System.out.println("Processing " + this.getClass().getSimpleName());
23 |         System.out.println("Processing: blocks found: " + document.getBlocks().size());
24 |         return document;
25 |     }
26 | }
27 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/FailingPreprocessor.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.test.processors;
 2 | 
 3 | import java.util.Map;
 4 | 
 5 | import org.asciidoctor.ast.Document;
 6 | import org.asciidoctor.extension.Preprocessor;
 7 | import org.asciidoctor.extension.PreprocessorReader;
 8 | import org.asciidoctor.extension.Reader;
 9 | 
10 | public class FailingPreprocessor extends Preprocessor {
11 | 
12 |     public FailingPreprocessor(Map config) {
13 |         super(config);
14 |         System.out.println(String.format("%s(%s) initialized", this.getClass().getSimpleName(), this.getClass().getSuperclass().getSimpleName()));
15 |     }
16 | 
17 |     @Override
18 |     public Reader process(Document document, PreprocessorReader reader) {
19 |         System.out.println("Processing " + this.getClass().getSimpleName());
20 |         System.out.println("Processing: blocks found: " + document.getBlocks().size());
21 |         throw new RuntimeException("That's all folks");
22 |     }
23 | 
24 | }
25 | 


--------------------------------------------------------------------------------
/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/GistBlockMacroProcessor.java:
--------------------------------------------------------------------------------
 1 | package org.asciidoctor.maven.test.processors;
 2 | 
 3 | import java.util.List;
 4 | import java.util.Map;
 5 | 
 6 | import org.asciidoctor.ast.Block;
 7 | import org.asciidoctor.ast.StructuralNode;
 8 | import org.asciidoctor.extension.BlockMacroProcessor;
 9 | 
10 | public class GistBlockMacroProcessor extends BlockMacroProcessor {
11 | 
12 |     public GistBlockMacroProcessor(String macroName, Map config) {
13 |         super(macroName, config);
14 |     }
15 | 
16 |     @Override
17 |     public Block process(StructuralNode parent, String target,
18 |                          Map attributes) {
19 | 
20 |         final String content = "
\n" + 21 | "\n" + 22 | "
"; 23 | 24 | return createBlock(parent, "pass", List.of(content), attributes); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/ManpageInlineMacroProcessor.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.test.processors; 2 | 3 | import org.asciidoctor.ast.PhraseNode; 4 | import org.asciidoctor.ast.StructuralNode; 5 | import org.asciidoctor.extension.InlineMacroProcessor; 6 | 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | public class ManpageInlineMacroProcessor extends InlineMacroProcessor { 11 | 12 | public ManpageInlineMacroProcessor(String macroName) { 13 | super(macroName); 14 | } 15 | 16 | @Override 17 | public PhraseNode process(StructuralNode parent, String target, Map attributes) { 18 | final Map options = new HashMap<>(); 19 | options.put("type", ":link"); 20 | options.put("target", target + ".html"); 21 | return createPhraseNode(parent, "anchor", target, attributes, options); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/MetaDocinfoProcessor.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.test.processors; 2 | 3 | import java.util.Map; 4 | 5 | import org.asciidoctor.ast.Document; 6 | import org.asciidoctor.extension.DocinfoProcessor; 7 | 8 | public class MetaDocinfoProcessor extends DocinfoProcessor { 9 | 10 | public MetaDocinfoProcessor(Map config) { 11 | super(config); 12 | System.out.println(String.format("%s(%s) initialized", this.getClass().getSimpleName(), this.getClass().getSuperclass().getSimpleName())); 13 | } 14 | 15 | @Override 16 | public String process(Document document) { 17 | System.out.println("Processing " + this.getClass().getSimpleName()); 18 | System.out.println("Processing: blocks found: " + document.getBlocks().size()); 19 | return ""; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/RequireCheckerTreeprocessor.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.test.processors; 2 | 3 | import org.asciidoctor.ast.Document; 4 | import org.asciidoctor.extension.Treeprocessor; 5 | import org.asciidoctor.jruby.internal.JRubyRuntimeContext; 6 | 7 | import static org.junit.jupiter.api.Assertions.assertEquals; 8 | 9 | public class RequireCheckerTreeprocessor extends Treeprocessor { 10 | 11 | @Override 12 | public Document process(Document document) { 13 | assertEquals("constant", JRubyRuntimeContext.get(document).evalScriptlet("defined? ::DateTime").toString()); 14 | // Leave a trace in the converted document so that the test can check that I was called 15 | document.getBlocks() 16 | .add(createBlock(document, "paragraph", RequireCheckerTreeprocessor.class.getSimpleName() + " was here")); 17 | return document; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/UriIncludeProcessor.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.test.processors; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | import java.net.URL; 7 | import java.util.Map; 8 | import java.util.stream.Collectors; 9 | 10 | import org.asciidoctor.ast.Document; 11 | import org.asciidoctor.extension.IncludeProcessor; 12 | import org.asciidoctor.extension.PreprocessorReader; 13 | 14 | public class UriIncludeProcessor extends IncludeProcessor { 15 | 16 | public UriIncludeProcessor(Map config) { 17 | super(config); 18 | System.out.println(String.format("%s(%s) initialized", this.getClass().getSimpleName(), this.getClass().getSuperclass().getSimpleName())); 19 | } 20 | 21 | @Override 22 | public boolean handles(String target) { 23 | return target.matches("^https?://.*"); 24 | } 25 | 26 | @Override 27 | public void process(Document document, PreprocessorReader reader, String target, 28 | Map attributes) { 29 | System.out.println("Processing " + this.getClass().getSimpleName()); 30 | final String content = readContent(target); 31 | reader.pushInclude(content, target, target, 1, attributes); 32 | } 33 | 34 | private String readContent(String target) { 35 | try (var openStream = new URL(target).openStream()) { 36 | try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(openStream))) { 37 | return bufferedReader.lines() 38 | .collect(Collectors.joining("\n")); 39 | } 40 | } catch (IOException e) { 41 | throw new RuntimeException(e); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/YellBlockProcessor.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.test.processors; 2 | 3 | import java.util.HashMap; 4 | import java.util.List; 5 | import java.util.Map; 6 | import java.util.stream.Collectors; 7 | 8 | import org.asciidoctor.ast.StructuralNode; 9 | import org.asciidoctor.extension.BlockProcessor; 10 | import org.asciidoctor.extension.Reader; 11 | 12 | public class YellBlockProcessor extends BlockProcessor { 13 | 14 | @SuppressWarnings("serial") 15 | private static Map configs = Map.of( 16 | "contexts", List.of(":listing"), 17 | "content_model", ":compound" 18 | ); 19 | 20 | public YellBlockProcessor(String name, Map config) { 21 | super(name, configs); 22 | } 23 | 24 | @Override 25 | public Object process(StructuralNode parent, Reader reader, Map attributes) { 26 | final String upperLines = reader.readLines() 27 | .stream() 28 | .map(String::toUpperCase) 29 | .collect(Collectors.joining("\n")); 30 | 31 | return createBlock(parent, "paragraph", List.of(upperLines), attributes, new HashMap<>()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/META-INF/org.asciidoctor.extension.spi.ExtensionRegistry: -------------------------------------------------------------------------------- 1 | org.asciidoctor.maven.test.processors.AutoregisteredProcessor 2 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/attribute-missing.adoc: -------------------------------------------------------------------------------- 1 | == Attribute Missing Test document 2 | 3 | Here is a line that has an attribute that is {missing}! 4 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/attribute-undefined.adoc: -------------------------------------------------------------------------------- 1 | == Attribute Undefined Test document 2 | 3 | Here is a line that has an attribute that is {set:missing!}! 4 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/attributes-example.adoc: -------------------------------------------------------------------------------- 1 | Document Title 2 | ============== 3 | Doc Writer 4 | :execution.attribute: cosa 5 | :idprefix: id_ 6 | 7 | Preamble paragraph. 8 | 9 | NOTE: This is test, only a test. 10 | 11 | == Section A 12 | 13 | * This attribute is set in the plugin configuration: {plugin-configuration-attribute} 14 | * This attribute is set in the execution configuration: {execution-attribute} 15 | * This attribute is set in the project's properties: {project-property-attribute} 16 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/book.adoc: -------------------------------------------------------------------------------- 1 | = Book 2 | Author Name 3 | :doctype: book 4 | 5 | == Chapter 1 6 | 7 | content 8 | 9 | == Chapter 2 10 | 11 | content 12 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/errors/document-with-invalid-reference.adoc: -------------------------------------------------------------------------------- 1 | = My Document 2 | 3 | == Code example 4 | 5 | Missing file reference to <<../path/some-file.adoc,the lost doc>>. 6 | 7 | Missing section reference to <>. 8 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/errors/document-with-missing-include.adoc: -------------------------------------------------------------------------------- 1 | = My Document 2 | 3 | include::unexistingdoc.adoc[] 4 | 5 | include::unexistingdoc.adoc[] 6 | 7 | include::https://raw.githubusercontent.com/asciidoctor/asciidoctor-maven-plugin/main/src/test/resources/src/asciidoctor/github-include.adoc[] 8 | 9 | include::unexistingdoc.adoc[] 10 | 11 | 12 | == Code example 13 | 14 | [source,java] 15 | ---- 16 | public class HelloWorld { 17 | 18 | public static void main(String[] args) { 19 | // Prints "Hello, World" to the terminal window. 20 | System.out.println("Hello, World"); 21 | } 22 | 23 | } 24 | ---- 25 | <1> Missing callout reference? 26 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/errors/valid.adoc: -------------------------------------------------------------------------------- 1 | = Document Title 2 | 3 | This a valid document. 4 | 5 | == Section A 6 | 7 | No errors to be seen. 8 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/file-extensions/sample: -------------------------------------------------------------------------------- 1 | Document Title 2 | ============== 3 | Doc Writer 4 | :idprefix: id_ 5 | 6 | Preamble paragraph. 7 | 8 | NOTE: This is test, only a test. 9 | 10 | == Section A 11 | 12 | *Section A* paragraph. 13 | 14 | === Section A Subsection 15 | 16 | *Section A* 'subsection' paragraph. 17 | 18 | == Section B 19 | 20 | *Section B* paragraph. 21 | 22 | .Section B list 23 | * Item 1 24 | * Item 2 25 | * Item 3 26 | 27 | [source,ruby] 28 | require 'asciidoctor' 29 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/file-extensions/sample.ad: -------------------------------------------------------------------------------- 1 | Document Title 2 | ============== 3 | Doc Writer 4 | :idprefix: id_ 5 | 6 | Preamble paragraph. 7 | 8 | NOTE: This is test, only a test. 9 | 10 | == Section A 11 | 12 | *Section A* paragraph. 13 | 14 | === Section A Subsection 15 | 16 | *Section A* 'subsection' paragraph. 17 | 18 | == Section B 19 | 20 | *Section B* paragraph. 21 | 22 | .Section B list 23 | * Item 1 24 | * Item 2 25 | * Item 3 26 | 27 | [source,ruby] 28 | require 'asciidoctor' 29 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/file-extensions/sample.adoc: -------------------------------------------------------------------------------- 1 | Document Title 2 | ============== 3 | Doc Writer 4 | :idprefix: id_ 5 | 6 | Preamble paragraph. 7 | 8 | NOTE: This is test, only a test. 9 | 10 | == Section A 11 | 12 | *Section A* paragraph. 13 | 14 | === Section A Subsection 15 | 16 | *Section A* 'subsection' paragraph. 17 | 18 | == Section B 19 | 20 | *Section B* paragraph. 21 | 22 | .Section B list 23 | * Item 1 24 | * Item 2 25 | * Item 3 26 | 27 | [source,ruby] 28 | require 'asciidoctor' 29 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/file-extensions/sample.asc: -------------------------------------------------------------------------------- 1 | Document Title 2 | ============== 3 | Doc Writer 4 | :idprefix: id_ 5 | 6 | Preamble paragraph. 7 | 8 | NOTE: This is test, only a test. 9 | 10 | == Section A 11 | 12 | *Section A* paragraph. 13 | 14 | === Section A Subsection 15 | 16 | *Section A* 'subsection' paragraph. 17 | 18 | == Section B 19 | 20 | *Section B* paragraph. 21 | 22 | .Section B list 23 | * Item 1 24 | * Item 2 25 | * Item 3 26 | 27 | [source,ruby] 28 | require 'asciidoctor' 29 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/file-extensions/sample.asciidoc: -------------------------------------------------------------------------------- 1 | Document Title 2 | ============== 3 | Doc Writer 4 | :idprefix: id_ 5 | 6 | Preamble paragraph. 7 | 8 | NOTE: This is test, only a test. 9 | 10 | == Section A 11 | 12 | *Section A* paragraph. 13 | 14 | === Section A Subsection 15 | 16 | *Section A* 'subsection' paragraph. 17 | 18 | == Section B 19 | 20 | *Section B* paragraph. 21 | 22 | .Section B list 23 | * Item 1 24 | * Item 2 25 | * Item 3 26 | 27 | [source,ruby] 28 | require 'asciidoctor' 29 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/file-extensions/sample.my-adoc: -------------------------------------------------------------------------------- 1 | Document Title 2 | ============== 3 | Doc Writer 4 | :idprefix: id_ 5 | 6 | Preamble paragraph. 7 | 8 | NOTE: This is test, only a test. 9 | 10 | == Section A 11 | 12 | *Section A* paragraph. 13 | 14 | === Section A Subsection 15 | 16 | *Section A* 'subsection' paragraph. 17 | 18 | == Section B 19 | 20 | *Section B* paragraph. 21 | 22 | .Section B list 23 | * Item 1 24 | * Item 2 25 | * Item 3 26 | 27 | [source,ruby] 28 | require 'asciidoctor' 29 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/github-include.adoc: -------------------------------------------------------------------------------- 1 | = Document Title 2 | Doc Writer 3 | 4 | Preamble paragraph. 5 | 6 | NOTE: This is test, only a test. 7 | 8 | == Includes a file from GitHub 9 | 10 | This works using jRuby 9k or >= 1.7.22. 11 | 12 | [source,xml] 13 | ---- 14 | include::https://raw.githubusercontent.com/cometd/cometd/4.0.x/pom.xml[] 15 | ---- 16 | 17 | 18 | == Includes a local file 19 | 20 | [source,groovy] 21 | .groovy-include.groovy 22 | ---- 23 | include::includes/groovy-include.groovy[] 24 | ---- 25 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/imageDir.adoc: -------------------------------------------------------------------------------- 1 | = Testing for imageDir being passed properly 2 | 3 | image::my-cool-image.jpg[] 4 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/includes/asciidoctor-icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asciidoctor/asciidoctor-maven-plugin/fd42dbf7b2dd1fa1204962df8aa4afcb85b28cde/asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/includes/asciidoctor-icon.jpg -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/includes/groovy-include.groovy: -------------------------------------------------------------------------------- 1 | 2 | println "HelloWorld from Groovy on ${new Date()}" 3 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/includes/new-include.adoc: -------------------------------------------------------------------------------- 1 | This is an included file. 2 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/issue-78/halliburton_lab.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asciidoctor/asciidoctor-maven-plugin/fd42dbf7b2dd1fa1204962df8aa4afcb85b28cde/asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/issue-78/halliburton_lab.jpg -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/issue-78/image-test.adoc: -------------------------------------------------------------------------------- 1 | Here's an image: 2 | 3 | image::halliburton_lab.jpg[] 4 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/issue-78/main.adoc: -------------------------------------------------------------------------------- 1 | = Testing image include 2 | 3 | This should test https://github.com/asciidoctor/asciidoctor-maven-plugin/issues/78[Issue-78] 4 | 5 | include::image-test.adoc[] 6 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/main-document.adoc: -------------------------------------------------------------------------------- 1 | = Include test 2 | 3 | This is the parent document 4 | 5 | include::includes/new-include.adoc[] 6 | 7 | == Code 8 | 9 | [source,groovy] 10 | .groovy-include.groovy 11 | ---- 12 | include::includes/groovy-include.groovy[] 13 | ---- 14 | 15 | ifdef::my-label[] 16 | == Optional section 17 | 18 | This shows how to add optional text. 19 | For example, this {my-label}. 20 | 21 | TIP: Use `ifdef` to control what is shown. 22 | 23 | endif::[] 24 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/processors-sample.adoc: -------------------------------------------------------------------------------- 1 | Document Title 2 | ============== 3 | Doc Writer 4 | :idprefix: id_ 5 | 6 | Preamble paragraph. 7 | 8 | NOTE: This is test, only a test. 9 | 10 | == Section A 11 | 12 | *Section A* paragraph. 13 | 14 | === Section A Subsection 15 | 16 | *Section A* 'subsection' paragraph. 17 | 18 | == Section B 19 | 20 | *Section B* paragraph. 21 | 22 | .Section B list 23 | * Item 1 24 | * Item 2 25 | * Item 3 26 | 27 | [source,ruby] 28 | require 'asciidoctor' 29 | 30 | == This is an example of a custom block macro 31 | .My Gist 32 | gist::123456[] 33 | 34 | == This is an example of a custom inline block macro 35 | 36 | See man:gittutorial[7] to get started. 37 | 38 | == This is an example of an block processor 39 | 40 | [yell] 41 | ---- 42 | The time is now. Get a move on. 43 | ---- 44 | 45 | == This is an example of an include processor 46 | 47 | .Gemfile 48 | [source,ruby] 49 | ---- 50 | include::https://raw.githubusercontent.com/asciidoctor/asciidoctor/master/Gemfile[] 51 | ---- 52 | 53 | Created by {author} 54 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/project-version.adoc: -------------------------------------------------------------------------------- 1 | Document Title 2 | ============== 3 | Doc Writer 4 | :idprefix: id_ 5 | :revnumber: {project-version} 6 | 7 | Preamble paragraph. 8 | 9 | NOTE: This is test, only a test. 10 | 11 | This is the project version: {project-version} 12 | 13 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/relative-path-treatment/.these_sources_are_not_processed/ignored.adoc: -------------------------------------------------------------------------------- 1 | :toc: left 2 | :icons: 3 | 4 | == Summary 5 | This document won't get converted by default because it is inside a hidden folder. + 6 | Hidden folders begin with underscore `.`. 7 | 8 | TIP: How cool is this? 9 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/relative-path-treatment/HelloWorld.adoc: -------------------------------------------------------------------------------- 1 | :toc: left 2 | :icons: 3 | 4 | == Summary 5 | TIP: Documentation for script in root folder 6 | 7 | image::level-1-1/asciidoctor-icon.jpg[Asciidoctor cool icon] 8 | 9 | == Code 10 | [source,groovy] 11 | .HelloWorld.groovy 12 | ---- 13 | include::HelloWorld.groovy[] 14 | ---- 15 | 16 | == Some link 17 | 18 | link:level-1-1/HelloWorld2.html[Docs] -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/relative-path-treatment/HelloWorld.groovy: -------------------------------------------------------------------------------- 1 | package random 2 | 3 | println "HelloWorld from the root!!" -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/relative-path-treatment/_this_is_ignored/ignored.adoc: -------------------------------------------------------------------------------- 1 | :toc: left 2 | :icons: 3 | 4 | == Summary 5 | This document won't get converted by default because it is inside a hidden folder. + 6 | Hidden folders begin with underscore `_`. 7 | 8 | TIP: How cool is this? -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/relative-path-treatment/level-1-1/.internal-dot-partial.adoc: -------------------------------------------------------------------------------- 1 | :toc: left 2 | :icons: 3 | 4 | == Summary 5 | This document won't get converted by default because it considered "internal". + 6 | That is, is prefixed with a dot `.`. 7 | 8 | TIP: How cool is this? 9 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/relative-path-treatment/level-1-1/HelloWorld2.adoc: -------------------------------------------------------------------------------- 1 | :toc: left 2 | :icons: 3 | 4 | == Summary 5 | TIP: Documentation for script 1 in depth 1 6 | 7 | image::asciidoctor-icon.jpg[Asciidoctor cool icon] 8 | 9 | == Code 10 | [source,groovy] 11 | .HelloWorld2.groovy 12 | ---- 13 | include::HelloWorld2.groovy[] 14 | ---- 15 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/relative-path-treatment/level-1-1/HelloWorld2.groovy: -------------------------------------------------------------------------------- 1 | package random.folder 2 | 3 | println "HelloWorld again!!" -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/relative-path-treatment/level-1-1/HelloWorld22.adoc: -------------------------------------------------------------------------------- 1 | :toc: left 2 | :icons: 3 | 4 | == Summary 5 | TIP: Documentation for script 2 in depth 1 6 | 7 | image::asciidoctor-icon.jpg[Asciidoctor cool icon] 8 | 9 | == Code 10 | [source,groovy] 11 | .HelloWorld2.groovy 12 | ---- 13 | include::HelloWorld2.groovy[] 14 | ---- 15 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/relative-path-treatment/level-1-1/_internal-partial.adoc: -------------------------------------------------------------------------------- 1 | :toc: left 2 | :icons: 3 | 4 | == Summary 5 | This document won't get converted by default because it considered "internal". + 6 | That is, is prefixed with underscore `_`. 7 | 8 | TIP: How cool is this? -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/relative-path-treatment/level-1-1/asciidoctor-icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asciidoctor/asciidoctor-maven-plugin/fd42dbf7b2dd1fa1204962df8aa4afcb85b28cde/asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/relative-path-treatment/level-1-1/asciidoctor-icon.jpg -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/relative-path-treatment/level-1-1/level-2-1/HelloWorld3.adoc: -------------------------------------------------------------------------------- 1 | :toc: left 2 | :icons: 3 | 4 | == Summary 5 | TIP: Documentation for script 1 in depth 2 6 | 7 | == Code 8 | [source,groovy] 9 | .HelloWorld3.groovy 10 | ---- 11 | include::HelloWorld3.groovy[] 12 | ---- 13 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/relative-path-treatment/level-1-1/level-2-1/HelloWorld3.groovy: -------------------------------------------------------------------------------- 1 | package random.folder.structure 2 | 3 | println "HelloWorld for the thrid time!!" -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/relative-path-treatment/level-1-1/level-2-2/HelloWorld3.adoc: -------------------------------------------------------------------------------- 1 | :toc: left 2 | :icons: 3 | 4 | == Summary 5 | TIP: Documentation for script 2 in depth 2 6 | 7 | == Code 8 | [source,groovy] 9 | .HelloWorld3.groovy 10 | ---- 11 | include::HelloWorld3.groovy[] 12 | ---- 13 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/relative-path-treatment/level-1-1/level-2-2/HelloWorld3.groovy: -------------------------------------------------------------------------------- 1 | package random.folder.structure 2 | 3 | println "HelloWorld for the thrid time (second folder)!!" -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/relative-path-treatment/level-1-1/level-2-2/_this_is_ignored/ignored.adoc: -------------------------------------------------------------------------------- 1 | :toc: left 2 | :icons: 3 | 4 | == Summary 5 | This document won't get converted by default because it is inside a hidden folder. + 6 | Hidden folders begin with underscore `_`. 7 | 8 | TIP: How cool is this? -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/relative-path-treatment/level-1-1/level-2-2/level-3-1/HelloWorld4.adoc: -------------------------------------------------------------------------------- 1 | :toc: left 2 | :icons: 3 | 4 | == Summary 5 | TIP: Documentation for script 1 in depth 4 6 | 7 | == Code 8 | [source,groovy] 9 | .HelloWorld4.groovy 10 | ---- 11 | include::HelloWorld4.groovy[] 12 | ---- 13 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/relative-path-treatment/level-1-1/level-2-2/level-3-1/HelloWorld4.groovy: -------------------------------------------------------------------------------- 1 | package random.folder.structure 2 | 3 | println "HelloWorld for the fourth time!!" -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/ruby.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asciidoctor/asciidoctor-maven-plugin/fd42dbf7b2dd1fa1204962df8aa4afcb85b28cde/asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/ruby.png -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/sample-embedded.adoc: -------------------------------------------------------------------------------- 1 | = Document Title 2 | Doc Writer 3 | :idprefix: id_ 4 | 5 | Preamble paragraph. 6 | 7 | NOTE: This is test, only a test. 8 | 9 | == Section A 10 | 11 | *Section A* paragraph. 12 | 13 | === Section A Subsection 14 | 15 | *Section A* 'subsection' paragraph. 16 | 17 | == Section B 18 | 19 | *Section B* paragraph. 20 | 21 | .Section B list 22 | * Item 1 23 | * Item 2 24 | * Item 3 25 | 26 | TIP: Here is a tip! 27 | 28 | image::ruby.png[] 29 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/sample-with-doc-info-docinfo-footer.html: -------------------------------------------------------------------------------- 1 |

This is the docinfo html footer.

2 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/sample-with-doc-info-docinfo-footer.xml: -------------------------------------------------------------------------------- 1 | This is the docinfo docbook footer. 2 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/sample-with-doc-info-docinfo.html: -------------------------------------------------------------------------------- 1 |

This is the docinfo html file.

2 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/sample-with-doc-info-docinfo.xml: -------------------------------------------------------------------------------- 1 | This is the docinfo docbook file. 2 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/sample-with-doc-info.asciidoc: -------------------------------------------------------------------------------- 1 | = Document Title 2 | Doc Writer 3 | :docinfo: 4 | 5 | This is the sample-with-doc-info file. 6 | 7 | == Section A 8 | 9 | *Section A* paragraph. 10 | 11 | == Section B 12 | 13 | *Section B* paragraph. 14 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/sample-with-source-highlighting.adoc: -------------------------------------------------------------------------------- 1 | Document Title 2 | ============== 3 | Doc Writer 4 | :idprefix: id_ 5 | :source-highlighter: coderay 6 | 7 | Preamble paragraph. 8 | 9 | NOTE: This is test, only a test. 10 | 11 | == Section A 12 | 13 | *Section A* paragraph. 14 | 15 | === Section A Subsection 16 | 17 | *Section A* 'subsection' paragraph. 18 | 19 | == Section B 20 | 21 | *Section B* paragraph. 22 | 23 | .Section B list 24 | * Item 1 25 | * Item 2 26 | * Item 3 27 | 28 | [source,ruby] 29 | require 'asciidoctor' 30 | 31 | [source,java] 32 | ---- 33 | public class HelloWorld { 34 | 35 | public static void main(String[] args) { 36 | // Prints "Hello, World" to the terminal window. 37 | System.out.println("Hello, World"); 38 | } 39 | 40 | } 41 | ---- -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/sample.asciidoc: -------------------------------------------------------------------------------- 1 | Document Title 2 | ============== 3 | Doc Writer 4 | :idprefix: id_ 5 | 6 | Preamble paragraph. 7 | 8 | NOTE: This is test, only a test. 9 | 10 | == Section A 11 | 12 | *Section A* paragraph. 13 | 14 | === Section A Subsection 15 | 16 | *Section A* 'subsection' paragraph. 17 | 18 | == Section B 19 | 20 | *Section B* paragraph. 21 | 22 | .Section B list 23 | * Item 1 24 | * Item 2 25 | * Item 3 26 | 27 | [source,ruby] 28 | require 'asciidoctor' 29 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/sample.ext: -------------------------------------------------------------------------------- 1 | Document Title 2 | ============== 3 | Doc Writer 4 | :idprefix: id_ 5 | 6 | Preamble paragraph. 7 | 8 | NOTE: This is test, only a test. 9 | 10 | == Section A 11 | 12 | *Section A* paragraph. 13 | 14 | === Section A Subsection 15 | 16 | *Section A* 'subsection' paragraph. 17 | 18 | == Section B 19 | 20 | *Section B* paragraph. 21 | 22 | .Section B list 23 | * Item 1 24 | * Item 2 25 | * Item 3 26 | 27 | [source,ruby] 28 | require 'asciidoctor' 29 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/source-finder/_enclosing/src/simple.adoc: -------------------------------------------------------------------------------- 1 | = Document Title 2 | 3 | Preamble paragraph. 4 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/src/asciidoctor/templates/block_paragraph.html.slim: -------------------------------------------------------------------------------- 1 | - if title? 2 | .title=title 3 | p id=id class="custom-template #{role}" =content 4 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/templates/erb/section.html.erb: -------------------------------------------------------------------------------- 1 | <%#encoding:UTF-8%><% 2 | slevel = @level.zero? && @special ? 1 : @level 3 | anchor = link_start = link_end = nil 4 | if @id 5 | if @document.attr? :sectanchors 6 | anchor = %() 7 | elsif @document.attr? :sectlinks 8 | link_start = %() 9 | link_end = '' 10 | end 11 | end 12 | if slevel.zero? 13 | %> class="sect0"><%= %(#{anchor}#{link_start}#{title}#{link_end}) %> 14 | <%= content %><% 15 | else 16 | snum = @numbered && @caption.nil? && slevel <= (@document.attr 'sectnumlevels', 3).to_i ? %(#{sectnum} ) : nil 17 | hlevel = slevel + 1 18 | %>
19 | <%= @id && %( id="#{@id}") %>><%= %(#{anchor}#{link_start}#{snum}#{captioned_title}#{link_end}) %>><% 20 | if slevel == 1 %> 21 |
22 | <%= content %> 23 |
<% 24 | else %> 25 | <%= content %><% 26 | end %> 27 |
<% 28 | end %> 29 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/templates/slim/set-1/admonition.html.slim: -------------------------------------------------------------------------------- 1 | .custom-admonition-block id=@id class=[(attr :name),role] 2 | table: tr 3 | td.icon 4 | td.content 5 | - if title? 6 | .title=title 7 | =content 8 | -------------------------------------------------------------------------------- /asciidoctor-maven-plugin/src/test/resources/templates/slim/set-2/block_paragraph.html.slim: -------------------------------------------------------------------------------- 1 | - if title? 2 | .title=title 3 | p id=id class="#{role} .custom-block-style" =content 4 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/it/maven-site-plugin/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals=clean site:site 2 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/it/maven-site-plugin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | org.asciidoctor 6 | maven-site-plugin-it 7 | 1.0-SNAPSHOT 8 | Maven Site Plugin IT 9 | Checks asciidoctor integration in Maven Site Plugin through Doxia Parser Module 10 | 11 | 12 | v1.2.3 13 | 14 | 15 | 16 | 17 | 18 | org.apache.maven.plugins 19 | maven-project-info-reports-plugin 20 | 3.4.5 21 | 22 | 23 | 24 | org.apache.maven.plugins 25 | maven-site-plugin 26 | 3.21.0 27 | 28 | 29 | ${project.basedir}/src/site/asciidoc 30 | 31 | 2 32 | 33 | 34 | false 35 | 36 | **/_*.adoc,**/_*/ 37 | 38 | 39 | 40 | 41 | org.asciidoctor 42 | asciidoctor-parser-doxia-module 43 | @project.version@ 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/it/maven-site-plugin/src/site/asciidoc/sample.adoc: -------------------------------------------------------------------------------- 1 | = Sample 2 | The Author 3 | :docdatetime: 2024-02-07 23:36:29 4 | 5 | This is an example `.adoc` file that was processed by the Doxia Parser module in the Asciidoctor Maven Plugin. 6 | Version {docs-version}. 7 | 8 | == First section 9 | 10 | This is the first section of the page. 11 | 12 | === Sub section 13 | 14 | This is a subsection of the first section 15 | 16 | == Features 17 | 18 | This is the second section of the page. 19 | 20 | === Image 21 | 22 | image::images/asciidoctor-logo.png[Asciidoctor is awesome] 23 | 24 | === Table 25 | 26 | .Ruby platforms 27 | |=== 28 | |Name |Language 29 | 30 | |JRuby |Java 31 | |Opal |JavaScript 32 | |Rubinius |Ruby 33 | |=== 34 | 35 | === Literal 36 | 37 | This is a literal. 38 | 39 | === Code blocks 40 | 41 | [source,ruby] 42 | .Ruby example 43 | ---- 44 | puts "Hello, World!" 45 | ---- 46 | 47 | [,java] 48 | ---- 49 | public class HelloWorld { 50 | 51 | public static void main(String[] args) { 52 | // Prints "Hello, World" to the terminal window. 53 | System.out.println("Hello, World"); 54 | } 55 | 56 | } 57 | ---- 58 | 59 | === Lists 60 | 61 | ==== Unordered list 62 | 63 | * Apples 64 | * Oranges 65 | * Walnuts 66 | * Almonds 67 | 68 | ==== Unordered list with formatting 69 | 70 | * *Apples* 71 | * _Oranges_ 72 | * ~Walnuts~ 73 | * `Almonds` 74 | * https://some-link.here[link] 75 | 76 | ==== Ordered list 77 | 78 | . Protons 79 | . Electrons 80 | . Neutrons 81 | 82 | ==== Description list 83 | 84 | Operating Systems:: 85 | Linux::: 86 | . Fedora 87 | * Desktop 88 | . Ubuntu 89 | * Desktop 90 | * Server 91 | BSD::: 92 | . FreeBSD 93 | . NetBSD 94 | 95 | === Examples 96 | 97 | .Optional title (1) 98 | ==== 99 | This is an example of an example block (1). 100 | ==== 101 | 102 | .Optional title (2) 103 | [example] 104 | This is an example of an example block (2). 105 | *dadsas* https://dasd.com 106 | 107 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/it/maven-site-plugin/src/site/resources/images/asciidoctor-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asciidoctor/asciidoctor-maven-plugin/fd42dbf7b2dd1fa1204962df8aa4afcb85b28cde/asciidoctor-parser-doxia-module/src/it/maven-site-plugin/src/site/resources/images/asciidoctor-logo.png -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/it/maven-site-plugin/src/site/site.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | org.apache.maven.skins 16 | maven-fluido-skin 17 | 2.0.0-M9 18 | 19 | 20 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/AsciidoctorAstDoxiaParserModule.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site.parser; 2 | 3 | import org.apache.maven.doxia.parser.module.AbstractParserModule; 4 | import org.apache.maven.doxia.parser.module.ParserModule; 5 | import org.codehaus.plexus.component.annotations.Component; 6 | 7 | /** 8 | * This class is the entry point for integration with the Maven Site Plugin 9 | * integration since Doxia 1.6 (i.e., maven-site-plugin 3.4 and above): 10 | * it defines source directory and file extensions to be added to 11 | * Doxia provided modules. 12 | * 13 | * @author abelsromero 14 | * @since 3.0.0 15 | */ 16 | @Component(role = ParserModule.class, hint = AsciidoctorAstDoxiaParser.ROLE_HINT) 17 | public class AsciidoctorAstDoxiaParserModule extends AbstractParserModule { 18 | 19 | /** 20 | * The source directory for AsciiDoc files. 21 | */ 22 | public static final String SOURCE_DIRECTORY = AsciidoctorAstDoxiaParser.ROLE_HINT; 23 | 24 | /** 25 | * The extensions for AsciiDoc files. 26 | */ 27 | public static final String[] FILE_EXTENSIONS = new String[]{"adoc", "asciidoc"}; 28 | 29 | /** 30 | * Build a new instance of {@link AsciidoctorAstDoxiaParserModule}. 31 | */ 32 | public AsciidoctorAstDoxiaParserModule() { 33 | super(SOURCE_DIRECTORY, AsciidoctorAstDoxiaParser.ROLE_HINT, FILE_EXTENSIONS); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/NodeProcessor.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site.parser; 2 | 3 | import org.asciidoctor.ast.StructuralNode; 4 | 5 | /** 6 | * Basic unit for content generation. 7 | *

8 | * A NodeProcessor is responsible for generating the output (HTML) 9 | * for one AST node. In Asciidoctor terms, it's a Converter for 10 | * a specific Node type (but can be accommodated to convert multiples). 11 | * 12 | * @author abelsromero 13 | * @since 3.0.0 14 | */ 15 | public interface NodeProcessor { 16 | 17 | /** 18 | * Whether the processor can process the node. 19 | * 20 | * @param node candidate node to process 21 | * @return {@literal true} if the node can be processed 22 | */ 23 | boolean applies(StructuralNode node); 24 | 25 | /** 26 | * Whether sub-nodes should be processed recursively. 27 | * 28 | * @param node candidate node to process 29 | * @return {@literal true} if the node is terminal 30 | */ 31 | default boolean isTerminal(StructuralNode node) { 32 | return false; 33 | } 34 | 35 | /** 36 | * Processes the node. 37 | * 38 | * @param node node to process 39 | */ 40 | void process(StructuralNode node); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/AbstractSinkNodeProcessor.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site.parser.processors; 2 | 3 | import org.apache.maven.doxia.sink.Sink; 4 | import org.asciidoctor.ast.ContentNode; 5 | import org.asciidoctor.ast.StructuralNode; 6 | import org.asciidoctor.maven.site.parser.NodeSinker; 7 | 8 | /** 9 | * Recommended base case to build a {@link org.asciidoctor.maven.site.parser.NodeProcessor}. 10 | * 11 | * @author abelsromero 12 | * @since 3.0.0 13 | */ 14 | public class AbstractSinkNodeProcessor { 15 | 16 | private final Sink sink; 17 | private final NodeSinker nodeSinker; 18 | 19 | /** 20 | * Constructor. 21 | * 22 | * @param sink Doxia {@link Sink} 23 | * @param nodeSinker 24 | */ 25 | public AbstractSinkNodeProcessor(Sink sink, NodeSinker nodeSinker) { 26 | this.sink = sink; 27 | this.nodeSinker = nodeSinker; 28 | } 29 | 30 | /** 31 | * Returns internal {@link Sink}. 32 | * 33 | * @return Doxia {@link Sink} 34 | */ 35 | protected Sink getSink() { 36 | return sink; 37 | } 38 | 39 | /** 40 | * Delegates the processing of the new node to the appropriate processor. 41 | * Similar to {@link org.asciidoctor.maven.site.parser.NodeProcessor#process(StructuralNode)} 42 | * but this selects the processor from the ones available. 43 | * 44 | * @param node Node to process 45 | */ 46 | protected void sink(StructuralNode node) { 47 | nodeSinker.sink(node); 48 | } 49 | 50 | /** 51 | * Tests for the presence of an attribute in current and parent nodes. 52 | * 53 | * @param name attribute name 54 | * @param node node to check 55 | * @return true if attribute is found 56 | */ 57 | protected boolean hasAttribute(String name, ContentNode node) { 58 | ContentNode current = node; 59 | while (current != null) { 60 | if (current.getAttribute(name) != null) 61 | return true; 62 | current = current.getParent(); 63 | } 64 | return false; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/DescriptionListNodeProcessor.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site.parser.processors; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.maven.doxia.sink.Sink; 6 | import org.asciidoctor.ast.DescriptionList; 7 | import org.asciidoctor.ast.DescriptionListEntry; 8 | import org.asciidoctor.ast.ListItem; 9 | import org.asciidoctor.ast.StructuralNode; 10 | import org.asciidoctor.maven.site.parser.NodeProcessor; 11 | import org.asciidoctor.maven.site.parser.NodeSinker; 12 | 13 | /** 14 | * Description list processor. 15 | * 16 | * @author abelsromero 17 | * @since 3.0.0 18 | */ 19 | public class DescriptionListNodeProcessor extends AbstractSinkNodeProcessor implements NodeProcessor { 20 | 21 | /** 22 | * Constructor. 23 | * 24 | * @param sink Doxia {@link Sink} 25 | * @param nodeSinker 26 | */ 27 | public DescriptionListNodeProcessor(Sink sink, NodeSinker nodeSinker) { 28 | super(sink, nodeSinker); 29 | } 30 | 31 | @Override 32 | public boolean applies(StructuralNode node) { 33 | return "dlist".equals(node.getNodeName()); 34 | } 35 | 36 | @Override 37 | public boolean isTerminal(StructuralNode node) { 38 | return true; 39 | } 40 | 41 | @Override 42 | public void process(StructuralNode node) { 43 | 44 | final List items = ((DescriptionList) node).getItems(); 45 | final Sink sink = getSink(); 46 | 47 | if (!items.isEmpty()) { 48 | sink.definitionList(); 49 | for (DescriptionListEntry item : items) { 50 | // About the model, see https://asciidoctor.zulipchat.com/#narrow/stream/279642-users/topic/.E2.9C.94.20Description.20List.20AST.20structure/near/419353063 51 | final ListItem term = item.getTerms().get(0); 52 | sink.definedTerm(); 53 | sink.rawText(term.getText()); 54 | sink.definedTerm_(); 55 | 56 | final ListItem description = item.getDescription(); 57 | sink.definition(); 58 | if (description.getBlocks().isEmpty()) { 59 | sink.rawText(description.getText()); 60 | } else { 61 | super.sink(description); 62 | } 63 | sink.definition_(); 64 | } 65 | sink.definitionList_(); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/DocumentNodeProcessor.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site.parser.processors; 2 | 3 | import org.apache.maven.doxia.sink.Sink; 4 | import org.asciidoctor.ast.StructuralNode; 5 | import org.asciidoctor.maven.site.parser.NodeProcessor; 6 | import org.asciidoctor.maven.site.parser.NodeSinker; 7 | 8 | import static org.asciidoctor.maven.commons.StringUtils.isNotBlank; 9 | 10 | /** 11 | * Root document processor. 12 | * 13 | * @author abelsromero 14 | * @since 3.0.0 15 | */ 16 | public class DocumentNodeProcessor extends AbstractSinkNodeProcessor implements NodeProcessor { 17 | 18 | /** 19 | * Constructor. 20 | * 21 | * @param sink Doxia {@link Sink} 22 | * @param nodeSinker 23 | */ 24 | public DocumentNodeProcessor(Sink sink, NodeSinker nodeSinker) { 25 | super(sink, nodeSinker); 26 | } 27 | 28 | @Override 29 | public boolean applies(StructuralNode node) { 30 | return "document".equals(node.getNodeName()); 31 | } 32 | 33 | @Override 34 | public void process(StructuralNode node) { 35 | final Sink sink = getSink(); 36 | 37 | sink.body(); 38 | String title = node.getTitle(); 39 | if (isNotBlank(title)) { 40 | sink.sectionTitle1(); 41 | sink.rawText(title); 42 | sink.sectionTitle1_(); 43 | } 44 | node.getBlocks() 45 | .forEach(this::sink); 46 | 47 | sink.body_(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/ListItemNodeProcessor.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site.parser.processors; 2 | 3 | import org.apache.maven.doxia.sink.Sink; 4 | import org.asciidoctor.ast.ListItem; 5 | import org.asciidoctor.ast.StructuralNode; 6 | import org.asciidoctor.maven.site.parser.NodeProcessor; 7 | import org.asciidoctor.maven.site.parser.NodeSinker; 8 | 9 | /** 10 | * List items processor, including numbered and unnumbered. 11 | * 12 | * @author abelsromero 13 | * @since 3.0.0 14 | */ 15 | public class ListItemNodeProcessor extends AbstractSinkNodeProcessor implements NodeProcessor { 16 | 17 | /** 18 | * Constructor. 19 | * 20 | * @param sink Doxia {@link Sink} 21 | * @param nodeSinker 22 | */ 23 | public ListItemNodeProcessor(Sink sink, NodeSinker nodeSinker) { 24 | super(sink, nodeSinker); 25 | } 26 | 27 | @Override 28 | public boolean applies(StructuralNode node) { 29 | return "list_item".equals(node.getNodeName()); 30 | } 31 | 32 | @Override 33 | public void process(StructuralNode node) { 34 | final ListItem item = (ListItem) node; 35 | final Sink sink = getSink(); 36 | final ListType listType = getListType(item); 37 | 38 | // description type does not require any action 39 | switch (listType) { 40 | case ordered: 41 | sink.numberedListItem(); 42 | break; 43 | case unordered: 44 | sink.listItem(); 45 | break; 46 | } 47 | 48 | final String text = item.getText(); 49 | sink.rawText(text == null ? "" : text); 50 | 51 | node.getBlocks().forEach(this::sink); 52 | 53 | switch (listType) { 54 | case ordered: 55 | sink.numberedListItem_(); 56 | break; 57 | case unordered: 58 | sink.listItem_(); 59 | break; 60 | } 61 | } 62 | 63 | private static ListType getListType(ListItem item) { 64 | final String marker = item.getMarker(); 65 | if (marker == null) { 66 | return ListType.description; 67 | } else if (marker.startsWith("*") || marker.startsWith("-")) { 68 | return ListType.ordered; 69 | } else { 70 | return ListType.unordered; 71 | } 72 | } 73 | 74 | enum ListType { 75 | ordered, unordered, description 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/LiteralNodeProcessor.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site.parser.processors; 2 | 3 | import org.apache.maven.doxia.sink.Sink; 4 | import org.asciidoctor.ast.StructuralNode; 5 | import org.asciidoctor.jruby.ast.impl.BlockImpl; 6 | import org.asciidoctor.maven.commons.StringUtils; 7 | import org.asciidoctor.maven.site.parser.NodeProcessor; 8 | import org.asciidoctor.maven.site.parser.NodeSinker; 9 | 10 | /** 11 | * Literal (aka. monospace) text processor. 12 | * 13 | * @author abelsromero 14 | * @since 3.0.0 15 | */ 16 | public class LiteralNodeProcessor extends AbstractSinkNodeProcessor implements NodeProcessor { 17 | 18 | /** 19 | * Constructor. 20 | * 21 | * @param sink Doxia {@link Sink} 22 | * @param nodeSinker 23 | */ 24 | public LiteralNodeProcessor(Sink sink, NodeSinker nodeSinker) { 25 | super(sink, nodeSinker); 26 | } 27 | 28 | @Override 29 | public boolean applies(StructuralNode node) { 30 | return "literal".equals(node.getNodeName()); 31 | } 32 | 33 | @Override 34 | public void process(StructuralNode node) { 35 | final Sink sink = getSink(); 36 | 37 | String source = ((BlockImpl) node).getSource(); 38 | if (StringUtils.isNotBlank(source)) { 39 | sink.division(); 40 | sink.rawText("

");
41 |             sink.rawText(source);
42 |             sink.rawText("
"); 43 | sink.division_(); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/NoOpNodeProcessor.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site.parser.processors; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.maven.doxia.sink.Sink; 6 | import org.asciidoctor.ast.StructuralNode; 7 | import org.asciidoctor.maven.site.parser.AsciidoctorAstDoxiaParser; 8 | import org.asciidoctor.maven.site.parser.NodeProcessor; 9 | import org.asciidoctor.maven.site.parser.NodeSinker; 10 | import org.slf4j.LoggerFactory; 11 | 12 | /** 13 | * Fallback NodeProcessor to collect nodes that have not dedicated processor. 14 | */ 15 | public class NoOpNodeProcessor extends AbstractSinkNodeProcessor implements NodeProcessor { 16 | 17 | private static final org.slf4j.Logger logger = LoggerFactory.getLogger(NoOpNodeProcessor.class); 18 | 19 | /** 20 | * Constructor. 21 | * 22 | * @param sink Doxia {@link Sink} 23 | * @param nodeSinker 24 | */ 25 | public NoOpNodeProcessor(Sink sink, NodeSinker nodeSinker) { 26 | super(sink, nodeSinker); 27 | } 28 | 29 | @Override 30 | public boolean applies(StructuralNode node) { 31 | return false; 32 | } 33 | 34 | @Override 35 | public void process(StructuralNode node) { 36 | final List blocks = node.getBlocks(); 37 | 38 | logger.warn("Fallback behaviour for node: {}", node.getNodeName()); 39 | if (!blocks.isEmpty()) { 40 | blocks.forEach(this::sink); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/OrderedListNodeProcessor.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site.parser.processors; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.maven.doxia.sink.Sink; 6 | import org.asciidoctor.ast.StructuralNode; 7 | import org.asciidoctor.maven.site.parser.NodeProcessor; 8 | import org.asciidoctor.maven.site.parser.NodeSinker; 9 | 10 | /** 11 | * Ordered list processor. 12 | * 13 | * @author abelsromero 14 | * @since 3.0.0 15 | */ 16 | public class OrderedListNodeProcessor extends AbstractSinkNodeProcessor implements NodeProcessor { 17 | 18 | /** 19 | * Constructor. 20 | * 21 | * @param sink Doxia {@link Sink} 22 | * @param nodeSinker 23 | */ 24 | public OrderedListNodeProcessor(Sink sink, NodeSinker nodeSinker) { 25 | super(sink, nodeSinker); 26 | } 27 | 28 | @Override 29 | public boolean applies(StructuralNode node) { 30 | return "olist".equals(node.getNodeName()); 31 | } 32 | 33 | @Override 34 | public boolean isTerminal(StructuralNode node) { 35 | return true; 36 | } 37 | 38 | @Override 39 | public void process(StructuralNode node) { 40 | final List subNodes = node.getBlocks(); 41 | final Sink sink = getSink(); 42 | 43 | /* 44 | * doxia numberingStyle 0: 1. 2. 45 | * 1: a. b. 46 | * 2: A. B. 47 | * 3: i. ii. 48 | * >: 1. 2. 49 | */ 50 | if (!subNodes.isEmpty()) { 51 | sink.numberedList(0); 52 | subNodes.forEach(this::sink); 53 | sink.numberedList_(); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/ParagraphNodeProcessor.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site.parser.processors; 2 | 3 | import org.apache.maven.doxia.sink.Sink; 4 | import org.asciidoctor.ast.StructuralNode; 5 | import org.asciidoctor.maven.site.parser.NodeProcessor; 6 | import org.asciidoctor.maven.site.parser.NodeSinker; 7 | 8 | /** 9 | * Paragraph processor. 10 | * 11 | * @author abelsromero 12 | * @since 3.0.0 13 | */ 14 | public class ParagraphNodeProcessor extends AbstractSinkNodeProcessor implements NodeProcessor { 15 | 16 | /** 17 | * Constructor. 18 | * 19 | * @param sink Doxia {@link Sink} 20 | * @param nodeSinker 21 | */ 22 | public ParagraphNodeProcessor(Sink sink, NodeSinker nodeSinker) { 23 | super(sink, nodeSinker); 24 | } 25 | 26 | @Override 27 | public boolean applies(StructuralNode node) { 28 | return "paragraph".equals(node.getNodeName()); 29 | } 30 | 31 | @Override 32 | public void process(StructuralNode node) { 33 | final Sink sink = getSink(); 34 | sink.paragraph(); 35 | // content returns HTML processed including bold, italics, monospace, etc. attributes resolution 36 | sink.rawText((String) node.getContent()); 37 | sink.paragraph_(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/PreambleNodeProcessor.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site.parser.processors; 2 | 3 | import org.apache.maven.doxia.sink.Sink; 4 | import org.asciidoctor.ast.StructuralNode; 5 | import org.asciidoctor.maven.site.parser.NodeProcessor; 6 | import org.asciidoctor.maven.site.parser.NodeSinker; 7 | 8 | /** 9 | * Document preamble processor. 10 | * 11 | * @author abelsromero 12 | * @since 3.0.0 13 | */ 14 | public class PreambleNodeProcessor extends AbstractSinkNodeProcessor implements NodeProcessor { 15 | 16 | /** 17 | * Constructor. 18 | * 19 | * @param sink Doxia {@link Sink} 20 | * @param nodeSinker 21 | */ 22 | public PreambleNodeProcessor(Sink sink, NodeSinker nodeSinker) { 23 | super(sink, nodeSinker); 24 | } 25 | 26 | @Override 27 | public boolean applies(StructuralNode node) { 28 | return "preamble".equals(node.getNodeName()); 29 | } 30 | 31 | /** 32 | * Do nothing, preamble only aggregates other blocks. 33 | **/ 34 | @Override 35 | public void process(StructuralNode node) { 36 | node.getBlocks().forEach(this::sink); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/SinkAttributes.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site.parser.processors; 2 | 3 | import org.apache.maven.doxia.sink.SinkEventAttributes; 4 | import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet; 5 | 6 | class SinkAttributes { 7 | 8 | static SinkEventAttributes of(String name, String value) { 9 | final var attributes = new SinkEventAttributeSet(); 10 | attributes.addAttribute(name, value); 11 | return attributes; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/Styles.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site.parser.processors; 2 | 3 | import java.util.stream.Collectors; 4 | import java.util.stream.Stream; 5 | 6 | class Styles { 7 | 8 | public static final String CAPTION = Stream.of( 9 | "color: #7a2518", 10 | "margin-bottom: .25em" 11 | ).collect(Collectors.joining("; ")); 12 | 13 | 14 | public static final String EXAMPLE = Stream.of( 15 | "background: #fffef7", 16 | "border-color: #e0e0dc", 17 | "border: 1px solid #e6e6e6", 18 | "box-shadow: 0 1px 4px #e0e0dc", 19 | "margin-bottom: 1.25em", 20 | "padding: 1.25em" 21 | ).collect(Collectors.joining("; ")); 22 | 23 | public static final String TABLE = "background: #FFFFFF"; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/TitleCaptionExtractor.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site.parser.processors; 2 | 3 | import org.asciidoctor.ast.StructuralNode; 4 | 5 | import static org.asciidoctor.maven.commons.StringUtils.isBlank; 6 | 7 | /** 8 | * Utility to extract composed title and caption text. 9 | * 10 | * @author abelsromero 11 | * @since 3.1.0 12 | */ 13 | class TitleCaptionExtractor { 14 | 15 | // Not used in SectionNodeProcessor to avoid extra node processing 16 | static String getText(StructuralNode node) { 17 | // Caption is returned when a title is set in: 18 | // - Image blocks 19 | // - Listings 20 | final String caption = node.getCaption(); 21 | return isBlank(caption) ? node.getTitle() : String.format("%s %s", caption.trim(), node.getTitle()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/UnorderedListNodeProcessor.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site.parser.processors; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.maven.doxia.sink.Sink; 6 | import org.asciidoctor.ast.StructuralNode; 7 | import org.asciidoctor.maven.site.parser.NodeProcessor; 8 | import org.asciidoctor.maven.site.parser.NodeSinker; 9 | 10 | /** 11 | * Unordered list processor. 12 | * 13 | * @author abelsromero 14 | * @since 3.0.0 15 | */ 16 | public class UnorderedListNodeProcessor extends AbstractSinkNodeProcessor implements NodeProcessor { 17 | 18 | private ListItemNodeProcessor itemNodeProcessor; 19 | 20 | /** 21 | * Constructor. 22 | * 23 | * @param sink Doxia {@link Sink} 24 | * @param nodeSinker 25 | */ 26 | public UnorderedListNodeProcessor(Sink sink, NodeSinker nodeSinker) { 27 | super(sink, nodeSinker); 28 | } 29 | 30 | /** 31 | * Inject a {@link ListItemNodeProcessor}. 32 | * 33 | * @param nodeProcessor {@link ListItemNodeProcessor} 34 | */ 35 | public void setItemNodeProcessor(ListItemNodeProcessor nodeProcessor) { 36 | this.itemNodeProcessor = nodeProcessor; 37 | } 38 | 39 | @Override 40 | public boolean applies(StructuralNode node) { 41 | return "ulist".equals(node.getNodeName()); 42 | } 43 | 44 | @Override 45 | public boolean isTerminal(StructuralNode node) { 46 | return true; 47 | } 48 | 49 | @Override 50 | public void process(StructuralNode node) { 51 | final List items = node.getBlocks(); 52 | final Sink sink = getSink(); 53 | 54 | if (!items.isEmpty()) { 55 | sink.list(); 56 | node.getBlocks().forEach(this::sink); 57 | sink.list_(); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/DocumentNodeProcessorTest.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site.parser.processors; 2 | 3 | import java.io.StringWriter; 4 | 5 | import org.asciidoctor.Asciidoctor; 6 | import org.asciidoctor.Options; 7 | import org.asciidoctor.ast.StructuralNode; 8 | import org.asciidoctor.maven.site.parser.NodeProcessor; 9 | import org.asciidoctor.maven.site.parser.processors.test.NodeProcessorTest; 10 | import org.junit.jupiter.api.Test; 11 | 12 | import static org.assertj.core.api.Assertions.assertThat; 13 | 14 | @NodeProcessorTest(DocumentNodeProcessor.class) 15 | class DocumentNodeProcessorTest { 16 | 17 | private Asciidoctor asciidoctor; 18 | private NodeProcessor nodeProcessor; 19 | private StringWriter sinkWriter; 20 | 21 | @Test 22 | void should_not_fail_if_document_is_empty() { 23 | String content = ""; 24 | 25 | String html = process(content, 0); 26 | 27 | assertThat(html) 28 | .isEmpty(); 29 | } 30 | 31 | @Test 32 | void should_convert_document_title() { 33 | String content = "= Document tile"; 34 | 35 | String html = process(content, 0); 36 | 37 | assertThat(html) 38 | .isEqualTo("

Document tile

"); 39 | } 40 | 41 | @Test 42 | void should_convert_document_title_with_markup() { 43 | String content = "= *Document* _tile_"; 44 | 45 | String html = process(content, 0); 46 | 47 | assertThat(html) 48 | .isEqualTo("

Document tile

"); 49 | } 50 | 51 | private String process(String content, int level) { 52 | StructuralNode node = asciidoctor.load(content, Options.builder().build()); 53 | nodeProcessor.process(node); 54 | return sinkWriter.toString(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/LiteralNodeProcessorTest.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site.parser.processors; 2 | 3 | import java.io.StringWriter; 4 | import java.util.Collections; 5 | 6 | import org.asciidoctor.Asciidoctor; 7 | import org.asciidoctor.Options; 8 | import org.asciidoctor.ast.StructuralNode; 9 | import org.asciidoctor.maven.site.parser.NodeProcessor; 10 | import org.asciidoctor.maven.site.parser.processors.test.NodeProcessorTest; 11 | import org.junit.jupiter.api.Test; 12 | 13 | import static org.assertj.core.api.Assertions.assertThat; 14 | 15 | @NodeProcessorTest(LiteralNodeProcessor.class) 16 | class LiteralNodeProcessorTest { 17 | 18 | private Asciidoctor asciidoctor; 19 | private NodeProcessor nodeProcessor; 20 | private StringWriter sinkWriter; 21 | 22 | @Test 23 | void should_convert_simple_literal() { 24 | String content = documentWithLiteralBlock(); 25 | 26 | String html = process(content); 27 | 28 | assertThat(html) 29 | .isEqualTo("
This is a literal line.
"); 30 | } 31 | 32 | private String documentWithLiteralBlock() { 33 | return "= Document tile\n\n" 34 | + "== Section\n\n This is a literal line.\n"; 35 | } 36 | 37 | private String process(String content) { 38 | StructuralNode node = asciidoctor.load(content, Options.builder().build()) 39 | .findBy(Collections.singletonMap("context", ":literal")) 40 | .get(0); 41 | 42 | nodeProcessor.process(node); 43 | 44 | return sinkWriter.toString(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/test/NodeProcessorTest.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site.parser.processors.test; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | import org.asciidoctor.maven.site.parser.NodeProcessor; 9 | import org.junit.jupiter.api.extension.ExtendWith; 10 | 11 | @Target({ElementType.TYPE}) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | @ExtendWith(JUnitNodeProcessorExtension.class) 14 | public @interface NodeProcessorTest { 15 | 16 | Class value(); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/test/ReflectionUtils.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site.parser.processors.test; 2 | 3 | import java.io.StringWriter; 4 | import java.lang.reflect.Field; 5 | import java.lang.reflect.Modifier; 6 | 7 | public class ReflectionUtils { 8 | 9 | public static StringWriter extractField(Object sink, String fieldName) throws NoSuchFieldException, IllegalAccessException { 10 | Field field = sink.getClass().getDeclaredField(fieldName); 11 | // We don't care to alter the instance, only lives during the test 12 | field.setAccessible(true); 13 | return (StringWriter) field.get(sink); 14 | } 15 | 16 | public static Field findField(Object testInstance, Class clazz) { 17 | for (Field field : testInstance.getClass().getDeclaredFields()) { 18 | if (clazz.equals(field.getType())) return field; 19 | } 20 | return null; 21 | } 22 | 23 | public static void injectField(Object testInstance, Field field, Object value) throws IllegalAccessException { 24 | 25 | if (Modifier.isPrivate(field.getModifiers())) { 26 | field.setAccessible(true); 27 | field.set(testInstance, value); 28 | field.setAccessible(false); 29 | } else { 30 | field.set(testInstance, value); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/test/StringTestUtils.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site.parser.processors.test; 2 | 3 | public class StringTestUtils { 4 | 5 | /** 6 | * Removes linebreaks to validate to avoid OS dependant issues. 7 | * 8 | * @param value string to clean 9 | */ 10 | public static String removeLineBreaks(String value) { 11 | return value.replaceAll("(\r)?\n", "") 12 | .trim(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/test/TestNodeProcessorFactory.java: -------------------------------------------------------------------------------- 1 | package org.asciidoctor.maven.site.parser.processors.test; 2 | 3 | import java.lang.reflect.Constructor; 4 | 5 | import lombok.SneakyThrows; 6 | import org.apache.commons.lang3.tuple.Pair; 7 | import org.apache.maven.doxia.sink.Sink; 8 | import org.apache.maven.doxia.siterenderer.DocumentRenderingContext; 9 | import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink; 10 | import org.asciidoctor.maven.site.parser.NodeProcessor; 11 | import org.asciidoctor.maven.site.parser.NodeSinker; 12 | import org.mockito.Mockito; 13 | 14 | public class TestNodeProcessorFactory { 15 | 16 | @SneakyThrows 17 | public static Pair create(Class clazz) { 18 | final Sink siteRendererSink = createSink(); 19 | final NodeSinker nodeSinker = new NodeSinker(siteRendererSink); 20 | 21 | Constructor constructor = clazz.getConstructor(Sink.class, NodeSinker.class); 22 | return Pair.of(constructor.newInstance(siteRendererSink, nodeSinker), siteRendererSink); 23 | } 24 | 25 | public static Sink createSink() { 26 | return new SiteRendererSink(Mockito.mock(DocumentRenderingContext.class)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/test/resources/sample.asciidoc: -------------------------------------------------------------------------------- 1 | = Document Title 2 | Doc Writer 3 | :idprefix: id_ 4 | 5 | Preamble paragraph. 6 | 7 | NOTE: This is a test, only a test. 8 | 9 | == Section A 10 | 11 | *Section A* paragraph. 12 | 13 | === Section A Subsection 14 | 15 | *Section A* 'subsection' paragraph. 16 | 17 | == Section B 18 | 19 | *Section B* paragraph. 20 | 21 | .Section B list 22 | * Item 1 23 | * Item 2 24 | * Item 3 25 | 26 | [source,ruby] 27 | require 'asciidoctor' 28 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/test/resources/with-locale/en/asciidoc/included.adoc: -------------------------------------------------------------------------------- 1 | == Included section 2 | 3 | This has been included. 4 | -------------------------------------------------------------------------------- /asciidoctor-parser-doxia-module/src/test/resources/with-locale/en/asciidoc/sample.adoc: -------------------------------------------------------------------------------- 1 | = Document Title 2 | 3 | == Include 4 | 5 | include::included.adoc[] 6 | -------------------------------------------------------------------------------- /docs/antora.yml: -------------------------------------------------------------------------------- 1 | name: maven-tools 2 | title: Maven Tools 3 | version: '3.2' 4 | asciidoc: 5 | attributes: 6 | release-version: 3.2.0 7 | project-repo: asciidoctor/asciidoctor-maven-plugin 8 | uri-asciidoc: https://asciidoc.org 9 | uri-asciidoctor: https://asciidoctor.org 10 | uri-asciidoctorj: https://github.com/asciidoctor/asciidoctorj 11 | uri-examples: https://github.com/asciidoctor/asciidoctor-maven-examples 12 | uri-maven: https://maven.apache.org 13 | uri-maven-site-plugin: https://maven.apache.org/plugins/maven-site-plugin 14 | maven-site-plugin-version: 3.21.0 15 | nav: 16 | - modules/plugin/nav.adoc 17 | - modules/site-integration/nav.adoc 18 | - modules/project/nav.adoc 19 | -------------------------------------------------------------------------------- /docs/modules/ROOT/pages/index.adoc: -------------------------------------------------------------------------------- 1 | = Asciidoctor Maven Tools Documentation 2 | :navtitle: Introduction 3 | 4 | The Asciidoctor Maven Plugin is the official way to convert your {uri-asciidoc}[AsciiDoc] documentation using {uri-asciidoctor}[Asciidoctor] from an {uri-maven}[Apache Maven] build. 5 | 6 | The project main goal is to offer a thin layer on top of https://github.com/asciidoctor/asciidoctorj[AsciidoctorJ] following as much as possible to common Maven practices. 7 | 8 | The conversion can happen in 2 flavors: 9 | 10 | . As a xref:plugin:introduction.adoc[Maven plugin]: AsciiDoc files are converted at full Asciidoctor power independently from Maven site, 11 | 12 | . As a xref:site-integration:introduction.adoc[Maven site module]: AsciiDoc files are integrated with https://maven.apache.org/doxia/[Maven Doxia] tools, however, with a few limitations. 13 | -------------------------------------------------------------------------------- /docs/modules/plugin/nav.adoc: -------------------------------------------------------------------------------- 1 | * Maven Plugin 2 | ** xref:introduction.adoc[] 3 | ** Goals 4 | *** xref:goals/process-asciidoc.adoc[] 5 | *** xref:goals/auto-refresh.adoc[] 6 | *** xref:goals/http.adoc[] 7 | ** xref:usage.adoc[] 8 | ** xref:command-line-configuration.adoc[] 9 | ** xref:compatibility-matrix.adoc[] 10 | ** xref:examples.adoc[] 11 | ** Help & Guides 12 | *** xref:tips-and-tricks.adoc[] 13 | *** xref:v2-migration-guide.adoc[] 14 | *** xref:v3-migration-guide.adoc[] 15 | -------------------------------------------------------------------------------- /docs/modules/plugin/pages/command-line-configuration.adoc: -------------------------------------------------------------------------------- 1 | = Command Line Configuration 2 | 3 | Configuration options can be set (but not replaced) using system properties directly in the command line as follows: 4 | 5 | mvn generate-resources -Dasciidoctor.sourceDirectory=src/docs -Dasciidoctor.outputDirectory=target/docs 6 | 7 | All options follow the naming convention _`asciidoctor.` + option_name_. 8 | 9 | In order to provide a higher degree of flexibility `attributes` configuration follows a different behavior. 10 | Attributes defined through the command line are added to the ones already found in the XML configuration. 11 | The result of it is that attributes and other configuration options can be updated if they are added to the command line as attributes. 12 | For example, the following configuration could be modified with the command options as seen below. 13 | 14 | [source,xml] 15 | ---- 16 | 17 | html5 18 | 19 | left 20 | 21 | 22 | ---- 23 | 24 | mvn generate-resources -Dasciidoctor.attributes=toc=right 25 | 26 | mvn generate-resources -Dasciidoctor.attributes="toc=right source-highlighter=highlight.js imagesdir=my_images" 27 | 28 | Note that in the second case we need to use quotes due to the spaces. 29 | -------------------------------------------------------------------------------- /docs/modules/plugin/pages/compatibility-matrix.adoc: -------------------------------------------------------------------------------- 1 | = Compatibility Matrix 2 | 3 | Here is the list of supported versions alongside the required {uri-asciidoctorj}[AsciidoctorJ] version. 4 | Release candidate releases are not accounted. 5 | 6 | == Maven compatible versions 7 | 8 | The current policy for Maven compatibility is to support https://maven.apache.org/docs/history.html[1-year-old releases and the most recent minor]. 9 | 10 | That is: 11 | 12 | * Maven v3.8.8 and higher 13 | * Maven v3.9.x 14 | 15 | == AsciidoctorJ compatible versions 16 | 17 | Versions not listed below are not supported, please consider upgrading. 18 | 19 | |=== 20 | |Asciidoctor Maven Plugin | AsciidoctorJ | Supported 21 | 22 | |v3.x.x 23 | |v2.x.x, v3.x.x 24 | |Yes 25 | 26 | |=== 27 | -------------------------------------------------------------------------------- /docs/modules/plugin/pages/examples.adoc: -------------------------------------------------------------------------------- 1 | = Examples 2 | 3 | You can find examples ready to copy-paste in the {uri-examples}[Asciidoctor Maven examples] project. -------------------------------------------------------------------------------- /docs/modules/plugin/pages/goals/process-asciidoc.adoc: -------------------------------------------------------------------------------- 1 | [#process-asciidoc-goal] 2 | = process-asciidoc: Converting documents 3 | :navtitle: process-asciidoc 4 | 5 | Converts AsciiDoc documents using {uri-asciidoctorj}[AsciidoctorJ]. 6 | Additionally, the goal takes care of placing additional resources (eg. images) in the output path. 7 | 8 | include::partial$breaking-changes-warning.adoc[] 9 | 10 | == Setup 11 | 12 | include::partial$basic-maven-setup.adoc[] 13 | 14 | [source,xml] 15 | .Goal setup 16 | ---- 17 | 18 | ... 19 | 20 | 21 | output-html 22 | generate-resources 23 | 24 | process-asciidoc 25 | 26 | 27 | 28 | 29 | ---- 30 | <1> This is simply a unique id for the execution. 31 | <2> The asciidoctor-maven-plugin does not run in any phase by default, so one must be specified. 32 | <3> The Asciidoctor Maven plugin conversion goal. 33 | 34 | == Configuration 35 | 36 | There are several configuration parameters that the Asciidoctor Maven plugin accepts, which parallel the options in Asciidoctor: 37 | 38 | include::partial$process-asciidoc-mojo-parameters.adoc[] 39 | -------------------------------------------------------------------------------- /docs/modules/plugin/pages/tips-and-tricks.adoc: -------------------------------------------------------------------------------- 1 | = Tips and Tricks 2 | 3 | == Fail on missing attributes 4 | 5 | Attributes whose value cannot be resolved are ignored by default and not shown as error or warning. 6 | If you need to, this behavior can be modified using the https://asciidoctor.org/docs/user-manual/#missing-attribute[missing-attribute] attribute. 7 | 8 | Combining it with logHandler option it is possible to report an error and abort a build in case of missing attributes. 9 | 10 | [source,xml] 11 | ---- 12 | 13 | 14 | warn 15 | 16 | 17 | 18 | WARN 19 | 20 | 21 | 22 | ---- 23 | 24 | == Generate your documentation in separate folders per version 25 | 26 | Use Maven `project.version` property to create dedicated custom output directories. 27 | 28 | [source,xml] 29 | ----- 30 | 31 | ... 32 | target/generated-docs/${project.version} 33 | ... 34 | 35 | ----- 36 | 37 | == Enable section numbering 38 | 39 | Enable section numbering in the build using the `attributes` section. 40 | 41 | [source,xml] 42 | ----- 43 | 44 | ... 45 | 46 | ... 47 | true 48 | ... 49 | 50 | ... 51 | 52 | ----- 53 | 54 | == Add version and build date to the header 55 | 56 | Automatically add version details to header and footer to all documents. 57 | 58 | [source,xml] 59 | ----- 60 | 61 | 62 | yyyy-MM-dd HH 63 | 64 | 65 | 66 | ... 67 | 68 | ... 69 | ${project.version} 70 | ${maven.build.timestamp} 71 | ${project.organization.name} 72 | 73 | ... 74 | 75 | ----- 76 | <1> Add `maven.build.timestamp.format` to the pom's properties section to set a custom date format. 77 | 78 | == Show Asciidoctor version 79 | 80 | If you are not sure what version of the Asciidoctor converter is being used. 81 | You can obtain it using the version attribute like in the example below. 82 | 83 | Asciidoctor version: {asciidoctor-version} 84 | -------------------------------------------------------------------------------- /docs/modules/plugin/partials/auto-refresh-mojo-parameters.adoc: -------------------------------------------------------------------------------- 1 | [#configuration-interval] 2 | interval:: time in milliseconds between checks of the filesystem. 3 | Defaults to `2000` 4 | 5 | [#configuration-refreshOn] 6 | refreshOn:: regular expression describing additional sources that force a full refresh. 7 | Useful when working with included/partial sources that aren't converted individually. 8 | Defaults to `empty` 9 | -------------------------------------------------------------------------------- /docs/modules/plugin/partials/basic-maven-setup.adoc: -------------------------------------------------------------------------------- 1 | As this is a typical Maven plugin, simply declare the plugin in the `` section of your POM file: 2 | 3 | [source,xml,subs=attributes+] 4 | .Plugin declaration in pom.xml 5 | ---- 6 | 7 | 8 | org.asciidoctor 9 | asciidoctor-maven-plugin 10 | {release-version} 11 | 12 | 13 | org.asciidoctor 14 | asciidoctorj 15 | ${asciidoctorj.version} 16 | 17 | 18 | ... 19 | 20 | 21 | ---- 22 | <1> The plugin will use the latest AsciidoctorJ version available at release. 23 | To change it, set the desired version as a plugin dependency. 24 | -------------------------------------------------------------------------------- /docs/modules/plugin/partials/breaking-changes-warning.adoc: -------------------------------------------------------------------------------- 1 | WARNING: 2.0.0 version introduced breaking changes. 2 | If you are upgrading from a previous version, please read the xref:v2-migration-guide.adoc[v2 migration guide]. -------------------------------------------------------------------------------- /docs/modules/plugin/partials/http-mojo-parameters.adoc: -------------------------------------------------------------------------------- 1 | [#configuration-port] 2 | port:: server port. 3 | Defaults to `2000`. 4 | 5 | [#configuration-home] 6 | home:: default resource to open when no url is indicated, that is when browsing to http://localhost:2000. 7 | Defaults to `index`. 8 | -------------------------------------------------------------------------------- /docs/modules/plugin/partials/setting-boolean-attributes.adoc: -------------------------------------------------------------------------------- 1 | Boolean attributes only require to be enabled or _set_. 2 | These, can be set with a empty tag or a boolean value. 3 | To _unset_ an attribute, use value `false`. 4 | 5 | [source,xml] 6 | ---- 7 | 8 | true 9 | false 10 | ---- 11 | -------------------------------------------------------------------------------- /docs/modules/project/nav.adoc: -------------------------------------------------------------------------------- 1 | * Project Documentation 2 | ** xref:contributing.adoc[Contributing] 3 | ** xref:copyright-and-licence.adoc[Copyright and License] 4 | -------------------------------------------------------------------------------- /docs/modules/project/pages/contributing.adoc: -------------------------------------------------------------------------------- 1 | = Contributing 2 | 3 | This plugin is an open source project made possible with the help of users and enthusiasts. 4 | To continue to be useful and to evolve, this plugin needs continuing contributions. 5 | There are multiple ways where you can help: 6 | 7 | * join the discussions 8 | * give feedback on ideas 9 | * report issue 10 | * test new releases 11 | * contribute source code to fix issues or add new functionality 12 | * write documentation 13 | 14 | == Hacking 15 | 16 | Developer setup for hacking on this project isn't very difficult. 17 | The requirements are very small: 18 | 19 | * Java 11 or higher 20 | * Maven 3 21 | 22 | Everything else will be brought in by Maven. 23 | This is a typical Maven Java project, nothing special. 24 | You should be able to use IntelliJ, Eclipse, or NetBeans without any issue for hacking on the project. 25 | 26 | == Code formatting 27 | 28 | The project doesn't have a strict policy, but there are some rules provided in using https://editorconfig.org/[.editorconfig] file. 29 | Check your IDE for `editorconfig` support. 30 | 31 | The rules are: 32 | 33 | * Use of spaces for indentation. 34 | * Maven import https://maven.apache.org/developers/conventions/code.html#java-code-convention-import-layouts[policy]. 35 | 36 | == Testing 37 | 38 | Unit tests are written with http://spockframework.org/[Spock]. 39 | This will be downloaded by Maven and can be run from IntelliJ without any additional setup. 40 | Tests are run simply by: 41 | 42 | ./mvnw clean test 43 | 44 | Or any of the other goals which run tests. 45 | 46 | Integration tests under `src/it` are run using link:https://maven.apache.org/plugins/maven-invoker-plugin/[maven-invoker-plugin] and the `runt-its` profile. 47 | To only run them without excluding unit tests, use: 48 | 49 | ./mvnw clean verify -DskipTests -Prun-its 50 | 51 | To run all tests at once just use `./mvnw clean verify -DskipTests -Prun-its`. 52 | -------------------------------------------------------------------------------- /docs/modules/project/pages/copyright-and-licence.adoc: -------------------------------------------------------------------------------- 1 | == Copyright and License 2 | :uri-license: https://github.com/asciidoctor/asciidoctor-maven-plugin/blob/main/LICENSE.txt 3 | 4 | Copyright (C) 2013-2020 Jason Porter, Dan Allen, Abel Salgado Romero and the individual contributors. 5 | Use of this software is granted under the terms of the Apache License, Version 2.0. 6 | 7 | See the {uri-license}[LICENSE^] for the full license text. 8 | -------------------------------------------------------------------------------- /docs/modules/site-integration/nav.adoc: -------------------------------------------------------------------------------- 1 | * Maven Site Integration 2 | ** xref:introduction.adoc[] 3 | ** Modules 4 | *** xref:converter-module-setup-and-configuration.adoc[] 5 | *** xref:parser-module-setup-and-configuration.adoc[] 6 | *** xref:exposed-metadata.adoc[] 7 | *** xref:compatibility-matrix.adoc[] 8 | ** Help & Guides 9 | *** xref:v3-migration-guide.adoc[] 10 | -------------------------------------------------------------------------------- /docs/modules/site-integration/pages/compatibility-matrix.adoc: -------------------------------------------------------------------------------- 1 | = Compatibility Matrix 2 | 3 | Here is the list of supported versions alongside the required {uri-maven-site-plugin}[Maven Site Plugin] version. 4 | Release candidate releases are not accounted. 5 | 6 | == Versions 7 | 8 | Versions not listed below are not supported, please consider upgrading. 9 | 10 | |=== 11 | |Asciidoctor Doxia Module | Maven Site Plugin | Supported 12 | 13 | |v3.0.x 14 | |v3.1x.x ~ v3.12.x 15 | |Yes 16 | 17 | |v3.1.x ~ v3.2.x 18 | |v3.20.x 19 | |Yes 20 | 21 | |=== 22 | -------------------------------------------------------------------------------- /docs/modules/site-integration/pages/exposed-metadata.adoc: -------------------------------------------------------------------------------- 1 | = Exposed Metadata 2 | :asciidoctor-docs-url: https://docs.asciidoctor.org/asciidoc/latest 3 | :maven-site-plugin-docs-url: https://maven.apache.org/plugins/maven-site-plugin 4 | 5 | The Asciidoctor Maven Site integration collaborates with Doxia to expose some of its information. 6 | 7 | == Document Header Metadata 8 | 9 | The following elements from the {asciidoctor-docs-url}/document/header/[header] are integrated: 10 | 11 | document title:: used to inform the {maven-site-plugin-docs-url}/examples/sitedescriptor.html#Breadcrumbs[breadcrumb] line when these are enabled. 12 | 13 | author(s):: full representation (full name and email) will be present as HTML `` tags inside the HTML ``. 14 | In case of multiple authors, each one will appear in a distinct `meta` element. 15 | 16 | revision date:: the header revision date value will be presented as-is in a `` element. 17 | Alternatively, if not set, the generated value of `docdatetime` will be used. 18 | -------------------------------------------------------------------------------- /docs/modules/site-integration/pages/introduction.adoc: -------------------------------------------------------------------------------- 1 | = Introduction 2 | :maven-doxia-url: https://maven.apache.org/doxia/ 3 | 4 | The Asciidoctor Maven Site integration provides two {maven-doxia-url}[Maven Doxia] modules to author your content with the {uri-maven-site-plugin}[Maven Site Plugin]. 5 | 6 | * xref:converter-module-setup-and-configuration.adoc[Converter Doxia Module] converts AsciiDoc sources into HTML using Asciidoctor without customizations. 7 | That means you will get the same HTML as using Asciidoctor but some elements may not be well presented due to incompatibilities with Doxia Skins. 8 | You may need to add custom CSS or Asciidoctor templates. + 9 | This is continuation of the previous `asciidoctor-maven-plugin`. 10 | * xref:parser-module-setup-and-configuration.adoc[Parser Doxia Module] converts AsciiDoc sources into HTML using custom converters, adapting the output to better match Maven Site styles. 11 | This module offers the better out-of-the-box experience and does not require additional CSS styles or other elements. + 12 | However, not all AsciiDoc structures are supported _YET_ and this module is considered _experimental_. 13 | See the list of currently supported features in xref:parser-module-setup-and-configuration.adoc#supported-asciidoc-elements[Supported AsciiDoc elements]. 14 | 15 | -------------------------------------------------------------------------------- /docs/modules/site-integration/pages/v3-migration-guide.adoc: -------------------------------------------------------------------------------- 1 | = Site integration 3.x.x Migration Guide 2 | :navtitle: 3.x.x Migration Guide 3 | :doxia-compatible-module-name: asciidoctor-converter-doxia-module 4 | :doxia-new-module-name: asciidoctor-parser-doxia-module 5 | 6 | The `asciidoctor-maven-plugin` and its Doxia Modules 3.0.0 introduces some breaking changes. 7 | This guide will provide the steps required to update a project currently using 2.x.x version. 8 | For each of the breaking changes, the motivation and new equivalent configuration will be offered. 9 | 10 | NOTE: New configuration details are highlighted in *bold*. 11 | 12 | == Motivations 13 | 14 | Changes in this version have been motivated to provide a new easier to use asciidoctor to build sites with Maven site plugin. 15 | With that goal in mind, the single project that contained both the maven plugin and site integration components has been split into different maven submodules. 16 | 17 | The old Doxia module embedded in `asciidocto-maven-plugin` library it's now an independent JAR called `{doxia-compatible-module-name}`, and a new one has been created `{doxia-new-module-name}`. 18 | 19 | == Changes 20 | 21 | === Minimal Java version 22 | 23 | Minimal Java version is 11. 24 | 25 | Note this also imposes versions on dependencies, for example: 26 | 27 | * Only AsciidoctorJ v2.5.x 28 | * Only asciidoctorj-diagram previous v2.2.8 29 | 30 | === Site plugin module renamed 31 | 32 | The https://maven.apache.org/doxia/[Doxia] module has been extracted into a separated subproject named `{doxia-compatible-module-name}`. 33 | 34 | *Rename the maven-site-plugin dependency from `asciidoctor-maven-plugin` to `{doxia-compatible-module-name}`.* 35 | 36 | [source,xml,subs=attributes+] 37 | .new configuration 38 | ---- 39 | 40 | org.apache.maven.plugins 41 | maven-site-plugin 42 | {maven-site-plugin-version} 43 | 44 | 45 | org.asciidoctor 46 | {doxia-compatible-module-name} 47 | {release-version} 48 | 49 | 50 | 51 | ---- 52 | --------------------------------------------------------------------------------