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

feat(validator): validate manpage document #545

Merged
merged 1 commit into from
Apr 19, 2020
Merged
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
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
run:
skip-dirs:
- pkg/parser/includes
- pkg/renderer/html5/includes
- test/includes
skip-files:
- pkg/parser/parser.go # generated

Expand All @@ -10,6 +9,7 @@ linters:
- megacheck
- govet
- gocyclo
- unused
enable-all: false
disable:
- maligned
Expand Down
16 changes: 14 additions & 2 deletions libasciidoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/bytesparadise/libasciidoc/pkg/renderer"
htmlrenderer "github.com/bytesparadise/libasciidoc/pkg/renderer/html5"
"github.com/bytesparadise/libasciidoc/pkg/types"
"github.com/bytesparadise/libasciidoc/pkg/validator"
"github.com/pkg/errors"

log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -57,8 +58,19 @@ func ConvertToHTML(r io.Reader, output io.Writer, config configuration.Configura
if err != nil {
return types.Metadata{}, err
}
rendererCtx := renderer.NewContext(doc, config)
metadata, err := htmlrenderer.Render(rendererCtx, doc, output)
// validate the document
problems := validator.Validate(&doc)
for _, problem := range problems {
switch problem.Severity {
case validator.Error:
log.Error(problem.Message)
case validator.Warning:
log.Warn(problem.Message)
}
}
// render
ctx := renderer.NewContext(doc, config)
metadata, err := htmlrenderer.Render(ctx, doc, output)
if err != nil {
return types.Metadata{}, err
}
Expand Down
Loading