IF Commons GitHub

physical/sources/markdown

Written to: 1 requirement: 0 proved, 0 partly, 0 failing, 1 with no test recorded. 0004-planning-sources FR-008

The source for Markdown (0037-planning FR-026): each task list item of GitHub Flavored Markdown 0.29-gfm section 5.3 is an item. A task list item is a list item whose first block is a paragraph that begins with a marker (optional spaces, [, a whitespace character or x or X, ]) and at least one whitespace character before any other content, under any list marker the list allows (-, +, *, or an ordered number with . or )); unchecked where the character is whitespace and checked otherwise. A task nested under another is its child, linked as parent of. Closing an item changes the one character between the brackets to x, reopening it to a space, and no other byte; a task list in a fenced code block is not read.

The reader works on lines: a list item is a line of optional indentation, a list marker, one or more spaces or a tab and its content; a child is a list item indented at least to the content of the one above; continuation lines indented to the content are the item's body. It reads no list inside a block quote and takes a lazy continuation line as part of the item above, which is the common shape of tasks.md and of the body of an issue. The checked state of Markdown says only done, so a task checked reads as closed as completed and a close for another reason cannot be written and goes to the outbox.

import { markdownLens } from "./markdown.ts";
markdownLens().name; // "markdown"

Source: commons/planning/src/physical/sources/markdown.ts

0 of 6 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

physical.Tasktypeno test imports it
type Task = {
  readonly startLine: number;
  readonly endLine: number;
  /** The index in its line of the character between the brackets. */
  readonly markIndex: number;
  readonly mark: string;
  readonly title: string;
  readonly body: string;
  readonly ownText: string;
  readonly parentLine: number | undefined;
};

A task found in a text: where it is, what it says and how it nests.

physical.tasksOffunctionno test imports it
function tasksOf(text: string): readonly Task[]

Every list item of a text, task or not, as the reader sees them, with the task items marked.

physical.markdownLensfunctionno test imports it
function markdownLens(): FileLens

The lens for the task lists of the Markdown files (.md, .markdown) of a place.

Tasktypeno test imports it
type Task = {
  readonly startLine: number;
  readonly endLine: number;
  /** The index in its line of the character between the brackets. */
  readonly markIndex: number;
  readonly mark: string;
  readonly title: string;
  readonly body: string;
  readonly ownText: string;
  readonly parentLine: number | undefined;
};

A task found in a text: where it is, what it says and how it nests.

tasksOffunctionno test imports it
function tasksOf(text: string): readonly Task[]

Every list item of a text, task or not, as the reader sees them, with the task items marked.

markdownLensfunctionno test imports it
function markdownLens(): FileLens

The lens for the task lists of the Markdown files (.md, .markdown) of a place.

Titles, headings, exports, tables, columns and requirements. Esc closes.