Skip to content

Commit

Permalink
feat: remove experimental man and epub outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantm committed Mar 16, 2024
1 parent cf25bd3 commit 45ca70c
Show file tree
Hide file tree
Showing 16 changed files with 2 additions and 274 deletions.
13 changes: 0 additions & 13 deletions doc/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ Given a table of contents Markdown file, and some other Markdown files, generate

* A single-page HTML document
* Multi-page HTML documents, with full-text search
* man pages (experimental)
* An ePub book (experimental)

```ShellSession
$ mmdoc project_name src_dir out_dir
Expand Down Expand Up @@ -35,17 +33,6 @@ and ouputs

```text
out
├── epub
│   └── OEBPS
│   └── index.xhtml
├── man
│   └── man1
│   ├── mmdoc-development.1
│   ├── mmdoc-features.1
│   ├── mmdoc-introduction.1
│   ├── mmdoc-license.1
│   └── mmdoc-usage.1
├── mmdoc.epub
├── multi
│   ├── development
│   │   └── index.html
Expand Down
47 changes: 1 addition & 46 deletions src/anchors.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ int mmdoc_anchors_locations(AnchorLocationArray *anchor_locations,
return -1;
}

char *man_path =
malloc(strlen(inputs.out_man) + 1 + strlen(inputs.project_name) +
strlen(al->file_path) + 2);

int dash_count = 0;
for (int k = 0; *(al->file_path + strlen(inputs.src) + k) != '\0'; k++) {
char *c = al->file_path + strlen(inputs.src) + k;
Expand All @@ -123,48 +119,7 @@ int mmdoc_anchors_locations(AnchorLocationArray *anchor_locations,
if (c[0] == '-')
dash_count++;
}
char *man_page_name = malloc(strlen(inputs.project_name) +
strlen(al->file_path) + dash_count + 1);
man_page_name[0] = '\0';
strcpy(man_path, inputs.out_man);
strcat(man_path, "/");
strcat(man_path, inputs.project_name);
strcpy(man_page_name, inputs.project_name);
for (int k = 0; *(al->file_path + strlen(inputs.src) + k) != '\0'; k++) {
char *c = al->file_path + strlen(inputs.src) + k;
if (c[0] == '/') {
strcat(man_path, "-");
strcat(man_page_name, "\\-");
} else if (c[0] == '-') {
strncat(man_path, c, 1);
strcat(man_page_name, "\\-");
} else {
strncat(man_path, c, 1);
strncat(man_page_name, c, 1);
}
}
lastExt = strrchr(man_path, '.');
while (lastExt != NULL) {
*lastExt = '\0';
lastExt = strrchr(man_path, '.');
}
lastExt = strrchr(man_page_name, '.');
while (lastExt != NULL) {
*lastExt = '\0';
lastExt = strrchr(man_page_name, '.');
}
strcat(man_path, ".1");
al->man_output_file_path = man_path;
char *man_page_header =
malloc(19 + strlen(man_path) * 2 + strlen(inputs.project_name) + 1);
strcpy(man_page_header, ".TH \"");
strcat(man_page_header, man_page_name);
strcat(man_page_header, "\" \"1\" \"\" \"");
strcat(man_page_header, inputs.project_name);
strcat(man_page_header, "\" \"");
strcat(man_page_header, man_page_name);
strcat(man_page_header, "\"");
al->man_header = man_page_header;

insert_anchor_location_array(anchor_locations, al);
count++;
}
Expand Down
8 changes: 0 additions & 8 deletions src/asset.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* SPDX-License-Identifier: CC0-1.0 */
#include "a11y-dark.css.h"
#include "a11y-light.css.h"
#include "epub.css.h"
#include "fuse.basic.min.js.h"
#include "highlight.pack.js.h"
#include "mmdoc.css.h"
Expand Down Expand Up @@ -86,13 +85,6 @@ int asset_write_to_file_a11y_dark_css(FILE *file) {
___src_asset_a11y_dark_css_len);
}

extern unsigned char ___src_asset_epub_css[];
extern unsigned int ___src_asset_epub_css_len;
int asset_write_to_dir_epub_css(char *dir) {
return asset_write_to_dir(dir, "epub.css", ___src_asset_epub_css,
___src_asset_epub_css_len);
}

