npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

reoff-markup-to-style

v0.3.0

Published

Plugin for `reoff` that is able to change the styles of paragraphs based on the markup of the underlying text

Downloads

2

Readme

Note This repository is automatically generated from the main parser monorepo. Please submit any issues or pull requests there.

reoff-markup-to-style

npm version npm downloads

Plugin for reoff that is able to change the styles of paragraphs based on the markup of the underlying text

Contents

What is this?

A plugin for reoff for finding paragraphs that have a certain markup in a docx document and changing their style to a different style.

When should I use this?

If you want to change the style of paragraphs based on the markup of the underlying text.

If you want to change the style of paragraphs based on the markup of the underlying text, but are handling the [ooxast][ooxast] syntax tree yourself, use ooxast-util-markup-to-style

Install

This package is ESM only. In Node.js (version 12.20+, 14.14+, 16.0+, 18.0+), install as

pnpm add reoff-markup-to-style
# or with yarn
# yarn add reoff-markup-to-style
# or with npm
# npm install reoff-markup-to-style

Use

API


default()

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.

Example

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',
 },
]

Signature

default(options: Options = ...): ReturnType<Plugin<[Options?] | void[], Root, Root>>;

Parameters

| Name | Type | Description | | :------ | :------ | :------ | | options | Options | Plugin options. |

Returns

ReturnType<Plugin<[Options?] | void[], Root, Root>>

A reoff plugin.

Defined in: reoff/reoff-markup-to-style/src/lib/reoff-markup-to-style.ts:35


Options

Option[]

Example

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

Syntax tree

Uses the [ooxast][ooxast] syntax tree.

Security

Related

Contribute

License

GPL-3.0-or-later © Thomas F. K. Jorna