securemark 0.241.0 → 0.243.1
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/CHANGELOG.md +12 -0
- package/dist/securemark.js +790 -613
- package/global.dev.d.ts +6 -2
- package/markdown.d.ts +60 -32
- package/package-lock.json +82 -56
- package/package.json +4 -3
- package/src/combinator/control/manipulation/indent.test.ts +3 -1
- package/src/combinator/control/manipulation/indent.ts +5 -4
- package/src/parser/block/blockquote.test.ts +4 -4
- package/src/parser/block/blockquote.ts +1 -7
- package/src/parser/block/codeblock.test.ts +27 -27
- package/src/parser/block/codeblock.ts +1 -1
- package/src/parser/block/extension/example.ts +1 -1
- package/src/parser/block/extension/fig.test.ts +3 -3
- package/src/parser/block/extension/fig.ts +7 -6
- package/src/parser/block/extension/figure.test.ts +24 -24
- package/src/parser/block/extension/figure.ts +79 -32
- package/src/parser/block/extension/message.test.ts +7 -7
- package/src/parser/block/extension/message.ts +5 -1
- package/src/parser/block/extension/placeholder.ts +2 -2
- package/src/parser/block/indentblock.test.ts +30 -0
- package/src/parser/block/indentblock.ts +13 -0
- package/src/parser/block/sidefence.test.ts +66 -0
- package/src/parser/block/sidefence.ts +31 -0
- package/src/parser/block/table.ts +2 -2
- package/src/parser/block.ts +7 -1
- package/src/parser/inline/extension/placeholder.ts +2 -2
- package/src/parser/processor/figure.ts +3 -3
- package/src/parser/processor/footnote.ts +1 -1
- package/src/renderer/render/media/twitter.ts +4 -4
- package/src/renderer/render.ts +3 -5
- package/src/util/info.ts +3 -7
|
@@ -12,9 +12,9 @@ export function* figure(
|
|
|
12
12
|
}> = {},
|
|
13
13
|
): Generator<HTMLAnchorElement | undefined, undefined, undefined> {
|
|
14
14
|
const refs = new MultiMap<string, HTMLAnchorElement>(push(push(push([],
|
|
15
|
-
target.querySelectorAll
|
|
16
|
-
footnotes?.annotations.querySelectorAll
|
|
17
|
-
footnotes?.references.querySelectorAll
|
|
15
|
+
target.querySelectorAll('a.label:not(.disabled)[data-label]')),
|
|
16
|
+
footnotes?.annotations.querySelectorAll('a.label:not(.disabled)') ?? []),
|
|
17
|
+
footnotes?.references.querySelectorAll('a.label:not(.disabled)') ?? [])
|
|
18
18
|
.map(el => [el.getAttribute('data-label')!, el]));
|
|
19
19
|
const labels = new Set<string>();
|
|
20
20
|
const numbers = new Map<string, string>();
|
|
@@ -42,7 +42,7 @@ function build(
|
|
|
42
42
|
const check = footnotes.some(el => target.contains(el));
|
|
43
43
|
let style: 'count' | 'abbr';
|
|
44
44
|
for (
|
|
45
|
-
let refs = target.querySelectorAll
|
|
45
|
+
let refs = target.querySelectorAll(`sup.${syntax}:not(.disabled)`),
|
|
46
46
|
i = 0, len = refs.length; i < len; ++i) {
|
|
47
47
|
yield;
|
|
48
48
|
const ref = refs[i];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { window, document } from 'spica/global';
|
|
2
2
|
import { parse } from '../../../parser';
|
|
3
|
-
import { html, define } from 'typed-dom/dom';
|
|
3
|
+
import { html as h, define } from 'typed-dom/dom';
|
|
4
4
|
import { sanitize } from 'dompurify';
|
|
5
5
|
|
|
6
6
|
declare global {
|
|
@@ -21,8 +21,8 @@ export function twitter(source: HTMLImageElement, url: URL): HTMLElement | undef
|
|
|
21
21
|
if (!origins.includes(url.origin)) return;
|
|
22
22
|
if (url.pathname.split('/').pop()!.includes('.')) return;
|
|
23
23
|
if (!url.pathname.match(/^\/\w+\/status\/[0-9]{15,}(?!\w)/)) return;
|
|
24
|
-
const el =
|
|
25
|
-
|
|
24
|
+
const el = h('div', { class: source.className, 'data-type': 'twitter' }, [
|
|
25
|
+
h('em', `Loading ${source.getAttribute('data-src')}...`),
|
|
26
26
|
]);
|
|
27
27
|
$.ajax(`https://publish.twitter.com/oembed?url=${url.href.replace('?', '&')}&omit_script=true`, {
|
|
28
28
|
dataType: 'jsonp',
|
|
@@ -33,7 +33,7 @@ export function twitter(source: HTMLImageElement, url: URL): HTMLElement | undef
|
|
|
33
33
|
if (window.twttr) return void window.twttr.widgets.load(el);
|
|
34
34
|
const id = 'twitter-wjs';
|
|
35
35
|
if (document.getElementById(id)) return;
|
|
36
|
-
document.body.appendChild(
|
|
36
|
+
document.body.appendChild(h('script', { id, src: 'https://platform.twitter.com/widgets.js' }));
|
|
37
37
|
},
|
|
38
38
|
error({ status, statusText }) {
|
|
39
39
|
assert(Number.isSafeInteger(status));
|
package/src/renderer/render.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { RenderingOptions } from '../../';
|
|
|
3
3
|
import { code } from './render/code';
|
|
4
4
|
import { math } from './render/math';
|
|
5
5
|
import { media } from './render/media';
|
|
6
|
+
import { querySelectorAll } from 'typed-dom/query';
|
|
6
7
|
import { reduce } from 'spica/memoize';
|
|
7
8
|
|
|
8
9
|
const selector = 'img.media:not(.invalid):not([src])[data-src], a > :not(img).media:not(.invalid), pre.code:not(.invalid), .math:not(.invalid)';
|
|
@@ -13,11 +14,8 @@ const extend = reduce((opts: RenderingOptions): RenderingOptions =>
|
|
|
13
14
|
export function render(source: HTMLElement, opts: RenderingOptions = {}): void {
|
|
14
15
|
opts = extend(opts);
|
|
15
16
|
const base = location.href;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
let es = source.querySelectorAll<HTMLElement>(selector),
|
|
19
|
-
i = 0, len = es.length; i < len; ++i) {
|
|
20
|
-
render_(base, es[i], opts);
|
|
17
|
+
for (const el of querySelectorAll<HTMLElement>(source, selector)) {
|
|
18
|
+
render_(base, el, opts);
|
|
21
19
|
}
|
|
22
20
|
}
|
|
23
21
|
|
package/src/util/info.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Info } from '../..';
|
|
2
2
|
import { scope } from './scope';
|
|
3
|
+
import { querySelectorAll } from 'typed-dom/query';
|
|
3
4
|
|
|
4
5
|
export function info(source: DocumentFragment | HTMLElement | ShadowRoot): Info {
|
|
5
6
|
const match = scope(source, '.invalid');
|
|
@@ -19,12 +20,7 @@ export function info(source: DocumentFragment | HTMLElement | ShadowRoot): Info
|
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
function find<T extends HTMLElement>(selector: string): T[] {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const el = es[i];
|
|
25
|
-
if (!match(el)) continue;
|
|
26
|
-
acc.push(el);
|
|
27
|
-
}
|
|
28
|
-
return acc;
|
|
23
|
+
return querySelectorAll<T>(source, selector)
|
|
24
|
+
.filter(match);
|
|
29
25
|
}
|
|
30
26
|
}
|