From f1c4910993d601ab57176f65ff5730e053fa2597 Mon Sep 17 00:00:00 2001 From: Charlie Humphreys Date: Fri, 10 Dec 2021 20:25:31 -0600 Subject: [PATCH] Add to migrate document and update colon-replacement for the markdown renderer --- client/homebrew/pages/homePage/migrate_gmb.md | 13 ++++--------- shared/naturalcrit/markdown.js | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/client/homebrew/pages/homePage/migrate_gmb.md b/client/homebrew/pages/homePage/migrate_gmb.md index f90eaff18..5a70452df 100644 --- a/client/homebrew/pages/homePage/migrate_gmb.md +++ b/client/homebrew/pages/homePage/migrate_gmb.md @@ -139,25 +139,20 @@ ___ **Use these find/replace commands in the order listed for the best result.** #### Blockquotes -The key difference is the lack of blockquotes. GMBinder uses the `>` symbol at the start of the line for each line in the stat block, and Homebrewery's v3 renderer does not. Running the following find/replace commands with regex enabled should remove the blockquotes: - -| Find | Replace | -|:------|:--------| -| `^> ` | | -| `^>` | | +The key difference is the lack of blockquotes. GMBinder uses the `>` symbol at the start of the line for each line in the stat block, and Homebrewery's v3 renderer does not. **You will want to remove all `>` characters at the beginning of all lines, and delete any leading spaces.** #### Lists -The basic characteristics and advanced characteristics sections are not list elements in Homebrewery. You can remove them by finding `^- ` and replacing it with nothing. +The basic characteristics and advanced characteristics sections are not list elements in Homebrewery. **You will want to remove all `-` or `*` characters from the beginning of lines.** #### Spacing -In order to have the correct spacing after removing the list elements, you will want to add `\:\:` between the name of each basic/advanced characteristic and its value. i.e: +In order to have the correct spacing after removing the list elements, **you will want to add two colons (`::`) between the name of each basic/advanced characteristic and its value.** i.e: ``` **Skills** :: Athletics +6 ``` : -Additionally, in the special traits and actions sections, you will want to add a `\:` at the beginning of each line that separates a trait/action from another, as seen below. This can be accomplished with find/replace by replacing `^$` with `\:`. +Additionally, in the special traits and actions sections, you will want to add a colon at the beginning of each line that separates a trait/action from another, as seen below. **Any empty lines between special traits and actions should contain only a colon.** ``` ### Actions diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 5003d1053..10e92eb4e 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -535,7 +535,24 @@ module.exports = { marked : Markdown, render : (rawBrewText)=>{ rawBrewText = rawBrewText.replace(/^\\column$/gm, `\n
\n`) - .replace(/^(:+)$/gm, (match)=>`${`
`.repeat(match.length)}\n`); + .replace(/^(:+)$/gm, (match, _, i)=>{ + let test, matches=[]; + const codeBlock = /`/gm, inlineCodeBlock = /[^`]`[^`]/g; + while (test = codeBlock.exec(rawBrewText)) { + matches.push(test); + } + // console.log(match, m, i, indexes); + if(matches.filter((m)=>m.index < i).length % 2 !== 0) return match; + + // matches = []; + // while (test = inlineCodeBlock.exec(rawBrewText)) { + // matches.push(test); + // } + // console.log(matches, match, i); + // if(matches.filter((m)=>m.index < i).length % 2 !== 0) return match; + + return `${`
`.repeat(match.length)}\n`; + }); return Markdown( sanatizeScriptTags(rawBrewText), { renderer: renderer }