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

Attributes customizer compatibility #33

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions src/org/intellij/markdown/html/GeneratingProviders.kt
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ internal abstract class LinkGeneratingProvider(protected val baseURI: URI?) : Ge
}

try {
if (destination.startsWith('#')) {
return destination
}
return baseURI?.resolve(destination.toString())?.toString() ?: destination
}
catch (e : IllegalArgumentException) {
Expand Down
2 changes: 1 addition & 1 deletion src/org/intellij/markdown/html/HtmlGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class HtmlGenerator(private val markdownText: String,

@Deprecated("To be removed, pass custom visitor instead",
ReplaceWith("generateHtml(HtmlGeneratingVisitor)"))
fun generateHtml(customizer: AttributesCustomizer): String {
fun generateHtml(customizer: AttributesCustomizer = DUMMY_ATTRIBUTES_CUSTOMIZER): String {
HtmlGeneratingVisitor(DefaultTagRenderer(customizer, includeSrcPositions)).visitNode(root)
return htmlString.toString()
}
Expand Down
2 changes: 2 additions & 0 deletions test/data/html/baseUriFile.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
+ [parent directory relative link definition]
+ [absolute link definition]
+ [root link definition]
+ [bookmark link definition]


[implicit current directory relative link definition]: baz.html
[explicit current directory relative link definition]: ./baz.html
[parent directory relative link definition]: ../quux.html
[absolute link definition]: https://google.com/
[root link definition]: /root
[bookmark link definition]: #abc
3 changes: 3 additions & 0 deletions test/data/html/baseUriFile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,8 @@
<li>
<a href="file:/root">root link definition</a>
</li>
<li>
<a href="#abc">bookmark link definition</a>
</li>
</ul>
</body>