Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

posthtml-time-japanese-date

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

posthtml-time-japanese-date

Transform Japanese date notation to <time> element using PostHTML

  • 1.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

posthtml-time-japanese-date

npm version Build Status Coverage Status

PostHTML logo

Transform Japanese date notation to <time> element using PostHTML

Before:

<p><x-japanese-date>2022年1月2日</x-japanese-date></p>
<p><x-japanese-date>2022年1月</x-japanese-date></p>
<p><x-japanese-date>2022年</x-japanese-date></p>
<p><x-japanese-date lang="ja"> 2022 年 1 月 2 日 </x-japanese-date></p>

<!-- ↓ not transform -->
<p><x-japanese-date>2022年123月2日</x-japanese-date></p><!-- Incorrect format -->
<p><x-japanese-date datetime="2022-01-02">2022年1月2日</x-japanese-date></p><!-- Do not include the `datetime` attribute -->

<!-- ↓ It is possible to set the transform to occur only when a specific class name is included -->
<p><span class="japanese-date">2022年1月2日</span></p>
<p><span class="foo japanese-date bar">2022年1月2日</span></p>

After:

<p><time datetime="2022-01-02">2022年1月2日</time></p>
<p><time datetime="2022-01">2022年1月</time></p>
<p><time datetime="2022">2022年</time></p>
<p><time lang="ja" datetime="2022-01-02"> 2022 年 1 月 2 日 </time></p>

<p><x-japanese-date>2022年123月2日</x-japanese-date></p>
<p><x-japanese-date datetime="2022-01-02">2022年1月2日</x-japanese-date></p>

<p><time datetime="2022-01-02">2022年1月2日</time></p>
<p><time class="foo bar" datetime="2022-01-02">2022年1月2日</time></p>

Install

npm i -D posthtml-time-japanese-date

Usage

import posthtml from 'posthtml';
import posthtmlTimeJapaneseDate from 'posthtml-time-japanese-date';

const beforeHtml = '<!DOCTYPE html>...';

const result = posthtml([
	posthtmlTimeJapaneseDate({ element: 'x-japanese-date' })
]).process(beforeHtml);

const afterHtml = result.html;

Options

element [Required]
Element name
class [Optional]
Class name

e.g. { element: 'x-japanese-date' }, { element: 'span', class: 'japanese-date' }

Keywords

FAQs

Package last updated on 25 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc