diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-08-26 15:29:58 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-08-26 15:30:42 -0400 |
commit | 43020d3bbd07f6583d4385e361b974c899389b70 (patch) | |
tree | 5eae968c857558350d114911406f67a861650661 | |
parent | b91f8c354b60f9db22d4ad65a1e6f72b13c8b693 (diff) | |
download | stasis-43020d3bbd07f6583d4385e361b974c899389b70.tar.gz |
Tweak pandoc command and add a style sheet
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/stasis_indexer.c | 25 | ||||
-rw-r--r-- | stasis_pandoc.css | 232 |
3 files changed, 252 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f358b22..abb700c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,5 +35,6 @@ endif() set(SYSCONFDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_SYSCONFDIR}") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/config.h @ONLY) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/stasis_pandoc.css DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/stasis) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/stasis.ini DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/stasis) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/mission DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/stasis) diff --git a/src/stasis_indexer.c b/src/stasis_indexer.c index 4f57a86..34f8ecf 100644 --- a/src/stasis_indexer.c +++ b/src/stasis_indexer.c @@ -119,12 +119,7 @@ int indexer_load_metadata(struct Delivery *ctx, const char *filename) { } else if (!strcmp(name, "codename")) { ctx->meta.codename = strdup(value); } else if (!strcmp(name, "platform")) { - ctx->system.platform = calloc(DELIVERY_PLATFORM_MAX, sizeof(*ctx->system.platform)); - char **platform = split(value, " ", 0); - ctx->system.platform[DELIVERY_PLATFORM] = platform[DELIVERY_PLATFORM]; - ctx->system.platform[DELIVERY_PLATFORM_CONDA_SUBDIR] = platform[DELIVERY_PLATFORM_CONDA_SUBDIR]; - ctx->system.platform[DELIVERY_PLATFORM_CONDA_INSTALLER] = platform[DELIVERY_PLATFORM_CONDA_INSTALLER]; - ctx->system.platform[DELIVERY_PLATFORM_RELEASE] = platform[DELIVERY_PLATFORM_RELEASE]; + ctx->system.platform = split(value, " ", 0); } else if (!strcmp(name, "arch")) { ctx->system.arch = strdup(value); } else if (!strcmp(name, "time")) { @@ -238,6 +233,15 @@ int indexer_make_website(struct Delivery *ctx) { return 0; } + char *css_filename = calloc(PATH_MAX, sizeof(*css_filename)); + if (!css_filename) { + SYSERROR("unable to allocate string for CSS file path: %s", strerror(errno)); + return -1; + } + + sprintf(css_filename, "%s/%s", globals.sysconfdir, "stasis_pandoc.css"); + int have_css = access(css_filename, F_OK | R_OK) == 0; + struct StrList *dirs = strlist_init(); strlist_append(&dirs, ctx->storage.delivery_dir); strlist_append(&dirs, ctx->storage.results_dir); @@ -269,7 +273,16 @@ int indexer_make_website(struct Delivery *ctx) { // Converts a markdown file to html strcpy(cmd, "pandoc "); + strcat(cmd, "--embed-resources "); strcat(cmd, "--standalone "); + strcat(cmd, "-f markdown+alerts "); + strcat(cmd, "-f markdown+autolink_bare_uris "); + if (have_css) { + strcat(cmd, "--css "); + strcat(cmd, css_filename); + } + strcat(cmd, " "); + strcat(cmd, "--metadata title=\"STASIS\" "); strcat(cmd, "-o "); strcat(cmd, fullpath_dest); strcat(cmd, " "); diff --git a/stasis_pandoc.css b/stasis_pandoc.css new file mode 100644 index 0000000..456c3e9 --- /dev/null +++ b/stasis_pandoc.css @@ -0,0 +1,232 @@ +/* Modified pandoc defaults */ + +html { + color: #1a1a1a; + background-color: #fdfdfd; +} + +body { + margin: 0 auto; + max-width: 50%; + padding-left: 50px; + padding-right: 50px; + padding-top: 50px; + padding-bottom: 50px; + hyphens: auto; + overflow-wrap: break-word; + text-rendering: optimizeLegibility; + font-kerning: normal; +} + +@media (max-width: 600px) { + body { + font-size: 0.9em; + padding: 12px; + } + + h1 { + font-size: 1.8em; + } +} + +@media print { + html { + background-color: white; + } + + body { + background-color: transparent; + color: black; + font-size: 12pt; + } + + p, + h2, + h3 { + orphans: 3; + widows: 3; + } + + h2, + h3, + h4 { + page-break-after: avoid; + } +} + +p { + margin: 1em 0; +} + +/* Use browser defaults +a { +color: #1a1a1a; +} +a:visited { +color: #1a1a1a; +} +*/ +img { + max-width: 100%; +} + +svg { + height: auto; + max-width: 100%; +} + +h1, +h2, +h3, +h4, +h5, +h6 { + margin-top: 1.4em; +} + +h5, +h6 { + font-size: 1em; + font-style: italic; +} + +h6 { + font-weight: normal; +} + +ol, +ul { + padding-left: 1.7em; + margin-top: 1em; +} + +li>ol, +li>ul { + margin-top: 0; +} + +blockquote { + margin: 1em 0 1em 1.7em; + padding-left: 1em; + border-left: 2px solid #e6e6e6; + color: #606060; +} + +code { + font-family: Menlo, Monaco, Consolas, 'Lucida Console', monospace; + font-size: 90%; + margin: 0; + hyphens: manual; +} + +pre { + margin: 1em 0; + overflow: auto; +} + +pre code { + padding: 0; + overflow: visible; + overflow-wrap: normal; +} + +.sourceCode { + background-color: transparent; + overflow: visible; +} + +hr { + background-color: #1a1a1a; + border: none; + height: 1px; + margin: 1em 0; +} + +table { + margin: 1em 0; + border-collapse: collapse; + width: 100%; + overflow-x: auto; + display: block; + font-variant-numeric: lining-nums tabular-nums; +} + +table caption { + margin-bottom: 0.75em; +} + +tbody { + margin-top: 0.5em; + border-top: 1px solid #1a1a1a; + border-bottom: 1px solid #1a1a1a; +} + +th { + border-top: 1px solid #1a1a1a; + padding: 0.25em 0.5em 0.25em 0.5em; +} + +td { + padding: 0.125em 0.5em 0.25em 0.5em; +} + +header { + margin-bottom: 4em; + text-align: center; +} + +#TOC li { + list-style: none; +} + +#TOC ul { + padding-left: 1.3em; +} + +#TOC>ul { + padding-left: 0; +} + +#TOC a:not(:hover) { + text-decoration: none; +} + +code { + white-space: pre-wrap; +} + +span.smallcaps { + font-variant: small-caps; +} + +div.columns { + display: flex; + gap: min(4vw, 1.5em); +} + +div.column { + flex: auto; + overflow-x: auto; +} + +div.hanging-indent { + margin-left: 1.5em; + text-indent: -1.5em; +} + +ul.task-list[class] { + list-style: none; +} + +ul.task-list li input[type="checkbox"] { + font-size: inherit; + width: 0.8em; + margin: 0 0.8em 0.2em -1.6em; + vertical-align: middle; +} + +.display.math { + display: block; + text-align: center; + margin: 0.5rem auto; +}
\ No newline at end of file |