-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit 76712d2.
- Loading branch information
Showing
33 changed files
with
4,854 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: CI | ||
'on': | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
env: | ||
MAVEN_OPTS: >- | ||
-Dhttp.keepAlive=false | ||
-Dmaven.wagon.http.pool=false | ||
-Dmaven.wagon.httpconnectionManager.ttlSeconds=120 | ||
jobs: | ||
sonarcloud: | ||
name: SonarCloud Scan | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v3 | ||
- name: Use Java 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 17 | ||
distribution: 'zulu' | ||
- name: SonarCloud Scan | ||
uses: jason-fox/sonarcloud-action@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_CLOUD_LOGIN: ${{ secrets.SONAR_CLOUD_LOGIN }} | ||
|
||
unit-test: | ||
name: Unit Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v3 | ||
- name: Run DITA-OT Unit Test | ||
uses: jason-fox/dita-unit-test-action@master | ||
with: | ||
dita-ot-version: '4.0' | ||
plugin: 'fox.jason.prismjs' | ||
prerequisites: fox.jason.extend.css | ||
setup-script: 'test/setup.sh' | ||
- uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: test-results | ||
path: test-results.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* This file is part of the DITA-OT Pretty DITA Plug-in project. | ||
* See the accompanying LICENSE file for applicable licenses. | ||
*/ | ||
|
||
package fox.jason.prismjs.tasks; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.apache.tools.ant.BuildException; | ||
import org.apache.tools.ant.DirectoryScanner; | ||
import org.apache.tools.ant.Task; | ||
import org.apache.tools.ant.taskdefs.MacroInstance; | ||
import org.apache.tools.ant.types.FileSet; | ||
|
||
// | ||
// Iterator function to run a given macro against a set of files | ||
// | ||
|
||
public class IterateDitaFilesTask extends Task { | ||
|
||
/** | ||
* Field list. | ||
*/ | ||
private String list; | ||
/** | ||
* Field macro. | ||
*/ | ||
private String macro; | ||
|
||
/** | ||
* Creates a new <code>IterateDitaFilesTask</code> instance. | ||
*/ | ||
public IterateDitaFilesTask() { | ||
super(); | ||
this.list = null; | ||
this.macro = null; | ||
} | ||
|
||
/** | ||
* Method setList. | ||
* | ||
* @param list String | ||
*/ | ||
public void setList(String list) { | ||
this.list = list; | ||
} | ||
|
||
/** | ||
* Method setMacro. | ||
* | ||
* @param macro String | ||
*/ | ||
public void setMacro(String macro) { | ||
this.macro = macro; | ||
} | ||
|
||
/** | ||
* Method execute. | ||
* | ||
* @throws BuildException if something goes wrong | ||
*/ | ||
@Override | ||
public void execute() { | ||
// @param list - The list of files to annotate | ||
if (this.list == null) { | ||
throw new BuildException("You must supply a list of files to annotate"); | ||
} | ||
if (this.macro == null) { | ||
throw new BuildException("You must supply a macro"); | ||
} | ||
|
||
String[] filenames = list.split(";", 0); | ||
|
||
for (String file : filenames) { | ||
|
||
MacroInstance task = (MacroInstance) getProject() | ||
.createTask(this.macro); | ||
try { | ||
task.setDynamicAttribute("file", file); | ||
task.execute(); | ||
} catch (Exception err) { | ||
throw new BuildException(err); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/* | ||
* This file is part of the DITA-OT Pretty DITA Plug-in project. | ||
* See the accompanying LICENSE file for applicable licenses. | ||
*/ | ||
|
||
package fox.jason.prismjs.tasks; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.apache.tools.ant.BuildException; | ||
import org.apache.tools.ant.DirectoryScanner; | ||
import org.apache.tools.ant.Task; | ||
import org.apache.tools.ant.taskdefs.MacroInstance; | ||
import org.apache.tools.ant.types.FileSet; | ||
|
||
// | ||
// Iterator function to run a given macro against a set of files | ||
// | ||
|
||
public class IterateFilesetTask extends Task { | ||
/** | ||
* Field filesets. | ||
*/ | ||
private List<FileSet> filesets; | ||
/** | ||
* Field macro. | ||
*/ | ||
private String macro; | ||
/** | ||
* Field file. | ||
*/ | ||
private String file; | ||
|
||
/** | ||
* Field dir. | ||
*/ | ||
private String dir; | ||
|
||
/** | ||
* Creates a new <code>IterateFilesetTask</code> instance. | ||
*/ | ||
public IterateFilesetTask() { | ||
super(); | ||
this.dir = null; | ||
this.file = null; | ||
this.macro = null; | ||
this.filesets = new ArrayList<>(); | ||
} | ||
|
||
/** | ||
* Method setDir. | ||
* | ||
* @param dir String | ||
*/ | ||
public void setDir(String dir) { | ||
this.dir = dir; | ||
} | ||
|
||
/** | ||
* Method setfile. | ||
* | ||
* @param file String | ||
*/ | ||
public void setFile(String file) { | ||
this.file = file; | ||
} | ||
|
||
/** | ||
* Method setMacro. | ||
* | ||
* @param macro String | ||
*/ | ||
public void setMacro(String macro) { | ||
this.macro = macro; | ||
} | ||
|
||
/** | ||
* @param set FileSet | ||
*/ | ||
public void addFileset(FileSet set) { | ||
this.filesets.add(set); | ||
} | ||
|
||
/** | ||
* Method execute. | ||
* | ||
* @throws BuildException if something goes wrong | ||
*/ | ||
@Override | ||
public void execute() { | ||
// @param file - The output location of the files | ||
// @param dir - The location of the files to process | ||
// @param macro - A macro to run. | ||
// @param fileset - A set of files | ||
if (this.dir == null) { | ||
throw new BuildException("You must supply a source directory"); | ||
} | ||
if (this.file == null) { | ||
throw new BuildException("You must supply a destination file"); | ||
} | ||
if (this.macro == null) { | ||
throw new BuildException("You must supply a macro"); | ||
} | ||
if (this.filesets.isEmpty()) { | ||
throw new BuildException("You must supply a set of files"); | ||
} | ||
|
||
for (FileSet fileset : this.filesets) { | ||
DirectoryScanner scanner = fileset.getDirectoryScanner(getProject()); | ||
scanner.scan(); | ||
|
||
for (String src : scanner.getIncludedFiles()) { | ||
MacroInstance task = (MacroInstance) getProject() | ||
.createTask(this.macro); | ||
try { | ||
task.setDynamicAttribute("src", src); | ||
task.setDynamicAttribute("dir", this.dir); | ||
task.setDynamicAttribute("file", this.file); | ||
task.execute(); | ||
} catch (Exception err) { | ||
throw new BuildException(err); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* This file is part of the DITA-OT Prism-JS Plug-in project | ||
* See the accompanying LICENSE file for applicable licenses. | ||
*/ | ||
|
||
package fox.jason.prismjs.tasks; | ||
|
||
import org.apache.tools.ant.BuildException; | ||
import org.apache.tools.ant.Task; | ||
import java.util.regex.Pattern; | ||
import java.util.regex.Matcher; | ||
|
||
// | ||
// Obtains the corrected highlighting language from the outputclass | ||
// | ||
|
||
public class ShortLangTask extends Task { | ||
|
||
/** | ||
* Field outputclass. | ||
*/ | ||
private String outputclass; | ||
|
||
/** | ||
* Field property. | ||
*/ | ||
private String property; | ||
|
||
/** | ||
* Field regex. | ||
*/ | ||
private Pattern regex; | ||
|
||
/** | ||
* Creates a new <code>ShortLangTask</code> instance. | ||
*/ | ||
public ShortLangTask() { | ||
super(); | ||
this.outputclass = null; | ||
this.property = null; | ||
this.regex = Pattern.compile("\\blang(?:uage)?-([\\w-]+)\\b", Pattern.CASE_INSENSITIVE); | ||
} | ||
|
||
/** | ||
* Method setOutputclass. | ||
* | ||
* @param outputclass String | ||
*/ | ||
public void setOutputclass(String outputclass) { | ||
this.outputclass = outputclass; | ||
} | ||
|
||
/** | ||
* Method setProperty. | ||
* | ||
* @param property String | ||
*/ | ||
public void setProperty(String property) { | ||
this.property = property; | ||
} | ||
|
||
/** | ||
* Method execute. | ||
* | ||
* @throws BuildException if something goes wrong | ||
*/ | ||
@Override | ||
public void execute() { | ||
// @param outputclass - The outputclass of the codeblock | ||
// @param property - The property to set with the corrected | ||
// highighting language | ||
if (outputclass == null) { | ||
throw new BuildException("You must supply an outputclass"); | ||
} | ||
if (property == null) { | ||
throw new BuildException("You must supply a property to set"); | ||
} | ||
|
||
|
||
String language = outputclass.toLowerCase(); | ||
Matcher matcher = regex.matcher(outputclass); | ||
if (matcher.find()) { | ||
language = matcher.group(); | ||
language = language.substring(language.indexOf('-') + 1, language.length()); | ||
} | ||
getProject().setProperty(property, language); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<project basedir="." default="unit-test"> | ||
<import file="../bootstrap.xml"/> | ||
<description> | ||
Expect that PDF codeblock text highlights using ancestor | ||
</description> | ||
<target description="" name="unit-test"> | ||
<exec-pdf/> | ||
<get-pdf-article/> | ||
<compare-output/> | ||
</target> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE bookmap PUBLIC "-//OASIS//DTD DITA BookMap//EN" "bookmap.dtd"> | ||
<bookmap> | ||
<chapter navtitle="codeblock"> | ||
<topicref format="dita" type="topic" href="topic.dita"/> | ||
</chapter> | ||
</bookmap> | ||
|
Oops, something went wrong.