Hmmm... these don't contain my suggestions

```

...

// check if the file contains too many header levels

// (stripos($markdown,'###') !== false) ? throw new InvalidArgumentException('This markdown file contains too many header levels. Please correct down to 2 levels and retry.') : $markdown;

// break the file into metadata and sections

// $markdownFormatted = explode("^##\s", $markdown);

$markdownFormatted = preg_split("^##\s", $markdown); // split on all lines beginning with `##` followed by a space, indicating heading level #2

// check if the file contains too few header levels

(count($markdownFormatted) === 1) ? throw new InvalidArgumentException('This markdown file contain no headers or only one level of headers. Please add a second level and retry.') : $markdownFormatted;

$this->set_short_title(trim($this->bookArguments[1], ".md"));

// $bookTitle = array_shift($markdownFormatted);

$bookCover = explode(PHP_EOL, $markdownFormatted[0], 2);

if(count($bookCover) > 1) {

$bookTitle = $bookCover[0];

$markdownFormatted[0] = $bookCover[1];

} else {

$bookTitle = $bookCover[0];

$bookCover = "";

array_shift($markdownFormatted);

}

$this->set_title(trim(trim($bookTitle, "# ")));

...

```

Reply to this note

Please Login to reply.

Discussion

Changed line 135 to:

$markdownFormatted = preg_split('/^##/\s/', $markdown);

$markdownFormatted = preg_split('\'/^##/\\s/\'', $markdown);

this one seems to work

I can't seem to get it to work. Have you tried it on a file with only 2 header levels and with no content before the first ##?

Let me check...

I think it depends on the implementation of the new line in the *.md. Here's the fix:

`preg_split("/[\n\r]##\s/", $markdown)`

Okay, I'll try that and get back to you.

I've opened up an issue for myself, to figure out why this isn't working on my installation and integrate your ideas. Thank you!

nostr:nevent1qqstsczw4lxjdtwnysemzg8sjl3ythhf7va2h63lrwt4lkdu8m9kvcgpz4mhxue69uhhqatjwpkx2un9d3shjtnrdaksygxavex4usqkgvage45lqpdwzjqgqs630zd4nhj67p38dhn9vv7nryrtntwm