Generate Emmet code from HTML - reverse action
Asked Answered
C

0

6

I am talking about Emmet.io (former Zen Coding).

Is there JavaScript code or jQuery plugin that does that in reverse?

Example:

emmet('ul > li*3') => '<ul><li></li><li></li><li></li></ul>'

I want something like this:

emmet('<ul><li></li><li></li><li></li></ul>') => 'ul > li*3'
Comparator answered 4/3, 2013 at 16:36 Comment(9)
This is kinda tough because, there can be many types. Whereas the former is only one.Kasper
just wondering, why would you want to turn markup into emmet code? You basically want to reserve back what you have already done?Synonymy
you could write a regular exp and the loop through those results and spit out what you want that way.Synonymy
@JamieHutber That would be a worst case algo! :(Kasper
@JamieHutber regexp is overkill, jquery could do it easily and i can spend few days really writing it myself and i will if i don't get answers by tomorrow. reason is, this is a great way to store templates, and that has to be revers-able process.Comparator
We have the Sizzle selector. And with the .size() I guess we might be able to achieve it. Check this question (it seems similar): https://mcmap.net/q/1919934/-reverse-zen-coding.Kasper
@iggy fair enough. but JS can do regex ;)Synonymy
@Comparator did you write anything to do this you could share?Klina
@AdamHeath yes i did, you can find it here: linkComparator

© 2022 - 2024 — McMap. All rights reserved.