Skip to main content
Commonmark migration
Source Link

#rs, 107 bytes

rs, 107 bytes

\t/  (?<!\\)((\*|_){2})((?=\S)(?!\2)(\\\2|.)*?)?(?<=\S)\1/(\n)^^((^^\3))\3 \\(\*|_)/\t [^\t\n]/ \n/_ \t_?/ (_*)/(^^\1) 

Live demo and test cases.

This is a pretty crazy...thing.

The newest test case does not work yet. WIP...

##Explanation

Explanation

\t/  

Replace tabs with spaces. They have the same character count, and tabs are used later on as a special character.

(?<!\\)((\*|_){2})((?=\S)(?!\2)(\\\2|.)*?)?(?<=\S)\1/(\n)^^((^^\3))\3 

Replace any text of length N that should be bolded with N newlines followed by the original text.

\\(\*|_)/\t 

Replace any occurrences of a delimiter immediately preceded by a slash with a tab. This is to make sure that entries like **a\*** have a character count of 2 instead of 3.

[^\t\n]/ 

Remove any character that's not a tab or newline.

\n/_ 

Replace all the newlines with underscores.

\t_?/ 

Remove any tabs (which represent escaped delimiters), along with any underscores that may follow them. This is related to the above issue of character counts with escaped ending delimiters.

(_*)/(^^\1) 

Replace the underscore sequence with its length. This is the character count.

#rs, 107 bytes

\t/  (?<!\\)((\*|_){2})((?=\S)(?!\2)(\\\2|.)*?)?(?<=\S)\1/(\n)^^((^^\3))\3 \\(\*|_)/\t [^\t\n]/ \n/_ \t_?/ (_*)/(^^\1) 

Live demo and test cases.

This is a pretty crazy...thing.

The newest test case does not work yet. WIP...

##Explanation

\t/  

Replace tabs with spaces. They have the same character count, and tabs are used later on as a special character.

(?<!\\)((\*|_){2})((?=\S)(?!\2)(\\\2|.)*?)?(?<=\S)\1/(\n)^^((^^\3))\3 

Replace any text of length N that should be bolded with N newlines followed by the original text.

\\(\*|_)/\t 

Replace any occurrences of a delimiter immediately preceded by a slash with a tab. This is to make sure that entries like **a\*** have a character count of 2 instead of 3.

[^\t\n]/ 

Remove any character that's not a tab or newline.

\n/_ 

Replace all the newlines with underscores.

\t_?/ 

Remove any tabs (which represent escaped delimiters), along with any underscores that may follow them. This is related to the above issue of character counts with escaped ending delimiters.

(_*)/(^^\1) 

Replace the underscore sequence with its length. This is the character count.

rs, 107 bytes

\t/  (?<!\\)((\*|_){2})((?=\S)(?!\2)(\\\2|.)*?)?(?<=\S)\1/(\n)^^((^^\3))\3 \\(\*|_)/\t [^\t\n]/ \n/_ \t_?/ (_*)/(^^\1) 

Live demo and test cases.

This is a pretty crazy...thing.

The newest test case does not work yet. WIP...

Explanation

\t/  

Replace tabs with spaces. They have the same character count, and tabs are used later on as a special character.

(?<!\\)((\*|_){2})((?=\S)(?!\2)(\\\2|.)*?)?(?<=\S)\1/(\n)^^((^^\3))\3 

Replace any text of length N that should be bolded with N newlines followed by the original text.

\\(\*|_)/\t 

Replace any occurrences of a delimiter immediately preceded by a slash with a tab. This is to make sure that entries like **a\*** have a character count of 2 instead of 3.

[^\t\n]/ 

Remove any character that's not a tab or newline.

\n/_ 

Replace all the newlines with underscores.

\t_?/ 

Remove any tabs (which represent escaped delimiters), along with any underscores that may follow them. This is related to the above issue of character counts with escaped ending delimiters.

(_*)/(^^\1) 

Replace the underscore sequence with its length. This is the character count.

deleted 72 characters in body
Source Link
kirbyfan64sos
  • 9.2k
  • 1
  • 27
  • 47

#rs, 114107 bytes

$$x=\t/  (?<!\\)((\*|_){2}) \t/  $x\1/ $x(\S(?=\S)(?!\2)(\\\2|.)*?)?(?<=\S)\1/(\n)^^((^^\3))\3 \\(\*|_)/\t [^\t\n]/ \n/_ \t_?/ (_*)/(^^\1) 

Live demo and test cases.Live demo and test cases.

This is a pretty crazy...thing.

##ExplanationThe newest test case does not work yet. WIP...

$$x=(?<!\\)((\*|_){2}) 

Create a macro that matches a set of delimiters (e.g. ** but not \**).##Explanation

\t/  

Replace tabs with spaces. They have the same character count, and tabs are used later on as a special character.

$x\1/ 

Remove all empty delimiters like ****.

$x(\S?<!\\)((\*|_){2})((?=\S)(?!\2)(\\\2|.)*?)?(?<=\S)\1/(\n)^^((^^\3))\3 

Replace any text of length N that should be bolded with N newlines followed by the original text.

\\(\*|_)/\t 

Replace any occurrences of a delimiter immediately preceded by a slash with a tab. This is to make sure that entries like **a\*** have a character count of 2 instead of 3.

[^\t\n]/ 

Remove any character that's not a tab or newline.

\n/_ 

Replace all the newlines with underscores.

\t_?/ 

Remove any tabs (which represent escaped delimiters), along with any underscores that may follow them. This is related to the above issue of character counts with escaped ending delimiters.

(_*)/(^^\1) 

Replace the underscore sequence with its length. This is the character count.

#rs, 114 bytes

$$x=(?<!\\)((\*|_){2}) \t/  $x\1/ $x(\S(\\\2|.)*?)?\1/(\n)^^((^^\3))\3 \\(\*|_)/\t [^\t\n]/ \n/_ \t_?/ (_*)/(^^\1) 

Live demo and test cases.

This is a pretty crazy...thing.

##Explanation

$$x=(?<!\\)((\*|_){2}) 

Create a macro that matches a set of delimiters (e.g. ** but not \**).

\t/  

Replace tabs with spaces. They have the same character count, and tabs are used later on as a special character.

$x\1/ 

Remove all empty delimiters like ****.

$x(\S(\\\2|.)*?)?\1/(\n)^^((^^\3))\3 

Replace any text of length N that should be bolded with N newlines followed by the original text.

\\(\*|_)/\t 

Replace any occurrences of a delimiter immediately preceded by a slash with a tab. This is to make sure that entries like **a\*** have a character count of 2 instead of 3.

[^\t\n]/ 

Remove any character that's not a tab or newline.

\n/_ 

Replace all the newlines with underscores.

\t_?/ 

Remove any tabs (which represent escaped delimiters), along with any underscores that may follow them. This is related to the above issue of character counts with escaped ending delimiters.

(_*)/(^^\1) 

Replace the underscore sequence with its length. This is the character count.

#rs, 107 bytes

\t/  (?<!\\)((\*|_){2})((?=\S)(?!\2)(\\\2|.)*?)?(?<=\S)\1/(\n)^^((^^\3))\3 \\(\*|_)/\t [^\t\n]/ \n/_ \t_?/ (_*)/(^^\1) 

Live demo and test cases.

This is a pretty crazy...thing.

The newest test case does not work yet. WIP...

##Explanation

\t/  

Replace tabs with spaces. They have the same character count, and tabs are used later on as a special character.

(?<!\\)((\*|_){2})((?=\S)(?!\2)(\\\2|.)*?)?(?<=\S)\1/(\n)^^((^^\3))\3 

Replace any text of length N that should be bolded with N newlines followed by the original text.

\\(\*|_)/\t 

