GithubHelp home page GithubHelp logo

main-kun / transform Goto Github PK

View Code? Open in Web Editor NEW

This project forked from diplodoc-platform/transform

0.0 0.0 0.0 3.03 MB

Simple transformer YFM (Yandex Flavored Markdown) to HTML.

License: MIT License

JavaScript 0.97% TypeScript 94.01% SCSS 5.02%

transform's Introduction

english | русский


NPM version

@diplodoc/transform is a package for converting Yandex Flavored Markdown to HTML.

Use it in your code to work with text during program execution. For example, to display user-generated content.

Installation {#install}

  1. Install a package:

    npm i @diplodoc/transform
  2. Add the package in your code using the require() or import() function:

    const transform = require('@diplodoc/transform');
  3. To ensure text is displayed properly, add CSS styles and client scripts to the project:

    @import '~@diplodoc/transform/dist/css/yfm.css';
    import '@diplodoc/transform/dist/js/yfm';

Usage {#use}

The package provides the transform() function:

  • Input data: Settings and a string with YFM.
  • Returned value: An object with the result and logs fields.

Result field

result: Resulting object, contains the fields:

  • html: A line with HTML.
  • meta: Metadata from the transmitted content.
  • title: The document title. Returned if extractTitle = true or needTitle = true.
  • headings: A list of document headers.

Logs field

logs: Information about the transformation process, includes arrays:

  • error: Errors.
  • warn: Warnings.
  • info: Additional information.

Example of a function invocation

const fs = require('fs');
const transform = require('@diplodoc/transform');

const content = fs.readFileSync(filePath, 'utf');
const vars = { user: { name: 'Alice' } };

const {
    result: {html, meta, title, headings},
    logs,
    } = transform(content, {vars});

License

MIT

transform's People

Contributors

burashka avatar yfm-team avatar yndx-birman avatar amje avatar yc-ui-bot avatar smsochneg avatar moki avatar d3m1d0v avatar v8tenko avatar postamentovich avatar tsufiev avatar dependabot[bot] avatar 3y3 avatar main-kun avatar gorgeousvlad avatar nanov94 avatar vsesh avatar martyanovandrey avatar chervyakovru avatar lunatic174 avatar kiri111enz avatar myusosnovskay avatar makishvili avatar rusandorx avatar feverqwe avatar kyzyl-ool avatar vovcyan avatar yndx-madfriend avatar ogonkov avatar melikhov-dev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.