@Test void testErrorSuppressionErrorFromJavaScriptValidator() throws RedPenException, IOException { File javaScriptValidatorsDir = File.createTempFile("test", "js"); javaScriptValidatorsDir.delete(); javaScriptValidatorsDir.mkdirs(); System.setProperty("REDPEN_HOME", javaScriptValidatorsDir.getAbsolutePath()); File validatorJS = new File(javaScriptValidatorsDir.getAbsolutePath() + File.separator + "MyValidationScript.js"); String content2 = "function validateSentence(sentence) {\n" + "addLocalizedError(sentence, 'validation error in JavaScript Validator');}"; Files.write(Paths.get(validatorJS.getAbsolutePath()), content2.getBytes(UTF_8)); validatorJS.deleteOnExit(); Configuration config = Configuration.builder() .addValidatorConfig(new ValidatorConfiguration("JavaScript").addProperty("script-path", javaScriptValidatorsDir.getAbsolutePath())) .build(); String sampleAsciiDocShortText = "[suppress]\n" + "the good item is a good example.\n"; Document doc = createFileContent(sampleAsciiDocShortText, DocumentParser.ASCIIDOC); RedPen redPen = new RedPen(config); List<ValidationError> errors = redPen.validate(doc); assertEquals(0, errors.size()); }
@Override public void validate(Document document) { for (JavaScriptLoader js : scripts) { js.setErrorList(errors); js.validate(document); } }
JavaScriptValidator extends Validator { @Override public void validate(Document document) { for (JavaScriptLoader js : scripts) { js.setErrorList(errors); js.validate(document); } } }
JavaScriptValidator extends Validator { @Override public void validate(Document document) { for (JavaScriptLoader js : scripts) { js.setErrorList(errors); js.validate(document); } } JavaScriptValidator(); }
JavaScriptValidator extends Validator { @Override public void validate(Document document) { for (JavaScriptLoader js : scripts) { js.setErrorList(errors); js.validate(document); } } JavaScriptValidator(); @Override void preInit(ValidatorConfiguration config, Configuration globalConfig); @Override void setErrorList(List<ValidationError> errors); @Override void preValidate(Sentence sentence); @Override void preValidate(Section section); @Override void validate(Document document); @Override void validate(Sentence sentence); @Override void validate(Section section); }
JavaScriptValidator extends Validator { @Override public void validate(Document document) { for (JavaScriptLoader js : scripts) { js.setErrorList(errors); js.validate(document); } } JavaScriptValidator(); @Override void preInit(ValidatorConfiguration config, Configuration globalConfig); @Override void setErrorList(List<ValidationError> errors); @Override void preValidate(Sentence sentence); @Override void preValidate(Section section); @Override void validate(Document document); @Override void validate(Sentence sentence); @Override void validate(Section section);  }