Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • TransFem-org/sfm-js
  • dakkar/sfm-js
  • septicake/sfm-js-docs
3 results
Show changes
Commits on Source (188)
node_modules
/built
/coverage
/.eslintrc.js
/jest.config.ts
parser.js
/test
/test-d
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
plugins: [
'@typescript-eslint',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
],
rules: {
'indent': ['error', 'tab', {
'SwitchCase': 1,
'MemberExpression': 'off',
'flatTernaryExpressions': true,
'ArrayExpression': 'first',
'ObjectExpression': 'first',
}],
'eol-last': ['error', 'always'],
'semi': ['error', 'always'],
'quotes': ['error', 'single'],
'comma-dangle': ['error', 'always-multiline'],
'keyword-spacing': ['error', {
'before': true,
'after': true,
}],
'key-spacing': ['error', {
'beforeColon': false,
'afterColon': true,
}],
'space-infix-ops': ['error'],
'space-before-blocks': ['error', 'always'],
'object-curly-spacing': ['error', 'always'],
'nonblock-statement-body-position': ['error', 'beside'],
'eqeqeq': ['error', 'always', { 'null': 'ignore' }],
'no-multiple-empty-lines': ['error', { 'max': 1 }],
'no-multi-spaces': ['error'],
'no-var': ['error'],
'prefer-arrow-callback': ['error'],
'no-throw-literal': ['error'],
'no-param-reassign': ['warn'],
'no-constant-condition': ['warn', {
checkLoops: false,
}],
'no-empty-pattern': ['warn'],
'@typescript-eslint/no-unnecessary-condition': ['warn', {
allowConstantLoopConditions: true,
}],
'@typescript-eslint/no-inferrable-types': ['warn'],
'@typescript-eslint/no-non-null-assertion': ['warn'],
'@typescript-eslint/explicit-function-return-type': ['warn'],
'@typescript-eslint/no-misused-promises': ['error', {
'checksVoidReturn': false,
}],
'@typescript-eslint/no-unused-vars': ['error', {
"argsIgnorePattern": "^_",
}]
},
};
name: Test
on: [push, pull_request]
jobs:
test:
runs-on: docker
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.5.1
- name: Install dependencies
run: npm i
- name: Build
run: npm run build
- name: Test
run: npm test
env:
CI: true
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: CI
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: npm i
- name: Build
run: npm run build
- name: Test
run: npm run test
# npm
node_modules
package-lock.json
# editor
.vscode
......@@ -8,3 +7,7 @@ package-lock.json
# app dir
built
temp
coverage
src/internal/parser.js
image: node:latest
stages:
- testing
- deploy
test:
stage: testing
script:
- npm i
- npm run build
- npm run test
publish-npm:
stage: deploy
needs: ['test']
rules:
- if: $CI_COMMIT_BRANCH == "stable"
changes:
paths:
- package.json
script:
- echo "@transfem-org:registry=https://${CI_SERVER_HOST}/api/v4/projects/2/packages/npm/" > .npmrc
- echo "//${CI_SERVER_HOST}/api/v4/projects/2/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> .npmrc
- npm i
- npm run build
- npm publish
<!--
## 0.x.x (unreleased)
### Features
### Improvements
### Changes
### Bugfixes
-->
## 0.24.0
### Features
- Supports Unicode 15.0 emoji
## 0.23.3
- tweak fn parsing
- fnNameList option removed
- emojiCodeList option removed
## 0.23.2
### Features
- Supports whitelisting of emoji code names. (#130)
## 0.23.1
### Improvements
- improve emoji code parsing
## 0.23.0
### Features
- Add Plain syntax (#101)
### Improvements
- The parser is now implemented in TypeScript! 🎉 (#92)
- Disable all syntax when nesting limited (#90)
### Changes
- Rename existing plain series (#113):
- parsePlain -> parseSimple
- MfmPlainNode -> MfmSimpleNode
### Bugfixes
- Fix a bug that allows line breaks in link label (#115)
## 0.22.1
### Improvements
- Removes a unnecessary built file
## 0.22.0
### Features
- Unicode emoji supports Unicode 14.0 emoji (#109)
### Improvements
- `()` pair is available on outside the hashtag (#111)
- Changes specs the center tag and strike (#108, 100fb0b)
- Improves link label parsing (#107)
### Bugfixes
- If there is a `[]` pair before the link, it will be mistakenly recognized as a part of link label. (#104)
## 0.21.0
### Features
- Supports nestLimit option. (#87, #91)
### Improvements
- Improve generation of brackets property of url node.
### Bugfixes
- Fix the Link node of the enclosed in `<>`. (#84)
- Fix parsing of the link label.
## 0.20.0
### Features
- Add tag syntaxes of bold `<b></b>` and strikethrough `<s></s>`. (#76)
- Supports whitelisting of MFM function names. (#77)
### Improvements
- Mentions in the link label are parsed as text. (#66)
- Add a property to the URL node indicating whether it was enclosed in `<>`. (#69)
- Disallows `<` and `>` in hashtags. (#74)
- Improves security.
### Changes
- Abolished MFM function v1 syntax. (#79)
## 0.19.0
### Improvements
- Ignores a blank line after quote lines. (#61)
## 0.18.0
### Improvements
- Twemoji v13.1 is supported.
## 0.17.0
### Improvements
- Improves syntax of inline code.
- Improves syntax of url.
- Improves syntax of hashtag.
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
syuilotan@yahoo.co.jp.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series
of actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
# Contribution guide
**[✨ English version available](/docs/CONTRIBUTING.en.md)**
プロジェクトに興味を持っていただきありがとうございます!
このドキュメントでは、プロジェクトに貢献する際に必要な情報をまとめています。
## 実装をする前に
機能追加やバグ修正をしたいときは、まずIssueなどで設計、方針をレビューしてもらいましょう(無い場合は作ってください)。このステップがないと、せっかく実装してもPRがマージされない可能性が高くなります。
また、実装に取り掛かるときは当該Issueに自分をアサインしてください(自分でできない場合は他メンバーに自分をアサインしてもらうようお願いしてください)。
自分が実装するという意思表示をすることで、作業がバッティングするのを防ぎます。
## Issues
Issueを作成する前に、以下をご確認ください:
- 重複を防ぐため、既に同様の内容のIssueが作成されていないか検索してから新しいIssueを作ってください。
- Issueを質問に使わないでください。
- Issueは、要望、提案、問題の報告にのみ使用してください。
- 質問は、[Misskey Forum](https://forum.misskey.io/)[Discord](https://discord.gg/Wp8gVStHW3)でお願いします。
## PRの作成
PRを作成する前に、以下をご確認ください:
- 可能であればタイトルに、以下で示すようなPRの種類が分かるキーワードをプリフィクスしてください。
- fix / refactor / feat / enhance / perf / chore 等
- また、PRの粒度が適切であることを確認してください。ひとつのPRに複数の種類の変更や関心を含めることは避けてください。
- このPRによって解決されるIssueがある場合は、そのIssueへの参照を本文内に含めてください。
- [`CHANGELOG.md`](/CHANGELOG.md)に変更点を追記してください。リファクタリングなど、利用者に影響を与えない変更についてはこの限りではありません。
- この変更により新たに作成、もしくは更新すべきドキュメントがないか確認してください。
- 機能追加やバグ修正をした場合は、可能であればテストケースを追加してください。
- テスト、Lintが通っていることを予め確認してください。
- `npm run test``npm run lint`でぞれぞれ実施可能です
- `npm run api`を実行してAPIレポートを更新し、差分がある場合はコミットしてください。
- APIレポートの詳細については[こちら](#api-extractor)
ご協力ありがとうございます🤗
## Tools
### eslint
このプロジェクトではコードのフォーマットチェック/整形に[eslint](https://eslint.org/)を導入しています。
CI上でも自動でチェックされ、ルールに則っていないコードがあるとエラーになります。
### Jest
このプロジェクトではテストフレームワークとして[Jest](https://jestjs.io/)を導入しています。
テストは[`/test`ディレクトリ](/test)に置かれます。
テストはCIにより各コミット/各PRに対して自動で実施されます。
ローカル環境でテストを実施するには、`npm run test`を実行してください。
### tsd
このプロジェクトでは型のテストを行うために[tsd](https://github.com/SamVerschueren/tsd)を導入しています。
Jestによるテストでは「型が期待したものか」というのはチェックすることができません。tsdを使うことで、型が意図したものであることを担保することができます。
tsdによる型テストは[`/test-d`ディレクトリ](/test-d)に置かれます。
テストはCIにより各コミット/各PRに対して自動で実施されます。
ローカル環境でテストを実施するには、`npm run test`を実行してください。
### API Extractor
このプロジェクトでは[API Extractor](https://api-extractor.com/)を導入しています。API ExtractorはAPIレポートを生成する役割を持ちます。
APIレポートはいわばAPIのスナップショットで、このライブラリが外部に公開(export)している各種関数や型の定義が含まれています。`npm run api`コマンドを実行すると、その時点でのレポートが[`/etc`ディレクトリ](/etc)に生成されるようになっています。
exportしているAPIに変更があると、当然生成されるレポートの内容も変わるので、例えばdevelopブランチで生成されたレポートとPRのブランチで生成されたレポートを比較することで、意図しない破壊的変更の検出や、破壊的変更の影響確認に用いることができます。
また、各コミットや各PRで実行されるCI内部では、都度APIレポートを生成して既存のレポートと差分が無いかチェックしています。もし差分があるとエラーになります。
PRを作る際は、`npm run api`コマンドを実行してAPIレポートを生成し、差分がある場合はコミットしてください。
レポートをコミットすることでその破壊的変更が意図したものであると示すことができるほか、上述したようにレポート間の差分が出ることで影響範囲をレビューしやすくなります。
### Codecov
このプロジェクトではカバレッジの計測に[Codecov](https://about.codecov.io/)を導入しています。カバレッジは、コードがどれくらいテストでカバーされているかを表すものです。
カバレッジ計測はCIで自動的に行われ、特に操作は必要ありません。カバレッジは[ここ](https://codecov.io/gh/misskey-dev/mfm.js)から見ることができます。
また、各PRに対してもそのブランチのカバレッジが自動的に計算され、マージ先のカバレッジとの差分を含んだレポートがCodecovのbotによりコメントされます。これにより、そのPRをマージすることでどれくらいカバレッジが増加するのか/減少するのかを確認することができます。
## レビュイーの心得
[PRのセクション](#PRの作成)をご一読ください。
また、後述の「レビュー観点」も意識してみてください。
## レビュワーの心得
- 直して欲しい点だけでなく、良い点も積極的にコメントしましょう。
- 貢献するモチベーションアップに繋がります。
### レビュー観点
- セキュリティ
- このPRをマージすることで、脆弱性を生まないか?
- パフォーマンス
- このPRをマージすることで、予期せずパフォーマンスが悪化しないか?
- もっと効率的な方法は無いか?
- テスト
- 期待する振る舞いがテストで担保されているか?
- 抜けやモレは無いか?
- 異常系のチェックは出来ているか?
The MIT License (MIT)
Copyright (c) 2020 Marihachi
Copyright (c) 2020-2022 Marihachi and other contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
# mfm.js
An MFM parser implementation with PEG.js.
[Try it out!](https://runkit.com/npm/mfm-js)
[![NPM](https://nodei.co/npm/mfm-js.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/mfm-js)
# sfm.js
An SFM parser implementation with fixes based on MFM
## Installation
```
npm i mfm-js
npm config set @transfem-org:registry https://activitypub.software/api/v4/packages/npm/
npm i @transfem-org/sfm-js
```
## Usage
Please see [docs](./docs/index.md) for the detail.
Please see [docs](./docs/index.md) for the detail.
TypeScript:
TypeScript:
```ts
import * as mfm from 'mfm-js';
import * as mfm from '@transfem-org/sfm-js';
const inputText =
`<center>
......@@ -25,11 +23,11 @@ I'm @ai, A bot of misskey!
https://github.com/syuilo/ai
</center>`;
// Generate a MFM tree from the MFM text.
// Generate a MFM tree from the full MFM text.
const mfmTree = mfm.parse(inputText);
// Generate a MFM tree from the MFM plain text.
const plainMfmTree = mfm.parsePlain('I like the hot soup :soup:​');
// Generate a MFM tree from the simple MFM text.
const simpleMfmTree = mfm.parseSimple('I like the hot soup :soup:​');
// Reverse to a MFM text from the MFM tree.
const text = mfm.toString(mfmTree);
......@@ -39,12 +37,12 @@ const text = mfm.toString(mfmTree);
## Develop
### 1. Clone
```
git clone https://github.com/misskey-dev/mfm.js.git
git clone https://activitypub.software/TransFem-org/sfm-js.git
```
### 2. Install packages
```
cd mfm.js
cd sfm.js
npm i
```
......@@ -59,10 +57,10 @@ full parser:
npm run parse
```
plain parser:
simple parser:
```
npm run parse-plain
npm run parse-simple
```
## License
This software is released under the [MIT License](LICENSE).
This software is released under the [MIT License](LICENSE).
/**
* Config file for API Extractor. For more info, please visit: https://api-extractor.com
*/
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
/**
* Optionally specifies another JSON config file that this file extends from. This provides a way for
* standard settings to be shared across multiple projects.
*
* If the path starts with "./" or "../", the path is resolved relative to the folder of the file that contains
* the "extends" field. Otherwise, the first path segment is interpreted as an NPM package name, and will be
* resolved using NodeJS require().
*
* SUPPORTED TOKENS: none
* DEFAULT VALUE: ""
*/
// "extends": "./shared/api-extractor-base.json"
// "extends": "my-package/include/api-extractor-base.json"
/**
* Determines the "<projectFolder>" token that can be used with other config file settings. The project folder
* typically contains the tsconfig.json and package.json config files, but the path is user-defined.
*
* The path is resolved relative to the folder of the config file that contains the setting.
*
* The default value for "projectFolder" is the token "<lookup>", which means the folder is determined by traversing
* parent folders, starting from the folder containing api-extractor.json, and stopping at the first folder
* that contains a tsconfig.json file. If a tsconfig.json file cannot be found in this way, then an error
* will be reported.
*
* SUPPORTED TOKENS: <lookup>
* DEFAULT VALUE: "<lookup>"
*/
// "projectFolder": "..",
/**
* (REQUIRED) Specifies the .d.ts file to be used as the starting point for analysis. API Extractor
* analyzes the symbols exported by this module.
*
* The file extension must be ".d.ts" and not ".ts".
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as "<projectFolder>".
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
*/
"mainEntryPointFilePath": "<projectFolder>/built/index.d.ts",
/**
* A list of NPM package names whose exports should be treated as part of this package.
*
* For example, suppose that Webpack is used to generate a distributed bundle for the project "library1",
* and another NPM package "library2" is embedded in this bundle. Some types from library2 may become part
* of the exported API for library1, but by default API Extractor would generate a .d.ts rollup that explicitly
* imports library2. To avoid this, we can specify:
*
* "bundledPackages": [ "library2" ],
*
* This would direct API Extractor to embed those types directly in the .d.ts rollup, as if they had been
* local files for library1.
*/
"bundledPackages": [],
/**
* Determines how the TypeScript compiler engine will be invoked by API Extractor.
*/
"compiler": {
/**
* Specifies the path to the tsconfig.json file to be used by API Extractor when analyzing the project.
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as "<projectFolder>".
*
* Note: This setting will be ignored if "overrideTsconfig" is used.
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
* DEFAULT VALUE: "<projectFolder>/tsconfig.json"
*/
// "tsconfigFilePath": "<projectFolder>/tsconfig.json",
/**
* Provides a compiler configuration that will be used instead of reading the tsconfig.json file from disk.
* The object must conform to the TypeScript tsconfig schema:
*
* http://json.schemastore.org/tsconfig
*
* If omitted, then the tsconfig.json file will be read from the "projectFolder".
*
* DEFAULT VALUE: no overrideTsconfig section
*/
// "overrideTsconfig": {
// . . .
// }
/**
* This option causes the compiler to be invoked with the --skipLibCheck option. This option is not recommended
* and may cause API Extractor to produce incomplete or incorrect declarations, but it may be required when
* dependencies contain declarations that are incompatible with the TypeScript engine that API Extractor uses
* for its analysis. Where possible, the underlying issue should be fixed rather than relying on skipLibCheck.
*
* DEFAULT VALUE: false
*/
// "skipLibCheck": true,
},
/**
* Configures how the API report file (*.api.md) will be generated.
*/
"apiReport": {
/**
* (REQUIRED) Whether to generate an API report.
*/
"enabled": true
/**
* The filename for the API report files. It will be combined with "reportFolder" or "reportTempFolder" to produce
* a full file path.
*
* The file extension should be ".api.md", and the string should not contain a path separator such as "\" or "/".
*
* SUPPORTED TOKENS: <packageName>, <unscopedPackageName>
* DEFAULT VALUE: "<unscopedPackageName>.api.md"
*/
// "reportFileName": "<unscopedPackageName>.api.md",
/**
* Specifies the folder where the API report file is written. The file name portion is determined by
* the "reportFileName" setting.
*
* The API report file is normally tracked by Git. Changes to it can be used to trigger a branch policy,
* e.g. for an API review.
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as "<projectFolder>".
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
* DEFAULT VALUE: "<projectFolder>/etc/"
*/
// "reportFolder": "<projectFolder>/etc/",
/**
* Specifies the folder where the temporary report file is written. The file name portion is determined by
* the "reportFileName" setting.
*
* After the temporary file is written to disk, it is compared with the file in the "reportFolder".
* If they are different, a production build will fail.
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as "<projectFolder>".
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
* DEFAULT VALUE: "<projectFolder>/temp/"
*/
// "reportTempFolder": "<projectFolder>/temp/"
},
/**
* Configures how the doc model file (*.api.json) will be generated.
*/
"docModel": {
/**
* (REQUIRED) Whether to generate a doc model file.
*/
"enabled": true
/**
* The output path for the doc model file. The file extension should be ".api.json".
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as "<projectFolder>".
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
* DEFAULT VALUE: "<projectFolder>/temp/<unscopedPackageName>.api.json"
*/
// "apiJsonFilePath": "<projectFolder>/temp/<unscopedPackageName>.api.json"
},
/**
* Configures how the .d.ts rollup file will be generated.
*/
"dtsRollup": {
/**
* (REQUIRED) Whether to generate the .d.ts rollup file.
*/
"enabled": false
/**
* Specifies the output path for a .d.ts rollup file to be generated without any trimming.
* This file will include all declarations that are exported by the main entry point.
*
* If the path is an empty string, then this file will not be written.
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as "<projectFolder>".
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
* DEFAULT VALUE: "<projectFolder>/dist/<unscopedPackageName>.d.ts"
*/
// "untrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>.d.ts",
/**
* Specifies the output path for a .d.ts rollup file to be generated with trimming for a "beta" release.
* This file will include only declarations that are marked as "@public" or "@beta".
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as "<projectFolder>".
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
* DEFAULT VALUE: ""
*/
// "betaTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-beta.d.ts",
/**
* Specifies the output path for a .d.ts rollup file to be generated with trimming for a "public" release.
* This file will include only declarations that are marked as "@public".
*
* If the path is an empty string, then this file will not be written.
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as "<projectFolder>".
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
* DEFAULT VALUE: ""
*/
// "publicTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-public.d.ts",
/**
* When a declaration is trimmed, by default it will be replaced by a code comment such as
* "Excluded from this release type: exampleMember". Set "omitTrimmingComments" to true to remove the
* declaration completely.
*
* DEFAULT VALUE: false
*/
// "omitTrimmingComments": true
},
/**
* Configures how the tsdoc-metadata.json file will be generated.
*/
"tsdocMetadata": {
/**
* Whether to generate the tsdoc-metadata.json file.
*
* DEFAULT VALUE: true
*/
// "enabled": true,
/**
* Specifies where the TSDoc metadata file should be written.
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as "<projectFolder>".
*
* The default value is "<lookup>", which causes the path to be automatically inferred from the "tsdocMetadata",
* "typings" or "main" fields of the project's package.json. If none of these fields are set, the lookup
* falls back to "tsdoc-metadata.json" in the package folder.
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
* DEFAULT VALUE: "<lookup>"
*/
// "tsdocMetadataFilePath": "<projectFolder>/dist/tsdoc-metadata.json"
},
/**
* Specifies what type of newlines API Extractor should use when writing output files. By default, the output files
* will be written with Windows-style newlines. To use POSIX-style newlines, specify "lf" instead.
* To use the OS's default newline kind, specify "os".
*
* DEFAULT VALUE: "crlf"
*/
// "newlineKind": "crlf",
/**
* Configures how API Extractor reports error and warning messages produced during analysis.
*
* There are three sources of messages: compiler messages, API Extractor messages, and TSDoc messages.
*/
"messages": {
/**
* Configures handling of diagnostic messages reported by the TypeScript compiler engine while analyzing
* the input .d.ts files.
*
* TypeScript message identifiers start with "TS" followed by an integer. For example: "TS2551"
*
* DEFAULT VALUE: A single "default" entry with logLevel=warning.
*/
"compilerMessageReporting": {
/**
* Configures the default routing for messages that don't match an explicit rule in this table.
*/
"default": {
/**
* Specifies whether the message should be written to the the tool's output log. Note that
* the "addToApiReportFile" property may supersede this option.
*
* Possible values: "error", "warning", "none"
*
* Errors cause the build to fail and return a nonzero exit code. Warnings cause a production build fail
* and return a nonzero exit code. For a non-production build (e.g. when "api-extractor run" includes
* the "--local" option), the warning is displayed but the build will not fail.
*
* DEFAULT VALUE: "warning"
*/
"logLevel": "warning"
/**
* When addToApiReportFile is true: If API Extractor is configured to write an API report file (.api.md),
* then the message will be written inside that file; otherwise, the message is instead logged according to
* the "logLevel" option.
*
* DEFAULT VALUE: false
*/
// "addToApiReportFile": false
}
// "TS2551": {
// "logLevel": "warning",
// "addToApiReportFile": true
// },
//
// . . .
},
/**
* Configures handling of messages reported by API Extractor during its analysis.
*
* API Extractor message identifiers start with "ae-". For example: "ae-extra-release-tag"
*
* DEFAULT VALUE: See api-extractor-defaults.json for the complete table of extractorMessageReporting mappings
*/
"extractorMessageReporting": {
"default": {
"logLevel": "none"
// "addToApiReportFile": false
}
// "ae-extra-release-tag": {
// "logLevel": "warning",
// "addToApiReportFile": true
// },
//
// . . .
},
/**
* Configures handling of messages reported by the TSDoc parser when analyzing code comments.
*
* TSDoc message identifiers start with "tsdoc-". For example: "tsdoc-link-tag-unescaped-text"
*
* DEFAULT VALUE: A single "default" entry with logLevel=warning.
*/
"tsdocMessageReporting": {
"default": {
"logLevel": "warning"
// "addToApiReportFile": false
}
// "tsdoc-link-tag-unescaped-text": {
// "logLevel": "warning",
// "addToApiReportFile": true
// },
//
// . . .
}
}
}
codecov:
token: fcfdc680-8bb5-4185-ad31-22b1e1e4c207
# Contribution guide
:v: Thanks for your contributions :v:
**ℹ️ Important:** This project uses Japanese as its major language, **but you do not need to translate and write the Issues/PRs in Japanese.**
Also, you might receive comments on your Issue/PR in Japanese, but you do not need to reply to them in Japanese as well.\
The accuracy of translation into Japanese is not high, so it will be easier for us to understand if you write it in the original language.
It will also allow the reader to use the translation tool of their preference if necessary.
## Issues
Before creating an issue, please check the following:
- To avoid duplication, please search for similar issues before creating a new issue.
- Do not use Issues as a question.
- Issues should only be used to feature requests, suggestions, and report problems.
- Please ask questions in the [Misskey Forum](https://forum.misskey.io/) or [Discord](https://discord.gg/Wp8gVStHW3).
## Creating a PR
Thank you for your PR! Before creating a PR, please check the following:
- If possible, prefix the title with a keyword that identifies the type of this PR, as shown below.
- fix / refactor / feat / enhance / perf / chore etc.
- Also, make sure that the granularity of this PR is appropriate. Please do not include more than one type of change or interest in a single PR.
- If there is an Issue which will be resolved by this PR, please include a reference to the Issue in the text.
- Please add the summary of the changes to [`CHANGELOG.md`](/CHANGELOG.md). However, this is not necessary for changes that do not affect the users, such as refactoring.
- Check if there are any documents that need to be created or updated due to this change.
- If you have added a feature or fixed a bug, please add a test case if possible.
- Please make sure that tests and Lint are passed in advance.
- You can run it with `npm run test` and `npm run lint`.
- Run `npm run api` to update the API report and commit it if there are any diffs.
Thanks for your cooperation 🤗
## Testing with Sharkey
Let's say you have Sharkey checked out at `~/src/Sharkey`, and this
repository at `~/src/sfm-js`. You have made some modifications to this
code, and want to run Sharkey with your modifications.
```shell
cd ~/src/Sharkey
pnpm --filter=backend add ../../../sfm-js
pnpm --filter=frontend add ../../../sfm-js
```
this will replace the "real" `@transfem-org/sfm-js` in the
dependencies, with your local version. Remember to *not* commit the
changes to `package.json` that this causes! (`pnpm link` should also
work, but I couldn't figure it out)
Then you'll need to tell Vite to handle that package specially. Edit
`packages/frontend/vite.config.local-dev.ts` and add, before `define`:
```json
optimizeDeps: {
include: ['@transfem-org/sfm-js'],
},
```
Now you can `pnpm dev` and test your changes.
......@@ -4,20 +4,30 @@
例:
```ts
const nodes = mfm.parse('hello [tada world]');
const nodes = mfm.parse('hello $[tada world]');
console.log(JSON.stringify(nodes));
// => "[{"type":"text","props":{"text":"hello "}},{"type":"fn","props":{"name":"tada","args":{}},"children":[{"type":"text","props":{"text":"world"}}]}]"
// => [{"type":"text","props":{"text":"hello "}},{"type":"fn","props":{"name":"tada","args":{}},"children":[{"type":"text","props":{"text":"world"}}]}]
```
## parsePlain API
### 最大のネストの深さを変更する
デフォルトで20に設定されています。
例:
```ts
const nodes = mfm.parse('**<s>cannot nest</s>**', { nestLimit: 1 });
console.log(JSON.stringify(nodes));
// => [{"type":"bold","children":[{"type":"text","props":{"text":"<s>cannot nest</s>"}}]}]
```
## parseSimple API
入力文字列からノードツリーを生成します。
絵文字コードとUnicode絵文字を利用可能です。
例:
```ts
const nodes = mfm.parsePlain('Hello :surprised_ai:');
const nodes = mfm.parseSimple('Hello :surprised_ai:');
console.log(JSON.stringify(nodes));
// => "[{"type":"text","props":{"text":"Hello "}},{"type":"emojiCode","props":{"name":"surprised_ai"}}]"
// => [{"type":"text","props":{"text":"Hello "}},{"type":"emojiCode","props":{"name":"surprised_ai"}}]
```
## toString API
......@@ -25,9 +35,9 @@ console.log(JSON.stringify(nodes));
例:
```ts
const nodes = mfm.parse('hello [tada world]');
const nodes = mfm.parse('hello $[tada world]');
const output = mfm.toString(nodes);
console.log(output); // => "hello [tada world]"
console.log(output); // => "hello $[tada world]"
```
※元の文字列とtoString APIで出力される文字列の同一性は保障されません。
......
......@@ -8,27 +8,25 @@
- [中央寄せブロック](#center)
インライン構文:
構文 | 改行可能?
-------------------------------|-----------
[揺れる字](#big) | はい
[太字](#bold) | はい
[目立たない字](#small) | はい
[イタリック](#italic) | はい
[打ち消し線](#strike) | いいえ
[インラインコード](#inline-code) | いいえ
[インライン数式](#math-inline) | いいえ
[メンション](#mention) | いいえ
[ハッシュタグ](#hashtag) | いいえ
[URL](#url) | いいえ
[リンク](#link) | いいえ
[絵文字コード(カスタム絵文字)](#emoji-code) | いいえ
[MFM関数](#fn) | はい
[Unicode絵文字](#unicode-emoji) | いいえ
[テキスト](#text) | はい
<h1 id="quote">引用ブロック</h1>
- [揺れる字](#big)
- [太字](#bold)
- [目立たない字](#small)
- [イタリック](#italic)
- [打ち消し線](#strike)
- [インラインコード](#inline-code)
- [インライン数式](#math-inline)
- [メンション](#mention)
- [ハッシュタグ](#hashtag)
- [URL](#url)
- [リンク](#link)
- [絵文字コード(カスタム絵文字)](#emoji-code)
- [MFM関数](#fn)
- [Unicode絵文字](#unicode-emoji)
- [テキスト](#text)
<h1 id="quote">Block: 引用ブロック</h1>
## 形式
```
......@@ -37,6 +35,13 @@
>>nest
```
## 詳細
- 引用された内容には再度FullParserを適用する。
- `>`の後に続く0~1文字のスペースを無視する。
- 隣接する引用の行は一つになる。
- 複数行の引用では空行も含めることができる。
- 引用の後ろにある空行は無視される。([#61](https://github.com/misskey-dev/mfm.js/issues/61))
## ノード
```js
{
......@@ -47,16 +52,9 @@
}
```
## 詳細
- ブロック構文です。
- 引用された内容には再度FullParserを適用する。
- `>`の後に続く0~1文字のスペースを無視する。
- 隣接する引用の行は一つになる。
- 複数行の引用では空行も含めることができる。
<h1 id="search">検索ブロック</h2>
<h1 id="search">Block: 検索ブロック</h2>
## 形式
```
......@@ -66,6 +64,9 @@ MFM 書き方 [Search]
MFM 書き方 [検索]
```
## 詳細
- Searchの大文字小文字は区別されない。
## ノード
```js
{
......@@ -77,13 +78,9 @@ MFM 書き方 [検索]
}
```
## 詳細
- ブロック構文。
- Searchの大文字小文字は区別されない。
<h1 id="code-block">コードブロック</h2>
<h1 id="code-block">Block: コードブロック</h2>
## 形式
<pre>
......@@ -102,6 +99,9 @@ abc
````
</pre>
## 詳細
- langは指定されない場合はnullになる。
## ノード
```js
{
......@@ -113,13 +113,9 @@ abc
}
```
## 詳細
- ブロック構文です。
- langは指定されない場合はnullになる。
<h1 id="math-block">数式ブロック</h2>
<h1 id="math-block">Block: 数式ブロック</h2>
## 形式
```
......@@ -132,6 +128,11 @@ a = 2
\]
```
## 詳細
- `\[`は行頭でなければならない。
- `\]`は行末でなければならない。
- 前後のスペースと改行はトリミングされる。
## ノード
```js
{
......@@ -142,15 +143,9 @@ a = 2
}
```
## 詳細
- ブロック構文です。
- `\[`は行頭でなければならない。
- `\]`は行末でなければならない。
- 前後のスペースと改行はトリミングされる。
<h1 id="center">中央寄せブロック</h2>
<h1 id="center">Block: 中央寄せブロック</h2>
## 形式
```
......@@ -162,6 +157,11 @@ abc
</center>
```
## 詳細
- `<center>`は行頭でなければならない。
- `</center>`は行末でなければならない。
- 内容には再度InlineParserを適用する。
## ノード
```js
{
......@@ -172,16 +172,9 @@ abc
}
```
## 詳細
- ブロック構文。
- `<center>`は行頭でなければならない。
- `</center>`は行末でなければならない。
- 中身を空にすることはできない。
- 内容には再度InlineParserを適用する。
<h1 id="big">揺れる字</h2>
<h1 id="big">Inline: 揺れる字</h2>
**廃止予定の構文。代替の構文が用意されています。**
## 形式
......@@ -189,6 +182,11 @@ abc
***big!***
```
## 詳細
- 内容には再度InlineParserを適用する。
- 内容にはすべての文字、改行が使用できる。
- 内容を空にすることはできない。
## ノード
```js
{
......@@ -203,24 +201,36 @@ abc
}
```
## 詳細
- インライン構文
- 内容には再度InlineParserを適用する。
- 内容には改行も含めることが可能です。
<h1 id="bold">太字</h2>
<h1 id="bold">Inline: 太字</h2>
## 形式
構文1:
```
**bold**
```
構文2:
```
__bold__
```
構文3:
```
<b>bold</b>
```
## 詳細
- 内容には再度InlineParserを適用する。
- 内容を空にすることはできない。
構文1,3のみ:
- 内容にはすべての文字、改行が使用できる。
構文2のみ:
- 内容には`[a-z0-9 \t]i`にマッチする文字が使用できる。
## ノード
```js
{
......@@ -231,20 +241,20 @@ __bold__
}
```
## 詳細
- インライン構文。
- 内容には再度InlineParserを適用する。
- 内容には改行も含めることが可能です。
<h1 id="small">目立たない字</h2>
<h1 id="small">Inline: 目立たない字</h2>
## 形式
```
<small>small</small>
```
## 詳細
- 内容には再度InlineParserを適用する。
- 内容を空にすることはできない。
- 内容にはすべての文字、改行が使用できる。
## ノード
```js
{
......@@ -255,14 +265,9 @@ __bold__
}
```
## 詳細
- インライン構文です。
- 内容には再度InlineParserを適用する。
- 内容には改行も含めることが可能です。
<h1 id="italic">イタリック</h2>
<h1 id="italic">Inline: イタリック</h2>
## 形式
構文1:
......@@ -280,6 +285,18 @@ __bold__
_italic_
```
## 詳細
- 内容には再度InlineParserを適用する。
- 内容を空にすることはできない。
構文1のみ:
- 内容にはすべての文字、改行が使用できる。
構文2,3のみ:
※1つ目の`*``_`を開始記号と呼ぶ。
- 内容には`[a-z0-9 \t]i`にマッチする文字が使用できる。
- 開始記号の前の文字が`[a-z0-9]i`に一致しない時にイタリック文字として判定される。
## ノード
```js
{
......@@ -290,27 +307,31 @@ _italic_
}
```
## 詳細
- インライン構文。
- 内容には再度InlineParserを適用する。
構文1のみ:
- 内容には改行も含めることが可能です。
構文2,3のみ:
※1つ目の`*``_`を開始記号と呼ぶ。
- 内容には`[a-z0-9 \t]i`にマッチする文字が使用できる。
- 開始記号の前の文字が(無い、改行、半角スペース、[a-zA-Z0-9]に一致しない)のいずれかの時にイタリック文字として判定される。
<h1 id="strike">打ち消し線</h2>
<h1 id="strike">Inline: 打ち消し線</h2>
## 形式
構文1:
```
~~strike~~
```
構文2:
```
<s>strike</s>
```
## 詳細
- 内容には再度InlineParserを適用する。
- 内容を空にすることはできない。
構文1のみ:
- 内容には`~`、改行以外の文字を使用できる。
構文2のみ:
- 内容にはすべての文字、改行が使用できる。
## ノード
```js
{
......@@ -321,21 +342,20 @@ _italic_
}
```
## 詳細
- インライン構文。
- 内容には再度InlineParserを適用する。
- 内容には改行を含めることができない。
- 内容には`~`を含めることができない。
<h1 id="inline-code">インラインコード</h2>
<h1 id="inline-code">Inline: インラインコード</h2>
## 形式
```
`$abc <- 1`
```
## 詳細
- 内容を空にすることはできない。
- 内容には改行を含めることができない。
- 内容には「´」を含めることができない。
## ノード
```js
{
......@@ -346,20 +366,19 @@ _italic_
}
```
## 詳細
- インライン構文。
- 内容には改行を含めることができない。
- 内容には「´」を含めることができない。
<h1 id="math-inline">インライン数式</h2>
<h1 id="math-inline">Inline: インライン数式</h2>
## 形式
```
\(y = 2x\)
```
## 詳細
- 内容を空にすることはできない。
- 内容には改行を含めることができない。
## ノード
```js
{
......@@ -370,13 +389,9 @@ _italic_
}
```
## 詳細
- インライン構文。
- 内容には改行を含めることができない。
<h1 id="mention">メンション</h2>
<h1 id="mention">Inline: メンション</h2>
## 形式
```
......@@ -386,6 +401,19 @@ _italic_
@user
```
## 詳細
- 最初の`@`の前の文字が`[a-z0-9]i`に一致しない場合にメンションとして認識する。
### ユーザ名
- 1文字以上。
- `A``Z` `0``9` `_` `-`が含められる。
- 1文字目と最後の文字は`-`にできない。
### ホスト名
- 1文字以上。
- `A``Z` `0``9` `_` `-` `.`が含められる。
- 1文字目と最後の文字は`-` `.`にできない。
## ノード
```js
{
......@@ -409,29 +437,23 @@ _italic_
}
```
## 詳細
- インライン構文。
- 最初の`@`の前の文字が(改行、スペース、無し、[a-zA-Z0-9]に一致しない)のいずれかの場合にメンションとして認識する。
### ユーザ名
- 1文字以上。
- `A``Z` `0``9` `_` `-`が含められる。
- 1文字目と最後の文字は`-`にできない。
### ホスト名
- 1文字以上。
- `A``Z` `0``9` `_` `-` `.`が含められる。
- 1文字目と最後の文字は`-` `.`にできない。
<h1 id="hashtag">ハッシュタグ</h2>
<h1 id="hashtag">Inline: ハッシュタグ</h2>
## 形式
```
#abc
```
## 詳細
- 内容を空にすることはできない。
- 内容には半角スペース、全角スペース、改行、タブ文字を含めることができない。
- 内容には`.` `,` `!` `?` `'` `"` `#` `:` `/` `【` `】` `<` `>` `【` `】` `(` `)` `「` `」` `(` `)` を含めることができない。
- 括弧は対になっている時のみ内容に含めることができる。対象: `()` `[]` `「」` `()`
- `#`の前の文字が`[a-z0-9]i`に一致しない場合にハッシュタグとして認識する。
- 内容が数字のみの場合はハッシュタグとして認識しない。
## ノード
```js
{
......@@ -442,17 +464,9 @@ _italic_
}
```
## 詳細
- インライン構文。
- 内容には半角スペース、全角スペース、改行、タブ文字を含めることができない。
- 内容には`.` `,` `!` `?` `'` `"` `#` `:` `/` `【` `】` を含めることができない。
- 括弧は対になっている時のみ内容に含めることができる。対象: `()` `[]` `「」`
- `#`の前の文字が(改行、スペース、無し、[a-zA-Z0-9]に一致しない)のいずれかの場合にハッシュタグとして認識する。
- 内容が数字のみの場合はハッシュタグとして認識しない。
<h1 id="url">URL</h2>
<h1 id="url">Inline: URL</h2>
## 形式
構文1:
......@@ -473,7 +487,17 @@ http://hoge.jp/abc
<http://藍.jp/abc>
```
## 詳細
構文1のみ:
- 内容には`[.,a-z0-9_/:%#@$&?!~=+-]i`にマッチする文字を使用できる。
- 内容には対になっている括弧を使用できる。対象: `( )` `[ ]`
- `.``,`は最後の文字にできない。
構文2のみ:
- 内容には改行、スペース以外の文字を使用できる。
## ノード
構文1:
```js
{
type: 'url',
......@@ -483,20 +507,32 @@ http://hoge.jp/abc
}
```
## 詳細
- インライン構文。
または
構文1のみ:
- 内容には`[.,a-z0-9_/:%#@$&?!~=+-]i`にマッチする文字を使用できる。
- 内容には対になっている括弧を使用できる。対象: `(` `)` `[` `]`
- `.``,`は最後の文字にできない。
```js
{
type: 'url',
props: {
url: 'https://misskey.io/@ai',
brackets: false
}
}
```
構文2のみ:
- 内容には改行、スペース以外の文字を使用できる。
構文2:
```js
{
type: 'url',
props: {
url: 'https://misskey.io/@ai',
brackets: true
}
}
```
<h1 id="link">リンク</h2>
<h1 id="link">Inline: リンク</h2>
## 形式
silent=false
......@@ -509,6 +545,9 @@ silent=true
?[Misskey.io](https://misskey.io/)
```
## 詳細
- 表示テキストには再度InlineParserを適用する。ただし、表示テキストではURL、リンク、メンションは使用できない。
## ノード
```js
[
......@@ -530,20 +569,19 @@ silent=true
]
```
## 詳細
- インライン構文。
- 内容には再度InlineParserを適用する。
- 内容に含まれるURLはテキストとしてパースする。
<h1 id="emoji-code">絵文字コード(カスタム絵文字)</h2>
<h1 id="emoji-code">Inline: 絵文字コード(カスタム絵文字)</h2>
## 形式
```
:thinking_ai:
```
## 詳細
- 内容を空にすることはできない。
- 内容には[a-z0-9_+-]iにマッチする文字を使用できる。
## ノード
```js
{
......@@ -554,12 +592,9 @@ silent=true
}
```
## 詳細
- インライン構文。
<h1 id="fn">関数</h2>
<h1 id="fn">Inline: 関数</h2>
## 形式
構文1:
......@@ -579,23 +614,10 @@ $[shake.speed=1s 🍮]
$[flip.h,v MisskeyでFediverseの世界が広がります]
```
構文2:
**廃止予定の構文。代替の構文(構文1)が用意されています。**
```
[shake 🍮]
```
```
[spin.alternate 🍮]
```
```
[shake.speed=1s 🍮]
```
```
[flip.h,v MisskeyでFediverseの世界が広がります]
```
## 詳細
- 内容には再度InlineParserを適用する。
- 内容を空にすることはできない。
- 内容には改行も含めることが可能です。
## ノード
```js
......@@ -611,15 +633,9 @@ $[flip.h,v MisskeyでFediverseの世界が広がります]
}
```
## 詳細
- インライン構文
- 内容には再度InlineParserを適用する。
- 内容には改行も含めることが可能です。
- 使用できる関数名やパラメータはホスト側で定義され、パーサはその登録状況を関知しません。
<h1 id="unicode-emoji">Unicode絵文字</h2>
<h1 id="unicode-emoji">Inline: Unicode絵文字</h2>
## 形式
```
......@@ -638,7 +654,7 @@ $[flip.h,v MisskeyでFediverseの世界が広がります]
<h1 id="text">テキスト</h2>
<h1 id="text">Inline: テキスト</h2>
## 形式
```
......
## API Report File for "mfm-js"
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
// @public (undocumented)
export const BOLD: (children: MfmInline[]) => NodeType<'bold'>;
// @public (undocumented)
export const CENTER: (children: MfmInline[]) => NodeType<'center'>;
// @public (undocumented)
export const CODE_BLOCK: (code: string, lang: string | null) => NodeType<'blockCode'>;
// @public (undocumented)
export const EMOJI_CODE: (name: string) => NodeType<'emojiCode'>;
// @public (undocumented)
export function extract(nodes: MfmNode[], predicate: (node: MfmNode) => boolean): MfmNode[];
// @public (undocumented)
export const FN: (name: string, args: MfmFn['props']['args'], children: MfmFn['children']) => NodeType<'fn'>;
// @public (undocumented)
export const HASHTAG: (value: string) => NodeType<'hashtag'>;
// @public (undocumented)
export const INLINE_CODE: (code: string) => NodeType<'inlineCode'>;
// @public (undocumented)
export function inspect(node: MfmNode, action: (node: MfmNode) => void): void;
// @public (undocumented)
export function inspect(nodes: MfmNode[], action: (node: MfmNode) => void): void;
// @public (undocumented)
export const ITALIC: (children: MfmInline[]) => NodeType<'italic'>;
// @public (undocumented)
export const LINK: (silent: boolean, url: string, children: MfmInline[]) => NodeType<'link'>;
// @public (undocumented)
export const MATH_BLOCK: (formula: string) => NodeType<'mathBlock'>;
// @public (undocumented)
export const MATH_INLINE: (formula: string) => NodeType<'mathInline'>;
// @public (undocumented)
export const MENTION: (username: string, host: string | null, acct: string) => NodeType<'mention'>;
// @public (undocumented)
export type MfmBlock = MfmQuote | MfmSearch | MfmCodeBlock | MfmMathBlock | MfmCenter;
// @public (undocumented)
export type MfmBold = {
type: 'bold';
props?: Record<string, unknown>;
children: MfmInline[];
};
// @public (undocumented)
export type MfmCenter = {
type: 'center';
props?: Record<string, unknown>;
children: MfmInline[];
};
// @public (undocumented)
export type MfmCodeBlock = {
type: 'blockCode';
props: {
code: string;
lang: string | null;
};
children?: [];
};
// @public (undocumented)
export type MfmEmojiCode = {
type: 'emojiCode';
props: {
name: string;
};
children?: [];
};
// @public (undocumented)
export type MfmFn = {
type: 'fn';
props: {
name: string;
args: Record<string, string | true>;
};
children: MfmInline[];
};
// @public (undocumented)
export type MfmHashtag = {
type: 'hashtag';
props: {
hashtag: string;
};
children?: [];
};
// @public (undocumented)
export type MfmInline = MfmUnicodeEmoji | MfmEmojiCode | MfmBold | MfmSmall | MfmItalic | MfmStrike | MfmInlineCode | MfmMathInline | MfmMention | MfmHashtag | MfmUrl | MfmLink | MfmFn | MfmPlain | MfmText;
// @public (undocumented)
export type MfmInlineCode = {
type: 'inlineCode';
props: {
code: string;
};
children?: [];
};
// @public (undocumented)
export type MfmItalic = {
type: 'italic';
props?: Record<string, unknown>;
children: MfmInline[];
};
// @public (undocumented)
export type MfmLink = {
type: 'link';
props: {
silent: boolean;
url: string;
};
children: MfmInline[];
};
// @public (undocumented)
export type MfmMathBlock = {
type: 'mathBlock';
props: {
formula: string;
};
children?: [];
};
// @public (undocumented)
export type MfmMathInline = {
type: 'mathInline';
props: {
formula: string;
};
children?: [];
};
// @public (undocumented)
export type MfmMention = {
type: 'mention';
props: {
username: string;
host: string | null;
acct: string;
};
children?: [];
};
// @public (undocumented)
export type MfmNode = MfmBlock | MfmInline;
// @public (undocumented)
export type MfmPlain = {
type: 'plain';
props?: Record<string, unknown>;
children: MfmText[];
};
// @public (undocumented)
export type MfmQuote = {
type: 'quote';
props?: Record<string, unknown>;
children: MfmNode[];
};
// @public (undocumented)
export type MfmSearch = {
type: 'search';
props: {
query: string;
content: string;
};
children?: [];
};
// @public (undocumented)
export type MfmSimpleNode = MfmUnicodeEmoji | MfmEmojiCode | MfmText | MfmPlain;
// @public (undocumented)
export type MfmSmall = {
type: 'small';
props?: Record<string, unknown>;
children: MfmInline[];
};
// @public (undocumented)
export type MfmStrike = {
type: 'strike';
props?: Record<string, unknown>;
children: MfmInline[];
};
// @public (undocumented)
export type MfmText = {
type: 'text';
props: {
text: string;
};
children?: [];
};
// @public (undocumented)
export type MfmUnicodeEmoji = {
type: 'unicodeEmoji';
props: {
emoji: string;
};
children?: [];
};
// @public (undocumented)
export type MfmUrl = {
type: 'url';
props: {
url: string;
brackets?: boolean;
};
children?: [];
};
// @public (undocumented)
export const N_URL: (value: string, brackets?: boolean) => NodeType<'url'>;
// @public (undocumented)
export type NodeType<T extends MfmNode['type']> = T extends 'quote' ? MfmQuote : T extends 'search' ? MfmSearch : T extends 'blockCode' ? MfmCodeBlock : T extends 'mathBlock' ? MfmMathBlock : T extends 'center' ? MfmCenter : T extends 'unicodeEmoji' ? MfmUnicodeEmoji : T extends 'emojiCode' ? MfmEmojiCode : T extends 'bold' ? MfmBold : T extends 'small' ? MfmSmall : T extends 'italic' ? MfmItalic : T extends 'strike' ? MfmStrike : T extends 'inlineCode' ? MfmInlineCode : T extends 'mathInline' ? MfmMathInline : T extends 'mention' ? MfmMention : T extends 'hashtag' ? MfmHashtag : T extends 'url' ? MfmUrl : T extends 'link' ? MfmLink : T extends 'fn' ? MfmFn : T extends 'plain' ? MfmPlain : T extends 'text' ? MfmText : never;
// @public (undocumented)
export function parse(input: string, opts?: Partial<{
nestLimit: number;
}>): MfmNode[];
// @public (undocumented)
export function parseSimple(input: string): MfmSimpleNode[];
// @public (undocumented)
export const PLAIN: (text: string) => NodeType<'plain'>;
// @public (undocumented)
export const QUOTE: (children: MfmNode[]) => NodeType<'quote'>;
// @public (undocumented)
export const SEARCH: (query: string, content: string) => NodeType<'search'>;
// @public (undocumented)
export const SMALL: (children: MfmInline[]) => NodeType<'small'>;
// @public (undocumented)
export const STRIKE: (children: MfmInline[]) => NodeType<'strike'>;
// @public (undocumented)
export const TEXT: (value: string) => NodeType<'text'>;
// @public (undocumented)
function toString_2(tree: MfmNode[]): string;
// @public (undocumented)
function toString_2(node: MfmNode): string;
export { toString_2 as toString }
// @public (undocumented)
export const UNI_EMOJI: (value: string) => NodeType<'unicodeEmoji'>;
// (No @packageDocumentation comment for this package)
```
/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/en/configuration.html
*/
export default {
// All imported modules in your tests should be mocked automatically
// automock: false,
// Stop running tests after `n` failures
// bail: 0,
// The directory where Jest should store its cached dependency information
// cacheDirectory: "C:\\Users\\ai\\AppData\\Local\\Temp\\jest",
// Automatically clear mock calls and instances between every test
// clearMocks: false,
// Indicates whether the coverage information should be collected while executing the test
// collectCoverage: false,
// An array of glob patterns indicating a set of files for which coverage information should be collected
collectCoverageFrom: ['src/**/*.ts', '!src/cli/**/*.ts'],
// The directory where Jest should output its coverage files
coverageDirectory: "coverage",
// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "\\\\node_modules\\\\"
// ],
// Indicates which provider should be used to instrument code for coverage
coverageProvider: "v8",
// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
// "json",
// "text",
// "lcov",
// "clover"
// ],
// An object that configures minimum threshold enforcement for coverage results
// coverageThreshold: undefined,
// A path to a custom dependency extractor
// dependencyExtractor: undefined,
// Make calling deprecated APIs throw helpful error messages
// errorOnDeprecated: false,
// Force coverage collection from ignored files using an array of glob patterns
// forceCoverageMatch: [],
// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: undefined,
// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: undefined,
// A set of global variables that need to be available in all test environments
// globals: {},
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
// maxWorkers: "50%",
// An array of directory names to be searched recursively up from the requiring module's location
// moduleDirectories: [
// "node_modules"
// ],
// An array of file extensions your modules use
// moduleFileExtensions: [
// "js",
// "json",
// "jsx",
// "ts",
// "tsx",
// "node"
// ],
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
// moduleNameMapper: {},
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],
// Activates notifications for test results
// notify: false,
// An enum that specifies notification mode. Requires { notify: true }
// notifyMode: "failure-change",
// A preset that is used as a base for Jest's configuration
// preset: undefined,
// Run tests from one or more projects
// projects: undefined,
// Use this configuration option to add custom reporters to Jest
// reporters: undefined,
// Automatically reset mock state between every test
// resetMocks: false,
// Reset the module registry before running each individual test
// resetModules: false,
// A path to a custom resolver
// resolver: undefined,
// Automatically restore mock state between every test
// restoreMocks: false,
// The root directory that Jest should scan for tests and modules within
// rootDir: undefined,
// A list of paths to directories that Jest should use to search for files in
roots: [
"<rootDir>"
],
// Allows you to use a custom runner instead of Jest's default test runner
// runner: "jest-runner",
// The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: [],
// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],
// The number of seconds after which a test is considered as slow and reported as such in the results.
// slowTestThreshold: 5,
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],
// The test environment that will be used for testing
testEnvironment: "node",
// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},
// Adds a location field to test results
// testLocationInResults: false,
// The glob patterns Jest uses to detect test files
testMatch: [
"**/__tests__/**/*.[jt]s?(x)",
"**/?(*.)+(spec|test).[tj]s?(x)",
"<rootDir>/test/**/*"
],
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "\\\\node_modules\\\\"
// ],
// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],
// This option allows the use of a custom results processor
// testResultsProcessor: undefined,
// This option allows use of a custom test runner
// testRunner: "jasmine2",
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
// testURL: "http://localhost",
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
// timers: "real",
// A map from regular expressions to paths to transformers
transform: {
"^.+\\.(ts|tsx)$": "ts-jest"
},
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "\\\\node_modules\\\\",
// "\\.pnp\\.[^\\\\]+$"
// ],
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,
// Indicates whether each individual test should be reported during the run
// verbose: undefined,
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
// watchPathIgnorePatterns: [],
// Whether to use watchman for file crawling
// watchman: true,
};
This diff is collapsed.
{
"name": "mfm-js",
"version": "0.18.0",
"description": "An MFM parser implementation with PEG.js",
"name": "@transfem-org/sfm-js",
"version": "0.24.4",
"description": "An SFM parser implementation with fixes based on MFM",
"main": "./built/index.js",
"types": "./built/index.d.ts",
"scripts": {
"build": "npm run tsc && npm run peg",
"build-debug": "npm run tsc && npm run peg-debug",
"peg": "peggy --cache -o built/parser.js --allowed-start-rules fullParser,inlineParser,plainParser src/parser.pegjs",
"peg-debug": "peggy --cache -o built/parser.js --allowed-start-rules fullParser,inlineParser,plainParser --trace src/parser.pegjs",
"build": "npm run tsc",
"tsc": "tsc",
"tsd": "tsd",
"parse": "node ./built/cli/parse",
"parse-plain": "node ./built/cli/parsePlain",
"test": "mocha -r ts-node/register 'test/**/*.ts' && npm run tsd"
"parse-simple": "node ./built/cli/parseSimple",
"api": "npx api-extractor run --local --verbose",
"api-prod": "npx api-extractor run --verbose",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"jest": "jest --coverage",
"test": "npm run jest && npm run tsd"
},
"repository": {
"type": "git",
"url": "git+https://github.com/misskey-dev/mfm.js.git"
"url": "git+https://activitypub.software/TransFem-org/sfm.js.git"
},
"author": "Marihachi",
"author": "Marie",
"license": "MIT",
"devDependencies": {
"@types/mocha": "8.2.x",
"@types/node": "14.14.x",
"mocha": "8.3.x",
"peggy": "1.2.0",
"ts-node": "9.1.x",
"tsd": "^0.14.0",
"typescript": "4.2.x"
"@microsoft/api-extractor": "7.38.5",
"@types/jest": "29.5.11",
"@types/node": "20.10.5",
"@typescript-eslint/eslint-plugin": "6.14.0",
"@typescript-eslint/parser": "6.14.0",
"eslint": "8.56.0",
"jest": "29.7.0",
"ts-jest": "29.1.1",
"ts-node": "10.9.2",
"tsd": "0.30.0",
"tslib": "2.6.2",
"typescript": "5.3.3"
},
"dependencies": {
"twemoji-parser": "13.1.x"
"@twemoji/parser": "15.0.0"
},
"files": [
"built"
"built",
"CHANGELOG.md"
]
}