Replace any occurrences of a delimiter immediately preceded by a slash with a tab. This is to make sure that entries like **a\*** have a character count of 2 instead of 3.

[^\t\n]/ 

Remove any character that's not a tab or newline.

\n/_ 

Replace all the newlines with underscores.

\t_?/ 

Remove any tabs (which represent escaped delimiters), along with any underscores that may follow them. This is related to the above issue of character counts with escaped ending delimiters.

(_*)/(^^\1) 

Replace the underscore sequence with its length. This is the character count.

added 70 characters in body
Source Link
kirbyfan64sos
  • 9.2k
  • 1
  • 27
  • 47

#rs, 114 bytes

$$x=(?<!\\)((\*|_){2}) \t/  $x\1/ $x(\S(\\\2|.)*?)?\1/(\n)^^((^^\3))\3 \\(\*|_)/\t [^\t\n]/ \n/_ \t_?/ (_*)/(^^\1) 

Live demo and test cases.

This is a pretty crazy...thing.

##Explanation

$$x=(?<!\\)((\*|_){2}) 

Create a macro that matches a set of delimiters (e.g. ** but not \**).

\t/  

Replace tabs with spaces. They have the same character count, and tabs are used later on as a special character.

$x\1/ 

Remove all empty delimiters like ****.

$x(\S(\\\2|.)*?)?\1/(\n)^^((^^\3))\3 

Replace any text of length N that should be bolded with N newlines followed by the original text.

\\(\*|_)/\t 

Replace any occurrences of a delimiter immediately preceded by a slash with a tab. This is to make sure that entries like **a\*** have a character count of 2 instead of 3.

[^\t\n]/ 

Remove any character that's not a tab or newline.

\n/_ 

Replace all the newlines with underscores.

\t_?/ 

Remove any tabs (which represent escaped delimiters), along with any underscores that may follow them. This is related to the above issue of character counts with escaped ending delimiters.

(_*)/(^^\1) 

Replace the underscore sequence with its length. This is the character count.

#rs, 114 bytes

$$x=(?<!\\)((\*|_){2}) \t/  $x\1/ $x(\S(\\\2|.)*?)?\1/(\n)^^((^^\3))\3 \\(\*|_)/\t [^\t\n]/ \n/_ \t_?/ (_*)/(^^\1) 

Live demo and test cases.

#rs, 114 bytes

$$x=(?<!\\)((\*|_){2}) \t/  $x\1/ $x(\S(\\\2|.)*?)?\1/(\n)^^((^^\3))\3 \\(\*|_)/\t [^\t\n]/ \n/_ \t_?/ (_*)/(^^\1) 

Live demo and test cases.

This is a pretty crazy...thing.

##Explanation

$$x=(?<!\\)((\*|_){2}) 

Create a macro that matches a set of delimiters (e.g. ** but not \**).

\t/  

Replace tabs with spaces. They have the same character count, and tabs are used later on as a special character.

$x\1/ 

Remove all empty delimiters like ****.

$x(\S(\\\2|.)*?)?\1/(\n)^^((^^\3))\3 

Replace any text of length N that should be bolded with N newlines followed by the original text.

\\(\*|_)/\t 

Replace any occurrences of a delimiter immediately preceded by a slash with a tab. This is to make sure that entries like **a\*** have a character count of 2 instead of 3.

[^\t\n]/ 

Remove any character that's not a tab or newline.

\n/_ 

Replace all the newlines with underscores.

\t_?/ 

Remove any tabs (which represent escaped delimiters), along with any underscores that may follow them. This is related to the above issue of character counts with escaped ending delimiters.

(_*)/(^^\1) 

Replace the underscore sequence with its length. This is the character count.

added 70 characters in body
Source Link
kirbyfan64sos
  • 9.2k
  • 1
  • 27
  • 47
Loading
Source Link
kirbyfan64sos
  • 9.2k
  • 1
  • 27
  • 47
Loading