Skip to content

Instantly share code, notes, and snippets.

@kmuto
Created August 15, 2016 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmuto/80650cd2afb40dcdab6ac3d078859e80 to your computer and use it in GitHub Desktop.
Save kmuto/80650cd2afb40dcdab6ac3d078859e80 to your computer and use it in GitHub Desktop.
怠惰なCSSチェッカー
#!/usr/bin/env ruby
# coding: utf-8
# Lazy AutoLayout CSS Checker
# Copyright 2016 Kenshi Muto
# MIT License
lno = 0
ARGF.each do |l|
lno += 1
l.chomp!
if l =~ /-@-[^\s]+/
puts "#{lno}: #{$&} : @-にすべきでは"
elsif l =~ /\s+epub[^:]+/ || l =~ /\Aepub[^:]+/
puts "#{lno}: #{$&} : 「-」から始まるべきでは"
elsif l =~ /@\-epubx\-(.+)\s*:/
sub = $1
puts "#{lno}: @-epubx-#{sub} : 存在しないパラメータ" unless
%w(page-template when define viewport region page-master partition partition-group flow page-template).include?(sub)
elsif l =~ /\-epub\-(.+)\s*:/
sub = $1
puts "#{lno}: -epub-#{sub} : 存在しないパラメータ。-epubxの誤り?" unless
%w(hyphens transform transform-origin writing-mode).include?(sub)
elsif l =~ /\-epubx\-(.+)\s*:/
sub = $1
puts "#{lno}: -epubx-#{sub} : 存在しないパラメータ。-epubの誤り?" unless
%w(flow-into flow-options flow-consume flow-linger flow-property flow-from expr shape-inside shape-outside wrap-flow page utilization enabled min-page-height min-page-width snap-height snap-width required required-partitions conflicting-partitions text-zoom).include?(sub)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment