View Single Post
Old 06-02-2012, 02:04 PM   #14
PeterT
Taking a break; Fed up
PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.PeterT ought to be getting tired of karma fortunes by now.
 
PeterT's Avatar
 
Posts: 6,499
Karma: 42516438
Join Date: Nov 2007
Location: Toronto
Device: Wife: Touch, Arc, Vox Me: Nexus 7, Glo
You might like to look at Degristling the sausage that has some discussions on locating unused CSS classes.

Unfortunately, it uses a Mac editor BBEDIT

However in one of the comments the responder points to a python3 script that will list all used CSS styles.

Code:
Usage: from the CLI, type ./cssstylelist.py > dump.txt
Spoiler:

Code:
#! /usr/bin/env python3
# file: cssstylelist.py
# Make a list of every style used in html and returns that
# From the CLI, type `./cssstylelist.py > file_with_a_list.txt
# Feel free to address any complain to @gabalese

import os, glob, sys
try:
	from lxml import etree as ET
except ImportError:
	import xml.etree.ElementTree as ET
	print("lxml not installed. Running with xml.etree instead")

path = "OEBPS/Text" # your mileage may vary
list = []
new_list = []

def cssList():
	global list
	global new_list 
	for infile in glob.glob(os.path.join(path, '*html')):
		try:
			html = ET.parse(infile).getroot()
		except:
			print("ERROR: Unable to parse " + infile)
			print("This is likely to happen with ill-formed xhtml files.")
			sys.exit(1)
		for i in html.iter():
			list.append(i.get("class"))
	
	for i in list:
		if i not in new_list:
			if i is not None:
				new_list.append(i)
			
	return new_list	


	
if __name__ == "__main__":
	for item in (cssList()):
		print(item)
PeterT is offline   Reply With Quote