53 lines
2.8 KiB
Plaintext
53 lines
2.8 KiB
Plaintext
Heading 2 Core API
|
|
class mt-12
|
|
Markdown
|
|
**Note:** The Core API is designed for maximum portability and is not intended to be directly consumed.
|
|
|
|
For most projects you'll want to use the [Document API](#document-api) instead.
|
|
It provides an ergonomic wrapper around the Core API and lets you focus on parsing
|
|
your documents.
|
|
|
|
Heading 3 terrace_linedata_t
|
|
class mb-4 mt-12
|
|
Markdown
|
|
This struct holds information about each line as it is parsed. Mutated each time [terrace_parse_line()](#terrace-parse-line) is called. Not intended to be used directly.
|
|
Use the relevant `terrace_` functions from the [Document API](#document-api) instead.
|
|
CodeBlock c
|
|
// Holds the parsed information from each line.
|
|
typedef struct terrace_linedata_s {
|
|
// Which character is being used for indentation. Avoids having to specify it on each terrace_parse_line call.
|
|
char indent;
|
|
// How many indent characters are present in the current line before the first non-indent character.
|
|
unsigned int level;
|
|
// The number of characters before the start of the line's "head" section.
|
|
// (Normally the same as `level`)
|
|
unsigned int offsetHead;
|
|
// The number of characters before the start of the line's "tail" section.
|
|
unsigned int offsetTail;
|
|
} terrace_linedata_t;
|
|
|
|
Heading 3 terrace_create_linedata()
|
|
class mb-4 mt-12
|
|
Markdown
|
|
| Parameter | Type | Description
|
|
| -------------- | --------------------- | -----------------------------------------------------------------------
|
|
| indent | const char | The character used for indentation in the document. Only a single character is permitted.
|
|
| **@returns** | [terrace_linedata_t](#terrace-linedatat) | A terrace_linedata_t struct with the specified indent character and all other values initialized to 0.
|
|
|
|
Initialize a [terrace_linedata](#terrace-linedatat) struct with default values to pass to [terrace_parse_line()](#terrace-parse-line).
|
|
CodeBlock c
|
|
// Call Signature
|
|
terrace_linedata_t terrace_create_linedata(const char indent)
|
|
Heading 3 terrace_parse_line()
|
|
class mb-4 mt-12
|
|
Markdown
|
|
| Parameter | Type | Description
|
|
| -------------- | --------------------- | -----------------------------------------------------------------------
|
|
| line | char* | A pointer to the line to parse as a C-style string. Shouldn't end with a newline.
|
|
| lineData | [terrace_linedata_t](#terrace-linedatat)* | A pointer to the terrace_linedata_t struct to store information about the current line in.
|
|
|
|
Core Terrace parser function, sets `level`, `offsetHead`, and `offsetTail` in a [terrace_linedata](#terrace-linedatat) struct based on the current line.
|
|
CodeBlock c
|
|
// Call Signature
|
|
void terrace_parse_line(const char* line, terrace_linedata_t* lineData)
|