

Typeset.js – A ty­po­graphic pre-proces­sor for HTML - dmerfield
http://blot.im/typeset

======
doomrobo
Is small cap conversion done for every word that's written in all capitals?
The convention that I'm familiar with (I think from The Elements of
Typographical Style) is to only set acronyms - that is, pronounceable
initialisms like "NASA" or "PETA" \- in small caps. All other initialisms like
FBI or USA are set as normal-sized caps. I think the reasoning is that small
caps are there to preserve the capitals but not disturb the flow of the text,
since it's read as a word just like the words around it. Full caps do disturb
the flow of the text because they are not words and not pronounced as words
either.

~~~
dmerfield
Any word in all-caps is 'converted' to small-caps. This behaviour can be
changed, or even disabled, by setting a flag in the options object before
processing. I prefer to keep all-caps out of my body text.

~~~
buymorechuck
Back at Flipboard, for our RSS typography processing, we used a rule of thumb
that all-capped words 3 letters or longer would get small-caps treatment. It
worked pretty well.

------
juriansluiman
I have used a similar tool [1] some time ago in PHP. The project hasn't been
kept updated, but the idea of processing text/HTML and converting the right
entities is pretty neat. At least the readability improves massively.

This project Typeset.js is slightly different as it adds additional markup and
styles. For me, converting here's to here’s was enough for me back then.

[1]:
[https://github.com/scoates/lexentity](https://github.com/scoates/lexentity)

~~~
Damin0u
For PHP you can have a look at JoliTypo [1], much more up to date, tested,
working for any style guide and using a real parser.

[1]:
[https://github.com/jolicode/jolitypo](https://github.com/jolicode/jolitypo)

Disclaimer: I'm the author, and I've tested them all.

------
chrisfosterelli
This is great! I wish there was an easy way to incorporate this into Jekyll
blogs.

~~~
nthnclrk
Could it not be managed in a Grunt task?

~~~
chrisfosterelli
I suppose you could write a grunt or gulp task to parse all of the files after
jekyll has generated them and run them through typeset. It might be slightly
challenging to ensure that only the actual article content gets ran through
typeset and not any other content.

Unfortunately, I use Github pages so this wouldn't work for that from what I
can tell.

~~~
teamhappy
> It might be slightly challenging to ensure that only the actual article
> content gets ran through typeset and not any other content.

Not a problem. It accepts CSS selectors as options (e.g., ".article").

------
snurk
Sweet. I've been doing this in Rails helpers, and it's a pain.

Now, how would I add this to my Rails asset pipeline? I'm thinking either:

* Port to Ruby, or

* Use this as a microservice.

??

~~~
ultimape
It looks like much of code is some simple routines to find and replace
elements. Might not take long to recreate it in pure ruby.

~~~
Doches
Nope, didn't take long at all:
[https://news.ycombinator.com/item?id=10079270](https://news.ycombinator.com/item?id=10079270)

