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

Asciidoc Source Include files does not work as expected #582

Open
Heiss opened this issue Aug 9, 2024 · 1 comment
Open

Asciidoc Source Include files does not work as expected #582

Heiss opened this issue Aug 9, 2024 · 1 comment

Comments

@Heiss
Copy link

Heiss commented Aug 9, 2024

Hi,

[source]
----
include::https://raw.githubusercontent.com/avisi-cloud/structurizr-site-generatr/main/docs/example/workspace.dsl[lines=5..10]
----

generates the following text in the html output.

link:https://raw.githubusercontent.com/avisi-cloud/structurizr-site-generatr/main/docs/example/workspace.dsl[role=include]

This is obviously wrong.
I would expect, that the given file will be inlined and parsed via asciidoc. The following output is the expected one.

* - "Big Bank plc - Internet Banking System" (https://structurizr.com/share/36141/)
*/
workspace "Big Bank plc" "This is an example workspace to illustrate the key features of Structurizr, via the DSL, based around a fictional online banking system." {
    !docs workspace-docs
    !adrs workspace-adrs

Local resolutions are working as expected, so if you download the file and place it besides the .adoc file and link to it, it works as expected. So the following snippet...

[source]
----
include::workspace.dsl[lines=5..10]
----

returns the expected output from above.

Hope this helps as requested in #564

@jenspav
Copy link
Collaborator

jenspav commented Aug 13, 2024

Thanks. So this turns out to be permission issue. Using this patch allows fetching external content:

--- a/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/ToHtml.kt
+++ b/src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/ToHtml.kt
@@ -17,6 +17,7 @@ import net.sourceforge.plantuml.SourceStringReader
 import nl.avisi.structurizr.site.generatr.site.asUrlToDirectory
 import nl.avisi.structurizr.site.generatr.site.asUrlToFile
 import nl.avisi.structurizr.site.generatr.site.views.diagram
+import org.asciidoctor.Attributes
 import org.asciidoctor.Options
 import org.asciidoctor.SafeMode
 import org.jsoup.Jsoup
@@ -82,6 +83,7 @@ private fun asciidocToHtml(
 ): String {
     val options = Options.builder()
         .safe(SafeMode.SERVER)
+        .attributes(Attributes.builder().allowUriRead(true).build())
         // Docs dir needs to be exposed from structurizr using `.baseDir(File("./docs/example/workspace-docs"))`,
         // which is not the case at the moment.
         // Needed for partial include `include::partial.adoc[]`, which structurizr also does not support.

Will think about how we should handle this, since there is a reason for this property to be false by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants