From c4797d8369be6cb8342014ae6a31992029801399 Mon Sep 17 00:00:00 2001 From: Daniel Haim <2808046+danielhaim1@users.noreply.github.com> Date: Wed, 19 Oct 2022 10:11:15 +0200 Subject: [PATCH 1/2] README.md --- README.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3c82053..b6bbb06 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,15 @@ # Typeset -Typeset is an HTML pre-proces­sor for web ty­pog­ra­phy which pro­vides ty­po­graphic fea­tures used tra­di­tion­ally in fine print­ing which re­main un­avail­able to browser lay­out en­gines. Typeset's pro­cess­ing brings the fol­low­ing to your web­pages: +Typeset is an HTML pre-processor for web typography which provides typographic features used traditionally in fine printing which remain unavailable to browser layout engines. Typeset's processing brings the following to your webpages: -- [Hang­ing punc­tu­a­tion](https://en.wikipedia.org/wiki/Hanging_punctuation) +- [Hanging punctuation](https://en.wikipedia.org/wiki/Hanging_punctuation) - [Ligatures](https://en.wikipedia.org/wiki/Orthographic_ligature) -- [Optical mar­gin align­ment](https://en.wikipedia.org/wiki/Optical_margin_alignment) -- [Punctuation sub­sti­tu­tion](src/punctuation.js) +- [Optical margin alignment](https://en.wikipedia.org/wiki/Optical_margin_alignment) +- [Punctuation substitution](src/punctuation.js) - [Small caps](https://en.wikipedia.org/wiki/Small_caps) -- [Soft hy­phen in­ser­tion](https://en.wikipedia.org/wiki/Soft_hyphen) +- [Soft hyphen insertion](https://en.wikipedia.org/wiki/Soft_hyphen) -Typeset does not re­quire any client-side JavaScript and uses less than a kilo­byte of CSS. Processed HTML & CSS works in Internet Explorer 5 and with­out any CSS. Typeset can be used man­u­ally or as a plu­gin for [Grunt](https://github.com/mobinni/grunt-typeset) and [gulp](https://github.com/lucasconstantino/gulp-typeset). +Typeset does not require any client-side JavaScript and uses less than a kilobyte of CSS. Processed HTML & CSS works in Internet Explorer 5 and without any CSS. Typeset can be used manually or as a plugin for [Grunt](https://github.com/mobinni/grunt-typeset) and [gulp](https://github.com/lucasconstantino/gulp-typeset). @@ -58,7 +58,7 @@ Then tweak the CSS to match the metrics of your font and include it on your page /* Quotation mark - https://en.wikipedia.org/wiki/Quotation_mark) + https://en.wikipedia.org/wiki/Quotation_mark */ /* Single quotation marks (') */ @@ -173,5 +173,4 @@ See the [LICENSE](LICENSE) file for details. - [Language options & support](https://github.com/davidmerfield/Typeset/issues/25) - [Widows & orphans](https://github.com/davidmerfield/Typeset/issues/34). -- Incorporate features from [Normalize Opentype](http://kennethormandy.com/journal/normalize-opentype-css) -- Plugins for React, Angular, Svelte, jQuery \ No newline at end of file +- Incorporate features from [Normalize Opentype](http://kennethormandy.com/journal/normalize-opentype-css) \ No newline at end of file From 42d9ef7e91af5b22f808f05993b47adcb79e3331 Mon Sep 17 00:00:00 2001 From: Daniel Haim <2808046+danielhaim1@users.noreply.github.com> Date: Wed, 19 Oct 2022 11:47:25 +0200 Subject: [PATCH 2/2] v0.3.2a - documentation - replacing ... with `…` - updated tests --- src/punctuation.js | 12 ++++++++---- test/punctuationSpec.js | 8 ++++---- test/typesetSpec.js | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/punctuation.js b/src/punctuation.js index fc290d7..6f14e9c 100644 --- a/src/punctuation.js +++ b/src/punctuation.js @@ -1,12 +1,16 @@ module.exports = (text) => { - // Dashes + + // M Dash + // https://en.wikipedia.org/wiki/Dash text = text.replace(/--/g, "–"); text = text.replace(/ – /g, " — "); - // Elipses - text = text.replace(/\.\.\./g, "…"); + // Ellipsis + // https://en.wikipedia.org/wiki/Ellipsis + text = text.replace(/\.\.\./g, "…"); - // Nbsp for punc with spaces + // Non-breaking space + // https://en.wikipedia.org/wiki/Non-breaking_space const NBSP = " "; const NBSP_PUNCTUATION_START = /([«¿¡]) /g; const NBSP_PUNCTUATION_END = / ([\!\?:;\.,‽»])/g; diff --git a/test/punctuationSpec.js b/test/punctuationSpec.js index 1d7fabd..eaeea5e 100644 --- a/test/punctuationSpec.js +++ b/test/punctuationSpec.js @@ -13,16 +13,16 @@ describe("Punctuation", () => { expect(punc(html)).to.equal("

