Skip to content
webmaster442 edited this page Sep 18, 2021 · 1 revision

BookGen.Api

IReadOnlyAsset IReadOnlyBuildConfig
IReadOnlyConfig IReadonlyImageOptions
IReadOnlyMetadata IReadOnlyTemplateOptions
IReadOnlyTranslations IReadOnylStyleClasses
IArguments ILog
IScript IScriptHost
ITableOfContents Link
LogLevel

IReadOnlyAsset

Represents an asset that needs to be coppied to the output directory

Source

Source path not containing the root source folder

Target

Target path not containing the target root folder

IReadOnlyBuildConfig

Current build configuration

ImageOptions

Image processing options for this build configuration

OutPutDirectory

Config output directory

StyleClasses

Additional style classes that will be aplied

TemplateAssets

List of required assets

TemplateFile

Template file path

TemplateOptions

Additional template options

IReadOnlyConfig

Provides acces the current configuration

HostName

Host name

ImageDir

Images directory

Index

Index file

LinksOutSideOfHostOpenNewTab

Links that do not target the HostName open in new tabs

Metadata

Metadata information

ScriptsDirectory

Scripts folder

StopwordsFile

File containing list of stopwords to ignore, when generating chapter summary.

TargetEpub

Build configuration for epubs

TargetPrint

Build configuration for Printing

TargetWeb

Build configuration for static website

TargetWordpress

Build configuration for Wordpress export

TOCFile

Table of contents file

Translations

Translations

Version

Config file version

IReadonlyImageOptions

Image pipeline options

EnableResize

If set to true, then output images will be resized

EncodeSvgAsWebp

If set to true, then SVG images will be converted to WebP format

ImageQuality

WebP codec quality. Minimum 0 and maximum 100. Only used, when RecodeJpegToWebp enabled.

InlineImageSizeLimit

Inline images, that are smaller the given limit in bytes

MaxHeight

Maximal output image height when resize enabled or image is SVG

MaxWidth

Maximal output image width when resize enabled or image is SVG

RecodeJpegToWebp

If set to true, then JPEG images will be converted to WebP format

RecodePngToWebp

If set to true, then PNG images will be converted to WebP format

IReadOnlyMetadata

Metadata informations

Author

Atuhtor name

CoverImage

Cover Image

Title

Book title

IReadOnlyTemplateOptions

Template options.

TryGetOption``1(setting, value)

Tries to get an option from the config

Type Parameters

  • T - Option to cast to type
Name Description
setting System.String
Setting name
value ``0@
Casted setting value

Returns

true, if setting found and casted succesfully to target type, otherwise false

IReadOnlyTranslations

a Dictionary of key - value paris that can be used for translating

IReadOnylStyleClasses

Additional style classes that will be aplied to html elements during rendering

Blockquote

Style classed for Blockquote elements

Figure

Style classed for Figure elements

FigureCaption

Style classed for FigureCaption elements

Heading1

Style classed for H1 elements

Heading2

Style classed for H2 elements

Heading3

Style classed for H3 elements

Image

Img

Link

Style classed for A elements

ListItem

Style classed for Li elements

OrderedList

Style classed for Ol elements

Table

Style classed for Table elements

UnorederedList

Style classed for Ul elements

IArguments

Represents Arguments and values that are passed to the Script. Argument names are case insensitive.

ArgumentNames

Argument names -> all lowercase

GetArgumentOrFallback``1(argument, fallback)

Tries to get argument value and convert it to type. If argument not found fallback value will be returned

Type Parameters

  • T - Specifies conversion target type. Must implement IConvertible
Name Description
argument System.String
Argument to get
fallback ``0
Fallback value if argument not found

Returns

Argument value converted to type if found, otherwise the fallback value

GetArgumentOrThrow``1(argument)

Get argument value and convert it to type. If argument not found an exception will be thrown

Type Parameters

  • T - Specifies conversion target type. Must implement IConvertible
Name Description
argument System.String
Argument to get

Returns

Argument value converted to type.

System.ArgumentException:

HasArgument(name)

Checks if the specified argument name is in the collection or not.

Name Description
name System.String
Argument name to search

Returns

true, if argument name can be found, otherwise false

Item(System.Int32)

Get argument based on its index

Name Description
index Unknown type
Index of argument to get

Returns

The argument value at the specified index

ILog

Interface for logging. Provides methods that allow information logging to console.

Critical(ex)

Log a critical exception.

Name Description
ex System.Exception
Exception to log

Critical(format, args)

Log a Critical error. Critcal error is an error that causes the program to stop working

Name Description
format System.String
Message, a fomat string that can be handled by the String.Format method
args System.Object[]
Arguments for formatting

Detail(format, args)

Log a detail. Details are usually not important, so Details are only displayed when verbose output is enabled.

Name Description
format System.String
Message, a fomat string that can be handled by the String.Format method
args System.Object[]
Arguments for formatting

Info(format, args)

Log an iformational message. Informations give the user feedback about what is happening.

Name Description
format System.String
Message, a fomat string that can be handled by the String.Format method
args System.Object[]
Arguments for formatting

Log(logLevel, format, args)

Log a message

Name Description
logLevel BookGen.Api.LogLevel
Log level
format System.String
Message, a fomat string that can be handled by the String.Format method
args System.Object[]
Arguments for formatting

LogLevel

Current log level

PrintLine(obj)

Print an object

Name Description
obj System.Object
object to print

PrintLine(str)

Print a string, without formatting

Name Description
str System.String
string to print

Warning(ex)

Log a warning exception.

Name Description
ex System.Exception
Exception to log

Warning(format, args)

Log a warning message. Warning is an error that shouldn't happen idealy, but we are expecting it to occure.

Name Description
format System.String
Message, a fomat string that can be handled by the String.Format method
args System.Object[]
Arguments for formatting

IScript

Interface for scripts. Every Script must implement this interface.

InvokeName

Script name. Later you can reference the script as a shorcode with this name.

ScriptMain(host, arguments)

The main entrypoint of the script. It gets executed when parsing the shortcode.

Name Description
host BookGen.Api.IScriptHost
Current script host
arguments BookGen.Api.IArguments
Arguments for the script

Returns

Markdown string

IScriptHost

Interface for accesing the current script runtime

Configuration

Current configuration in read-only mode.

CurrentBuildConfig

Currently active build configuration

Log

Script host log

SourceDirectory

Source directory of input files

TableOfContents

Currently processed book table of contents

ITableOfContents

Interface for accesing the table of contents

Chapters

A flat list of chapters without hierarchy

Files

All files referenced in the Table of Contents

GetLinksForChapter(chapter)

Gets Links for a chapter

Name Description
chapter System.String
chapter name. Can be null. If null, all links returned from the TOC

Returns

Enumerable collection of HTMLLinks

Link

Represents a link in the Markdown Table of Contents.

Constructor(text, url)

Creates a new link

Name Description
text System.String
link text
url System.String
link url

ConvertToLinkOnHost(host)

Convert the link extension to .html file that can be referenced

Name Description
host System.String
Host link

Returns

A link on host

Text

Link text, that will be displayed.

Url

Link url

LogLevel

Logging level

Critical

Critical errors

Detail

Detailed info messages. Only visible when verbose

Info

Info messages

Warning

Warnings

Clone this wiki locally