24
24
//
25
25
// [url]http://blogs.stonesteps.ca/showpost.asp?pid=33[/url]
26
26
// [url=http://blogs.stonesteps.ca/showpost.asp?pid=33][b]BBCode[/b] Parser[/url]
27
+ // [url="http://blogs.stonesteps.ca/showpost.asp?pid=33"][b]BBCode[/b] Parser[/url]
27
28
//
28
29
// [q=http://blogs.stonesteps.ca/showpost.asp?pid=33]inline quote[/q]
29
30
// [q]inline quote[/q]
@@ -50,7 +51,7 @@ exports.parse = function(post, cb) {
50
51
var urlstart = - 1 ; // beginning of the URL if zero or greater (ignored if -1)
51
52
52
53
// aceptable BBcode tags, optionally prefixed with a slash
53
- var tagname_re = / ^ \/ ? (?: b | i | u | p r e | s a m p | c o d e | c o l o u ? r | s i z e | n o p a r s e | u r l | s | q | b l o c k q u o t e | i m g | u ? l i s t | l i ) $ / ;
54
+ var tagname_re = / ^ \/ ? (?: b | i | u | p r e | s a m p | c o d e | c o l o u ? r | s i z e | n o p a r s e | u r l | l i n k | s | q | b l o c k q u o t e | i m g | u ? l i s t | l i ) $ / ;
54
55
55
56
// color names or hex color
56
57
var color_re = / ^ ( : ? b l a c k | s i l v e r | g r a y | w h i t e | m a r o o n | r e d | p u r p l e | f u c h s i a | g r e e n | l i m e | o l i v e | y e l l o w | n a v y | b l u e | t e a l | a q u a | # (?: [ 0 - 9 a - f ] { 3 } ) ? [ 0 - 9 a - f ] { 3 } ) $ / i;
@@ -61,8 +62,8 @@ exports.parse = function(post, cb) {
61
62
// reserved, unreserved, escaped and alpha-numeric [RFC2396]
62
63
var uri_re = / ^ [ - ; \/ \? : @ & = \+ \$ , _ \. ! ~ \* ' \( \) % 0 - 9 a - z ] { 1 , 512 } $ / i;
63
64
64
- // main regular expression: CRLF, [tag=option], [tag] or [/tag]
65
- var postfmt_re = / ( [ \r \n ] ) | (?: \[ ( [ a - z ] { 1 , 16 } ) (?: = ( [ ^ \x00 - \x1F " ' \( \) < > \[ \] ] { 1 , 256 } ) ) ? \] ) | (?: \[ \/ ( [ a - z ] { 1 , 16 } ) \] ) / ig;
65
+ // main regular expression: CRLF, [tag=option], [tag="option"] [tag ] or [/tag]
66
+ var postfmt_re = / ( [ \r \n ] ) | (?: \[ ( [ a - z ] { 1 , 16 } ) (?: = (?: " | ' | ) ( [ ^ \x00 - \x1F " ' \( \) < > \[ \] ] { 1 , 256 } ) ) ? (?: " | ' | ) \] ) | (?: \[ \/ ( [ a - z ] { 1 , 16 } ) \] ) / ig;
66
67
67
68
// stack frame object
68
69
function taginfo_t ( bbtag , etag )
@@ -114,7 +115,7 @@ exports.parse = function(post, cb) {
114
115
return "[" + m2 + "]" ;
115
116
116
117
// ignore any tags if there's an open option-less [url] tag
117
- if ( opentags . length && opentags [ opentags . length - 1 ] . bbtag == "url" && urlstart >= 0 )
118
+ if ( opentags . length && ( opentags [ opentags . length - 1 ] . bbtag == "url" || opentags [ opentags . length - 1 ] . bbtag == "link" ) && urlstart >= 0 )
118
119
return "[" + m2 + "]" ;
119
120
120
121
switch ( m2 ) {
@@ -149,6 +150,7 @@ exports.parse = function(post, cb) {
149
150
noparse = true ;
150
151
return "" ;
151
152
153
+ case "link" :
152
154
case "url" :
153
155
opentags . push ( new taginfo_t ( m2 , "</a>" ) ) ;
154
156
@@ -214,7 +216,7 @@ exports.parse = function(post, cb) {
214
216
if ( ! opentags . length || opentags [ opentags . length - 1 ] . bbtag != m4 )
215
217
return "<span style=\"color: red\">[/" + m4 + "]</span>" ;
216
218
217
- if ( m4 == "url" ) {
219
+ if ( m4 == "url" || m4 == "link" ) {
218
220
// if there was no option, use the content of the [url] tag
219
221
if ( urlstart > 0 )
220
222
return "\">" + string . substr ( urlstart , offset - urlstart ) + opentags . pop ( ) . etag ;
@@ -262,7 +264,7 @@ exports.parse = function(post, cb) {
262
264
endtags = new String ( ) ;
263
265
264
266
// if there's an open [url] at the top, close it
265
- if ( opentags [ opentags . length - 1 ] . bbtag == "url" ) {
267
+ if ( opentags [ opentags . length - 1 ] . bbtag == "url" || opentags [ opentags . length - 1 ] . bbtag == "link" ) {
266
268
opentags . pop ( ) ;
267
269
endtags += "\">" + post . substr ( urlstart , post . length - urlstart ) + "</a>" ;
268
270
}
@@ -278,4 +280,4 @@ exports.parse = function(post, cb) {
278
280
} else {
279
281
return ret ;
280
282
}
281
- }
283
+ }
0 commit comments