all repos — hastyscribe @ 95181a83c7a4af9aacd9a69c4e43ec6d6b6a9ad3

A professional markdown compiler.

doc/-api.md

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
# Nim API

Besides its command libe, you can also import {{hs}} as a library within your [Nim](https://nim-lang.org) program.

## Types

{{hs}} exposes the following Nim types:

```
HastyOptions* = object
  toc*: bool
  input*: string
  output*: string
  css*: string
  js*: string
  watermark*: string
  fragment*: bool

HastyFields* = Table[string, proc():string]

HastySnippets* = Table[string, string]

HastyMacros* = Table[string, string]

HastyScribe* = object
  options: HastyOptions
  fields: HastyFields
  snippets: HastySnippets
  macros: HastyMacros
  document: string
```

## Procs

{{hs}} exposes the following [proc](class:kwd)s.

### newHastyScribe

     proc newHastyScribe*(options: HastyOptions, fields: HastyFields): HastyScribe

Instantiates a new {{hs}} object.

### dump

     proc dump*(hs: var HastyScribe, data="all", dest=".")

Saves linked resources to the [dest](class:dir) directory.

[data](class:kwd) can be set to one of the following values:

all
: Dumps all resource files.
styles
: Dumps all stylesheet files.
fonts
: Dumps all font files.

### compileFragment

     proc compileFragment*(hs: var HastyScribe, input, dir: string, toc = false): string {.discardable.}

Compiles the [input](class:kwd) markdown text into an HTML fragment, without embedding stylesheets or fonts. [dir](class:kwd) identifies the directory containing the input text (it is only used to resolve transclusions).

### compileDocument

     proc compileDocument*(hs: var HastyScribe, input, dir: string): string {.discardable.}

Compiles the [input](class:kwd) markdown text into a self-contained HTML document, embedding stylesheets and fonts. [dir](class:kwd) identifies the directory containing the input text (it is only used to resolve transclusions).

### compile

     proc compile*(hs: var HastyScribe, input_file: string)

Compiles the markdown file [input\_file](class:kwd) into a self-contained HTML document.