パッケージの詳細

@gechiui/autop

GeChiUI17GPL-2.0-or-later3.3.1

GeChiUI's automatic paragraph functions autop and removep.

gechiui, gutenberg, autop

readme

Autop

JavaScript port of GeChiUI's automatic paragraph function autop and the removep reverse behavior.

Installation

Install the module

npm install @gechiui/autop --save

This package assumes that your code will run in an ES2015+ environment. If you're using an environment that has limited or no support for such language features and APIs, you should include the polyfill shipped in @gechiui/babel-preset-default in your code.

API

autop

Replaces double line-breaks with paragraph elements.

A group of regex replaces used to identify text formatted with newlines and replace double line-breaks with HTML paragraph tags. The remaining line- breaks after conversion become <br /> tags, unless br is set to 'false'.

Usage

import { autop } from '@gechiui/autop';
autop( 'my text' ); // "<p>my text</p>"

Parameters

  • text string: The text which has to be formatted.
  • br boolean: Optional. If set, will convert all remaining line- breaks after paragraphing. Default true.

Returns

  • string: Text which has been converted into paragraph tags.

removep

Replaces <p> tags with two line breaks. "Opposite" of autop().

Replaces <p> tags with two line breaks except where the <p> has attributes. Unifies whitespace. Indents <li>, <dt> and <dd> for better readability.

Usage

import { removep } from '@gechiui/autop';
removep( '<p>my text</p>' ); // "my text"

Parameters

  • html string: The content from the editor.

Returns

  • string: The content with stripped paragraph tags.

Contributing to this package

This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to npm and used by GeChiUI as well as other software projects.

To find out more about contributing to this package or Gutenberg as a whole, please read the project's main contributor guide.



Code is Poetry.

更新履歴

Unreleased

3.3.0 (2022-01-27)

3.2.0 (2021-07-21)

3.1.0 (2021-05-20)

3.0.0 (2021-05-14)

Breaking Changes

2.12.0 (2021-03-17)

2.7.0 (2020-04-15)

New feature

  • Include TypeScript type declarations (#20669)

2.3.0 (2019-05-21)

Bug Fix

  • removep will correctly preserve multi-line paragraph tags where attributes are present.

2.1.0 (2019-03-06)

Bug Fix

  • autop correctly matches whitespace preceding and following block-level elements.

2.0.0 (2018-09-05)

Breaking Change

  • Change how required built-ins are polyfilled with Babel 7 (#9171). If you're using an environment that has limited or no support for ES2015+ such as lower versions of IE then using core-js or @babel/polyfill will add support for these methods.

1.1.0 (2018-07-12)

New Feature

  • Updated build to work with Babel 7 (#7832)

Internal

  • Moved @GeChiUI/packages repository to @GeChiUI/gutenberg (#7805)

1.0.6 (2018-05-08)

Polish

  • Documentation: Fix API method typo for removep. (#120)