@Override public void processHeader(final ParserContext context) { Map<String, Object> contents = context.getDocumentModel(); contents.put(Attributes.TYPE, "post"); contents.put(Attributes.STATUS, "published"); contents.put(Attributes.TITLE, "Rendering engine missing"); contents.put(Attributes.DATE, new Date()); contents.put(Attributes.TAGS, new String[0]); contents.put(Attributes.ID, context.getFile().getName()); }
@Override public void processBody(final ParserContext context) { context.setBody("The markup engine [" + engineName + "] for [" + context.getFile() + "] couldn't be loaded"); } }
private void setModelDefaultsIfNotSetInHeader(ParserContext context) { if (context.getDate() == null) { context.setDate(new Date(context.getFile().lastModified())); } // default status has been set if (context.getConfig().getDefaultStatus() != null && context.getStatus().isEmpty()) { // file hasn't got status so use default context.setDefaultStatus(); } // default type has been set if (context.getConfig().getDefaultType() != null && context.getType().isEmpty()) { // file hasn't got type so use default context.setDefaultType(); } }
Options options = getAsciiDocOptionsAndAttributes(context); final Asciidoctor asciidoctor = getEngine(options); DocumentHeader header = asciidoctor.readDocumentHeader(context.getFile()); Map<String, Object> documentModel = context.getDocumentModel(); if (header.getDocumentTitle() != null) {
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 processBody(final ParserContext context) { context.setBody("The markup engine [" + engineName + "] for [" + context.getFile() + "] couldn't be loaded"); } }
@Override public void processHeader(final ParserContext context) { Map<String, Object> contents = context.getDocumentModel(); contents.put(Attributes.TYPE, "post"); contents.put(Attributes.STATUS, "published"); contents.put(Attributes.TITLE, "Rendering engine missing"); contents.put(Attributes.DATE, new Date()); contents.put(Attributes.TAGS, new String[0]); contents.put(Attributes.ID, context.getFile().getName()); }
private void setModelDefaultsIfNotSetInHeader(ParserContext context) { if (context.getDate() == null) { context.setDate(new Date(context.getFile().lastModified())); } // default status has been set if (context.getConfig().getDefaultStatus() != null && context.getStatus().isEmpty()) { // file hasn't got status so use default context.setDefaultStatus(); } // default type has been set if (context.getConfig().getDefaultType() != null && context.getType().isEmpty()) { // file hasn't got type so use default context.setDefaultType(); } }
Options options = getAsciiDocOptionsAndAttributes(context); final Asciidoctor asciidoctor = getEngine(options); DocumentHeader header = asciidoctor.readDocumentHeader(context.getFile()); Map<String, Object> documentModel = context.getDocumentModel(); if (header.getDocumentTitle() != null) {
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; }