Note This repository is automatically generated from the main parser monorepo. Please submit any issues or pull requests there.
Plugin for reoff
that turns a single bolded or emphasized line into a heading
This is a plugin for reoff that turns a single bolded or emphasized line into a heading. Often times people do not use headings in their documents, but instead use bolded or emphasized lines to indicate a heading. This plugin turns those lines into headings.
You can configure the styles and elements that are used for headings.
This plugin is a focused subset of reoff-markup-to-style that only handles headings.
If you want to turn bolded or emphasized lines in a docx
file into headings.
If you want to turn different kinds of markup into arbitrary styles, use reoff-markup-to-style.
If you want more fine-grained control over when and where markup is turned into styles and are handling the [ooxast][ooxast]
syntax tree yourself, use ooxast-util-markup-to-style.
This package is ESM only. In Node.js (version 12.20+, 14.14+, 16.0+, 18.0+), install as
pnpm add reoff-infer-headings
# or with yarn
# yarn add reoff-infer-headings
# or with npm
# npm install reoff-infer-headings
reoff
plugin for inferring paragraph styles from the markup of the underlying text.
By default, this plugin will infer the following styles:
w:b
->Heading 1
w:i
->Heading 2
This plugin can be configured to infer other styles as well.
const options: Options = [
// find all paragraphs that are bold and larger than 24pt and make it a Title
{
markup: (rPr) => rPr['w:b'] && rPr['w:sz'] && rPr['w:sz']['w:val'] > 24,
style: 'Title',
},
// find all paragraphs that are strikethrough text and make it a Comment
{
markup: 'w:strike',
style: 'Comment',
},
]
default(options: Options = ...): ReturnType<Plugin<[Options?] | void[], Root, Root>>;
Name | Type | Description |
---|---|---|
options |
Options |
Plugin options. |
ReturnType
<Plugin
<[Options?
] | void
[], Root
, Root
>>
A reoff plugin.
Defined in: reoff/reoff-markup-to-style/src/lib/reoff-markup-to-style.ts:35
Option
[]
const options: Options = [
// find all paragraphs that are bold and larger than 24pt and make it a Title
{
markup: (rPr) => rPr['w:b'] && rPr['w:sz'] && rPr['w:sz']['w:val'] > 24,
style: 'Title',
},
// find all paragraphs that are strikethrough text and make it a Comment
{
markup: 'w:strike',
style: 'Comment',
},
]
Defined in: ooxast/ooxast-util-markup-to-style/src/lib/ooxast-util-markup-to-style.ts:80
This plugin uses the ooxast syntax tree.
GPL-3.0-or-later © Thomas F. K. Jorna