Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement CSS filter for image and advanced backgrounds #14

Merged
merged 10 commits into from
May 4, 2018
Merged

Conversation

yhatt
Copy link
Member

@yhatt yhatt commented May 2, 2018

This PR implements CSS filter support for Markdown image syntax. It applies to the inline image and the advanced backgrounds. User would be able to apply powerful filters easily.

Example

<!-- theme: gaia -->

![](https://raw.githubusercontent.com/yhatt/marp/master/images/marp.png)
![blur](https://raw.githubusercontent.com/yhatt/marp/master/images/marp.png)
![brightness](https://raw.githubusercontent.com/yhatt/marp/master/images/marp.png)
![contrast](https://raw.githubusercontent.com/yhatt/marp/master/images/marp.png)
![drop-shadow](https://raw.githubusercontent.com/yhatt/marp/master/images/marp.png)
![grayscale](https://raw.githubusercontent.com/yhatt/marp/master/images/marp.png)
![hue-rotate](https://raw.githubusercontent.com/yhatt/marp/master/images/marp.png)
![invert](https://raw.githubusercontent.com/yhatt/marp/master/images/marp.png)
![opacity](https://raw.githubusercontent.com/yhatt/marp/master/images/marp.png)
![saturate](https://raw.githubusercontent.com/yhatt/marp/master/images/marp.png)
![sepia](https://raw.githubusercontent.com/yhatt/marp/master/images/marp.png)

screen shot 2018-05-03 at 02 52 07

Advanced backgrounds

<!-- theme: gaia -->

![bg](https://raw.githubusercontent.com/yhatt/marp/master/images/marp.png)
![bg blur](https://raw.githubusercontent.com/yhatt/marp/master/images/marp.png)
![bg brightness](https://raw.githubusercontent.com/yhatt/marp/master/images/marp.png)
![bg contrast](https://raw.githubusercontent.com/yhatt/marp/master/images/marp.png)
![bg drop-shadow](https://raw.githubusercontent.com/yhatt/marp/master/images/marp.png)
![bg grayscale](https://raw.githubusercontent.com/yhatt/marp/master/images/marp.png)
![bg hue-rotate](https://raw.githubusercontent.com/yhatt/marp/master/images/marp.png)
![bg invert](https://raw.githubusercontent.com/yhatt/marp/master/images/marp.png)
![bg opacity](https://raw.githubusercontent.com/yhatt/marp/master/images/marp.png)
![bg saturate](https://raw.githubusercontent.com/yhatt/marp/master/images/marp.png)
![bg sepia](https://raw.githubusercontent.com/yhatt/marp/master/images/marp.png)

screen shot 2018-05-03 at 02 54 04

Arguments and mutiple filters

Of course each filter syntax can set the filter function arguments by filter:param(,param2...), and apply multiple filters with space-separated.

<!-- Arguments -->
![bg blur:20px](https://example.com/imageA.jpg)
![drop-shadow:0,5px,20px,#fff](https://example.com/imageB.jpg)

<!-- Multiple filters -->
![bg opacity:75% sepia](https://example.com/imageC.jpg)
![grayscale:.5 contrast:.75](https://example.com/imageD.jpg)

ToDo

  • Add test case

@yhatt
Copy link
Member Author

yhatt commented May 3, 2018

The latest stable Chrome has a rendering bug as same as the known issue. This issue will fix in Chrome beta (Chrome 67).

We are going to make an instance option to switch enabling/disabling this feature.

@yhatt yhatt merged commit afa62f9 into master May 4, 2018
@yhatt yhatt deleted the image-filter branch May 4, 2018 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant