Skip to content

Commit d9b2284

Browse files
authored
feat: add css-api (#515)
* feat: create css-api for all styles without modal * feat: add css-api * feat: add css-api -fix readme * feat: add css-api - fix comment about imports
1 parent 474e5c4 commit d9b2284

13 files changed

+309
-195
lines changed

README.md

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
**english** | [русский](https://github.com/yandex-cloud/yfm-transform/blob/master/README.ru.md)
2-
- - -
2+
3+
---
34

45
[![NPM version](https://img.shields.io/npm/v/@diplodoc/transform.svg?style=flat)](https://www.npmjs.org/package/@diplodoc/transform)
56

@@ -11,49 +12,49 @@ Use it in your code to work with text during program execution. For example, to
1112

1213
1. Install a package:
1314

14-
```shell
15-
npm i @diplodoc/transform
16-
```
15+
```shell
16+
npm i @diplodoc/transform
17+
```
1718

1819
1. Add the package in your code using the `require()` or `import()` function:
1920

20-
```javascript
21-
const transform = require('@diplodoc/transform');
22-
```
21+
```javascript
22+
const transform = require('@diplodoc/transform');
23+
```
2324

2425
1. To ensure text is displayed properly, add CSS styles and client scripts to the project:
2526

26-
```css
27-
@import '~@diplodoc/transform/dist/css/yfm.css';
28-
```
27+
```css
28+
@import '~@diplodoc/transform/dist/css/yfm.css';
29+
```
2930

30-
```javascript
31-
import '@diplodoc/transform/dist/js/yfm';
32-
```
31+
```javascript
32+
import '@diplodoc/transform/dist/js/yfm';
33+
```
3334

3435
## Usage {#use}
3536

3637
The package provides the `transform()` function:
3738

38-
* Input data: [Settings](settings.md) and a string with YFM.
39-
* Returned value: An object with the `result` and `logs` fields.
39+
- Input data: [Settings](settings.md) and a string with YFM.
40+
- Returned value: An object with the `result` and `logs` fields.
4041

4142
### Result field
4243

4344
`result`: Resulting object, contains the fields:
4445

45-
* `html`: A line with HTML.
46-
* `meta`: [Metadata](../../syntax/meta.md#meta) from the transmitted content.
47-
* `title`: The document title. Returned if `extractTitle = true` or `needTitle = true`.
48-
* `headings`: A list of document headers.
46+
- `html`: A line with HTML.
47+
- `meta`: [Metadata](../../syntax/meta.md#meta) from the transmitted content.
48+
- `title`: The document title. Returned if `extractTitle = true` or `needTitle = true`.
49+
- `headings`: A list of document headers.
4950

5051
### Logs field
5152

5253
`logs`: Information about the transformation process, includes arrays:
5354

54-
* `error`: Errors.
55-
* `warn`: Warnings.
56-
* `info`: Additional information.
55+
- `error`: Errors.
56+
- `warn`: Warnings.
57+
- `info`: Additional information.
5758

5859
### Example of a function invocation
5960

@@ -62,15 +63,14 @@ const fs = require('fs');
6263
const transform = require('@diplodoc/transform');
6364

6465
const content = fs.readFileSync(filePath, 'utf');
65-
const vars = { user: { name: 'Alice' } };
66+
const vars = {user: {name: 'Alice'}};
6667

6768
const {
68-
result: {html, meta, title, headings},
69-
logs,
70-
} = transform(content, {vars});
69+
result: {html, meta, title, headings},
70+
logs,
71+
} = transform(content, {vars});
7172
```
7273

7374
## License
7475

7576
MIT
76-

README.ru.md

+30-27
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
**русский** | [english](https://github.com/yandex-cloud/yfm-transform/blob/master/README.md)
2-
- - -
2+
3+
---
34

45
[![NPM version](https://img.shields.io/npm/v/@diplodoc/transform.svg?style=flat)](https://www.npmjs.org/package/@diplodoc/transform)
56

@@ -11,46 +12,49 @@
1112

1213
1. Установите пакет:
1314

14-
```shell
15-
npm i @diplodoc/transform
16-
```
15+
```shell
16+
npm i @diplodoc/transform
17+
```
1718

1819
1. Подключите пакет в своем коде, используя функцию `require()` или `import()`:
1920

20-
```javascript
21-
const transform = require('@diplodoc/transform');
22-
```
21+
```javascript
22+
const transform = require('@diplodoc/transform');
23+
```
2324

2425
1. Для корректного отображения подключите в проект CSS-стили и клиентские скрипты:
2526

26-
```css
27-
@import '~@diplodoc/transform/dist/css/yfm.css';
28-
```
27+
```css
28+
@import '~@diplodoc/transform/dist/css/yfm.css';
29+
```
2930

30-
```javascript
31-
import '@diplodoc/transform/dist/js/yfm';
32-
```
31+
```javascript
32+
import '@diplodoc/transform/dist/js/yfm';
33+
```
3334

3435
## Использование {#use}
3536

3637
Пакет предоставляет функцию `transform()`:
37-
* входные данные — строка с YFM и [настройки](settings.md);
38-
* возвращаемое значение — объект с полями `result` и `logs`.
38+
39+
- входные данные — строка с YFM и [настройки](settings.md);
40+
- возвращаемое значение — объект с полями `result` и `logs`.
3941

4042
### Поле result
4143

4244
`result` — объект результата, содержит поля:
43-
* `html` — строка с HTML.
44-
* `meta` — [метаданные](../../syntax/meta.md#meta) из переданного контента.
45-
* `title` — заголовок документа. Возвращается, если заданы настройки `extractTitle = true` или `needTitle = true`.
46-
* `headings` — список заголовков документа.
45+
46+
- `html` — строка с HTML.
47+
- `meta`[метаданные](../../syntax/meta.md#meta) из переданного контента.
48+
- `title` — заголовок документа. Возвращается, если заданы настройки `extractTitle = true` или `needTitle = true`.
49+
- `headings` — список заголовков документа.
4750

4851
### Поле logs
4952

5053
`logs` — информация о процессе трансформации, включает массивы:
51-
* `error` — ошибки.
52-
* `warn` — предупреждения.
53-
* `info` — дополнительная информация.
54+
55+
- `error` — ошибки.
56+
- `warn` — предупреждения.
57+
- `info` — дополнительная информация.
5458

5559
### Пример вызова функции
5660

@@ -59,15 +63,14 @@ const fs = require('fs');
5963
const transform = require('@diplodoc/transform');
6064

6165
const content = fs.readFileSync(filePath, 'utf');
62-
const vars = { user: { name: 'Alice' } };
66+
const vars = {user: {name: 'Alice'}};
6367

6468
const {
65-
result: {html, meta, title, headings},
66-
logs,
67-
} = transform(content, {vars});
69+
result: {html, meta, title, headings},
70+
logs,
71+
} = transform(content, {vars});
6872
```
6973

70-
7174
## License
7275

7376
MIT

0 commit comments

Comments
 (0)