closes make SyntaxHighlighter test independent of highlight.js version
MODIFY
CHANGELOG.adoc
CHANGELOG.adoc
@@ -15,6 +15,10 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
== 2.4.1 (2020-09-10)
+Build::
+
+* Make SyntaxHighlighter test independent of highlight.js version (@abelsromero) (#955)
+
Bug Fixes::
* Fix NullPointerException when a document contains an empty table with PDF backend (@anthonyroussel) (#944)

MODIFY
asciidoctor-gem-installer.pom
asciidoctor-gem-installer.pom
<pluginRepositories>
<pluginRepository>
<id>rubygems-releases</id>
- <url>http://rubygems-proxy.torquebox.org/releases</url>
+ <url>https://rubygems-proxy.torquebox.org/releases</url>
</pluginRepository>
</pluginRepositories>
<properties>
<plugin>
<groupId>de.saumya.mojo</groupId>
<artifactId>gem-maven-plugin</artifactId>
- <version>1.1.7</version>
+ <version>1.1.8</version>
<extensions>true</extensions>
</plugin>
</plugins>

MODIFY
asciidoctorj-core/src/test/groovy/org/asciidoctor/syntaxhighlighter/HighlightJsHighlighter.groovy
asciidoctorj-core/src/test/groovy/org/asciidoctor/syntaxhighlighter/HighlightJsHighlighter.groovy
@@ -11,7 +11,7 @@ abstract class AbstractHighlightJsHighlighter implements SyntaxHighlighterAdapte
@Override
String getDocinfo(LocationType location, Document document, Map<String, Object> options) {
- String baseUrl = document.getAttribute('highlightjsdir', "${options['cdn_base_url']}/highlight.js/9.15.6")
+ String baseUrl = document.getAttribute('highlightjsdir', "${options['cdn_base_url']}/highlight.js/9.15.5")
"""<link rel="stylesheet" href="$baseUrl/styles/${document.getAttribute('highlightjs-theme', 'github')}.min.css"${options['self_closing_tag_slash']}>
<script src="$baseUrl/highlight.min.js"></script>
<script>hljs.initHighlighting()</script>"""

MODIFY
asciidoctorj-core/src/test/groovy/org/asciidoctor/syntaxhighlighter/WhenAHighlightjsAdapterIsImplementedInGroovy.groovy
asciidoctorj-core/src/test/groovy/org/asciidoctor/syntaxhighlighter/WhenAHighlightjsAdapterIsImplementedInGroovy.groovy
@@ -9,8 +9,9 @@ import org.jboss.arquillian.test.api.ArquillianResource
import org.junit.runner.RunWith
import spock.lang.Specification
-import static junit.framework.Assert.assertEquals
+import static org.hamcrest.Matchers.containsString
import static org.hamcrest.Matchers.either
+import static org.hamcrest.Matchers.equalTo
import static org.hamcrest.Matchers.is
import static org.junit.Assert.assertThat
@@ -63,10 +64,17 @@ func main() {
.attributes(AttributesBuilder.attributes().sourceHighlighter(HIGHLIGHTJS)))
then:
+ assertThat(htmlJavaOld, containsString('highlight.js/9.15.5'))
+ assertThat(htmlJavaNew, containsString('highlight.js/9.15.6'))
// Cannot use `htmlRuby == htmlJava` because it fails with OOM
// Asciidoctor > 2.0.10 changed the location where the javascript is included,
// therefore test against both possibilities to pass with 2.0.10 and upstream
- assertThat(htmlRuby, either(is(htmlJavaNew)).or(is(htmlJavaOld)))
+ assertThat(stripHighlightjsVersion(htmlRuby),
+ either(is(stripHighlightjsVersion(htmlJavaNew))).or(is(stripHighlightjsVersion(htmlJavaOld))))
+ }
+
+ private String stripHighlightjsVersion(String htmlRuby) {
+ htmlRuby.replaceAll('highlight\\.js/(\\d)+\\.(\\d)+\\.(\\d)+/', 'highlight\\.js/ma\\.min\\.fix/')
}
def 'should autoregister from extension'() {
@@ -78,6 +86,6 @@ func main() {
.attributes(AttributesBuilder.attributes().sourceHighlighter(HighlightJsExtension.NAME_HIGHLIGHTER)))
then:
- assertEquals(2, ObservableHighlightJsHighlighter.called)
+ assertThat(ObservableHighlightJsHighlighter.called, is(equalTo(2)))
}
}

closes #953: make SyntaxHighlighter test independent of highlight.js version