penibelst/jekyll-compress-html

Property for easily replacing strings

leo opened this issue · 4 comments

leo commented

Could you please add a property which allows us to set specific strings which will then be replaced before the HTML is outputted? Maybe something like this (replaces "Apple" with "Orange", as well as "Bread" with "Butter") would be fitting:

replace: [
    [ 'Apple', 'Orange' ],
    [ 'Bread', 'Butter' ]
]

or what I would like even more (I'm not sure how objects are built in YAML):

replace: {
    'Apple': 'Orange',
    'Bread': 'Butter'
}

I know some really great use-cases for this.

For example, there's a very nasty problem with the footnote-icon: It's is getting converted into a Emoji on all devices running iOS. I already contacted the guys over at Jekyll and they - in turn - told me that I had to open an issue on the markdown processor (which I did, but it wasn't accepted. The reason: "Apple introduced this problem and therefore should also fix it") - see this issue.

What do you think? Is it possible to implement this?

This sounds like it's pretty much out of the scope of this project. That said, it's possible to write a layout like compress.html for that purpose.

leo commented

Ahh, that's a great idea! Sorry, I must have missed that while thinking about a possible solution. Works fine now! 😋

That said, it's possible to write a layout like compress.html for that purpose.

Exactly. Make sure you use the replace filter in row to avoid bad performance.

{{ content | replace: "1", "one" | replace: "2", "two" | replace: "3", "three" }}
leo commented

Thanks again! I did it like this.