En un lugar de la mancha

"); }); - it("should replace three dots by elipses symbol", () => { + it("should replace three dots by ellipsis symbol", () => { const html = "

En un lugar de la mancha...

"; - expect(punc(html)).to.equal("

En un lugar de la mancha…

"); + expect(punc(html)).to.equal("

En un lugar de la mancha…

"); }); - it("should replace three dots by elipses symbol on texts with multiple matches", () => { + it("should replace three dots by ellipsis symbol on texts with multiple matches", () => { const html = "

En un lugar de la mancha... De cuyo nombre no quiero acordarme... no ha mucho tiempo que vivía...

"; expect(punc(html)).to.equal( - "

En un lugar de la mancha… De cuyo nombre no quiero acordarme… no ha mucho tiempo que vivía…

" + "

En un lugar de la mancha… De cuyo nombre no quiero acordarme… no ha mucho tiempo que vivía…

" ); }); diff --git a/test/typesetSpec.js b/test/typesetSpec.js index e3509e8..557db32 100644 --- a/test/typesetSpec.js +++ b/test/typesetSpec.js @@ -21,7 +21,7 @@ describe("Typeset", () => { '

"She\'s faster than a 120\' 4" whale." Piña co­ladas were widely consumed in Götterdämmerung from 1880–1912. For the low price of $20 / year from Ex­hi­bits A–E... Then the duplex came forward. "Thrice the tower, he mounted the round gunrest, \'awaking\' HTML. He can print a fixed num­ber of dots in a square inch (for in­stance, 600 × 600)."

'; expect(typeset(html)).to.equal( - '

Yjarni Sigurðardóttir spoke to NATO from Iceland yes­ter­day: Light of my life, fire of my florins — my sin, my soul. The tip of the tongue tak­ing a trip to 118° 19′ 43.5″.”

She’s faster than a 120′ 4″ whale.” Piña co­ladas were widely con­sumed in Götterdämmerung from 1880–1912. For the low price of $20 / year from Ex­hi­bits A–E… Then the du­plex came for­ward. Thrice the tower, he mounted the round gun­rest, awaking’ HTML. He can print a fixed num­ber of dots in a square inch (for in­stance, 600 × 600).”

' + '

Yjarni Sigurðardóttir spoke to NATO from Iceland yes­ter­day: Light of my life, fire of my florins — my sin, my soul. The tip of the tongue tak­ing a trip to 118° 19′ 43.5″.”

She’s faster than a 120′ 4″ whale.” Piña co­ladas were widely con­sumed in Götterdämmerung from 1880–1912. For the low price of $20 / year from Ex­hi­bits A–E… Then the du­plex came for­ward. Thrice the tower, he mounted the round gun­rest, awaking’ HTML. He can print a fixed num­ber of dots in a square inch (for in­stance, 600 × 600).”

' ); }); });