Skip to content

Commit

Permalink
Only scan a limited number of lines for a headers block separator.
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraZizka committed Aug 2, 2018
1 parent 1685ab0 commit 194f127
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
13 changes: 10 additions & 3 deletions jbake-core/src/main/java/org/jbake/app/ConfigUtil.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
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;
import org.apache.commons.configuration.SystemConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;

/**
* Provides Configuration related functions.
*
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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";
Expand Down
6 changes: 3 additions & 3 deletions jbake-core/src/main/java/org/jbake/parser/MarkupEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;


/**
Expand Down Expand Up @@ -167,9 +166,10 @@ private boolean hasHeader(Configuration config, List<String> contents) {

List<String> headerLines = new ArrayList<String>();

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;
Expand Down
2 changes: 2 additions & 0 deletions jbake-core/src/main/resources/default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 194f127

Please sign in to comment.