Skip to content

Commit f6bade3

Browse files
committed
feat: add asciidoc_html_build script
Signed-off-by: Sebastian Davids <[email protected]>
1 parent 728e641 commit f6bade3

24 files changed

+1179
-0
lines changed

LICENSES/MIT.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MIT License
2+
3+
Copyright (c) <year> <copyright holders>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

REUSE.toml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,52 @@ path = "scripts/cert/js/nodejs/.nvmrc"
3737
SPDX-FileCopyrightText = "© 2024 Sebastian Davids <[email protected]>"
3838
SPDX-License-Identifier = "Apache-2.0"
3939

40+
[[annotations]]
41+
path = "scripts/asciidoc/example-html/src/_includes/*.adoc"
42+
SPDX-FileCopyrightText = "© 2024 Sebastian Davids <[email protected]>"
43+
SPDX-License-Identifier = "Apache-2.0"
44+
45+
[[annotations]]
46+
path = "scripts/asciidoc/example-html/src/docinfo/*.html"
47+
SPDX-FileCopyrightText = "© 2024 Sebastian Davids <[email protected]>"
48+
SPDX-License-Identifier = "Apache-2.0"
49+
50+
[[annotations]]
51+
path = "scripts/asciidoc/example-html/src/css/font-awesome.css"
52+
SPDX-FileCopyrightText = "© 2012 Dave Gandy (http://fontawesome.io)"
53+
SPDX-License-Identifier = "MIT"
54+
55+
[[annotations]]
56+
path = "scripts/asciidoc/example-html/src/fonts/fontawesome-webfont-4.7.0.woff2"
57+
SPDX-FileCopyrightText = "© 2012 Dave Gandy (http://fontawesome.io)"
58+
SPDX-License-Identifier = "OFL-1.1"
59+
60+
[[annotations]]
61+
path = "scripts/asciidoc/example-html/src/fonts/source-code-pro-**"
62+
SPDX-FileCopyrightText = "© 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/)"
63+
SPDX-License-Identifier = "OFL-1.1"
64+
65+
[[annotations]]
66+
path = "scripts/asciidoc/example-html/src/fonts/source-sans-3-**"
67+
SPDX-FileCopyrightText = "© 2010-2020 Adobe (http://www.adobe.com/)"
68+
SPDX-License-Identifier = "OFL-1.1"
69+
70+
[[annotations]]
71+
path = "scripts/asciidoc/example-html/src/fonts/source-serif-4-**"
72+
SPDX-FileCopyrightText = "© 2014 - 2023 Adobe (http://www.adobe.com/)"
73+
SPDX-License-Identifier = "OFL-1.1"
74+
4075
[[annotations]]
4176
path = [
77+
"scripts/asciidoc/example-html/src/src/csv/data.csv",
4278
"scripts/asciidoc/example-pdf/src/src/csv/data.csv",
4379
]
4480
SPDX-FileCopyrightText = "© 2024 Sebastian Davids <[email protected]>"
4581
SPDX-License-Identifier = "Apache-2.0"
4682

4783
[[annotations]]
4884
path = [
85+
"scripts/asciidoc/example-html/src/images/dragonfly.jpg",
4986
"scripts/asciidoc/example-pdf/src/images/dragonfly.jpg",
5087
]
5188
SPDX-FileCopyrightText = "© 2017 Charles J. Sharp (https://www.sharpphotography.co.uk)"

