github.com/anakojm/hugo-katex@v0.0.0-20231023141351-42d6f5de9c0b/markup/asciidocext/convert.go (about) 1 // Copyright 2020 The Hugo Authors. All rights reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // http://www.apache.org/licenses/LICENSE-2.0 7 // 8 // Unless required by applicable law or agreed to in writing, software 9 // distributed under the License is distributed on an "AS IS" BASIS, 10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 // Package asciidocext converts AsciiDoc to HTML using Asciidoctor 15 // external binary. The `asciidoc` module is reserved for a future golang 16 // implementation. 17 package asciidocext 18 19 import ( 20 "github.com/gohugoio/hugo/htesting" 21 "github.com/gohugoio/hugo/markup/asciidocext/internal" 22 "github.com/gohugoio/hugo/markup/converter" 23 ) 24 25 // Provider is the package entry point. 26 var Provider converter.ProviderProvider = provider{} 27 28 type provider struct{} 29 30 func (p provider) New(cfg converter.ProviderConfig) (converter.Provider, error) { 31 return converter.NewProvider("asciidocext", func(ctx converter.DocumentContext) (converter.Converter, error) { 32 return &internal.AsciidocConverter{ 33 Ctx: ctx, 34 Cfg: cfg, 35 }, nil 36 }), nil 37 } 38 39 // Supports returns whether Asciidoctor is installed on this computer. 40 func Supports() bool { 41 hasBin := internal.HasAsciiDoc() 42 if htesting.SupportsAll() { 43 if !hasBin { 44 panic("asciidoctor not installed") 45 } 46 return true 47 } 48 return hasBin 49 }