securemark 0.286.2 → 0.286.4
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 +8 -0
- package/design.md +59 -16
- package/dist/index.js +21 -18
- package/markdown.d.ts +1 -1
- package/package.json +1 -1
- package/src/combinator/control/manipulation/surround.ts +0 -1
- package/src/parser/api/parse.test.ts +2 -2
- package/src/parser/context.ts +10 -8
- package/src/parser/inline/reference.ts +6 -1
- package/src/parser/inline/template.ts +1 -1
- package/src/parser/inline.test.ts +1 -0
package/CHANGELOG.md
CHANGED
package/design.md
CHANGED
|
@@ -206,6 +206,10 @@ HTMLEntity構文はエンティティ追加時の互換性確保のため不正
|
|
|
206
206
|
また他の構文と同じ視覚表現で異なる意味付けを行うHTMLタグを追加してはならない。
|
|
207
207
|
ディレクティブなど文書でなくページを記述するための構文を追加してはならない。
|
|
208
208
|
|
|
209
|
+
### クラス化制約
|
|
210
|
+
|
|
211
|
+
他の構文を内部構文として包含可能な類似の構文は先行する構文の解析結果を利用してバックトラックを抑制できるよう構文を先行する類似構文のサブクラスおよび後行する類似構文のスーパークラスとして設計しなければならない。
|
|
212
|
+
|
|
209
213
|
## スケーラビリティ
|
|
210
214
|
|
|
211
215
|
パーサーおよびレンダラーはドキュメントサイズの増大により以下の利用性を損なってはならない。
|
|
@@ -277,7 +281,7 @@ HTMLEntity構文はエンティティ追加時の互換性確保のため不正
|
|
|
277
281
|
|
|
278
282
|
### AST(CST)
|
|
279
283
|
|
|
280
|
-
Securemarkはブロック単位の差分更新によりリアルタイムレンダリングを高速化しているがCST
|
|
284
|
+
Securemarkはブロック単位の差分更新によりリアルタイムレンダリングを高速化しているがCSTを生成する場合行の追加削除により以降すべてのノードの位置情報を更新する必要が生じ許容範囲を超える遅延が生じる可能性がある。このためこの最適化を行う必要があるが行位置の更新のみであればこれのみを行う処理経路の追加は容易であろう。Markdownでも行数は数万行以下と想定できることから行数を全ノードに直接記述せず行ノードの行数を参照する実装に変更すれば更新対象を数万以下の行ノードだけに局限できる。これらは数百行以下に規律されるソースコードにおいては生じない問題であり数十万文字を許容しなければならないマークアップ言語に新出の問題であるため新規にCSTの設計および運用を再考する必要がある。
|
|
281
285
|
|
|
282
286
|
またBlockquote構文を内包テキストまでシンタックスハイライトする場合、構文(>)と内包テキストが垂直に分割されるため構文と1対1で対応する単純なノードではCSTを表現できず構文の断片を表現するノードが必要となり、さらにこれをエディタ上でシンタックスハイライトするためのHTMLに変換する際に各行においてこの断片のCSTを断片のHTMLに正しく変換および表示しなければならずかなり煩雑な作業を要する。
|
|
283
287
|
|
|
@@ -285,15 +289,15 @@ CodeMirrorが素では速いがVimModeでは数万文字程度でも耐え難く
|
|
|
285
289
|
|
|
286
290
|
### バックトラック
|
|
287
291
|
|
|
288
|
-
SecuremarkのAnnotation
|
|
289
|
-
CommonMark
|
|
290
|
-
|
|
291
|
-
Securemarkは線形時間で解析不能な文脈依存言語をおおよそ14nの最悪時間計算量に改善しさらに解析時間と解析範囲の局限により一定時間内で解析不能な入力の影響を局限することでこれらの問題を解決している。この解析方法はほとんどの自然な入力に対して1nに近い時間で効率的に動作し、最悪計算量で低速に動作させる入力に対してもこの開発効率と安全性優先の低速な実装においてはサーバーで多数のユーザーのリクエストに応じるには低速で脆弱性となる可能性があるがクライアントで単一のユーザーの操作に応じるには十分高速であるためクライアントで解析する限り解析の効率または速度が実用上問題となることはなく仕様が固まり実行効率優先の高速な実装に移れば速度面の懸念もないだろう。
|
|
292
|
+
SecuremarkのAnnotation構文に典型的であるように文脈を変更する構文の中にその文脈に依存し変更される他の構文が存在する場合文脈の相違から解析結果を再利用不能(`αAβ | αA'B`)なバックトラックが生じる。またこの結果再帰的バックトラックが生じる可能性があり再帰的バックトラックは一般的にメモ化により解決されるがCommonMarkは実行性能追及のためメモ化を廃止しているためメモ化により性能を低下させてまで文脈依存構文の問題を解決するつもりはないと思われる(すなわちCommonMarkは機械を至上とし人間に制約を課す低水準の言語であり人間の需要を至上とするSecuremarkとは対極に位置する)。従って現在の再帰的バックトラックなしで解析可能な構文と最小計算量に制約されるCommonMarkにはこれ以上再帰的バックトラックが生じる可能性を増加させて文脈依存構文を追加できないという拡張性の欠陥が存在する。CommonMarkの仕様策定者が構文の拡張に(名称を維持するか否かにかかわらず)不自然なまでに消極的または進展がないのは正当な理由や怠慢からでなく文脈依存構文を追加するにつれて構文解析戦略の失敗が明白になっていくためおよび現在の高い実行性能を低下させたくないためであり陳腐な自尊心を守るためにこのような拡張性の欠陥を秘匿しCommonMarkとその仕様策定者である自分の評価が下がらないよう画策しているからである。でなければ何年も隠さず速やかにこの拡張性の欠陥を公表して助力を求めていなければならず不都合な事実を隠し全Markdown利用者および開発者を不必要に足止めした罪は重い。CommonMarkは`~~a~~`のような文脈自由構文は容易に追加できるがこうしたマージンを失えばもはや後はない。
|
|
293
|
+
CommonMarkは小さく単純であるがゆえに正しくいられる象牙の塔であり仕様策定者はこの正しさを失わず正しいままでいたいがために象牙の塔に引きこもり小さな表面的完全性に固執し続けているに過ぎない。しかし実際にはCommonMarkはまったく完全ではなく本来文脈依存構文である構文を文脈自由構文として解析しているため破綻している部分があり実際のところCommonMarkは最初から現在までずっと壊れている。またCommonMarkはバックトラックなく最小計算量で解析するために文脈自由言語として設計されているが実際には文脈依存言語であるMarkdownから文脈依存構文を文脈自由構文に変換して除去することができずCommonMarkは最初の数年間は再帰的バックトラックに気づかず最悪計算量が指数関数計算量になっており修正後は最悪計算量が当初の想定の1nから32nへと32倍に劇的に悪化している。CommonMarkは未だにバックトラックを忌避し1nの最小計算量に固執しているがそんなものはとっくの昔に破綻してるのを未練がましく執着しているだけである。最悪計算量が32nにまで悪化するのであれば計算量が少ないよう適切に設計された文脈依存言語と大差なく最初から文脈依存言語として適切に設計するほうが自然で破綻がなく拡張性を確保できていた。文脈依存構文を強引に文脈自由構文として解析して最悪計算量が当初の想定の1nから32nに劇的に悪化し結局文脈依存言語の妥当な最悪計算量の水準に落ちていることから文脈自由言語として設計されたCommonMarkの破綻と失敗は明らかでありCommonMarkは文脈自由構文に固執せず最初から多少の文脈依存構文を許容するよう設計しなければならなかった。実際には文脈依存言語であるにもかかわらず文脈自由言語としてしか構文解析できなければ構文解析が破綻し構文が増えるほど破綻が拡大することは自明でありすでに破綻済みで失敗済みのCommonMarkに未来などない。文脈依存言語であるMarkdownに対して文脈自由構文解析器として作られたCommonMarkは最初から技術選択を間違え失敗しており最初から破綻していた。Markdownを文脈自由言語として解析しようとして行き詰ったCommonMarkとその閉塞に技術的合理性はなくCommonMarkは最初からの失敗していた過去の遺物であり廃棄すべき負債である。CommonMarkに動きがないのはすでに破綻しており死んでいることに気付かれないように死んでいるからに過ぎない。このようにCommonMarkは完全に破綻し失敗に終わっているためCommonMarkの拡張や発展を期待しても無駄であり既存の文脈依存構文による破綻がなく新たに文脈依存構文を追加可能な拡張性の高いMarkdown仕様は新しく作り直さなければ作れない。しかしCommonMarkの仕様策定者は独自の新しい仕様においてもMarkdownをバックトラックを排除した文脈自由言語として設計しているため救いようがない。しかもその構文と仕様は機械可読性を至上としているため非常に醜く人間が書くことも読むことも困難で実用性の欠如したものである。
|
|
294
|
+
Securemarkはスーパークラス構文が解析に失敗した入力をサブクラス構文で解析しないことにより再帰的バックトラックを回避する(ここで解析中の構文自身はスーパークラスとサブクラスの両方に含まれるものとする)。スーパークラス構文A(`αAβ`)の解析が失敗すればサブクラス構文B(`α'A'β'`)の解析も失敗することは自明であり解析を試みるまでもなく省略できる。これは構文の文法が生成する言語空間がスーパーセットとサブセットの関係にあるならスーパーセットの言語空間の外にある文字列はサブセットの言語空間の内に入る余地がないことからも自明である(この解析法は事前処理によっても可能だが文脈内外のオートリンクURLの括弧解析などを高速に行うことは困難であるためMarkdownをこの事前処理により高速化することは難しい)。メモ化は解析結果を再利用することで結果的に副次的効果としてバックトラックを回避しているのでありメモ化はバックトラックを回避するだけなら過剰機能であり不要である(メモ化はバックトラックがなければ使用されないためバックトラックの少ないほとんどの入力に対してはほとんど使用されず無駄であり空間計算量を常に不必要に数倍以上に増加させてまで行う利益は少ないことから構文解析において必須ではない。バックトラック回避のためにメモ化するとバックトラックなしで解析可能な場合も常に不必要に空間計算量が増加することがメモ化の最大の欠点である(この問題は解析失敗時のみメモ化すれば解消可能のはずだが基本的にはこうなる)。特に文脈自由構文解析器におけるメモ化の使用は完全に無駄でありバグである。バックトラックが他の方法で解決されるならば最終的に文脈ごと破棄され使用されないメモ化も無駄であり複数の文脈で解析結果が同一である文脈独立性のある構文ならメモ化した解析結果を異なる文脈で再利用でき有用だがそのような構文は基本的に少数であるため効果が限定的であり最悪計算量は改善されない)。この独自の解析法によりSecuremarkはメモ化なしに線形時間で解析不能な文脈依存言語をメモ化なしでおおよそ16nの最悪時間計算量に改善しさらに一定時間内で解析不能な入力の影響を解析時間と解析範囲の局限することで解決している。この解析方法はほとんどの自然な入力に対して1nに近い時間で効率的に動作し、最悪計算量で低速に動作させる入力に対してもこの開発効率と安全性優先の低速な実装をサーバーで使用し多数のユーザーのリクエストに応じるには低速で脆弱性となる可能性があるがクライアントで個別のユーザーの操作に応じるには十分高速であるためクライアントで解析する限り解析の効率または速度が実用上問題となることはなく仕様が固まり実行効率優先の高速な実装に移れば速度面の懸念もないだろう。またSecuremarkはメモ化を行っていないため実装依存の非効率性を除けば空間計算量も小さく、異なる構文や状態の解析結果を利用して未知の入力に対してもバックトラックを回避できるためメモ化より時間計算量が小さい。時間計算量と空間計算量を合わせてO(n, n)と表記すると文脈依存言語の通常の最悪計算量はO(n^2, n)、メモ化により効率化できた場合もO(nm, nm)(解析結果の構文木等を記録するため空間使用量S(m)>=m byte)に過ぎないがSecuremarkの失敗単一化はO(nm, n + nm)(解析失敗のフラグしか記録しないためS(m)=m bit。また包含文字列を含め全体でn byteの構文1つに対してメモ化は少なくともn byteを消費するが失敗単一化のメモリ消費量は構文全体のサイズにかかわらず1 bit固定である。なお成功フラグによる解析は解析済みかの情報が追加で必要になり処理が複雑化かつほとんどの成功した解析に対してメモリ消費と追加処理が発生し解析効率が全体として悪化するが失敗フラグは少数の失敗した解析でしか解析効率が悪化しないため失敗フラグを記録するほうが全体として解析効率が高く優れている)と極めて効率的であり最も優れている。なお現在のSecuremarkは開発効率優先の実装により空間計算量が低下しているが時間計算量は低下せずメモ化より優れている。またSecuremarkの再帰数制限はパーサーコンビネーターの使用による実装依存の制限であるため再帰が生じないよう書き換えれば再帰数制限もない。SecuremarkをCommonMarkのような再帰数制限のない実装に変換することは設計上何の支障もないがCommonMarkをSecuremarkのような文脈依存言語解析器に変更することは根本的な設計変更なしに不可能である。例えば二重リンク`[[]()]()`を解析するときCommonMarkはバックトラックと計算量を最小化すべく文脈自由構文解析器として設計されているためリンク構文内を異なる文脈として解析せず外側のリンク構文の解析を破棄して内側のみリンクとして解析するがSecuremarkは文脈依存構文解析器とし設計されているため内側のリンク構文を無効化して外側のみリンクとして解析する。旧構文だけ従来通り文脈自由構文として解析し新構文を文脈依存構文として解析することも不可能ではないが構文としても解析器としてもキメラ的な非常に不自然で歪なものとなり解析規則の一貫性のなさによりユーザーを混乱させることになる。いずれにせよCommonMarkはこのような根本的設計変更なしに文脈依存構文解析器に変更して拡張性を確保することはできないためMarkdownは素直にCommonMarkの文脈自由言語特有の解析規則を捨てて素直な文脈依存構文言語として新しい仕様を作るのが賢明である。
|
|
292
295
|
|
|
293
296
|
### 最適化
|
|
294
297
|
|
|
295
|
-
-
|
|
296
|
-
-
|
|
298
|
+
- パーサー出力の木構造化とDOM出力の分離による、生成とバックトラックのコストの削減
|
|
299
|
+
- パーサーの展開またはトランポリン化
|
|
300
|
+
- 差分更新可能かつ利用環境に適合するCSTの開発
|
|
297
301
|
|
|
298
302
|
### 標準化
|
|
299
303
|
|
|
@@ -304,17 +308,56 @@ Markdownのように自然言語と自身の文法を分離する汎用構造が
|
|
|
304
308
|
|
|
305
309
|
よってMarkdownの標準化は後方互換性確保が不可能であることから発展性がなくスナップショット以上の技術的意味を持たない。
|
|
306
310
|
MarkdownはGFMのように最初から高機能で完成度の高い拡張不要な独自実装のほうが標準としての互換性を確保でき、構文に曖昧さがない形式言語と異なりまず最小限の標準仕様を策定しのちに拡張していく通常の標準化方法が適さない特殊な言語である。
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
-
|
|
312
|
-
-
|
|
313
|
-
-
|
|
314
|
-
-
|
|
311
|
+
Markdownに本当に必要な仕様はSecuremarkのクラス化制約のように構文の解釈の一貫性と安定性を保つ仕様、バックトラックを抑制する仕様、拡張を確保する仕様などの抽象的仕様であり拡張すると壊れる拡張不可能な具体的仕様などその場限りの価値しかない。
|
|
312
|
+
|
|
313
|
+
### CommonMarkの欠陥
|
|
314
|
+
|
|
315
|
+
- 構文解析戦略の選択の失敗と最小計算量への固執
|
|
316
|
+
- 拡張性の欠如
|
|
317
|
+
- 文脈依存構文を追加不可能(要解析戦略変更)
|
|
318
|
+
- 構文解析の破綻(文脈依存言語の文脈自由言語としての解析を仕様化したことによる破綻)
|
|
319
|
+
- 二重リンク(`[<a@b>]()`)の生成
|
|
320
|
+
-二重リンク自体は回避可能で杜撰なだけだが文脈依存構文として解析できないことが根本原因
|
|
321
|
+
- 画像のalt(`![*a*]()`, `![![a]()`)をMarkdownとして解釈
|
|
322
|
+
- 再帰的バックトラック回避の必要上修正不可能
|
|
323
|
+
- リンクのURLを効率的に解析不可能
|
|
324
|
+
- altはまだしもURLは文脈依存構文としての解析を避けられないため再帰もまた避けられず公式デモページのCommonMarkで`[](`を1万文字程度繰り返しただけで解析時間が1秒を超える
|
|
325
|
+
- この欠陥は入れ子数を制限することで回避可能だがこれはCommonmarkは文脈依存構文全般に入れ子数制限を要することを意味する
|
|
326
|
+
- CommonMarkは最初のバージョンから数年後にこの欠陥を入れ子数制限により修正しこれにより最悪計算量が当初の想定の1nから32nへと32倍に劇的に悪化したことから文脈自由言語および最小計算量としての設計と開発が破綻し失敗に終わったことが明らかである
|
|
327
|
+
- これほど計算量が悪ければ入れ子数制限付き文脈依存言語と大差ない計算量であり素直に文脈依存言語として作り直したほうが遥かに拡張性と発展性が高く優れている
|
|
328
|
+
- 計算資源は使うためにあるにもかかわらず言語と一致しない不適切な解析方法を使用してまでこの程度の計算資源を惜しんで人間に不便と不自由を強いて生産性を下げるのは本末転倒である
|
|
329
|
+
- 計算機は人間の生産性に奉仕しなければならない
|
|
330
|
+
- タブまたは4スペース以上で字下げ不可能(要構文削除)
|
|
331
|
+
- 情報の再利用困難性
|
|
315
332
|
- 引用に恒等性がない
|
|
316
333
|
- 改行に恒等性がない
|
|
317
334
|
|
|
335
|
+
### CommonMarkの解析規則の問題点
|
|
336
|
+
|
|
337
|
+
開閉が明示的でない構文は開閉の不明確な記号による再帰的適用を行わず早く閉じるよう解析しなければならない。このため終端記号の後ろを見て終端を中止し同じ構文を再帰的に適用してはならない。従って記号内側の非空白要件以外のflanking要件は不要である。
|
|
338
|
+
|
|
339
|
+
```
|
|
340
|
+
flanking*!?*
|
|
341
|
+
-> flanking*!?*
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
`**`が`*`に分解されるか一貫性がなく直感的使用が困難。
|
|
345
|
+
|
|
346
|
+
```
|
|
347
|
+
**a*b*
|
|
348
|
+
-> **a<em>b</em>
|
|
349
|
+
|
|
350
|
+
***a*b*c*
|
|
351
|
+
-> <em><em><em>a</em>b</em>c</em>
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
偶奇へ不必要に依存し偶数個の`*`がすべて`<strong>`に解析されるため`<em>`が含まれるか目視で判別不能。
|
|
355
|
+
|
|
356
|
+
```
|
|
357
|
+
******a******
|
|
358
|
+
-> <strong><strong><strong>a</strong></strong></strong>
|
|
359
|
+
```
|
|
360
|
+
|
|
318
361
|
### トランスクルージョン
|
|
319
362
|
|
|
320
363
|
分散的に管理される情報のトランスクルージョンは権利関係の不明瞭さおよびリンク先の消失によりリンク元の情報に欠損が生じるなどの脆さから壊れやすいウェブ上の情報を扱う方法として既存の方法より劣っておりWikipediaのように中央集権的管理を実施できる場合にのみ有用となる。
|
|
@@ -332,4 +375,4 @@ Data URIは保存および転送容量削減ならびにユーザーおよび管
|
|
|
332
375
|
|
|
333
376
|
### _ emphasis
|
|
334
377
|
|
|
335
|
-
|
|
378
|
+
外側非空白要件なしでは非分かち書き言語で使用できず非空白要件ありではオートリンクと単語検索と致命的に相性が悪いため不採用。
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.286.
|
|
1
|
+
/*! securemark v0.286.4 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
|
|
2
2
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
3
3
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
4
4
|
module.exports = factory(require("Prism"), require("DOMPurify"));
|
|
@@ -2002,7 +2002,7 @@ exports.url = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['http://'
|
|
|
2002
2002
|
exports.lineurl = (0, combinator_1.lazy)(() => (0, combinator_1.open)(source_1.linebreak, (0, combinator_1.focus)(/^!?https?:\/\/\S+(?=[^\S\n]*(?:$|\n))/, (0, combinator_1.tails)([(0, source_1.str)('!'), (0, combinator_1.union)([(0, combinator_1.constraint)(1 /* State.autolink */, false, (0, combinator_1.state)(1 /* State.autolink */, (0, combinator_1.convert)(url => `{ ${url} }`, link_1.unsafelink))), ({
|
|
2003
2003
|
source
|
|
2004
2004
|
}) => [[source], '']])]))));
|
|
2005
|
-
const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ')')), (0, source_1.str)(')'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 |
|
|
2005
|
+
const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ')')), (0, source_1.str)(')'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 0 /* Backtrack.url */), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ']')), (0, source_1.str)(']'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 0 /* Backtrack.url */), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), '}')), (0, source_1.str)('}'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 0 /* Backtrack.url */), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)(source_1.unescsource, '"'))), (0, source_1.str)('"'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 0 /* Backtrack.url */)]));
|
|
2006
2006
|
|
|
2007
2007
|
/***/ },
|
|
2008
2008
|
|
|
@@ -2076,7 +2076,7 @@ const source_1 = __webpack_require__(8745);
|
|
|
2076
2076
|
const dom_1 = __webpack_require__(394);
|
|
2077
2077
|
const body = (0, source_1.str)(/^\$[A-Za-z]*(?:(?:-[A-Za-z][0-9A-Za-z]*)+|-(?:(?:0|[1-9][0-9]*)\.)*(?:0|[1-9][0-9]*)(?![0-9A-Za-z]))/);
|
|
2078
2078
|
exports.segment = (0, combinator_1.clear)((0, combinator_1.union)([(0, combinator_1.surround)('[', body, ']'), body]));
|
|
2079
|
-
exports.label = (0, combinator_1.constraint)(16 /* State.label */, false, (0, combinator_1.fmap)((0, combinator_1.union)([(0, combinator_1.surround)('[', body, ']', false, undefined, undefined, 1 |
|
|
2079
|
+
exports.label = (0, combinator_1.constraint)(16 /* State.label */, false, (0, combinator_1.fmap)((0, combinator_1.union)([(0, combinator_1.surround)('[', body, ']', false, undefined, undefined, 1 | 4 /* Backtrack.bracket */), body]), ([text]) => [(0, dom_1.html)('a', {
|
|
2080
2080
|
class: 'label',
|
|
2081
2081
|
'data-label': text.slice(text[1] === '-' ? 0 : 1).toLowerCase()
|
|
2082
2082
|
}, text)]));
|
|
@@ -3274,7 +3274,7 @@ const optspec = {
|
|
|
3274
3274
|
rel: ['nofollow']
|
|
3275
3275
|
};
|
|
3276
3276
|
Object.setPrototypeOf(optspec, null);
|
|
3277
|
-
exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(8 /* State.link */, false, (0, combinator_1.creation)(10, (0, combinator_1.precedence)(1, (0, combinator_1.state)(251 /* State.linkers */ | 4 /* State.media */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [['\n', 9], [']', 1]])), ']', true, undefined, undefined, 1 |
|
|
3277
|
+
exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(8 /* State.link */, false, (0, combinator_1.creation)(10, (0, combinator_1.precedence)(1, (0, combinator_1.state)(251 /* State.linkers */ | 4 /* State.media */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [['\n', 9], [']', 1]])), ']', true, undefined, undefined, 1 | 8 /* Backtrack.linebracket */, 4 /* Backtrack.bracket */ | 1 /* BacktrackState.nobreak */)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/, false, undefined, undefined, 3 | 20 /* Backtrack.link */))])), ([params, content = []], rest, context) => {
|
|
3278
3278
|
if (content.length !== 0 && (0, visibility_1.trimBlankNodeEnd)(content).length === 0) return;
|
|
3279
3279
|
return [[parse((0, dom_1.defrag)(content), params, context)], rest];
|
|
3280
3280
|
}))))));
|
|
@@ -4360,7 +4360,7 @@ const visibility_1 = __webpack_require__(6364);
|
|
|
4360
4360
|
const dom_1 = __webpack_require__(394);
|
|
4361
4361
|
exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(128 /* State.annotation */, false, (0, combinator_1.surround)('((', (0, combinator_1.precedence)(1, (0, combinator_1.state)(128 /* State.annotation */ | 4 /* State.media */, (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [['\n', 9], [')', 1]])))), '))', false, ([, ns], rest) => (0, visibility_1.trimBlankNodeEnd)(ns).length > 0 ? [[(0, dom_1.html)('sup', {
|
|
4362
4362
|
class: 'annotation'
|
|
4363
|
-
}, [(0, dom_1.html)('span', (0, dom_1.defrag)(ns))])], rest] : undefined, undefined, 1 |
|
|
4363
|
+
}, [(0, dom_1.html)('span', (0, dom_1.defrag)(ns))])], rest] : undefined, undefined, 1 | 8 /* Backtrack.linebracket */, 4 /* Backtrack.bracket */ | 1 /* BacktrackState.nobreak */)));
|
|
4364
4364
|
|
|
4365
4365
|
/***/ },
|
|
4366
4366
|
|
|
@@ -5029,8 +5029,8 @@ const source_1 = __webpack_require__(8745);
|
|
|
5029
5029
|
const dom_1 = __webpack_require__(394);
|
|
5030
5030
|
exports.template = (0, combinator_1.lazy)(() => (0, combinator_1.surround)('{{', (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.verify)((0, combinator_1.union)([bracket, source_1.escsource]), ns => ns[0] !== "\u001B" /* Command.Escape */), '}')), '}}', true, ([, ns = []], rest) => [[(0, dom_1.html)('span', {
|
|
5031
5031
|
class: 'template'
|
|
5032
|
-
}, `{{${ns.join('')}}}`)], rest], undefined,
|
|
5033
|
-
const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ')')), (0, source_1.str)(')'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 |
|
|
5032
|
+
}, `{{${ns.join('')}}}`)], rest], undefined, 1 | 4 /* Backtrack.bracket */, 4 /* Backtrack.bracket */));
|
|
5033
|
+
const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ')')), (0, source_1.str)(')'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 28 /* Backtrack.template */), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ']')), (0, source_1.str)(']'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 28 /* Backtrack.template */), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}')), (0, source_1.str)('}'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 28 /* Backtrack.template */), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)(source_1.escsource, /^["\n]/))), (0, source_1.str)('"'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 28 /* Backtrack.template */)]));
|
|
5034
5034
|
|
|
5035
5035
|
/***/ },
|
|
5036
5036
|
|
|
@@ -5071,11 +5071,11 @@ const array_1 = __webpack_require__(6876);
|
|
|
5071
5071
|
const dom_1 = __webpack_require__(394);
|
|
5072
5072
|
const indexA = /^[0-9A-Za-z]+(?:(?:[.-]|, )[0-9A-Za-z]+)*(?=\))/;
|
|
5073
5073
|
const indexF = new RegExp(indexA.source.replace(', ', '[,、]').replace(/[09AZaz.]|\-(?!\w)|\)(?=\)$)/g, c => String.fromCodePoint(c.codePointAt(0) + 0xFEE0)));
|
|
5074
|
-
exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, source_1.str)(indexA))), (0, source_1.str)(')'), false, undefined, undefined, 3 |
|
|
5074
|
+
exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, source_1.str)(indexA))), (0, source_1.str)(')'), false, undefined, undefined, 3 | 4 /* Backtrack.bracket */), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, ')', [[')', 1]]))), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
|
|
5075
5075
|
class: 'paren'
|
|
5076
|
-
}, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], 3 |
|
|
5076
|
+
}, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], 3 | 4 /* Backtrack.bracket */), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, source_1.str)(indexF))), (0, source_1.str)(')'), false, undefined, undefined, 3 | 4 /* Backtrack.bracket */), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, ')', [[')', 1]]))), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
|
|
5077
5077
|
class: 'paren'
|
|
5078
|
-
}, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]))), (0, source_1.str)(']'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], 3 |
|
|
5078
|
+
}, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]))), (0, source_1.str)(']'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], 3 | 4 /* Backtrack.bracket */), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]))), (0, source_1.str)(']'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, '}', [['}', 1]]))), (0, source_1.str)('}'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], 3 | 4 /* Backtrack.bracket */), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, '}', [['}', 1]]))), (0, source_1.str)('}'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]),
|
|
5079
5079
|
// 改行禁止はバックトラックなしでは内側の構文を破壊するため安易に行えない。
|
|
5080
5080
|
(0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.precedence)(2, (0, combinator_1.some)(inline_1.inline, '"', [['\n', 9], ['"', 2]]))), (0, source_1.str)('"'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('“'), (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.precedence)(2, (0, combinator_1.some)(inline_1.inline, '”', [['\n', 9], ['”', 2]]))), (0, source_1.str)('”'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('‘'), (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.precedence)(2, (0, combinator_1.some)(inline_1.inline, '’', [['\n', 9], ['’', 2]]))), (0, source_1.str)('’'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('「'), (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.precedence)(2, (0, combinator_1.some)(inline_1.inline, '」', [['\n', 9], ['」', 2]]))), (0, source_1.str)('」'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('『'), (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.precedence)(2, (0, combinator_1.some)(inline_1.inline, '』', [['\n', 9], ['』', 2]]))), (0, source_1.str)('』'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest])]));
|
|
5081
5081
|
|
|
@@ -5159,7 +5159,7 @@ const visibility_1 = __webpack_require__(6364);
|
|
|
5159
5159
|
const dom_1 = __webpack_require__(394);
|
|
5160
5160
|
exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(32 /* State.index */, false, (0, combinator_1.fmap)((0, indexee_1.indexee)((0, combinator_1.surround)('[#', (0, combinator_1.precedence)(1, (0, combinator_1.state)(251 /* State.linkers */ | 4 /* State.media */, (0, visibility_1.tightStart)((0, combinator_1.some)((0, combinator_1.inits)([inline_1.inline, exports.signature]), ']', [['\n', 9], [']', 1]])))), ']', false, ([, ns], rest) => (0, visibility_1.trimBlankNodeEnd)(ns).length > 0 ? [[(0, dom_1.html)('a', {
|
|
5161
5161
|
'data-index': dataindex(ns)
|
|
5162
|
-
}, (0, dom_1.defrag)(ns))], rest] : undefined, undefined, 1 |
|
|
5162
|
+
}, (0, dom_1.defrag)(ns))], rest] : undefined, undefined, 1 | 8 /* Backtrack.linebracket */, 4 /* Backtrack.bracket */ | 1 /* BacktrackState.nobreak */)), ([el]) => [(0, dom_1.define)(el, {
|
|
5163
5163
|
id: el.id ? null : undefined,
|
|
5164
5164
|
class: 'index',
|
|
5165
5165
|
href: el.id ? `#${el.id}` : undefined
|
|
@@ -5168,7 +5168,7 @@ exports.signature = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('|',
|
|
|
5168
5168
|
class: 'indexer',
|
|
5169
5169
|
'data-index': (0, indexee_1.identity)('index', undefined, ns.join('')).slice(7)
|
|
5170
5170
|
})])));
|
|
5171
|
-
const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.txt]), ')')), (0, source_1.str)(')'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 |
|
|
5171
|
+
const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.txt]), ')')), (0, source_1.str)(')'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 24 /* Backtrack.index */), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.txt]), ']')), (0, source_1.str)(']'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 24 /* Backtrack.index */), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.txt]), '}')), (0, source_1.str)('}'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 24 /* Backtrack.index */), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)(source_1.txt, '"'))), (0, source_1.str)('"'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 24 /* Backtrack.index */)]));
|
|
5172
5172
|
function dataindex(ns) {
|
|
5173
5173
|
if (ns.length === 0) return;
|
|
5174
5174
|
for (let i = ns.length - 1; i >= 0; --i) {
|
|
@@ -6214,7 +6214,7 @@ exports.placeholder = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0
|
|
|
6214
6214
|
'data-invalid-syntax': 'extension',
|
|
6215
6215
|
'data-invalid-type': 'syntax',
|
|
6216
6216
|
'data-invalid-message': `Invalid start symbol or linebreak`
|
|
6217
|
-
}, (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest], 3 |
|
|
6217
|
+
}, (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest], 3 | 4 /* Backtrack.bracket */));
|
|
6218
6218
|
|
|
6219
6219
|
/***/ },
|
|
6220
6220
|
|
|
@@ -7158,13 +7158,13 @@ exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinato
|
|
|
7158
7158
|
}), [undefined])[0];
|
|
7159
7159
|
ns && ns.at(-1) === '' && ns.pop();
|
|
7160
7160
|
return ns && (0, visibility_1.isTightNodeStart)(ns) ? [ns, rest] : undefined;
|
|
7161
|
-
}, undefined, 3 |
|
|
7161
|
+
}, undefined, 3 | 16 /* Backtrack.ruby */)), (0, combinator_1.dup)((0, combinator_1.surround)('(', (0, source_1.str)(/^(?:\\[^\n]|[^\\[\](){}<>"\n])+/u), ')', false, ([, [source]], rest, context) => {
|
|
7162
7162
|
const ns = (0, parser_1.eval)(text({
|
|
7163
7163
|
source,
|
|
7164
7164
|
context
|
|
7165
7165
|
}), [undefined])[0];
|
|
7166
7166
|
return ns && [ns, rest];
|
|
7167
|
-
}, undefined, 3 |
|
|
7167
|
+
}, undefined, 3 | 16 /* Backtrack.ruby */))]), ([texts, rubies]) => {
|
|
7168
7168
|
switch (true) {
|
|
7169
7169
|
case rubies.length <= texts.length:
|
|
7170
7170
|
return [(0, dom_1.html)('ruby', attributes(texts, rubies), (0, dom_1.defrag)(texts.reduce((acc, _, i) => (0, array_1.push)(acc, (0, array_1.unshift)([texts[i]], i < rubies.length && rubies[i] ? [(0, dom_1.html)('rp', '('), (0, dom_1.html)('rt', rubies[i]), (0, dom_1.html)('rp', ')')] : [(0, dom_1.html)('rt')])), [])))];
|
|
@@ -7312,7 +7312,7 @@ const optspec = {
|
|
|
7312
7312
|
rel: undefined
|
|
7313
7313
|
};
|
|
7314
7314
|
Object.setPrototypeOf(optspec, null);
|
|
7315
|
-
exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(4 /* State.media */, false, (0, combinator_1.validate)(['![', '!{'], (0, combinator_1.creation)(10, (0, combinator_1.open)('!', (0, combinator_1.bind)((0, combinator_1.verify)((0, combinator_1.fmap)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.verify)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ns => ns[0] !== "\u001B" /* Command.Escape */), ']', [['\n', 9]])), ']', true, undefined, undefined, 1 |
|
|
7315
|
+
exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(4 /* State.media */, false, (0, combinator_1.validate)(['![', '!{'], (0, combinator_1.creation)(10, (0, combinator_1.open)('!', (0, combinator_1.bind)((0, combinator_1.verify)((0, combinator_1.fmap)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.verify)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ns => ns[0] !== "\u001B" /* Command.Escape */), ']', [['\n', 9]])), ']', true, undefined, undefined, 1 | 12 /* Backtrack.media */)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([link_1.uri, (0, combinator_1.some)(option)]), /^[^\S\n]*}/, false, undefined, undefined, 3 | 20 /* Backtrack.link */))]), ([as, bs]) => bs ? [[as.join('').trim() || as.join('')], bs] : [[''], as]), ([[text]]) => text === '' || text.trim() !== ''), ([[text], params], rest, context) => {
|
|
7316
7316
|
const INSECURE_URI = params.shift();
|
|
7317
7317
|
const url = new url_1.ReadonlyURL((0, link_1.resolve)(INSECURE_URI, context.host ?? location, context.url ?? context.host ?? location), context.host?.href || location.href);
|
|
7318
7318
|
let cache;
|
|
@@ -7339,7 +7339,7 @@ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(4 /* S
|
|
|
7339
7339
|
});
|
|
7340
7340
|
}))))));
|
|
7341
7341
|
exports.linemedia = (0, combinator_1.surround)(source_1.linebreak, (0, combinator_1.union)([exports.media]), /^(?=[^\S\n]*(?:$|\n))/);
|
|
7342
|
-
const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ')'), (0, source_1.str)(')'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 |
|
|
7342
|
+
const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ')'), (0, source_1.str)(')'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 12 /* Backtrack.media */), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']'), (0, source_1.str)(']'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 12 /* Backtrack.media */), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), '}'), (0, source_1.str)('}'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 12 /* Backtrack.media */), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, source_1.txt]), '"')), (0, source_1.str)('"'), true, undefined, () => [["\u001B" /* Command.Escape */], ''], 3 | 12 /* Backtrack.media */)])));
|
|
7343
7343
|
const option = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[1-9][0-9]*x[1-9][0-9]*(?=[^\S\n]|})/), ([opt]) => [` width="${opt.slice(1).split('x')[0]}"`, ` height="${opt.slice(1).split('x')[1]}"`]), (0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[1-9][0-9]*:[1-9][0-9]*(?=[^\S\n]|})/), ([opt]) => [` aspect-ratio="${opt.slice(1).split(':').join('/')}"`]), link_1.option]));
|
|
7344
7344
|
function sanitize(target, uri, alt) {
|
|
7345
7345
|
switch (uri.protocol) {
|
|
@@ -8904,7 +8904,10 @@ const inline_1 = __webpack_require__(7973);
|
|
|
8904
8904
|
const source_1 = __webpack_require__(8745);
|
|
8905
8905
|
const visibility_1 = __webpack_require__(6364);
|
|
8906
8906
|
const dom_1 = __webpack_require__(394);
|
|
8907
|
-
|
|
8907
|
+
const array_1 = __webpack_require__(6876);
|
|
8908
|
+
exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(64 /* State.reference */, false, (0, combinator_1.surround)('[[', (0, combinator_1.precedence)(1, (0, combinator_1.state)(128 /* State.annotation */ | 64 /* State.reference */ | 4 /* State.media */, (0, combinator_1.subsequence)([abbr, (0, visibility_1.trimBlankStart)((0, combinator_1.some)(inline_1.inline, ']', [['\n', 9], [']', 1]]))]))), ']]', false, ([, ns], rest) => (0, visibility_1.trimBlankNodeEnd)(ns).length > 0 ? [[(0, dom_1.html)('sup', attributes(ns), [(0, dom_1.html)('span', (0, dom_1.defrag)(ns))])], rest] : undefined, ([as, bs], rest, {
|
|
8909
|
+
state = 0
|
|
8910
|
+
}) => state & 128 /* State.annotation */ ? [(0, array_1.unshift)(as, bs), rest] : undefined, 1 | 8 /* Backtrack.linebracket */, 4 /* Backtrack.bracket */ | 1 /* BacktrackState.nobreak */)));
|
|
8908
8911
|
// Chicago-Style
|
|
8909
8912
|
const abbr = (0, combinator_1.surround)('^', (0, combinator_1.union)([(0, source_1.str)(/^(?=[A-Z])(?:[0-9A-Za-z]'?|(?:[-.:]|\.?\??,? ?)(?!['\-.:?, ]))+/)]), /^\|?(?=]])|^\|[^\S\n]*/, true, ([, ns], rest) => ns ? [['\n', ns[0].trimEnd()], rest.replace(visibility_1.blank.start, '')] : [[''], `^${rest}`], ([,, rest]) => [[''], `^${rest}`]);
|
|
8910
8913
|
function attributes(ns) {
|
package/markdown.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -66,7 +66,6 @@ export function surround<T>(
|
|
|
66
66
|
if (source[i] !== source[0]) break;
|
|
67
67
|
const pos = source.length + offset - i - 1;
|
|
68
68
|
if (!(pos in backtracks)) continue;
|
|
69
|
-
assert(backtrack >>> 2);
|
|
70
69
|
// bracket only
|
|
71
70
|
const shift = backtrack >>> 2 === state >>> 2 ? state & 3 : 0;
|
|
72
71
|
if (backtracks[pos] & 1 << (backtrack >>> 2) + shift) return;
|
|
@@ -350,7 +350,7 @@ describe('Unit: parser/api/parse', () => {
|
|
|
350
350
|
|
|
351
351
|
it('backtrack', function () {
|
|
352
352
|
this.timeout(5000);
|
|
353
|
-
const str = `${'.'.repeat(
|
|
353
|
+
const str = `${'.'.repeat(6)}((${'['.repeat(13)}{{http://[[[${'.'.repeat(6658)}`;
|
|
354
354
|
assert.deepStrictEqual(
|
|
355
355
|
[...parse(str).children].map(el => el.outerHTML.replace(/:\w+/, ':rnd')),
|
|
356
356
|
[`<p>${str}</p>`]);
|
|
@@ -358,7 +358,7 @@ describe('Unit: parser/api/parse', () => {
|
|
|
358
358
|
|
|
359
359
|
it('backtrack error', function () {
|
|
360
360
|
this.timeout(5000);
|
|
361
|
-
const str = `${'.'.repeat(
|
|
361
|
+
const str = `${'.'.repeat(6)}((${'['.repeat(13)}{{http://[[[${'.'.repeat(6658 + 1)}`;
|
|
362
362
|
assert.deepStrictEqual(
|
|
363
363
|
[...parse(str).children].map(el => el.outerHTML.replace(/:\w+/, ':rnd')),
|
|
364
364
|
[
|
package/src/parser/context.ts
CHANGED
|
@@ -29,15 +29,17 @@ export const enum Recursion {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export const enum Backtrack {
|
|
32
|
-
template =
|
|
33
|
-
index =
|
|
34
|
-
link =
|
|
35
|
-
ruby =
|
|
36
|
-
media =
|
|
37
|
-
linebracket =
|
|
38
|
-
bracket =
|
|
39
|
-
url =
|
|
32
|
+
template = 7 << 2,
|
|
33
|
+
index = 6 << 2,
|
|
34
|
+
link = 5 << 2,
|
|
35
|
+
ruby = 4 << 2,
|
|
36
|
+
media = 3 << 2,
|
|
37
|
+
linebracket = 2 << 2,
|
|
38
|
+
bracket = 1 << 2,
|
|
39
|
+
url = 0 << 2,
|
|
40
40
|
}
|
|
41
|
+
// バックトラックを削減するため括弧派生構文を改行禁止し
|
|
42
|
+
// 括弧派生構文内のバックトラック状態を統一する。
|
|
41
43
|
export const enum BacktrackState {
|
|
42
44
|
nobreak = 1,
|
|
43
45
|
}
|
|
@@ -5,6 +5,7 @@ import { inline } from '../inline';
|
|
|
5
5
|
import { str } from '../source';
|
|
6
6
|
import { blank, trimBlankStart, trimBlankNodeEnd } from '../visibility';
|
|
7
7
|
import { html, defrag } from 'typed-dom/dom';
|
|
8
|
+
import { unshift } from 'spica/array';
|
|
8
9
|
|
|
9
10
|
export const reference: ReferenceParser = lazy(() => constraint(State.reference, false, surround(
|
|
10
11
|
'[[',
|
|
@@ -19,7 +20,11 @@ export const reference: ReferenceParser = lazy(() => constraint(State.reference,
|
|
|
19
20
|
trimBlankNodeEnd(ns).length > 0
|
|
20
21
|
? [[html('sup', attributes(ns), [html('span', defrag(ns))])], rest]
|
|
21
22
|
: undefined,
|
|
22
|
-
|
|
23
|
+
([as, bs], rest, { state = 0 }) =>
|
|
24
|
+
state & State.annotation
|
|
25
|
+
? [unshift(as, bs), rest]
|
|
26
|
+
: undefined,
|
|
27
|
+
1 | Backtrack.linebracket, Backtrack.bracket | BacktrackState.nobreak)));
|
|
23
28
|
|
|
24
29
|
// Chicago-Style
|
|
25
30
|
const abbr: ReferenceParser.AbbrParser = surround(
|
|
@@ -10,7 +10,7 @@ export const template: TemplateParser = lazy(() => surround(
|
|
|
10
10
|
'}}',
|
|
11
11
|
true,
|
|
12
12
|
([, ns = []], rest) => [[html('span', { class: 'template' }, `{{${ns.join('')}}}`)], rest],
|
|
13
|
-
undefined,
|
|
13
|
+
undefined, 1 | Backtrack.bracket, Backtrack.bracket));
|
|
14
14
|
|
|
15
15
|
const bracket: TemplateParser.BracketParser = lazy(() => union([
|
|
16
16
|
surround(str('('), recursion(Recursion.terminal, some(union([bracket, escsource]), ')')), str(')'), true,
|
|
@@ -127,6 +127,7 @@ describe('Unit: parser/inline', () => {
|
|
|
127
127
|
assert.deepStrictEqual(inspect(parser('((${))}$')), [['(', '(', '<span class="math" translate="no" data-src="${))}$">${))}$</span>'], '']);
|
|
128
128
|
assert.deepStrictEqual(inspect(parser('((a\nb))')), [['<span class="paren">(<span class="paren">(a<br>b)</span>)</span>'], '']);
|
|
129
129
|
assert.deepStrictEqual(inspect(parser('(((a\nb)))')), [['<span class="paren">(<span class="paren">(<span class="paren">(a<br>b)</span>)</span>)</span>'], '']);
|
|
130
|
+
assert.deepStrictEqual(inspect(parser('(({{\n}}')), [['(', '(', '<span class="template">{{\n}}</span>'], '']);
|
|
130
131
|
assert.deepStrictEqual(inspect(parser('"((""))')), [['"', '(', '(', '"', '"', ')', ')'], '']);
|
|
131
132
|
assert.deepStrictEqual(inspect(parser('[[[a]]')), [['[', '<sup class="reference"><span>a</span></sup>'], '']);
|
|
132
133
|
assert.deepStrictEqual(inspect(parser('[[[[a]]')), [['[', '[', '<sup class="reference"><span>a</span></sup>'], '']);
|