docs/user-guide/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* xref:index.adoc[]
77
* xref:scripts/scripts.adoc[]
88
** xref:scripts/asciidoc/asciidoc.adoc[]
9+
*** xref:scripts/asciidoc/asciidoc-html-build.adoc[]
910
*** xref:scripts/asciidoc/asciidoc-pdf-build.adoc[]
1011
** xref:scripts/cert/cert.adoc[]
1112
*** Standalone
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
// SPDX-FileCopyrightText: © 2024 Sebastian Davids <[email protected]>
2+
// SPDX-License-Identifier: Apache-2.0
3+
= asciidoc_html_build
4+
:script_url: https://github.com/sdavids/sdavids-shell-misc/blob/main/scripts/asciidoc/asciidoc_html_build.sh
5+
:main_adoc_url: https://github.com/sdavids/sdavids-shell-misc/blob/main/scripts/asciidoc/example-html/src/main.adoc
6+
:docinfo_url: https://github.com/sdavids/sdavids-shell-misc/blob/main/scripts/asciidoc/example-html/src/docinfo/docinfo.html
7+
8+
{script_url}[This script^] will typeset the documents of a given source directory into HTML.
9+
10+
The following parameters are optional:
11+
12+
`f` :: delete the output directory before typesetting
13+
`n` :: turn caching off
14+
`o` :: the output directory (`$PWD/build` if not given)
15+
`s` :: the source directory (`$PWD/src` if not given)
16+
17+
[NOTE]
18+
====
19+
`*.adoc` files inside directories named `_includes` will not be typeset.
20+
21+
This is useful for https://docs.asciidoctor.org/asciidoc/latest/directives/include/#when-is-an-include-directive-useful[AsciiDoc includes].
22+
====
23+
24+
[NOTE]
25+
====
26+
This scripts configures Asciidoctor
27+
to not use https://docs.asciidoctor.org/asciidoctor/latest/html-backend/default-stylesheet/#disable-or-modify-the-web-fonts[webfonts],
28+
use https://docs.asciidoctor.org/asciidoctor/latest/html-backend/local-font-awesome/#switch-to-your-local-font-awesome-assets[local FontAwesome assets],
29+
https://docs.asciidoctor.org/asciidoctor/latest/html-backend/manage-images/#embed-images-with-the-data-uri-attribute[embed images], and
30+
https://docs.asciidoctor.org/asciidoctor/latest/html-backend/custom-stylesheet/#stylesdir-and-linkcss[inline CSS].
31+
====
32+
33+
[NOTE]
34+
====
35+
If you want to use custom fonts, this script assumes that the `woff2` fonts are found in the `<source directory>/fonts` directory.
36+
====
37+
38+
[TIP]
39+
====
40+
Depending on your use case, you might want to use https://docs.antora.org/antora/latest/[Antora] instead of this script.
41+
====
42+
43+
== Usage
44+
45+
[,shell]
46+
----
47+
$ tree --noreport -I scripts
48+
.
49+
└── src
50+
└── index.adoc
51+
$ scripts/asciidoc/asciidoc_html_build.sh
52+
$ tree --noreport -I scripts
53+
.
54+
├── build
55+
│ └── index.html <1>
56+
└── src
57+
└── index.adoc
58+
59+
$ tree --noreport -a /tmp/example
60+
/tmp/example
61+
└── src
62+
├── _includes
63+
│ └── footer.adoc
64+
├── a
65+
│ ├── b
66+
│ │ └── sub.adoc
67+
│ └── dir.adoc
68+
├── css
69+
│ └── font-awesome.css <2>
70+
├── docinfo
71+
│ └── docinfo.html <3>
72+
├── fonts
73+
│ └── fontawesome-webfont-4.7.0.woff2 <2>
74+
└── index.adoc
75+
$ cat /tmp/example/src/docinfo/docinfo.html <3>
76+
<style>
77+
pre.rouge .hll { <4>
78+
background-color: #ffffe0;
79+
display: block;
80+
}
81+
pre.rouge .hll * { <4>
82+
background-color: initial;
83+
}
84+
</style>
85+
$ cat /tmp/example/src/a/b/sub.adoc
86+
= 1. sub
87+
:source-highlighter: rouge <4>
88+
:rouge-style: github
89+
:docinfo: shared <3>
90+
:docinfodir: ../../docinfo <3>
91+
92+
[NOTE] <2>
93+
====
94+
Test
95+
====
96+
97+
[plantuml] <5>
98+
....
99+
@startuml
100+
101+
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
102+
103+
Person(p, "Support")
104+
105+
System(s, "Test System")
106+
107+
Rel(p, s, "Uses", "https")
108+
109+
@enduml
110+
....
111+
112+
[,shell,highlight=2..3;5] <4>
113+
....
114+
A
115+
B
116+
C
117+
D
118+
E
119+
F
120+
G
121+
....
122+
123+
includes::../../_includes/footer.adoc[]
124+
$ scripts/asciidoc/asciidoc_html_build.sh -s /tmp/example/src -o /tmp/example/out
125+
$ tree --noreport -a /tmp/example -I src
126+
/tmp/example
127+
└── out <6>
128+
├── a
129+
│ ├── b
130+
│ │ ├── .asciidoctor <8>
131+
│ │ │ └── diagram
132+
│ │ │ └── diag-plantuml-md5-757a0ec403d52693302a4f18fd7ec102.png.cache
133+
│ │ ├── css
134+
│ │ │ └── font-awesome.css <7>
135+
│ │ ├── diag-plantuml-md5-757a0ec403d52693302a4f18fd7ec102.png <8>
136+
│ │ ├── fonts
137+
│ │ │ └── fontawesome-webfont-4.7.0.woff2 <7>
138+
│ │ └── sub.html
139+
│ ├── css
140+
│ │ └── font-awesome.css <7>
141+
│ ├── dir.html
142+
│ └── fonts
143+
│ └── fontawesome-webfont-4.7.0.woff2 <7>
144+
├── css
145+
│ └── font-awesome.css <7>
146+
├── fonts
147+
│ └── fontawesome-webfont-4.7.0.woff2 <7>
148+
└── index.html
149+
$ scripts/asciidoc/asciidoc_html_build.sh -s /tmp/example/src -o /tmp/example/out -f -n
150+
$ tree --noreport -a /tmp/example -I src
151+
/tmp/example
152+
└── out <9>
153+
├── a
154+
│ ├── b
155+
│ │ ├── css
156+
│ │ │ └── font-awesome.css
157+
│ │ ├── fonts
158+
│ │ │ └── fontawesome-webfont-4.7.0.woff2
159+
│ │ └── sub.html
160+
│ ├── css
161+
│ │ └── font-awesome.css
162+
│ ├── dir.html
163+
│ └── fonts
164+
│ └── fontawesome-webfont-4.7.0.woff2
165+
├── css
166+
│ └── font-awesome.css
167+
├── fonts
168+
│ └── fontawesome-webfont-4.7.0.woff2
169+
└── index.html
170+
----
171+
172+
<1> the typeset HTML
173+
<2> https://docs.asciidoctor.org/asciidoc/latest/blocks/admonitions/[admonitions] need https://docs.asciidoctor.org/asciidoctor/latest/html-backend/local-font-awesome/[Font Awesome]
174+
<3> https://docs.asciidoctor.org/asciidoc/latest/docinfo[custom styles]
175+
<4> use https://docs.asciidoctor.org/asciidoc/latest/verbatim/highlight-lines/#rouge[Rogue source highlighter]
176+
<5> a document with an https://docs.asciidoctor.org/diagram-extension/latest/diagram_types/plantuml/[PlantUML diagram]
177+
<6> notice there is no `footer.html` in an `_includes` directory
178+
<7> Asciidoctor currently https://github.com/asciidoctor/asciidoctor/issues/4622[does not support a nested set of documents] well
179+
<8> the files of the https://docs.asciidoctor.org/diagram-extension/latest/generate/#diagram_caching[diagram cache]
180+
<9> the output directory has been cleaned (`-f`) and no files for the cache have been created (`-n`)
181+
182+
[#asciidoc-html-build-example]
183+
== Example
184+
185+
{main_adoc_url}[main.adoc],
186+
{docinfo_url}[docinfo.html]
187+
188+
[,console]
189+
----
190+
$ cd scripts/asciidoc/example-html
191+
$ ../asciidoc_html_build.sh
192+
----
193+
194+
=> `build/main.html`
195+
196+
== Prerequisites
197+
198+
* xref:developer-guide::dev-environment/dev-installation.adoc#docker[Docker]
199+
200+
== Related Scripts
201+
202+
* xref:scripts/asciidoc/asciidoc-pdf-build.adoc[]
203+
204+
== More Information
205+
206+
* https://github.com/asciidoctor/docker-asciidoctor[docker-asciidoctor]
207+
* https://asciidoctor.org[Asciidoctor]
208+
* https://docs.asciidoctor.org/asciidoc/latest/[AsciiDoc]
209+
* https://docs.asciidoctor.org/asciidoc/latest/docinfo[Docinfo Files]
210+
* https://docs.asciidoctor.org/asciidoctor/latest/html-backend/default-stylesheet/#disable-or-modify-the-web-fonts[Disable or modify the web fonts]
211+
* https://docs.asciidoctor.org/asciidoctor/latest/html-backend/local-font-awesome/[Use Local Font Awesome]

docs/user-guide/modules/ROOT/pages/scripts/asciidoc/asciidoc-pdf-build.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ Typeset PDF: xref:attachment$asciidoc/main.pdf[main.pdf]
174174

175175
== Related Scripts
176176

177+
* xref:scripts/asciidoc/asciidoc-html-build.adoc[]
177178
* xref:scripts/pdf/pdf-remove-metadata.adoc[]
178179
+
179180
[,shell]

docs/user-guide/modules/ROOT/pages/scripts/asciidoc/asciidoc.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44

55
This section contains scripts related to https://docs.asciidoctor.org/asciidoc/latest/[AsciiDoc]:
66

7+
xref:scripts/asciidoc/asciidoc-html-build.adoc[]:: typeset the documents of a given directory into HTML
78
xref:scripts/asciidoc/asciidoc-pdf-build.adoc[]:: typeset the documents of a given directory into PDFs

0 commit comments

Comments
 (0)