-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'stage' of github.com:Adventech/sabbath-school-resources…
… into stage
- Loading branch information
Showing
10 changed files
with
90 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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 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 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,22 +1,23 @@ | ||
let superscriptReplacement = function (str) { | ||
const unicodeMap = ["⁰", "¹", "²", "³", "⁴", "⁵", "⁶", "⁷", "⁸", "⁹"] | ||
let ret = str | ||
for (let i = 0; i <= 9; i++) { | ||
ret = ret.replace(new RegExp(`${i}`, "gm"), unicodeMap[i]) | ||
} | ||
return ret | ||
} | ||
|
||
export const superscript = function (block) { | ||
let sspmSuperscript = /(~|<sup>)(\d*)(~|<\/sup>)/img | ||
let sspmSuperscript = /(~|<sup>)(.*)(~|<\/sup>)/img | ||
let sspmSuperscriptMatch = block.raw.match(sspmSuperscript) | ||
|
||
|
||
if (sspmSuperscriptMatch && sspmSuperscriptMatch.length > 0) { | ||
for (let match of sspmSuperscriptMatch) { | ||
let unicodeNumber = superscriptReplacement(match.replace(sspmSuperscript, "$2")) | ||
block.text = block.text.replace(match, unicodeNumber).trim() | ||
let superscript = match.replace(sspmSuperscript, "$2") | ||
block.text = block.text.replace(match, `^[${superscript}]({"style":{"text":{"offset": "sup"}}})`).trim() | ||
} | ||
} | ||
|
||
let sspmSubscript = /(~|<sub>)(.*)(~|<\/sub>)/img | ||
let sspmSubscriptMatch = block.raw.match(sspmSubscript) | ||
|
||
if (sspmSubscriptMatch && sspmSubscriptMatch.length > 0) { | ||
for (let match of sspmSubscriptMatch) { | ||
let subscript = match.replace(sspmSubscript, "$2") | ||
block.text = block.text.replace(match, `^[${subscript}]({"style":{"text":{"offset": "sub"}}})`).trim() | ||
} | ||
} | ||
|
||
return block | ||
} |
This file contains 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 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 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 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 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
Binary file not shown.
This file contains 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