Skip to content

Instantly share code, notes, and snippets.

@philix philix/ct
Created May 11, 2012

Embed
What would you like to do?
CSS for ctags
--langdef=css \
--langmap=css:.css \
--regex-css='/^[ \t]*\.([A-Za-z0-9_-]+)/#\1/c,class,classes/' \
--regex-css='/^[ \t]*#([A-Za-z0-9_-]+)/.\1/i,id,ids/' \
--regex-css='/^[ \t]*(([A-Za-z0-9_-]+[ \t\n,]+)+)\{/\1/t,tag,tags/' \
--regex-css='/^[ \t]*@media\s+([A-Za-z0-9_-]+)/\1/m,media,medias/' \
@philix

This comment has been minimized.

Copy link
Owner Author

philix commented May 11, 2012

From http://book.abe.free.fr/blog/public/ctags and slightly changed

@marlun

This comment has been minimized.

Copy link

marlun commented Mar 19, 2013

I'm trying to add this but I'm getting error:

$ ctags -R .
ctags: Warning: Unknown language "css:.css \" in "langmap" option
ctags: Warning: unknown language "css" in --regex-css option
ctags: Warning: unknown language "css" in --regex-css option
ctags: Warning: unknown language "css" in --regex-css option
ctags: Warning: unknown language "css" in --regex-css option

It's like it's not seeing the --langdef=css \ line.

Any idea why?

@marlun

This comment has been minimized.

Copy link

marlun commented Mar 19, 2013

The problem was that I needed to remove the quotes around the regex and the \ in the end of the lines. Works fine now.

@philix

This comment has been minimized.

Copy link
Owner Author

philix commented May 31, 2013

I had to the quotes and backslashes cause I've made a script -- ct -- with the big command in it instead of adding theses line to a .ctagsrc file.

@alexrah

This comment has been minimized.

Copy link

alexrah commented Dec 11, 2013

I tried to include your CSS regex with a modified version of Ctags -> https://github.com/fishman/ctags
the only missing filter in the modded Ctags version above is Media Queries so I tried with your regex but:

your regex just filter the FIRST AND ONLY THE FIRST WORD of the media query string.
for instance I have this media query:
@media only screen and (min-device-width : 768px)

but your regex filter just the FIRST word after @media -> in this case "only".

so what I get is a list of "only" and "screen" under media queries instead of something more useful such as:
"only screen and (min-device-width: 768px)"

I'm not a good regex writer, otherwise I would modify it by myself: would you please help me fix this?

many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.