mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat(markdown): use BBCode-style [spoiler][/spoiler] tags
This commit is contained in:
@@ -145,7 +145,7 @@ type Token =
|
|||||||
| { type: 'crossBoardLink'; display: string; route: string }
|
| { type: 'crossBoardLink'; display: string; route: string }
|
||||||
| { type: 'spoiler'; tokens: Token[] };
|
| { type: 'spoiler'; tokens: Token[] };
|
||||||
|
|
||||||
const SPOILER_REGEX = /<spoiler>([\s\S]*?)<\/spoiler>/;
|
const SPOILER_REGEX = /\[spoiler\]([\s\S]*?)\[\/spoiler\]/;
|
||||||
const CROSSBOARD_REGEX = />>>\/((?:[a-zA-Z0-9]{1,10}\/(?:[a-zA-Z0-9]{46})?|[a-zA-Z0-9\-.]+(?:\/[a-zA-Z0-9]{46})?))[.,:;!?]*/;
|
const CROSSBOARD_REGEX = />>>\/((?:[a-zA-Z0-9]{1,10}\/(?:[a-zA-Z0-9]{46})?|[a-zA-Z0-9\-.]+(?:\/[a-zA-Z0-9]{46})?))[.,:;!?]*/;
|
||||||
const QUOTE_LINK_REGEX = /(?<![>/\w])>>(\d+)(?![\d/])/;
|
const QUOTE_LINK_REGEX = /(?<![>/\w])>>(\d+)(?![\d/])/;
|
||||||
const URL_REGEX = /https?:\/\/[^\s<\[\]]*[^\s<\[\].,;:!?\"'\)\]>]/;
|
const URL_REGEX = /https?:\/\/[^\s<\[\]]*[^\s<\[\].,;:!?\"'\)\]>]/;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export function getTextColorForBackground(rgb: string): string {
|
|||||||
|
|
||||||
export function removeMarkdown(md: string): string {
|
export function removeMarkdown(md: string): string {
|
||||||
return md
|
return md
|
||||||
.replace(/<spoiler>(.*?)<\/spoiler>/gs, '$1') // spoiler tags - keep inner text
|
.replace(/\[spoiler\](.*?)\[\/spoiler\]/gs, '$1') // spoiler tags - keep inner text
|
||||||
.replace(/\[([^\]]*?)\]\([^)]*\)/g, '$1') // [text](url) -> text
|
.replace(/\[([^\]]*?)\]\([^)]*\)/g, '$1') // [text](url) -> text
|
||||||
.replace(/ /g, ' ') // -> space
|
.replace(/ /g, ' ') // -> space
|
||||||
.replace(/^>\s*/gm, '') // greentext at line start
|
.replace(/^>\s*/gm, '') // greentext at line start
|
||||||
|
|||||||
@@ -188,8 +188,8 @@ const FAQ = () => {
|
|||||||
<dt id='spoiler'>Can I mark a submission as a spoiler?</dt>
|
<dt id='spoiler'>Can I mark a submission as a spoiler?</dt>
|
||||||
<dd>
|
<dd>
|
||||||
All boards allow you to mask plot-spoiling content. To mark your image as a spoiler, check the [x Spoiler?] box before submission. Spoilerizing text
|
All boards allow you to mask plot-spoiling content. To mark your image as a spoiler, check the [x Spoiler?] box before submission. Spoilerizing text
|
||||||
makes it unreadable to others until they mouse over it. To spoilerize a comment, place {`<spoiler>`} tags around the text you wish to hide (ex. "
|
makes it unreadable to others until they mouse over it. To spoilerize a comment, place {`[spoiler][/spoiler]`} tags around the text you wish to hide
|
||||||
{`<spoiler>`}SPIKE DIES!{`</spoiler>`}").
|
(ex. "{`[spoiler]`}SPIKE DIES!{`[/spoiler]`}").
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user