Skip to content

Commit

Permalink
Passing xrefstyle attribute value to generate xreftext
Browse files Browse the repository at this point in the history
Fixes #136
  • Loading branch information
zeldigas committed Jan 5, 2024
1 parent c618084 commit 85ad862
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
.idea
target
*.iml

.flattened-pom.xml
.asciidoctor
.asciidoc
.diagrams
out
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Fixed

- \[AsciiDoc] `xrefstyle` attribute is taken into account for references (#136)

## 0.15.1 - 2024-01-02

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def resolve_link(target)
def xref_text empty_fallback
if attributes[:refid] == text
ref = document.catalog[:refs][attributes['refid'] || target]
str = (ref ? ref.xreftext : empty_fallback || text)
str = (ref ? ref.xreftext(attr 'xrefstyle', nil, true) : empty_fallback || text)
else
str = text
end
Expand Down Expand Up @@ -268,7 +268,7 @@ def confluence_inline_quoted node

# @param text [String]
def link_content text
if text.include? '<'
if text.include?('<') || text.include?('&#')
%(<ac:link-body>#{text}</ac:link-body>)
else
%(<ac:plain-text-link-body><![CDATA[#{text}]]></ac:plain-text-link-body>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import assertk.assertThat
import com.github.zeldigas.text2confl.convert.Attachment
import com.github.zeldigas.text2confl.convert.PageHeader
import com.github.zeldigas.text2confl.convert.confluence.ReferenceProvider
import org.junit.jupiter.api.Tag
import org.junit.jupiter.api.Test
import kotlin.io.path.Path

Expand Down Expand Up @@ -166,6 +167,42 @@ internal class RenderingOfLinksTest : RenderingTestBase() {
""".trimIndent(),
)
}

@Test
@Tag("GH-136")
fun `Xrefstyle is used for xref rendering`() {
val result = toHtml(
"""
= Document
:sectnums:
:xrefstyle: full
== test
As it was described in <<another>>
== another
section
""".trimIndent(),
referenceProvider = AsciidocReferenceProvider(
Path("./test.adoc"),
ReferenceProvider.fromDocuments(
Path("."), emptyMap()
)
)
)

assertThat(result).isEqualToConfluenceFormat(
"""
<h1>1. test<ac:structured-macro ac:name="anchor"><ac:parameter ac:name="">test</ac:parameter></ac:structured-macro></h1>
<p>As it was described in <ac:link ac:anchor="another"><ac:link-body>Section 2, &#8220;another&#8221;</ac:link-body></ac:link></p>
<h1>2. another<ac:structured-macro ac:name="anchor"><ac:parameter ac:name="">another</ac:parameter></ac:structured-macro></h1>
<p>section</p>
""".trimIndent(),
)

}
}


0 comments on commit 85ad862

Please sign in to comment.