Changed around line 8: pageHeader
- customAsteriskParser
- extends wrapsOnParser
- crux *
+ wrapsOnParser
+ cruxFromId
+ description Only turn on named wraps.
+ example
+ Hello *world*!
+ wrapsOn bold
+ extends abstractAftertextDirectiveParser
+ catchAllCellType wrapNameCell
- compile() {return "⭐️⭐️" + this.content }
+ get shouldMatchAll() {
+ return true
+ }
+ get wraps() {
+ const wraps = [{delimiter: "¦", tag: "code", exclusive: true, name: "code"},{delimiter: "*", tag: "strong", name: "bold"}, {delimiter: "_", tag: "em", name: "italics"}]
+ if (this.content)
+ return wraps.filter(wrap => this.content.includes(wrap.name))
+ return wraps
+ }
+ matchWholeLine = true
+ getMatches(text) {
+ const exclusives = []
+ return this.wraps.map(wrap => this.runPattern(text, wrap, exclusives)).filter(i => i).flat()
+ }
+ runPattern(text, wrap, exclusives = []) {
+ const {delimiter, tag, attributes} = wrap
+ const escapedDelimiter = delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&")
+ const pattern = new RegExp(`${escapedDelimiter}[^${escapedDelimiter}]+${escapedDelimiter}`, "g")
+ const delimiterLength = delimiter.length
+ return [...text.matchAll(pattern)].map(match => {
+ const { index } = match
+ const endIndex = index + match[0].length
+ if (exclusives.some(exclusive => index >= exclusive[0] && index <= exclusive[1]))
+ return undefined
+ if (wrap.exclusive)
+ exclusives.push([index, endIndex])
+ return [
+ { index, string: `<${tag + (attributes ? " " + attributes : "")}>`, endIndex, consumeStartCharacters: delimiterLength },
+ { index: endIndex, endIndex, string: `${tag}>`, consumeEndCharacters: delimiterLength }
+ ]
+ }).filter(i => i)
+ }
- * This is my __custom__ *asterisk* parser.
+ * This is my ¦sdf¦ __custom__ *asterisk* parser.