-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsoupault.toml
157 lines (115 loc) · 3.86 KB
/
soupault.toml
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
### Configuration file for the soupault website generator ###
## Global settings
[settings]
# This configuration only works with soupault 4.0.0 or later
soupault_version = "4.0.0"
strict = true
verbose = true
debug = true
# Force "clean URLs", i.e. book/foo.md becomes build/foo/index.html
# (Clean URLs is the default, you can set it to false if you don't like it)
clean_urls = true
# Where generated files go
build_dir = "build"
# Where page files are stored
site_dir = "book/"
# Where in the template the page content is inserted
default_content_selector = "main"
default_template_file = "templates/main.html"
# Page considered the section index
index_page = "index"
# Files that are considered pages and processed
# All other files are considered assets and copied unchanged
page_file_extensions = ["html", "md"]
doctype = "<!DOCTYPE html>"
## Preprocessors convert non-HTML files to HTML
## for further processing by soupault
[preprocessors]
md = "pandoc -f commonmark+smart -t html"
# Removes the chapter number from the output path
# e.g. book/00_preface.md becomes build/preface/
[hooks.pre-process]
lua_source = '''
target_file_name = Sys.basename(target_file)
target_page_dir = Sys.basename(target_dir)
target_page_parent_dir = Sys.dirname(target_dir)
target_page_dir = Regex.replace(target_page_dir, "^\\d+_", "")
target_dir = Sys.join_path(target_page_parent_dir, target_page_dir)
target_file = Sys.join_path(target_dir, target_file_name)
Log.debug(format("Target file name set to \"%s\"", target_file))
'''
##
[hooks.post-index]
lua_source = '''
Log.debug("Extracting chapter number")
page_file_name = Sys.basename(page_file)
res = Regex.find_all(page_file_name, "^(\\d+)")
if res then
chapter_number = res[1]
else
chapter_number = 0
end
index_fields["chapter_number"] = format("%s", chapter_number)
Log.debug(format("Extracted chapter number: %s", chapter_number))
'''
[index]
index = true
# Make the index data available even to content pages,
# at cost of making a reduced first pass to extract that data before the "real" build
# This is to generate the sidebar with the chapter list on every page
index_first = true
sort_by = "chapter_number"
sort_type = "numeric"
sort_descending = false
[index.fields]
title = { selector = "h1" }
## Widgets
# Takes the content of the first <h1> and inserts it into the <title>
[widgets.page-title]
widget = "title"
selector = "h1"
default = "Sample book"
append = " — Sample book"
# Moves all elements with class="footnote" to <div id="footnotes">
# and replaces them with numbered links.
[widgets.footnotes]
widget = "footnotes"
selector = "div#footnotes"
footnote_selector = ["fn", ".footnote"]
footnote_link_class = "footnote"
# From plugins/footnotes-cleanup.lua
# Removes the <div> meant for footnotes if there are no footnotes in the chapter
[widgets.footnotes-container-cleanup]
widget = "footnotes-cleanup"
after = "footnotes"
footnote_link_selector = "a.footnote"
footnotes_container_selector = "div#footnotes"
[widgets.table-of-contents]
exclude_page = "index.md"
widget = "toc"
selector = "div#toc"
action = "append_child"
min_level = 2
toc_list_class = "toc"
toc_class_levels = false
numbered_list = true
heading_links = true
heading_link_text = "→ "
heading_link_class = "here"
use_heading_slug = true
[widgets.insert-chapters-index]
widget = "chapters-index"
index_selector = "div#chapters-index"
index_template = '''
<ul class="toc">
<li> <a href="/">About this book</a> </li>
{% for e in entries %}
<li> <a href="{{e.url}}">{{e.title}}</a> </li>
{% endfor %}
</ul>
'''
[widgets.cleanup-table-of-contents]
widget = "delete_element"
after = "table-of-contents"
selector = "div#toc"
only_if_empty = true