diff --git a/jbake-core/src/main/java/org/jbake/app/ConfigUtil.java b/jbake-core/src/main/java/org/jbake/app/ConfigUtil.java index 8ae065bcc..d0bb3fdf1 100644 --- a/jbake-core/src/main/java/org/jbake/app/ConfigUtil.java +++ b/jbake-core/src/main/java/org/jbake/app/ConfigUtil.java @@ -1,5 +1,6 @@ package org.jbake.app; +import java.io.File; import org.apache.commons.configuration.CompositeConfiguration; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; @@ -7,8 +8,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; - /** * Provides Configuration related functions. * @@ -133,10 +132,18 @@ public interface Keys { * Flag indicating if tag index file should be generated */ String RENDER_TAGS_INDEX = "render.tagsindex"; + + /** /** * String used to separate the header from the body. */ String HEADER_SEPARATOR = "header.separator"; + /** + * JBake will only scan this number of lines for a headers block separator. + */ + String MAX_HEADER_LINES_SCAN = "header.maxLines"; + + /** * Port used when running Jetty server */ @@ -181,7 +188,7 @@ public interface Keys { * The configured base URI for the hosted content */ String SITE_HOST = "site.host"; - } + } private final static Logger LOGGER = LoggerFactory.getLogger(ConfigUtil.class); private final static String LEGACY_CONFIG_FILE = "custom.properties"; diff --git a/jbake-core/src/main/java/org/jbake/parser/MarkupEngine.java b/jbake-core/src/main/java/org/jbake/parser/MarkupEngine.java index d63565494..c92e55d71 100644 --- a/jbake-core/src/main/java/org/jbake/parser/MarkupEngine.java +++ b/jbake-core/src/main/java/org/jbake/parser/MarkupEngine.java @@ -12,7 +12,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; - import org.apache.commons.configuration.Configuration; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; @@ -33,7 +32,7 @@ public abstract class MarkupEngine implements ParserEngine { private static final Logger LOGGER = LoggerFactory.getLogger(MarkupEngine.class); - public static final int MAX_HEADER_LINES = 50; + public static final int MAX_HEADER_LINES_DEFAULT = 50; /** @@ -167,9 +166,10 @@ private boolean hasHeader(Configuration config, List contents) { List headerLines = new ArrayList(); + int scanMaxLines = config.getInteger(Keys.MAX_HEADER_LINES_SCAN, MAX_HEADER_LINES_DEFAULT); //for (String line : contents) { - for (int i = 0; i < contents.size() && i < MAX_HEADER_LINES; i++) { + for (int i = 0; i < contents.size() && i < scanMaxLines; i++) { String line = contents.get(i); if (StringUtils.isBlank(line)) continue; diff --git a/jbake-core/src/main/resources/default.properties b/jbake-core/src/main/resources/default.properties index 01a45d96f..fb37ea7b0 100644 --- a/jbake-core/src/main/resources/default.properties +++ b/jbake-core/src/main/resources/default.properties @@ -97,3 +97,5 @@ uri.noExtension=false uri.noExtension.prefix= # String used to separate the header from the body header.separator=~~~~~~ +# JBake will only scan this number of lines for a headers block separator. +header.maxLines=50