Created
July 7, 2018 11:35
-
-
Save tindzk/bfdb967b9ffcf8bc8ae2ba3abdbf0875 to your computer and use it in GitHub Desktop.
Prefix all referenced CSS tags in HTML files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[project] | |
scalaVersion = "2.12.4-bin-typelevel-4" | |
scalaOptions = ["-Yliteral-types"] | |
scalaOrganisation = "org.typelevel" | |
[module.app.jvm] | |
root = "." | |
sources = ["src"] | |
scalaDeps = [ | |
["tech.sparse", "pine", "0.1.3"], | |
["com.github.pathikrit", "better-files", "3.5.0"] | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pine._ | |
import better.files._ | |
// Place file in src/ | |
object PrefixClasses extends App { | |
File.currentWorkingDirectory.glob("*.html").foreach { file => | |
val newContent = HtmlParser.fromString(file.contentAsString).map { | |
case t: Tag[_] => t.`class`.update(_.map(cls => | |
if (cls.startsWith("sk-")) cls else "sk-" + cls)) | |
case n => n | |
} | |
file.write(newContent.toHtml) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment