MCPcopy Create free account
hub / github.com/executablebooks/markdown-it-py / _postProcess

Function _postProcess

markdown_it/rules_inline/strikethrough.py:85–155  ·  view source on GitHub ↗
(state: StateInline, delimiters: list[Delimiter])

Source from the content-addressed store, hash-verified

83
84
85def _postProcess(state: StateInline, delimiters: list[Delimiter]) -> None:
86 loneMarkers = []
87 maximum = len(delimiters)
88 single_tilde = state.md.options.get("strikethrough_single_tilde", False)
89
90 i = 0
91 while i < maximum:
92 startDelim = delimiters[i]
93
94 if startDelim.marker != 0x7E: # /* ~ */
95 i += 1
96 continue
97
98 if startDelim.end == -1:
99 i += 1
100 continue
101
102 endDelim = delimiters[startDelim.end]
103
104 # In single-tilde mode, opener and closer must have the same width
105 # (both `~` or both `~~`). The width is stored in the text token.
106 if single_tilde:
107 opener_content = state.tokens[startDelim.token].content
108 closer_content = state.tokens[endDelim.token].content
109 if opener_content != closer_content:
110 i += 1
111 continue
112
113 markup = state.tokens[startDelim.token].content
114
115 token = state.tokens[startDelim.token]
116 token.type = "s_open"
117 token.tag = "s"
118 token.nesting = 1
119 token.markup = markup
120 token.content = ""
121
122 token = state.tokens[endDelim.token]
123 token.type = "s_close"
124 token.tag = "s"
125 token.nesting = -1
126 token.markup = markup
127 token.content = ""
128
129 if (
130 state.tokens[endDelim.token - 1].type == "text"
131 and state.tokens[endDelim.token - 1].content == "~"
132 ):
133 loneMarkers.append(endDelim.token - 1)
134
135 i += 1
136
137 # If a marker sequence has an odd number of characters, it's split
138 # like this: `~~~~~` -> `~` + `~~` + `~~`, leaving one marker at the
139 # start of the sequence.
140 #
141 # So, we have to move all those markers after subsequent s_close tags.
142 #

Callers 1

postProcessFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…