Giter VIP home page Giter VIP logo

js-arabic-reshaper's Introduction

js-arabic-reshaper

Text reshaper for Arabic text - ported from Python and Java versions.

Context

Arabic script is very special with two essential features:

  1. It is written from right to left.
  2. The characters change shape according to their surrounding characters.

So when you try to print text written in Arabic script in an application – or a library – that doesn’t support Arabic you might end up with something that looks like this:

Arabic text written from left to right with no reshaping

We have two problems here, first, the characters are in the isolated form, which means that every character is rendered regardless of its surroundings, and second is that the text is written from left to right.

This project does not solve the right-to-left issue, only the reshaping

Displayed in correct right-to-left order:

Arabic text written from right to left with no reshaping

The only issue left to solve is to reshape those characters and replace them with their correct shapes according to their surroundings. Using this library helps with the reshaping so we can get the proper result like this:

Arabic text written from right to left with reshaping

Install and Use

On the command-line:

npm install js-arabic-reshaper --save

Then in the source code:

const Reshaper = require('arabic-reshaper');
Reshaper.reshape(arabicWord);

// options
Reshaper.reshape(arabicWord, {
  ligatures: true,
  delete_harakat: false
});

Tests

npm install
npm install mocha -g
mocha

License

Open source, GPL v3+ (same as Python Arabic Reshaper)

js-arabic-reshaper's People

Contributors

mapmeld avatar

Watchers

Mohammad Khatib avatar James Cloos avatar Rasha Hussein 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.