A kashida engine that adds kashida to poem lines to unify their widths to match the widest text.
These instructions will guide you to consume the API provided by the app.
Following these instructions will integrate the app into your website and will provide a globally defined API to be used. Also, if you're using the Script tag method then the app will automatically add kashidas to the poem lines if the following structure is found in DOM, if not then check the Documentation to manually invoke the required functions.
<element class="poem">
<element class="linesGroup">
<div>
<div> [The line should exist here] </div>
</div>
</element>
<element class="linesGroup">
<div>
<div> [The line should exist here] </div>
<div> [The line should exist here] </div>
</div>
</element>
</element>
-
Download the latest version of the app.
-
Link the app's Javascript file in the body of your HTML File. Example:
<body> <script src="/static/js/kashida-engine.js"></script> </body>
Run the following command:
npm i kashida-engine
Here will explain the API provided by our app that can be found under the globally defined namespace NagwaHTMLEditor.
The KashidaEngine
is implementing the following interface:
interface KashidaEngine {
unifyTextsWidths: (texts: string[], font: string) => string[]
renderKashidaToPoems: (poemSelector?: string, lineSelector?: string) => void
renderKashidaToPoems: (e?: Event) => void
getTextWidth: (text: string, font: string) => number
getTextsWidths: (texts: string[], font: string) => TextWidths
}
interface TextWidths {
textWidths: number[]
maxTextWidth: number
}
Here's an explanation of the provided API:
KashidaEngine
:unifyTextsWidths
: Unifies the widths of all the inputted texts to match the max width.renderKashidaToPoems
: Has two overloads to render all the poem lines after adding kashida to it and unifying all its widths for all the poems available on page and still be able to use it as an event handler by using the second overload that accepts anEvent
as an argument.getTextWidth
: Usescanvas.measureText
to compute and return the width of the given text of given font in pixels.getTextsWidths
: UsesgetTextWidth
to compute and return the widths of the given texts of given font in pixels and the max width of all the sentences.
TextWidths
:textWidths
: An array of the width of the sentences.maxTextWidth
: The maximum width of all of these widths.
These instructions will get you a copy of the project up and running on your local machine.
You have to have Node.js v17.2.0, and npm v8.1.4 installed.
Also, check ./package.json
for all the packages used in this project.
Clone this repo, open the terminal and navigate to the repo directory on your local machine, and then run:
npm install
wait until it's done and you're good to go!
- TypeScript - The main language used.
- Webpack - The main bundler used.
- Unify the poem lines widths with kashidas if the expected structure is met.
- Provide a method in the public API to manually run the unifying widths method.
- Provide a method in the public API to manually run the method that calculates the widths.
- Provide a method in the public API that adds kashidas to a list of strings.
A commit messages consists of three distinct parts separated by a blank line: the title, an optional body and an optional footer. The layout looks like this:
type: subject
body
The type is contained within the title and can be one of these types:
- feat: a new feature
- fix: a bug fix
- docs: changes to documentation
- style: formatting, missing semi colons, etc; no code change
- refactor: refactoring production code
- test: adding tests, refactoring test; no production code change
- chore: updating build tasks, package manager configs, etc; no production code change
Subjects should be no greater than 50 characters, should begin with a capital letter and do not end with a period.
Use an imperative tone to describe what a commit does, rather than what it did. For example, use change; not changed or changes.
Not all commits are complex enough to warrant a body, therefore it is optional and only used when a commit requires a bit of explanation and context. Use the body to explain the what and why of a commit, not the how.
When writing a body, the blank line between the title and the body is required and you should limit the length of each line to no more than 72 characters.
For more information about the style guide for Git and programming Languages check: Udacity's Code Style Guide or Conventional Commits