Search⌘ K
AI Features

Parsing Doc Strings

Explore methods for parsing Gherkin doc strings in Laravel applications. Learn to identify doc string delimiters, manage indentation, and preserve relative whitespace while constructing DocString instances for effective string parsing.

We'll cover the following...

Parsing doc strings

We will begin parsing some more complicated structures, starting with Gherkin’s doc strings. Let’s familiarize ourselves again with the doc string syntax:

Feature: Feature Name

  Scenario: Doc String Example One
    Given a blog post named "Random" with Markdown body
      """
      Some Title, Eh?
      ===============
      Here is the first paragraph of my blog post. Lorem ipsum dolor
      consectetur adipiscing elit.
      """

The strategy for parsing doc strings will be similar to our free-form descriptions. The basic method will be to scan each line and check to see ...