Hacker News new | past | comments | ask | show | jobs | submit login
Typeset.js – A ty­po­graphic pre-proces­sor for HTML (blot.im)
143 points by dgam on Aug 17, 2015 | hide | past | favorite | 14 comments



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.


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.


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.


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


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

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


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


Could it not be managed in a Grunt task?


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.


> 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").


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.

??


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.


Nope, didn't take long at all: https://news.ycombinator.com/item?id=10079270


Rely on stdin/stdout, and call it via backticks?


I'd think execjs would be in the running.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: