@mfgames-writing/format 3.2.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/build.d.ts +6 -2
- package/lib/cli.d.ts +1 -1
- package/lib/content.d.ts +1 -1
- package/lib/image.d.ts +4 -2
- package/lib/includes.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/markdown.d.ts +4 -2
- package/lib/markdown.d.ts.map +1 -1
- package/lib/markdown.js +14 -14
- package/lib/markdown.js.map +1 -1
- package/lib/plugins.d.ts +6 -2
- package/lib/tests/OverrideTheme.d.ts +11 -3
- package/lib/tests/overrides-theme.d.ts +1 -1
- package/lib/tests/theme-overrides.test.d.ts +1 -1
- package/package.json +3 -2
package/lib/build.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
export declare function runBuild(
|
|
2
|
-
|
|
1
|
+
export declare function runBuild(
|
|
2
|
+
argv: any,
|
|
3
|
+
packageJson: any,
|
|
4
|
+
logger: any
|
|
5
|
+
): Promise<any>;
|
|
6
|
+
//# sourceMappingURL=build.d.ts.map
|
package/lib/cli.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=cli.d.ts.map
|
|
2
|
+
//# sourceMappingURL=cli.d.ts.map
|
package/lib/content.d.ts
CHANGED
|
@@ -13,4 +13,4 @@ export declare function loadContents(args: EditionArgs): Promise<EditionArgs>;
|
|
|
13
13
|
* Renders the various content for inclusion with the format.
|
|
14
14
|
*/
|
|
15
15
|
export declare function renderContents(args: EditionArgs): Promise<EditionArgs>;
|
|
16
|
-
//# sourceMappingURL=content.d.ts.map
|
|
16
|
+
//# sourceMappingURL=content.d.ts.map
|
package/lib/image.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { ContentArgs } from "@mfgames-writing/contracts";
|
|
2
|
-
export declare function processImages(
|
|
3
|
-
|
|
2
|
+
export declare function processImages(
|
|
3
|
+
content: ContentArgs
|
|
4
|
+
): Promise<ContentArgs>;
|
|
5
|
+
//# sourceMappingURL=image.d.ts.map
|
package/lib/includes.d.ts
CHANGED
package/lib/index.d.ts
CHANGED
package/lib/markdown.d.ts
CHANGED
|
@@ -2,5 +2,7 @@ import { ContentArgs } from "@mfgames-writing/contracts";
|
|
|
2
2
|
/**
|
|
3
3
|
* Renders a Markdown file as HTML.
|
|
4
4
|
*/
|
|
5
|
-
export declare function renderContentMarkdown(
|
|
6
|
-
|
|
5
|
+
export declare function renderContentMarkdown(
|
|
6
|
+
content: ContentArgs
|
|
7
|
+
): Promise<ContentArgs>;
|
|
8
|
+
//# sourceMappingURL=markdown.d.ts.map
|
package/lib/markdown.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAyB,MAAM,4BAA4B,CAAC;AAKhF;;GAEG;AACH,wBAAgB,qBAAqB,CACjC,OAAO,EAAE,WAAW,GACrB,OAAO,CAAC,WAAW,CAAC,CA8JtB"}
|
package/lib/markdown.js
CHANGED
|
@@ -3,15 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.renderContentMarkdown = void 0;
|
|
4
4
|
const plugins_1 = require("./plugins");
|
|
5
5
|
const markdownIt = require("markdown-it");
|
|
6
|
+
const smartypants_1 = require("smartypants");
|
|
6
7
|
/**
|
|
7
8
|
* Renders a Markdown file as HTML.
|
|
8
9
|
*/
|
|
9
10
|
function renderContentMarkdown(content) {
|
|
10
11
|
return new Promise((resolve) => {
|
|
11
12
|
var _a;
|
|
12
|
-
// Set up a new markdown-it renderer with our defaults.
|
|
13
|
+
// Set up a new markdown-it renderer with our defaults. We don't include
|
|
14
|
+
// typographer because we use Smartypants instead which seems to handle
|
|
15
|
+
// some edge cases better.
|
|
13
16
|
var markdown = markdownIt({
|
|
14
|
-
typographer:
|
|
17
|
+
typographer: false,
|
|
15
18
|
xhtmlOut: true,
|
|
16
19
|
});
|
|
17
20
|
if (content.edition.markdown) {
|
|
@@ -44,6 +47,9 @@ function renderContentMarkdown(content) {
|
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
49
|
}
|
|
50
|
+
// First process the code using Smartypants.
|
|
51
|
+
content.logger.debug("formatting output with SmartyPants");
|
|
52
|
+
const formatted = (0, smartypants_1.smartypantsu)(content.text, 2);
|
|
47
53
|
// Set up the theme overrides.
|
|
48
54
|
setThemeRenderRule(content, content.theme.renderRule, markdown, "hr");
|
|
49
55
|
setThemeRenderRule(content, content.theme.renderStrongOpen, markdown, "strong_open");
|
|
@@ -53,19 +59,8 @@ function renderContentMarkdown(content) {
|
|
|
53
59
|
setThemeRenderRule(content, content.theme.renderCodeSpan, markdown, "code_inline");
|
|
54
60
|
setThemeRenderRule(content, content.theme.renderBlockQuoteOpen, markdown, "blockquote_open");
|
|
55
61
|
setThemeRenderRule(content, content.theme.renderBlockQuoteClose, markdown, "blockquote_close");
|
|
56
|
-
markdown.renderer.rules.paragraph = () => {
|
|
57
|
-
//content.logger.error("paragraph");
|
|
58
|
-
return "AAA";
|
|
59
|
-
};
|
|
60
62
|
// Process the markdown content.
|
|
61
|
-
let html = markdown.render(
|
|
62
|
-
// For some reason, certain authors like me insist on having a em-dash
|
|
63
|
-
// at the end of a quote to represent interruptions. However, the
|
|
64
|
-
// typography park of Marked doesn't really handle quotes properly in
|
|
65
|
-
// that case.
|
|
66
|
-
html = html.replace(/—“/g, "—”");
|
|
67
|
-
// We also have a problem with italics at the end of quotes.
|
|
68
|
-
html = html.replace(/<\/em>“/g, "</em>”");
|
|
63
|
+
let html = markdown.render(formatted);
|
|
69
64
|
// Markdown has an interesting quirk that a "break" is actually a
|
|
70
65
|
// backslash followed by a space. However, trailing spaces are difficult
|
|
71
66
|
// to work with when you use EditorConfig to remove trailing them
|
|
@@ -83,6 +78,11 @@ function renderContentMarkdown(content) {
|
|
|
83
78
|
// Return the results.
|
|
84
79
|
return `<p class="single-image"><img${i} /></p>`;
|
|
85
80
|
});
|
|
81
|
+
// See if the theme wants to be able to manipulate the HTML.
|
|
82
|
+
if (content.theme.transformHtml) {
|
|
83
|
+
content.logger.debug("applying theme transformations");
|
|
84
|
+
html = content.theme.transformHtml(content, html);
|
|
85
|
+
}
|
|
86
86
|
// Set the content and resolve this promise.
|
|
87
87
|
content.text = html;
|
|
88
88
|
resolve(content);
|
package/lib/markdown.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":";;;AAEA,uCAAuC;AACvC,0CAA0C;AAC1C,6CAA2C;AAE3C;;GAEG;AACH,SAAgB,qBAAqB,CACjC,OAAoB;IAEpB,OAAO,IAAI,OAAO,CAAc,CAAC,OAAO,EAAE,EAAE;;QACxC,wEAAwE;QACxE,uEAAuE;QACvE,0BAA0B;QAC1B,IAAI,QAAQ,GAAG,UAAU,CAAC;YACtB,WAAW,EAAE,KAAK;YAClB,QAAQ,EAAE,IAAI;SACjB,CAAC,CAAC;QAEH,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE;YAC1B,qCAAqC;YACrC,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE;gBAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAChB,wCAAwC,EACxC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CACnC,CAAC;gBACF,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;aAClD;YAED,gDAAgD;YACh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;YACzD,oCAAoC;YACpC,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBACzB,CAAC,IAAI,WAAW,CAAC;aACpB;YAED,wCAAwC;YACxC,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;YAEpD,sBAAsB;YACtB,OAAO,+BAA+B,CAAC,SAAS,CAAC;QACrD,CAAC,CAAC,CAAC;QAEH,4DAA4D;QAC5D,IAAI,OAAO,CAAC,KAAK,CAAC,aAAa,EAAE;YAC7B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;YACvD,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;SACrD;QAED,4CAA4C;QAC5C,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QAEpB,OAAO,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;AACP,CAAC;AAhKD,sDAgKC;AAED,SAAS,kBAAkB,CACvB,IAAiB,EACjB,QAA2C,EAC3C,QAAoB,EACpB,QAAgB;IAEhB,IAAI,CAAC,QAAQ,EAAE;QACX,OAAO;KACV;IAED,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAChC,MAAM,EACN,GAAG,EACH,OAAO,EACP,GAAG,EACH,QAAQ,EACV,EAAE;QACA,OAAO,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC/D,CAAC,CAAC;AACN,CAAC"}
|
package/lib/plugins.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { EditionArgs } from "@mfgames-writing/contracts";
|
|
2
|
-
export declare function loadModule(
|
|
3
|
-
|
|
2
|
+
export declare function loadModule(
|
|
3
|
+
args: EditionArgs,
|
|
4
|
+
name: string,
|
|
5
|
+
requireDefault?: boolean
|
|
6
|
+
): any;
|
|
7
|
+
//# sourceMappingURL=plugins.d.ts.map
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Theme,
|
|
4
|
+
EditionArgs,
|
|
5
|
+
ContentArgs,
|
|
6
|
+
ContentTheme,
|
|
7
|
+
} from "@mfgames-writing/contracts";
|
|
3
8
|
import Token = require("markdown-it/lib/token");
|
|
4
9
|
export declare class OverrideTheme implements Theme {
|
|
5
10
|
stylesheetFileName: string;
|
|
@@ -16,8 +21,11 @@ export declare class OverrideTheme implements Theme {
|
|
|
16
21
|
renderHtml(args: ContentArgs): Promise<ContentArgs>;
|
|
17
22
|
renderLayout(args: ContentArgs): Promise<ContentArgs>;
|
|
18
23
|
renderNavigationTitle(args: ContentArgs): string;
|
|
19
|
-
renderStylesheet(
|
|
24
|
+
renderStylesheet(
|
|
25
|
+
args: EditionArgs,
|
|
26
|
+
mode?: string | string[] | undefined
|
|
27
|
+
): Buffer;
|
|
20
28
|
renderTableOfContents(args: ContentArgs): Promise<ContentArgs>;
|
|
21
29
|
getContentTheme(content: ContentArgs): ContentTheme;
|
|
22
30
|
}
|
|
23
|
-
//# sourceMappingURL=OverrideTheme.d.ts.map
|
|
31
|
+
//# sourceMappingURL=OverrideTheme.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=theme-overrides.test.d.ts.map
|
|
2
|
+
//# sourceMappingURL=theme-overrides.test.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mfgames-writing/format",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "A command-line framework for formatting books into a variety of formats and themes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ebook",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"test": "jest"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@mfgames-writing/contracts": "^4.
|
|
43
|
+
"@mfgames-writing/contracts": "^4.4.0",
|
|
44
44
|
"fs-finder": "^1.8.1",
|
|
45
45
|
"incremental": "^1.0.1",
|
|
46
46
|
"jimp": "^0.3.5",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"mkdirp-promise": "^2.0.0",
|
|
54
54
|
"mz": "^2.7.0",
|
|
55
55
|
"read-pkg-up": "^4.0.0",
|
|
56
|
+
"smartypants": "^0.1.6",
|
|
56
57
|
"source-map-support": "^0.4.2",
|
|
57
58
|
"tracer": "^0.8.3",
|
|
58
59
|
"uuid": "^2.0.2",
|