Skip to content

Commit

Permalink
Update stixview to use AST
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew-Morozko committed Oct 3, 2024
1 parent 1fdf597 commit e1ae96a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 5 additions & 4 deletions internal/stixview/content_stixview.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/blackstork-io/fabric/pkg/diagnostics"
"github.com/blackstork-io/fabric/plugin"
"github.com/blackstork-io/fabric/plugin/ast"
"github.com/blackstork-io/fabric/plugin/dataspec"
"github.com/blackstork-io/fabric/plugin/plugindata"
)
Expand Down Expand Up @@ -130,7 +131,7 @@ func renderStixView(ctx context.Context, params *plugin.ProvideContentParams) (*
if rctx.Objects == nil && args.StixURL == nil && args.GistID == nil {
return nil, diagnostics.Diag{{
Severity: hcl.DiagError,
Summary: "Missing arugments",
Summary: "Missing arguments",
Detail: "Must provide either stix_url or gist_id or objects",
}}
}
Expand All @@ -145,9 +146,9 @@ func renderStixView(ctx context.Context, params *plugin.ProvideContentParams) (*
}

return &plugin.ContentResult{
Content: &plugin.ContentElement{
Markdown: buf.String(),
},
Content: plugin.NewElement(
ast.HTMLBlock(buf.Bytes()),
),
}, nil
}

Expand Down
3 changes: 3 additions & 0 deletions internal/stixview/content_stixview_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func (s *StixViewTestSuite) TestGistID() {
`<script src="https://unpkg.com/stixview/dist/stixview.bundle.js" type="text/javascript"></script>`,
`<div data-stix-gist-id="123">`,
`</div>`,
``,
}, "\n"), mdprint.PrintString(res.Content))
}

Expand All @@ -68,6 +69,7 @@ func (s *StixViewTestSuite) TestStixURL() {
`<script src="https://unpkg.com/stixview/dist/stixview.bundle.js" type="text/javascript"></script>`,
`<div data-stix-url="https://example.com/stix.json">`,
`</div>`,
``,
}, "\n"), mdprint.PrintString(res.Content))
}

Expand Down Expand Up @@ -97,6 +99,7 @@ func (s *StixViewTestSuite) TestAllArgs() {
`<script src="https://unpkg.com/stixview/dist/stixview.bundle.js" type="text/javascript"></script>`,
`<div data-stix-gist-id="123" data-show-sidebar="true" data-show-footer="true" data-show-tlp-as-tags="true" data-caption="test caption" data-show-marking-nodes="true" data-show-labels="true" data-show-idrefs="true" data-graph-width="400" data-graph-height="300">`,
`</div>`,
``,
}, "\n"), mdprint.PrintString(res.Content))
}

Expand Down

0 comments on commit e1ae96a

Please sign in to comment.