Git Product home page Git Product logo

node-mdash's Introduction

mdash

NPM version Dependency status devDependency status

A node.js wrapper for the EMT typographer, written by Evgeny Muravjev.

Installation

$ npm install mdash

Examples

JavaScript

var mdash = require('mdash');

var text = 'May "the force" be with you.\n"The force" is a magical power that gives people strength. This phrase is kind of a way of saying "good luck".';

mdash.apply(text, function(error, result) {
  if (error) {
    throw new Error(error);
  }

  // result is a typographic text
  console.log(result);
});

CoffeeScript

mdash = require 'mdash'

text = 'May "the force" be with you.\n"The force" is a magical power that gives people strength. This phrase is kind of a way of saying "good luck".'

mdash.apply text, (error, result) ->
  throw new Error error if error

  # result is a typographic text
  console.log result

API

  • endpoint=
  • apply(text[, options], callback)

By default endpoint set to official API (http://mdash.ru/api.v1.php), but it does not support typographer options or multiple texts. You can change endpoint to yours. For example, you can run mdash-service and send all request to it.

API extras have different default options, can enable/disable options and accept not only text, but array and object of texts.

var texts = {
  title: 'May "the force" be with you.',
  text: '"The force" is a magical power that gives people strength. This phrase is kind of a way of saying "good luck".'
};

mdash.apply(texts, function(error, result) {
  if (error) {
    throw new Error(error);
  }

  // result is an object with title and text keys
  console.log(result);
});

EMT options list:

Quote.quotes
Quote.quotation
Dash.to_libo_nibud
Dash.iz_za_pod
Dash.ka_de_kas
Nobr.super_nbsp
Nobr.nbsp_in_the_end
Nobr.phone_builder
Nobr.ip_address
Nobr.spaces_nobr_in_surname_abbr
Nobr.nbsp_celcius
Nobr.hyphen_nowrap_in_small_words
Nobr.hyphen_nowrap
Nobr.nowrap
Symbol.tm_replace
Symbol.r_sign_replace
Symbol.copy_replace
Symbol.apostrophe
Symbol.degree_f
Symbol.arrows_symbols
Symbol.no_inches
Punctmark.auto_comma
Punctmark.hellip
Punctmark.fix_pmarks
Punctmark.fix_excl_quest_marks
Punctmark.dot_on_end
Number.minus_between_nums
Number.minus_in_numbers_range
Number.auto_times_x
Number.simple_fraction
Number.math_chars
Number.thinsp_between_number_triads
Number.thinsp_between_no_and_number
Number.thinsp_between_sect_and_number
Date.years
Date.mdash_month_interval
Date.nbsp_and_dash_month_interval
Date.nobr_year_in_date
Space.many_spaces_to_one
Space.clear_percent
Space.clear_before_after_punct
Space.autospace_after
Space.bracket_fix
Abbr.nbsp_money_abbr
Abbr.nobr_vtch_itd_itp
Abbr.nobr_sm_im
Abbr.nobr_acronym
Abbr.nobr_locations
Abbr.nobr_abbreviation
Abbr.ps_pps
Abbr.nbsp_org_abbr
Abbr.nobr_gost
Abbr.nobr_before_unit_volt
Abbr.nbsp_before_unit
OptAlign.all
OptAlign.oa_oquote
OptAlign.oa_obracket_coma
OptAlign.oa_oquote_extra
OptAlign.layout
Text.paragraphs
Text.auto_links
Text.email
Text.breakline
Text.no_repeat_words
Etc.unicode_convert

You can enable or disable option like this:

var options = {
  'Text.paragraphs': 'off',
  'Text.breakline': 'off',
  'Etc.unicode_convert': 'on'
};

mdash.apply(text, options, function(error, result) {
  if (error) {
    throw new Error(error);
  }

  console.log(result);
});

Author

License

The MIT License, see the included license.md file.

node-mdash's People

Contributors

meritt avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.