@diplodoc/transform 4.16.0 → 4.17.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/dist/css/print.css.map +1 -1
- package/dist/css/yfm.css +3 -0
- package/dist/css/yfm.css.map +3 -3
- package/dist/css/yfm.min.css +1 -1
- package/dist/css/yfm.min.css.map +3 -3
- package/lib/liquid/conditions.js +3 -1
- package/lib/liquid/conditions.js.map +1 -1
- package/lib/md.js +2 -3
- package/lib/md.js.map +1 -1
- package/lib/plugins/anchors/index.d.ts +1 -1
- package/lib/plugins/anchors/index.js +2 -2
- package/lib/plugins/anchors/index.js.map +1 -1
- package/lib/utils.d.ts +0 -4
- package/lib/utils.js +1 -9
- package/lib/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/scss/_cut.scss +2 -0
- package/src/transform/liquid/conditions.ts +3 -1
- package/src/transform/md.ts +2 -3
- package/src/transform/plugins/anchors/index.ts +4 -10
- package/src/transform/utils.ts +0 -16
|
@@ -76,7 +76,9 @@ function tailLinebreak(raw: string) {
|
|
|
76
76
|
|
|
77
77
|
function trimResult(content: string, ifTag: IfTag, ifCon: IfCondition | null) {
|
|
78
78
|
if (!ifCon) {
|
|
79
|
-
|
|
79
|
+
const head = headLinebreak(ifTag.rawStart);
|
|
80
|
+
const tail = tailLinebreak(ifTag.rawEnd);
|
|
81
|
+
return ifTag.isBlock ? '\n' : head + tail;
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
content = content.substring(ifCon.start, ifCon.end);
|
package/src/transform/md.ts
CHANGED
|
@@ -9,7 +9,6 @@ import attrs from 'markdown-it-attrs';
|
|
|
9
9
|
import extractTitle from './title';
|
|
10
10
|
import getHeadings from './headings';
|
|
11
11
|
import sanitizeHtml from './sanitize';
|
|
12
|
-
import {getDefaultPublicPath} from './utils';
|
|
13
12
|
|
|
14
13
|
function initMarkdownit(options: OptionsType) {
|
|
15
14
|
const {allowHTML = false, linkify = false, breaks = true, highlightLangs = {}} = options;
|
|
@@ -88,10 +87,10 @@ function initParser(md: MarkdownIt, options: OptionsType, env: EnvType) {
|
|
|
88
87
|
extractTitle: extractTitleOption,
|
|
89
88
|
needTitle,
|
|
90
89
|
needFlatListHeadings = false,
|
|
91
|
-
getPublicPath
|
|
90
|
+
getPublicPath,
|
|
92
91
|
} = options;
|
|
93
92
|
|
|
94
|
-
const href = getPublicPath(options);
|
|
93
|
+
const href = getPublicPath ? getPublicPath(options) : '';
|
|
95
94
|
|
|
96
95
|
let tokens = md.parse(input, env);
|
|
97
96
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {bold} from 'chalk';
|
|
2
2
|
import GithubSlugger from 'github-slugger';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {headingInfo} from '../../utils';
|
|
5
5
|
import {CUSTOM_ID_EXCEPTION, CUSTOM_ID_REGEXP} from './constants';
|
|
6
6
|
import StateCore from 'markdown-it/lib/rules_core/state_core';
|
|
7
7
|
import Token from 'markdown-it/lib/token';
|
|
@@ -76,17 +76,11 @@ interface Options {
|
|
|
76
76
|
extractTitle?: boolean;
|
|
77
77
|
supportGithubAnchors?: boolean;
|
|
78
78
|
transformLink: (v: string) => string;
|
|
79
|
-
getPublicPath
|
|
79
|
+
getPublicPath?: (options: Options, v?: string) => string;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
const index: MarkdownItPluginCb<Options> = (md, options) => {
|
|
83
|
-
const {
|
|
84
|
-
extractTitle,
|
|
85
|
-
path,
|
|
86
|
-
log,
|
|
87
|
-
supportGithubAnchors,
|
|
88
|
-
getPublicPath = getDefaultPublicPath,
|
|
89
|
-
} = options;
|
|
83
|
+
const {extractTitle, path, log, supportGithubAnchors, getPublicPath} = options;
|
|
90
84
|
|
|
91
85
|
const plugin = (state: StateCore) => {
|
|
92
86
|
/* Do not use the plugin if it is included in the file */
|
|
@@ -94,7 +88,7 @@ const index: MarkdownItPluginCb<Options> = (md, options) => {
|
|
|
94
88
|
return;
|
|
95
89
|
}
|
|
96
90
|
|
|
97
|
-
const href = getPublicPath(options, state.env.path);
|
|
91
|
+
const href = getPublicPath ? getPublicPath(options, state.env.path) : '';
|
|
98
92
|
|
|
99
93
|
const ids: Record<string, number> = {};
|
|
100
94
|
const tokens = state.tokens;
|
package/src/transform/utils.ts
CHANGED
|
@@ -102,19 +102,3 @@ export function defaultTransformLink(href: string) {
|
|
|
102
102
|
|
|
103
103
|
return href;
|
|
104
104
|
}
|
|
105
|
-
|
|
106
|
-
export function getDefaultPublicPath(
|
|
107
|
-
{
|
|
108
|
-
path,
|
|
109
|
-
transformLink,
|
|
110
|
-
}: {
|
|
111
|
-
path?: string;
|
|
112
|
-
transformLink?: (href: string) => string;
|
|
113
|
-
},
|
|
114
|
-
input?: string | null,
|
|
115
|
-
) {
|
|
116
|
-
const currentPath = input || path || '';
|
|
117
|
-
const transformer = transformLink || defaultTransformLink;
|
|
118
|
-
const href = transformer?.(currentPath) ?? currentPath;
|
|
119
|
-
return href;
|
|
120
|
-
}
|