Documentation ¶
Overview ¶
Copyright (c) 2022, Caltech All rights not granted herein are expressly reserved by Caltech.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Index ¶
Constants ¶
const ( // Version of package Version = "0.0.1" License = `` /* 1524-byte string literal not displayed */ )
Variables ¶
var ( // DefaultExtTypes maps file extensions to document types. This allows the "to", "from" // Pandoc options to be set based on file extension. This can be overwritten by setting // `.ext_types` in the JSON configuraiton file. DefaultExtTypes = map[string]string{ ".md": "markdown", ".html": "html5", } )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Port defaults to 3030, it is the port number that pandoc-server listens on Port string `json:"port,omitempty"` // From is the doc type you are converting from, e.g. markdown From string `json:"from,omitempty"` // To is the doc type you are converting to, e.g. html5 To string `json:"to,omitempty"` // // For the following fields see https://pandoc.org/pandoc-server.html#root-endpoint // ShiftHeadingLevel int `json:"shift-heading-level-by,omitempty"` IdentedCodeClasses []string `json:"indented-code-classes,omitempty"` DefaultImageExtension string `json:"default-image-extension,omitempty"` Metadata string `json:"metadata,omitempty"` TabStop int `json:"tab-stop,omitempty"` TrackChanges string `json:"track-changes,omitempty"` Abbreviations []string `json:"abbreviations,omitempty"` Standalone bool `json:"standalone,omitempty"` Text string `json:"text,omitempty"` Template string `json:"template,omitempty"` Variables map[string]interface{} `json:"variables,omitempty"` DPI int `json:"dpi,omitemtpy"` Wrap string `json:"wrap,omitempty"` Columns int `json:"columns,omitempty"` TableOfContents bool `json:"table-of-contents,omitempty"` TOCDepth int `json:"toc-depth,omitempty"` StripComments bool `json:"strip-comments,omitempty"` HighlightStyle string `json:"highlight-style,omitempty"` EmbedResources string `json:"embed-resources,omitempty"` HTMLQTags bool `json:"html-q-tags,omitempty"` Ascii bool `json:"ascii,omitempty"` ReferenceLinks bool `json:"reference-links,omitempty"` ReferenceLocation string `json:"reference-location,omitempty"` SetExtHeaders string `json:"setext-headers,omitempty"` TopLevelDivision string `json:"top-level-division,omitempty"` NumberSections string `json:"number-sections,omitempty"` NumberOffset []int `json:"number-offset,omitempty"` HTMLMathMethod string `json:"html-math-method,omitempty"` Listings bool `json:"listings,omitempty"` Incremental bool `json:"incremental,omitempty"` SideLevel int `json:"slide-level,omitempty"` SectionDivs bool `json:"section-divs,omitempty"` EmailObfuscation string `json:"email-obfuscation,omitempty"` IdentifierPrefix string `json:"identifier-prefix,omitempty"` TitlePrefix string `json:"title-prefix,omitempty"` ReferenceDoc string `json:"reference-doc,omitempty"` EPubCoverImage string `json:"epub-cover-image,omitempty"` EPubMetadata string `json:"epub-metadata,omitempty"` EPubChapterLevel int `json:"epub-chapter-level,omitempty"` EPubSubdirectory string `json:"epub-subdirectory,omitempty"` EPubFonts string `json:"epub-fonts,omitempty"` IpynbOutput string `json:"ipynb-output,omitempty"` Citeproc bool `json:"citeproc,omitempty"` Bibliography []string `json:"bibliography,omitempty"` Csl string `json:"csl,omitempty"` CiteMethod string `json:"cite-method,omitempty"` Files []string `json:files,omitempty"` // Verbose if set true then include logging on success as well as error Verbose bool }
func Load ¶
Load will read a JSON file containing config attributes and return a config struct and error.
func (*Config) Convert ¶
Pandoc a takes the configuration settings and sends a request to the Pandoc server with contents read from the io.Reader and returns a slice of bytes and error.
```
// Setup our client configuration cfg := pandoc_client.Config{ Standalone: true, From: "markdown", To: "html5", } src, err := os.ReadFile("htdocs/index.md") // ... handle error txt, err := cfg.Convert(bytes.NewReader(src)) if err := os.WriteFile("htdocs/index.html", src, 0664); err != nil { // ... handle error }
```
func (*Config) RootEndpoint ¶
RootEndpoint takes content type and sends the request to the Pandoc Server Root end point based on the state of configuration struct used.