From e32b4ccde61678473bf7eff0f7751a321d3a871d Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Sun, 8 Mar 2020 11:01:06 +0100 Subject: [PATCH] Add docs for `h.wrapText` in `readme.md` --- index.js | 3 ++- readme.md | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index b1d2b7e..52e9ae3 100644 --- a/index.js +++ b/index.js @@ -20,8 +20,8 @@ function toMdast(tree, options) { h.handlers = xtend(handlers, settings.handlers || {}) h.augment = augment - h.document = settings.document + h.document = settings.document h.checked = settings.checked || '[x]' h.unchecked = settings.unchecked || '[ ]' h.quotes = settings.quotes || ['"'] @@ -53,6 +53,7 @@ function toMdast(tree, options) { return augment(node, result) } + // To do: inline in a future major. // `right` is the finalized mdast node, created from `left`, a hast node. function augment(left, right) { if (left.position) { diff --git a/readme.md b/readme.md index 97f4e00..b94e402 100644 --- a/readme.md +++ b/readme.md @@ -72,6 +72,12 @@ Object mapping tag names or [*types*][type] to functions handling those [*elements*][element] or [*nodes*][hast-node]. See [`handlers/`][handlers] for examples. +In a handler, you have access to `h`, which should be used to create mdast nodes +from hast nodes. +On `h`, there are fields that may be of interest. +Most interesting of them is `h.wrapText`, which is `true` if the mdast content +can include newlines, and `false` if not (such as in headings or table cells). + ###### `options.document` Whether the given [*tree*][tree] is a complete document.