Skip to content

Commit

Permalink
Support for attributes in square brackets
Browse files Browse the repository at this point in the history
Fixes #176
  • Loading branch information
zeldigas committed Jun 27, 2024
1 parent 3429073 commit 001ff60
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

## 0.17.1 - 2024-06-27

### Fixed

- Using attributes enclosed in quotes, but not jsons. Extra scenario handled (#176)

### Changed

- Dependency updates
- asciidoctor-diagram to 2.3.1

## 0.17.0 - 2024-06-24

### Added
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.zeldigas.text2confl.convert

import com.fasterxml.jackson.core.JsonParseException
import com.fasterxml.jackson.core.JacksonException
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import io.github.oshai.kotlinlogging.KotlinLogging
Expand All @@ -18,7 +18,7 @@ fun parseAttribute(value: Any): Any {
} else {
value
}
} catch (e: JsonParseException) {
} catch (e: JacksonException) {
logger.debug(e) { "Failed to parse value $value, looks like not a valid json" }
value
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class AsciidocFileConverterTest {
"""
:title: Custom title
:labels: a,b,c
:with_braces: {hello}
:with_brackets: [a, b, c]
:json_with_braces: { "hello": "world" }
:json_with_brackets: ["hello", "world"]
= Doc title
Expand All @@ -59,7 +63,13 @@ class AsciidocFileConverterTest {

assertThat(result).all {
prop(PageHeader::title).isEqualTo("Prefixed: Custom title")
prop(PageHeader::attributes).contains("labels", "a,b,c")
prop(PageHeader::attributes).all {
contains("labels", "a,b,c")
contains("with_braces", "{hello}")
contains("with_brackets", "[a, b, c]")
contains("json_with_braces", mapOf("hello" to "world"))
contains("json_with_brackets", listOf("hello", "world"))
}
}
}

Expand Down

0 comments on commit 001ff60

Please sign in to comment.