Skip to content

Commit

Permalink
Merge pull request #37 from dgautier/fix/table-conversion
Browse files Browse the repository at this point in the history
Fix/table conversion
  • Loading branch information
bodiam committed Jun 5, 2023
2 parents bec22e3 + 477fd5d commit ef0e281
Show file tree
Hide file tree
Showing 9 changed files with 197 additions and 43 deletions.
64 changes: 28 additions & 36 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.1.4'
ext.kotlin_version = '1.8.0'
repositories {
mavenCentral()
}
Expand All @@ -15,27 +15,26 @@ plugins {
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'application'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'eclipse'

compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}



group 'nl.jworks.markdown_to_asciidoc'
version '1.1'
version '2.0.0-SNAPSHOT'

sourceCompatibility = targetCompatibility = 1.8
sourceCompatibility = targetCompatibility = 17
defaultTasks 'check'

repositories {
Expand Down Expand Up @@ -88,40 +87,23 @@ bintray {

}

publishing {
publications {
mavenJava(MavenPublication) {
if (plugins.hasPlugin('war')) {
from components.web
} else {
from components.java
}

artifact sourcesJar
artifact javadocJar
}
}
}

dependencies {
compile 'org.pegdown:pegdown:1.6.0'
compile 'org.jsoup:jsoup:1.8.1'

testCompile 'info.cukes:cucumber-picocontainer:1.1.8'
testCompile 'info.cukes:cucumber-junit:1.1.8'
testCompile 'junit:junit:4.12'
testCompile 'org.apache.commons:commons-io:1.3.2'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
}

task sourcesJar(type: Jar, dependsOn: classes) {
from sourceSets.main.allSource
classifier 'sources'
implementation 'org.pegdown:pegdown:1.6.0'
//We want to use latest parboiled version not the default one provided by pegdown
implementation 'org.parboiled:parboiled-java:1.4.1'
implementation 'org.jsoup:jsoup:1.16.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

testImplementation 'org.apache.commons:commons-io:1.3.2'
testImplementation 'io.cucumber:cucumber-picocontainer:7.11.0'
testImplementation 'io.cucumber:cucumber-junit:7.11.0'
testImplementation 'io.cucumber:cucumber-java:7.11.0'
}

task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
classifier 'javadoc'
java {
withSourcesJar()
withJavadocJar()
}

artifacts {
Expand All @@ -138,3 +120,13 @@ eclipse {
defaultOutputDir = file('build/eclipse')
}
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
}
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=1.0.0-SNAPSHOT
version=2.0.0-SNAPSHOT
description=Markdown to AsciiDoc converter for the JVM
121 changes: 121 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>

<groupId>nl.jworks.markdown_to_asciidoc</groupId>
<artifactId>markdown_to_asciidoc</artifactId>
<version>2.0.0-SNAPSHOT</version>

<properties>
<kotlin.version>1.8.0</kotlin.version>
<java.version>17</java.version>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.source>${java.version}</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.pegdown</groupId>
<artifactId>pegdown</artifactId>
<version>1.6.0</version>
<exclusions>
<exclusion>
<groupId>org.parboiled</groupId>
<artifactId>parboiled-java</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.parboiled</groupId>
<artifactId>parboiled-java</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.16.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>7.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.11.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/main/kotlin</source>
<source>src/main/java</source>
</sourceDirs>
</configuration>
</execution>
<!--
<execution>
<id>test-compile</id>
<phase>process-test-sources</phase>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/test/java</source>
<source>src/test/kotlin</source>
<source>src/test/resources</source>
</sourceDirs>
</configuration>
</execution>
-->
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,13 @@ public void visit(TableNode node) {
List<TableColumnNode> columns = node.getColumns();

if(ifColumnsHaveAlignmentSpecified(columns)) {
printer.println();
printer.print("[cols=\"");
printer.print(getColumnAlignment(columns));
printer.print("\"]");
printer.println();
} else {
printer.println();
}

printer.print("|===");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,13 @@ class ToAsciiDocSerializerKt @JvmOverloads constructor(private var rootNode: Roo
val columns = node.columns

if (ifColumnsHaveAlignmentSpecified(columns)) {
printer.println()
printer.print("[cols=\"")
printer.print(getColumnAlignment(columns))
printer.print("\"]")
printer.println()
} else {
printer.println()
}

printer.print("|===")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package nl.jworks.markdown_to_asciidoc;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(format = "pretty")
@CucumberOptions
public class RunCukesTest {
}
7 changes: 4 additions & 3 deletions src/test/java/nl/jworks/markdown_to_asciidoc/Stepdefs.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package nl.jworks.markdown_to_asciidoc;

import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;

import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;

import static org.junit.Assert.assertEquals;

Expand Down
4 changes: 4 additions & 0 deletions src/test/java/nl/jworks/markdown_to_asciidoc/TestSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
import org.junit.Ignore;
import org.junit.Test;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.nio.charset.StandardCharsets;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
Expand Down
30 changes: 30 additions & 0 deletions src/test/resources/nl/jworks/markdown_to_asciidoc/tables.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,36 @@ Feature: Tables
|===
"""

Scenario: Render a table under a paragraph
Given the Markdown source
"""
# Step
Lorem Ipsum etc.
- `sample.yaml`: sample file to do some stuff with
| Name of Column 1 | Name of Column 2|
| ---------------- | --------------- |
| Cell in column 1, row 1 | Cell in column 2, row 1|
| Cell in column 1, row 2 | Cell in column 2, row 2|
"""
When it is converted to AsciiDoc
Then the result should match the AsciiDoc source
"""
= Step
Lorem Ipsum etc.
* `sample.yaml`: sample file to do some stuff with
|===
|Name of Column 1 |Name of Column 2
|Cell in column 1, row 1 |Cell in column 2, row 1
|Cell in column 1, row 2 |Cell in column 2, row 2
|===
"""

# NOTE we are still getting trailing space at the end of lines
Scenario: Leave a trailing space at the end of each adjacent cell
Given the Markdown source
Expand Down

0 comments on commit ef0e281

Please sign in to comment.