@Override public void processHeader(final ParserContext context) { Options options = getAsciiDocOptionsAndAttributes(context); final Asciidoctor asciidoctor = getEngine(options); DocumentHeader header = asciidoctor.readDocumentHeader(context.getFile()); Map<String, Object> documentModel = context.getDocumentModel(); Object value = attribute.getValue(); if (hasJBakePrefix(key)) { String pKey = key.substring(6); if(canCastToString(value)) { storeHeaderValue(pKey, (String) value, documentModel); } else { documentModel.put(pKey, value); if (hasRevdate(key) && canCastToString(value)) { if (canCastToString(value)) { context.setTags(((String) value).split(",")); } else { LOGGER.error("Wrong value of 'jbake-tags'. Expected a String got '{}'", getValueClassName(value));
@Override public void processBody(ParserContext context) { StringBuilder body = new StringBuilder(context.getBody().length()); if (!context.hasHeader()) { for (String line : context.getFileLines()) { body.append(line).append("\n"); } context.setBody(body.toString()); } processAsciiDoc(context); }
private void processAsciiDoc(ParserContext context) { Options options = getAsciiDocOptionsAndAttributes(context); final Asciidoctor asciidoctor = getEngine(options); context.setBody(asciidoctor.render(context.getBody(), options)); }
private Options getAsciiDocOptionsAndAttributes(ParserContext context) { JBakeConfiguration config = context.getConfig(); List<String> asciidoctorAttributes = config.getAsciidoctorAttributes(); final AttributesBuilder attributes = attributes(asciidoctorAttributes.toArray(new String[asciidoctorAttributes.size()])); if (config.getExportAsciidoctorAttributes()) { final String prefix = config.getAttributesExportPrefixForAsciidoctor(); for (final Iterator<String> it = config.getKeys(); it.hasNext(); ) { final String key = it.next(); if (!key.startsWith("asciidoctor")) { attributes.attribute(prefix + key.replace(".", "_"), config.get(key)); } } } final List<String> optionsSubset = config.getAsciidoctorOptionKeys(); final Options options = options().attributes(attributes.get()).get(); for (final String optionKey : optionsSubset) { Object optionValue = config.getAsciidoctorOption(optionKey); if (optionKey.equals(Options.TEMPLATE_DIRS)) { List<String> dirs = getAsList(optionValue); if (!dirs.isEmpty()) { options.setTemplateDirs(String.valueOf(dirs)); } } else { options.setOption(optionKey, optionValue); } } options.setBaseDir(context.getFile().getParentFile().getAbsolutePath()); options.setSafe(UNSAFE); return options; }
private void processAsciiDoc(ParserContext context) { Options options = getAsciiDocOptionsAndAttributes(context); final Asciidoctor asciidoctor = getEngine(options); context.setBody(asciidoctor.render(context.getBody(), options)); }
private Options getAsciiDocOptionsAndAttributes(ParserContext context) { JBakeConfiguration config = context.getConfig(); List<String> asciidoctorAttributes = config.getAsciidoctorAttributes(); final AttributesBuilder attributes = attributes(asciidoctorAttributes.toArray(new String[asciidoctorAttributes.size()])); if (config.getExportAsciidoctorAttributes()) { final String prefix = config.getAttributesExportPrefixForAsciidoctor(); for (final Iterator<String> it = config.getKeys(); it.hasNext(); ) { final String key = it.next(); if (!key.startsWith("asciidoctor")) { attributes.attribute(prefix + key.replace(".", "_"), config.get(key)); } } } final List<String> optionsSubset = config.getAsciidoctorOptionKeys(); final Options options = options().attributes(attributes.get()).get(); for (final String optionKey : optionsSubset) { Object optionValue = config.getAsciidoctorOption(optionKey); if (optionKey.equals(Options.TEMPLATE_DIRS)) { List<String> dirs = getAsList(optionValue); if (!dirs.isEmpty()) { options.setTemplateDirs(String.valueOf(dirs)); } } else { options.setOption(optionKey, optionValue); } } options.setBaseDir(context.getFile().getParentFile().getAbsolutePath()); options.setSafe(UNSAFE); return options; }
@Override public void processHeader(final ParserContext context) { Options options = getAsciiDocOptionsAndAttributes(context); final Asciidoctor asciidoctor = getEngine(options); DocumentHeader header = asciidoctor.readDocumentHeader(context.getFile()); Map<String, Object> documentModel = context.getDocumentModel(); Object value = attribute.getValue(); if (hasJBakePrefix(key)) { String pKey = key.substring(6); if(canCastToString(value)) { storeHeaderValue(pKey, (String) value, documentModel); } else { documentModel.put(pKey, value); if (hasRevdate(key) && canCastToString(value)) { if (canCastToString(value)) { context.setTags(((String) value).split(",")); } else { LOGGER.error("Wrong value of 'jbake-tags'. Expected a String got '{}'", getValueClassName(value));
@Override public void processBody(ParserContext context) { StringBuilder body = new StringBuilder(context.getBody().length()); if (!context.hasHeader()) { for (String line : context.getFileLines()) { body.append(line).append("\n"); } context.setBody(body.toString()); } processAsciiDoc(context); }