Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for <style> tags #99

Merged
merged 42 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
527d5be
feat: introduce css lexer
rafaeltonholo Nov 27, 2024
bbd1449
feat: introduce css lexer
rafaeltonholo Nov 27, 2024
c0d28b4
feat: introduce css AST parser
rafaeltonholo Nov 27, 2024
46ed4a6
chore: cli output enhancements
rafaeltonholo Nov 28, 2024
3b4600c
feat(css-parser): support identifier property values
rafaeltonholo Nov 28, 2024
3bba49c
refactor: extract SvgRootNode to its own file
rafaeltonholo Nov 30, 2024
49e251c
feat(css-parser): add support for aggregate selectors
rafaeltonholo Nov 30, 2024
c081e63
chore: remove unit test folder from detekt linting
rafaeltonholo Dec 1, 2024
159ca62
feat: add support for multiple property values
rafaeltonholo Dec 1, 2024
9939861
feat(lexer): enhance css lexer to support dimensions and percentages
rafaeltonholo Dec 1, 2024
dd300ca
fix(css-parser): trim rule ignoring dot token
rafaeltonholo Dec 2, 2024
d231b45
refactor: rename CssSelector to CssComponent
rafaeltonholo Dec 2, 2024
03edace
feat: support more CSS features
rafaeltonholo Dec 3, 2024
f243d81
fix(css-parser): remove unnecessary whitespaces in CSS AST
rafaeltonholo Dec 4, 2024
f9b37e1
feat: introduce CSS specificity calculation
rafaeltonholo Dec 4, 2024
ff4ced4
chore: exclude test files from detekt
rafaeltonholo Dec 11, 2024
043fe38
chore: enable when-guards
rafaeltonholo Dec 11, 2024
ac2a4b5
refactor: improve string extensions and remove not used functions
rafaeltonholo Dec 11, 2024
0bb7acd
refactor(css): renamed CssLexer to CssTokenizer
rafaeltonholo Dec 11, 2024
b6fe619
chore(playground): introduce a new `File` data class for SampleFile
rafaeltonholo Dec 11, 2024
2f9f9a8
feat(svg): introduce style tags parsing
rafaeltonholo Dec 11, 2024
247704f
refactor(svg): simplify normalize id function
rafaeltonholo Dec 11, 2024
12d486f
fix: detekt issues
rafaeltonholo Dec 11, 2024
948d70a
refactor: rewrite the tokenizer to use a more efficient and maintaina…
rafaeltonholo Dec 12, 2024
748d158
feat(lexer): add support for CSS comments
rafaeltonholo Dec 14, 2024
84bce34
feat(lexer): add BadString token
rafaeltonholo Dec 14, 2024
a37a424
chore: add class and style backing field
rafaeltonholo Dec 17, 2024
a210b91
refactor(css): calculate selector specificities based on Prelude inst…
rafaeltonholo Dec 18, 2024
01ee81c
fix(lexer): IndexOutOfBounds when offset is on lastIndex
rafaeltonholo Dec 18, 2024
2229bf2
feat(svg): introduce support to style tags
rafaeltonholo Dec 18, 2024
3bbfd10
fix(css-lexer): improve number and dimension tokenization
rafaeltonholo Dec 18, 2024
656f110
refactor(lexer): improve CssTokenIterator readability
rafaeltonholo Dec 18, 2024
97e19fd
refactor(ast): improve parser error handling
rafaeltonholo Dec 19, 2024
4bc44b4
refactor(css): improve at-rule parsing
rafaeltonholo Dec 19, 2024
b1f2ece
fix: detekt issues
rafaeltonholo Dec 19, 2024
c802f53
refactor: reduce constructor parameters of CssParser
rafaeltonholo Dec 19, 2024
1efaafa
refactor(css): change CssStatementNode to extend of CssNode
rafaeltonholo Dec 19, 2024
f957cc9
refactor(css): enhance error handling when no consumers available for…
rafaeltonholo Dec 19, 2024
1e0e428
chore: add unit test to SvgStyleNode
rafaeltonholo Dec 19, 2024
55ecaf4
fix: unit test name
rafaeltonholo Dec 19, 2024
4dbd03e
fix: incomplete error message
rafaeltonholo Dec 19, 2024
5138b03
chore: handle unsafe cast
rafaeltonholo Dec 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .run/svg-to-compose [allTests].run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<configuration default="false" name="svg-to-compose [allTests]" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$/svg-to-compose" />
<option name="externalProjectPath" value="$PROJECT_DIR$/.." />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
Expand Down
1 change: 1 addition & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependencies {
// Workaround for using version catalog in Kotlin script convention plugins
// https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
implementation(libs.app.cash.burst.gradle.plugin)
implementation(libs.org.jetbrains.kotlin.gradle.plugin)
implementation(libs.org.jetbrains.kotlin.powerAssert.plugin)
implementation(libs.org.jetbrains.dokka.gradle.plugin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ plugins {
kotlin {
useNative()
useJvm()

compilerOptions {
freeCompilerArgs.add("-Xwhen-guards")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinTest
plugins {
id("dev.tonholo.s2c.conventions.kmp")
org.jetbrains.kotlin.plugin.`power-assert`
app.cash.burst
}

dependencies {
Expand Down
31 changes: 9 additions & 22 deletions config/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,10 @@ console-reports:

output-reports:
active: true
exclude:
# - 'TxtOutputReport'
# - 'XmlOutputReport'
# - 'HtmlOutputReport'
# - 'MdOutputReport'
# - 'SarifOutputReport'

comments:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**', '**/commonTest/**']
AbsentOrWrongFileLicense:
active: false
licenseTemplateFile: 'license.template'
Expand All @@ -67,31 +62,28 @@ comments:
endOfSentenceFormat: '([.?!][ \t\n\r\f<])|([.?!:]$)'
KDocReferencesNonPublicProperty:
active: false
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
OutdatedDocumentation:
active: false
matchTypeParameters: true
matchDeclarationsOrder: true
allowParamOnConstructorProperties: false
UndocumentedPublicClass:
active: false
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
searchInNestedClass: true
searchInInnerClass: true
searchInInnerObject: true
searchInInnerInterface: true
searchInProtectedClass: false
UndocumentedPublicFunction:
active: false
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
searchProtectedFunction: false
UndocumentedPublicProperty:
active: false
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
searchProtectedProperty: false

complexity:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**', '**/commonTest/**']
CognitiveComplexMethod:
active: true
threshold: 15
Expand Down Expand Up @@ -159,14 +151,13 @@ complexity:
active: false
StringLiteralDuplication:
active: false
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
threshold: 3
ignoreAnnotation: true
excludeStringsWithLessThan5Characters: true
ignoreStringsRegex: '$^'
TooManyFunctions:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**', '**/commonTest/**']
thresholdInFiles: 11
thresholdInClasses: 11
thresholdInInterfaces: 11
Expand Down Expand Up @@ -234,6 +225,7 @@ empty-blocks:

exceptions:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**', '**/commonTest/**']
ExceptionRaisedInUnexpectedLocation:
active: true
methodNames:
Expand All @@ -243,7 +235,6 @@ exceptions:
- 'toString'
InstanceOfCheckForException:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
NotImplementedDeclaration:
active: false
ObjectExtendsThrowable:
Expand All @@ -269,7 +260,6 @@ exceptions:
active: false
ThrowingExceptionsWithoutMessageOrCause:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
exceptions:
- 'ArrayIndexOutOfBoundsException'
- 'Exception'
Expand All @@ -284,7 +274,6 @@ exceptions:
active: true
TooGenericExceptionCaught:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
exceptionNames:
- 'ArrayIndexOutOfBoundsException'
- 'Error'
Expand All @@ -305,6 +294,7 @@ exceptions:

naming:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**', '**/commonTest/**']
BooleanPropertyNaming:
active: false
allowedPattern: '^(is|has|are)'
Expand All @@ -330,7 +320,6 @@ naming:
minimumFunctionNameLength: 3
FunctionNaming:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
functionPattern: '[a-z][a-zA-Z0-9]*'
excludeClassPattern: '$^'
FunctionParameterNaming:
Expand Down Expand Up @@ -381,24 +370,24 @@ naming:

performance:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**', '**/commonTest/**']
ArrayPrimitive:
active: true
CouldBeSequence:
active: false
threshold: 3
ForEachOnRange:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
SpreadOperator:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
UnnecessaryPartOfBinaryExpression:
active: false
UnnecessaryTemporaryInstantiation:
active: true

potential-bugs:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**', '**/commonTest/**']
AvoidReferentialEquality:
active: true
forbiddenTypePatterns:
Expand Down Expand Up @@ -464,7 +453,6 @@ potential-bugs:
active: true
LateinitUsage:
active: false
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
ignoreOnClassesPattern: ''
MapGetWithNotNullAssertionOperator:
active: true
Expand All @@ -491,7 +479,6 @@ potential-bugs:
active: true
UnsafeCallOnNullableType:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
UnsafeCast:
active: true
UnusedUnaryOperator:
Expand All @@ -503,6 +490,7 @@ potential-bugs:

style:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**', '**/*.kts']
AlsoCouldBeApply:
active: false
BracesOnIfStatements:
Expand Down Expand Up @@ -605,10 +593,9 @@ style:
excludedFunctions: []
LoopWithTooManyJumpStatements:
active: true
maxJumpCount: 1
maxJumpCount: 3
MagicNumber:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**', '**/*.kts']
ignoreNumbers:
- '-1'
- '0'
Expand Down
5 changes: 4 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[versions]
agp = "8.7.3"
burst = "2.2.0"
kotlin = "2.1.0"
clikt = "5.0.2"
okio = "3.9.1"
Expand All @@ -11,11 +12,13 @@ kotlinx-coroutines = "1.9.0"
dokka = "1.9.20"

[libraries]
clikt = { group = "com.github.ajalt.clikt", name = "clikt", version.ref = "clikt" }
com-github-ajalt-clikt = { module = "com.github.ajalt.clikt:clikt", version.ref = "clikt" }
com-github-ajalt-clikt-markdown = { module = "com.github.ajalt.clikt:clikt-markdown", version.ref = "clikt" }
com-squareup-okio = { group = "com.squareup.okio", name = "okio", version.ref = "okio" }
detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" }
com-fleeksoft-ksoup = { module = "com.fleeksoft.ksoup:ksoup", version.ref = "ksoup"}
org-jetbrains-kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
app-cash-burst-gradle-plugin = { module = "app.cash.burst:burst-gradle-plugin", version.ref = "burst" }

# Plugins
org-jetbrains-dokka-gradle-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
Expand Down
96 changes: 96 additions & 0 deletions samples/svg/css/house-with-trees.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions samples/svg/css/mountain-with-clouds.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion svg-to-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ kotlin {
}

nativeMain.dependencies {
implementation(libs.clikt)
implementation(libs.com.github.ajalt.clikt)
implementation(libs.com.github.ajalt.clikt.markdown)
}
}
}
Expand Down
Loading
Loading