Library

ashaar.js

Arabic poetry formatting in HTML.

ashaar.js parses marked-up Arabic, Urdu, and Persian poetry and renders it as clean right-to-left HTML. Its justification engine inserts kashida (tatweel) to balance every misra to the width of the longest line, the way fine print typesets verse.

It runs in the browser with no dependencies and is the engine behind ashaar.js for Word.

View it in action on the the Ashaar.JS project page..

Features

  • Parser for bayts (couplets), single misras, refrains, and multi-poem documents.
  • Right-to-left HTML rendering of parsed poetry.
  • Block-level kashida justification that balances misras to the longest line.
  • Canvas-based measurement for precise, font-aware tatweel placement.

Input format

  • \ separates the two misras of a bayt
  • | marks a single-misra line
  • * marks a refrain
  • --- separates poems
← All projects