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 Oct 26, 2018
1 parent 2026116 commit ce2f8a7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ public interface JBakeConfiguration {
*/
String getVersion();

/**
* @return Maximum lines to scan when looking for a JBake in-file header.
*/
int getMaxHeaderLinesScan();


/**
* Set a property value for the given key
*
Expand Down
5 changes: 3 additions & 2 deletions jbake-core/src/main/java/org/jbake/parser/MarkupEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public abstract class MarkupEngine implements ParserEngine {

private JBakeConfiguration configuration;

public static final int MAX_HEADER_LINES = 50;
public static final int MAX_HEADER_LINES_DEFAULT = 50;


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

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

int scanMaxLines = configuration.getMaxHeaderLinesScan(); // Default: 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
4 changes: 3 additions & 1 deletion jbake-core/src/main/resources/default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,6 @@ header.separator=~~~~~~
# update image path
img.path.update=false
# Prepend site.host to image paths
img.path.prepend.host=true
img.path.prepend.host=true
# JBake will only scan this number of lines for a headers block separator.
header.maxLines=50

0 comments on commit ce2f8a7

Please sign in to comment.