-
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.
- Loading branch information
Showing
7 changed files
with
75 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
This file was deleted.
Oops, something went wrong.
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,17 +1,20 @@ | ||
export default function parseHeadingTwo(text: string) { | ||
export default function parseHeadingTwo(text: string): string | boolean { | ||
let changed = false; | ||
let html = text; | ||
|
||
const headingTwoPattern = /^( {0,3}##\s+.*)/; | ||
const headingTwoPattern = /^( {0,3}##\s+.*)/g; | ||
html = html.replace(headingTwoPattern, (match, headingTwoText) => { | ||
changed = true; | ||
const headingTwo = headingTwoText.split(/##/).slice(1).join("##").trim(); | ||
return `<h2>${headingTwo}</h2>`; | ||
}); | ||
|
||
const headingTwoPattern2 = /^(.*\n {0,3}-+\s*)/; | ||
const headingTwoPattern2 = /^(.*\n {0,3}-+\s*)/g; | ||
html = html.replace(headingTwoPattern2, (match, headingTwoText) => { | ||
changed = true; | ||
const headingTwo = headingTwoText.split(/\n/)[0].trim(); | ||
return `<h2>${headingTwo}</h2>`; | ||
}); | ||
|
||
return html; | ||
return !!changed ? html : false; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export default function parseHorizontalRule(text: string): string | boolean { | ||
let changed = false; | ||
let html = text; | ||
|
||
const hrPattern1 = /^\n*\*{3,}$/g; | ||
html = html.replace(hrPattern1, (match) => { | ||
changed = true; | ||
return `<hr />`; | ||
}); | ||
|
||
const hrPattern2 = /^\n*-{3,}$/g; | ||
html = html.replace(hrPattern2, (match) => { | ||
changed = true; | ||
return `<hr />`; | ||
}); | ||
|
||
const hrPattern3 = /^\n*_{3,}$/g; | ||
html = html.replace(hrPattern3, (match) => { | ||
changed = true; | ||
return `<hr />`; | ||
}); | ||
|
||
return !!changed ? html : false; | ||
} |
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 |
---|---|---|
|
@@ -34,4 +34,8 @@ a { | |
|
||
.post > *:last-child { | ||
margin-bottom: 0px; | ||
} | ||
|
||
.post > hr { | ||
width: 100% | ||
} |