extern unsigned char ___src_asset_mmdoc_css[];
extern unsigned int ___src_asset_mmdoc_css_len;
int asset_write_to_file_mmdoc_css(FILE *file) {
Expand Down
4 changes: 0 additions & 4 deletions src/asset.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@

#include <stdio.h>

extern unsigned char ___src_asset_epub_css[];
extern unsigned int ___src_asset_epub_css_len;

int asset_write_to_dir_fuse_basic_min_js(char *dir);
int asset_write_to_dir_epub_css(char *dir);

int asset_write_to_file_a11y_dark_css(FILE *file);
int asset_write_to_file_a11y_light_css(FILE *file);
Expand Down
1 change: 0 additions & 1 deletion src/asset/epub.css

This file was deleted.

1 change: 0 additions & 1 deletion src/asset/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
assets = [
'epub.css',
'fuse.basic.min.js',
'highlight.pack.js',
'mmdoc.css',
Expand Down
1 change: 1 addition & 0 deletions src/asset/mmdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,4 @@ window.addEventListener('load', (event) => {
})
codeElems.forEach(e => e.classList.add('hljs'))
})

127 changes: 0 additions & 127 deletions src/epub.c

This file was deleted.

6 changes: 0 additions & 6 deletions src/epub.h

This file was deleted.

23 changes: 0 additions & 23 deletions src/inputs.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,12 @@ int mmdoc_inputs_derive(Inputs *inputs, char *argv[]) {
strcat(out_multi, multi);
inputs->out_multi = out_multi;

char *man = "/man/man1";
char *out_man = malloc(strlen(inputs->out) + 1 + strlen(man) + 1);
strcpy(out_man, inputs->out);
strcat(out_man, man);
if (mkdir_p(out_man) != 0) {
printf("Error recursively making directory %s", out_man);
return -1;
}
inputs->out_man = out_man;

char *single = "single";
char *out_single = malloc(strlen(inputs->out) + 1 + strlen(single) + 1);
strcpy(out_single, inputs->out);
strcat(out_single, "/");
strcat(out_single, single);
inputs->out_single = out_single;

char *epub = "epub";
char *out_epub_dir = malloc(strlen(inputs->out) + 1 + strlen(epub) + 1);
sprintf(out_epub_dir, "%s/%s", inputs->out, epub);
inputs->out_epub_dir = out_epub_dir;

char *epub_ext = ".epub";
char *out_epub_file =
malloc(strlen(inputs->out) + 1 + strlen(inputs->project_name) +
strlen(epub_ext) + 1);
sprintf(out_epub_file, "%s/%s%s", inputs->out, inputs->project_name,
epub_ext);
inputs->out_epub_file = out_epub_file;

return 0;
}
3 changes: 0 additions & 3 deletions src/inputs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ typedef struct {
char *toc_path;
char *out_multi;
char *out_single;
char *out_man;
char *out_epub_dir;
char *out_epub_file;
} Inputs;

int mmdoc_inputs_derive(Inputs *inputs, char *argv[]);
25 changes: 0 additions & 25 deletions src/man.c

This file was deleted.

5 changes: 0 additions & 5 deletions src/man.h

This file was deleted.

2 changes: 0 additions & 2 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ src = [
'anchors.c',
'asset.c',
'html.c',
'epub.c',
'files.c',
'inputs.c',
'man.c',
'mkdir_p.c',
'multi.c',
'parse.c',
Expand Down
8 changes: 0 additions & 8 deletions src/mmdoc.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/* SPDX-License-Identifier: CC0-1.0 */
#include "anchors.h"
#include "epub.h"
#include "files.h"
#include "inputs.h"
#include "man.h"
#include "multi.h"
#include "refs.h"
#include "render.h"
Expand Down Expand Up @@ -67,12 +65,6 @@ int main(int argc, char *argv[]) {
if (0 != mmdoc_multi(inputs, toc_anchor_locations, anchor_locations))
return 1;

if (0 != mmdoc_man(inputs, toc_anchor_locations, anchor_locations))
return 1;

if (0 != mmdoc_epub(inputs, toc_anchor_locations))
return 1;

if (0 != copy_imgs(inputs))
return 1;

Expand Down
2 changes: 0 additions & 2 deletions src/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ typedef struct {
char *multipage_output_directory_path;
char *multipage_url;
char *multipage_base_href;
char *man_output_file_path;
char *man_header;
char *anchor;
char *title;
} AnchorLocation;
Expand Down

0 comments on commit 45ca70c

Please sign in to comment.