-
Notifications
You must be signed in to change notification settings - Fork 142
Migrate Core Patches to TypeScript #2853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yihao03
wants to merge
6
commits into
MarkBind:master
Choose a base branch
from
yihao03:feat/migrate-core-patch
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b8ef944
Rename nunjucks patches to ts
yihao03 2838211
Migrate nunjucks patches to typescript
yihao03 1214b28
Rename core/src/patches to ts
yihao03 c2d44d6
Migrate core/src/patches to ts
yihao03 ce9f980
Rename core/src/lib/markdown-it/patches to TypeScript
yihao03 ea62ea3
Adapt core/src/lib/markdown-it/patches to TypeScript
yihao03 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,14 @@ | ||
| const { HTML_TAG_RE } = require('./htmlRe'); | ||
| import StateInline from 'markdown-it/lib/rules_inline/state_inline'; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prefer using |
||
| import { HTML_TAG_RE } from './htmlRe'; | ||
|
|
||
| // Forked and modified from 'markdown-it/lib/rules_inline/html_inline.js' | ||
|
|
||
| const isLetter = (ch) => { | ||
| const isLetter = (ch: number) => { | ||
| const lc = ch | 0x20 // to lower case | ||
| return lc >= 0x61 /* a */ && lc <= 0x7a /* z */ | ||
| } | ||
|
|
||
| const htmlInlineRule = (state, silent) => { | ||
| const htmlInlineRule = (state: StateInline, silent: boolean) => { | ||
| const pos = state.pos | ||
| if (!state.md.options.html) { | ||
| return false | ||
|
|
@@ -44,4 +45,4 @@ const htmlInlineRule = (state, silent) => { | |
| return true | ||
| } | ||
|
|
||
| module.exports = htmlInlineRule; | ||
| export = htmlInlineRule; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,4 +84,4 @@ const inlineTags = [ | |
| 'wbr', | ||
| ]; | ||
|
|
||
| module.exports = inlineTags; | ||
| export = inlineTags; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| export { } | ||
|
|
||
| declare module 'htmlparser2' { | ||
| interface TokenizerCallbacks { | ||
| onattribdata(value: string): void; | ||
| onattribend(): void; | ||
| onattribname(name: string): void; | ||
| oncdata(data: string): void; | ||
| oncomment(data: string): void; | ||
| ondeclaration(data: string): void; | ||
| onend(): void; | ||
| onerror(error: Error, state?: number): void; | ||
| onopentagend(): void; | ||
| onprocessinginstruction(name: string, value: string): void; | ||
| onselfclosingtag(): void; | ||
| ontext(data: string): void; | ||
| } | ||
|
|
||
| export class Tokenizer { | ||
| constructor(options: any, cbs: TokenizerCallbacks); | ||
| // Internal state | ||
| _state: number; | ||
| _buffer: string; | ||
| _sectionStart: number; | ||
| _index: number; | ||
| _bufferOffset: number; | ||
| _baseState: number; | ||
| _special: number; | ||
| _cbs: TokenizerCallbacks; | ||
| _running: boolean; | ||
| _ended: boolean; | ||
| _xmlMode: boolean; | ||
| _decodeEntities: boolean; | ||
|
|
||
| // MarkBind-added properties (set by patch) | ||
| specialTagNames: string[]; | ||
| _matchingSpecialTagIndexes: number[]; | ||
| _nextSpecialTagMatchIndex: number; | ||
|
|
||
| // Internal helpers | ||
| _getSection(): string; | ||
| _emitToken(name: string): void; | ||
| _cleanup(): void; | ||
|
|
||
| // State handler methods (original htmlparser2 internals) | ||
| _stateText(c: string): void; | ||
| _stateBeforeTagName(c: string): void; | ||
| _stateInTagName(c: string): void; | ||
| _stateBeforeCloseingTagName(c: string): void; | ||
| _stateInCloseingTagName(c: string): void; | ||
| _stateAfterCloseingTagName(c: string): void; | ||
| _stateBeforeAttributeName(c: string): void; | ||
| _stateInSelfClosingTag(c: string): void; | ||
| _stateInAttributeName(c: string): void; | ||
| _stateAfterAttributeName(c: string): void; | ||
| _stateBeforeAttributeValue(c: string): void; | ||
| _stateInAttributeValueDoubleQuotes(c: string): void; | ||
| _stateInAttributeValueSingleQuotes(c: string): void; | ||
| _stateInAttributeValueNoQuotes(c: string): void; | ||
| _stateBeforeDeclaration(c: string): void; | ||
| _stateInDeclaration(c: string): void; | ||
| _stateInProcessingInstruction(c: string): void; | ||
| _stateBeforeComment(c: string): void; | ||
| _stateInComment(c: string): void; | ||
| _stateAfterComment1(c: string): void; | ||
| _stateAfterComment2(c: string): void; | ||
| _stateBeforeCdata1(c: string): void; | ||
| _stateBeforeCdata2(c: string): void; | ||
| _stateBeforeCdata3(c: string): void; | ||
| _stateBeforeCdata4(c: string): void; | ||
| _stateBeforeCdata5(c: string): void; | ||
| _stateBeforeCdata6(c: string): void; | ||
| _stateInCdata(c: string): void; | ||
| _stateAfterCdata1(c: string): void; | ||
| _stateAfterCdata2(c: string): void; | ||
| _stateBeforeSpecial(c: string): void; | ||
| _stateBeforeSpecialEnd(c: string): void; | ||
| _stateBeforeEntity(c: string): void; | ||
| _stateBeforeNumericEntity(c: string): void; | ||
| _stateInNamedEntity(c: string): void; | ||
| _stateInNumericEntity(c: string): void; | ||
| _stateInHexEntity(c: string): void; | ||
|
|
||
| // MarkBind-added state handlers (set by patch) | ||
| _matchSpecialTagsFirstCharacters(c: string): boolean; | ||
| _matchSpecialTagsNextCharacters(c: string): number; | ||
| _matchNextSpecialTagClosingCharacter(c: string): number; | ||
| _parse(): void; | ||
| } | ||
|
|
||
| export interface Parser { | ||
| _attribname: string; | ||
| _closeCurrentTag(): void; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer using pure type imports
import type MarkdownIt from 'markdown-it';