breakout_parser 0.0.20 → 0.0.23
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +11 -5
- data/README +6 -1
- data/ext/breakout_parser/lex.yy.c +24 -20
- data/ext/breakout_parser/parser.tab.c +79 -85
- data/ext/breakout_parser/parser.tab.h +7 -6
- data/ext/breakout_parser/parser.y +14 -12
- data/ext/breakout_parser/ruby_ext.c +3 -3
- data/spec/parser_spec.rb +57 -55
- metadata +6 -6
data/ChangeLog
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
[ 0.0.21 ]
|
2
|
+
* emit correct urls for external svn links
|
3
|
+
(https://www.assembla.com/spaces/breakout/tickets/8472)
|
4
|
+
* emit restful wiki links
|
5
|
+
(https://www.assembla.com/spaces/breakout/tickets/8396)
|
6
|
+
|
1
7
|
[ 0.0.20 ]
|
2
8
|
|
3
9
|
* parse "$REV$" in external repo links
|
@@ -9,26 +15,26 @@
|
|
9
15
|
(https://www.assembla.com/spaces/breakout/tickets/6513)
|
10
16
|
|
11
17
|
[ 0.0.18 ]
|
12
|
-
|
18
|
+
|
13
19
|
* added README
|
14
20
|
* added option to make relative urls absolute
|
15
21
|
(https://www.assembla.com/spaces/breakout/tickets/6513)
|
16
22
|
|
17
23
|
[ 0.0.17 ]
|
18
|
-
|
24
|
+
|
19
25
|
* fix not-closing bold/italics tags when opened before <pre> and/or <code>
|
20
26
|
(https://www.assembla.com/spaces/breakout/tickets/6385)
|
21
27
|
|
22
28
|
[ 0.0.16 ]
|
23
|
-
|
29
|
+
|
24
30
|
* make a [[issue:123]] as a synonym to [[ticket:123]]
|
25
31
|
|
26
32
|
[ 0.0.15 ]
|
27
|
-
|
33
|
+
|
28
34
|
* allow spaces in links to wiki pages, re http://www.assembla.com/spaces/breakout/tickets/5916
|
29
35
|
|
30
36
|
[ 0.0.14 ]
|
31
|
-
|
37
|
+
|
32
38
|
* fix handling of broken multilevel lists, re https://www.assembla.com/spaces/breakout/tickets/5902
|
33
39
|
|
34
40
|
[ 0.0.13 ]
|
data/README
CHANGED
@@ -4,6 +4,11 @@ Breakout Parser
|
|
4
4
|
- simplified Textile parser with some Assembla-specific features
|
5
5
|
- converts Textile into HTML
|
6
6
|
|
7
|
+
Build dependencies
|
8
|
+
==================
|
9
|
+
|
10
|
+
You will need Flex, Bison, GCC, and GNU Make to build this gem.
|
11
|
+
|
7
12
|
|
8
13
|
Usage
|
9
14
|
===============
|
@@ -24,5 +29,5 @@ Arguments
|
|
24
29
|
data, # data to parse
|
25
30
|
space_name, # space name - for links parsing
|
26
31
|
site_url, # [optional] global site url
|
27
|
-
|
32
|
+
vcs_url # [optional] custom VCS url - f.ex. for github-hosted repos
|
28
33
|
)
|
@@ -53,7 +53,6 @@ typedef int flex_int32_t;
|
|
53
53
|
typedef unsigned char flex_uint8_t;
|
54
54
|
typedef unsigned short int flex_uint16_t;
|
55
55
|
typedef unsigned int flex_uint32_t;
|
56
|
-
#endif /* ! C99 */
|
57
56
|
|
58
57
|
/* Limits of integral types. */
|
59
58
|
#ifndef INT8_MIN
|
@@ -84,6 +83,8 @@ typedef unsigned int flex_uint32_t;
|
|
84
83
|
#define UINT32_MAX (4294967295U)
|
85
84
|
#endif
|
86
85
|
|
86
|
+
#endif /* ! C99 */
|
87
|
+
|
87
88
|
#endif /* ! FLEXINT_H */
|
88
89
|
|
89
90
|
#ifdef __cplusplus
|
@@ -140,7 +141,15 @@ typedef unsigned int flex_uint32_t;
|
|
140
141
|
|
141
142
|
/* Size of default input buffer. */
|
142
143
|
#ifndef YY_BUF_SIZE
|
144
|
+
#ifdef __ia64__
|
145
|
+
/* On IA-64, the buffer size is 16k, not 8k.
|
146
|
+
* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
|
147
|
+
* Ditto for the __ia64__ case accordingly.
|
148
|
+
*/
|
149
|
+
#define YY_BUF_SIZE 32768
|
150
|
+
#else
|
143
151
|
#define YY_BUF_SIZE 16384
|
152
|
+
#endif /* __ia64__ */
|
144
153
|
#endif
|
145
154
|
|
146
155
|
/* The state buf must be large enough to hold one state per character in the main buffer.
|
@@ -1188,7 +1197,7 @@ extern size_t in_buf_len;
|
|
1188
1197
|
|
1189
1198
|
|
1190
1199
|
|
1191
|
-
#line
|
1200
|
+
#line 1201 "lex.yy.c"
|
1192
1201
|
|
1193
1202
|
#define INITIAL 0
|
1194
1203
|
#define _PRE_CODE 1
|
@@ -1286,7 +1295,12 @@ static int input (void );
|
|
1286
1295
|
|
1287
1296
|
/* Amount of stuff to slurp up with each read. */
|
1288
1297
|
#ifndef YY_READ_BUF_SIZE
|
1298
|
+
#ifdef __ia64__
|
1299
|
+
/* On IA-64, the buffer size is 16k, not 8k */
|
1300
|
+
#define YY_READ_BUF_SIZE 16384
|
1301
|
+
#else
|
1289
1302
|
#define YY_READ_BUF_SIZE 8192
|
1303
|
+
#endif /* __ia64__ */
|
1290
1304
|
#endif
|
1291
1305
|
|
1292
1306
|
/* Copy whatever the last rule matched to the standard output. */
|
@@ -1294,7 +1308,7 @@ static int input (void );
|
|
1294
1308
|
/* This used to be an fputs(), but since the string might contain NUL's,
|
1295
1309
|
* we now use fwrite().
|
1296
1310
|
*/
|
1297
|
-
#define ECHO fwrite( yytext, yyleng, 1, yyout )
|
1311
|
+
#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
|
1298
1312
|
#endif
|
1299
1313
|
|
1300
1314
|
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
|
@@ -1305,7 +1319,7 @@ static int input (void );
|
|
1305
1319
|
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
|
1306
1320
|
{ \
|
1307
1321
|
int c = '*'; \
|
1308
|
-
|
1322
|
+
size_t n; \
|
1309
1323
|
for ( n = 0; n < max_size && \
|
1310
1324
|
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
|
1311
1325
|
buf[n] = (char) c; \
|
@@ -1394,7 +1408,7 @@ YY_DECL
|
|
1394
1408
|
|
1395
1409
|
if( parse_links_only ) BEGIN(_LINKS_ONLY);
|
1396
1410
|
|
1397
|
-
#line
|
1411
|
+
#line 1412 "lex.yy.c"
|
1398
1412
|
|
1399
1413
|
if ( !(yy_init) )
|
1400
1414
|
{
|
@@ -1954,7 +1968,7 @@ YY_RULE_SETUP
|
|
1954
1968
|
#line 203 "parser.l"
|
1955
1969
|
ECHO;
|
1956
1970
|
YY_BREAK
|
1957
|
-
#line
|
1971
|
+
#line 1972 "lex.yy.c"
|
1958
1972
|
case YY_STATE_EOF(INITIAL):
|
1959
1973
|
case YY_STATE_EOF(_LINKS_ONLY):
|
1960
1974
|
yyterminate();
|
@@ -2474,19 +2488,9 @@ static void yy_load_buffer_state (void)
|
|
2474
2488
|
yyfree((void *) b );
|
2475
2489
|
}
|
2476
2490
|
|
2477
|
-
#ifndef
|
2478
|
-
#ifdef __cplusplus
|
2479
|
-
extern "C" {
|
2480
|
-
#endif
|
2481
|
-
#ifdef __THROW /* this is a gnuism */
|
2482
|
-
extern int isatty (int ) __THROW;
|
2483
|
-
#else
|
2491
|
+
#ifndef __cplusplus
|
2484
2492
|
extern int isatty (int );
|
2485
|
-
#endif
|
2486
|
-
#ifdef __cplusplus
|
2487
|
-
}
|
2488
|
-
#endif
|
2489
|
-
#endif
|
2493
|
+
#endif /* __cplusplus */
|
2490
2494
|
|
2491
2495
|
/* Initializes or reinitializes a buffer.
|
2492
2496
|
* This function is sometimes called more than once on the same buffer,
|
@@ -2692,8 +2696,8 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
|
|
2692
2696
|
|
2693
2697
|
/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
|
2694
2698
|
* scan from a @e copy of @a bytes.
|
2695
|
-
* @param
|
2696
|
-
* @param
|
2699
|
+
* @param yybytes the byte buffer to scan
|
2700
|
+
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
|
2697
2701
|
*
|
2698
2702
|
* @return the newly allocated buffer state object.
|
2699
2703
|
*/
|
@@ -1,9 +1,10 @@
|
|
1
|
-
|
1
|
+
|
2
|
+
/* A Bison parser, made by GNU Bison 2.4.1. */
|
2
3
|
|
3
4
|
/* Skeleton implementation for Bison's Yacc-like parsers in C
|
4
5
|
|
5
|
-
Copyright (C) 1984, 1989
|
6
|
-
Foundation, Inc.
|
6
|
+
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
7
|
+
Free Software Foundation, Inc.
|
7
8
|
|
8
9
|
This program is free software: you can redistribute it and/or modify
|
9
10
|
it under the terms of the GNU General Public License as published by
|
@@ -45,7 +46,7 @@
|
|
45
46
|
#define YYBISON 1
|
46
47
|
|
47
48
|
/* Bison version. */
|
48
|
-
#define YYBISON_VERSION "2.4.
|
49
|
+
#define YYBISON_VERSION "2.4.1"
|
49
50
|
|
50
51
|
/* Skeleton name. */
|
51
52
|
#define YYSKELETON_NAME "yacc.c"
|
@@ -93,7 +94,7 @@ size_t space_name_len = 0;
|
|
93
94
|
const char *site_url = NULL;
|
94
95
|
size_t site_url_len = 0;
|
95
96
|
|
96
|
-
extern VALUE
|
97
|
+
extern VALUE vcs_url;
|
97
98
|
|
98
99
|
int list_level = 1;
|
99
100
|
int absolute_urls = 0;
|
@@ -137,7 +138,7 @@ void yyerror(const char *msg)
|
|
137
138
|
|
138
139
|
|
139
140
|
/* Line 189 of yacc.c */
|
140
|
-
#line
|
141
|
+
#line 142 "parser.tab.c"
|
141
142
|
|
142
143
|
/* Enabling traces. */
|
143
144
|
#ifndef YYDEBUG
|
@@ -226,7 +227,7 @@ typedef union YYSTYPE
|
|
226
227
|
|
227
228
|
|
228
229
|
/* Line 214 of yacc.c */
|
229
|
-
#line
|
230
|
+
#line 231 "parser.tab.c"
|
230
231
|
} YYSTYPE;
|
231
232
|
# define YYSTYPE_IS_TRIVIAL 1
|
232
233
|
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
@@ -238,7 +239,7 @@ typedef union YYSTYPE
|
|
238
239
|
|
239
240
|
|
240
241
|
/* Line 264 of yacc.c */
|
241
|
-
#line
|
242
|
+
#line 243 "parser.tab.c"
|
242
243
|
|
243
244
|
#ifdef short
|
244
245
|
# undef short
|
@@ -288,7 +289,7 @@ typedef short int yytype_int16;
|
|
288
289
|
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
|
289
290
|
|
290
291
|
#ifndef YY_
|
291
|
-
# if
|
292
|
+
# if YYENABLE_NLS
|
292
293
|
# if ENABLE_NLS
|
293
294
|
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
|
294
295
|
# define YY_(msgid) dgettext ("bison-runtime", msgid)
|
@@ -733,18 +734,9 @@ static const yytype_uint8 yystos[] =
|
|
733
734
|
|
734
735
|
/* Like YYERROR except do call yyerror. This remains here temporarily
|
735
736
|
to ease the transition to the new meaning of YYERROR, for GCC.
|
736
|
-
Once GCC version 2 has supplanted version 1, this can go.
|
737
|
-
YYFAIL appears to be in use. Nevertheless, it is formally deprecated
|
738
|
-
in Bison 2.4.2's NEWS entry, where a plan to phase it out is
|
739
|
-
discussed. */
|
737
|
+
Once GCC version 2 has supplanted version 1, this can go. */
|
740
738
|
|
741
739
|
#define YYFAIL goto yyerrlab
|
742
|
-
#if defined YYFAIL
|
743
|
-
/* This is here to suppress warnings from the GCC cpp's
|
744
|
-
-Wunused-macros. Normally we don't worry about that warning, but
|
745
|
-
some users do, and we want to make it easy for users to remove
|
746
|
-
YYFAIL uses, which will produce warnings from Bison 2.5. */
|
747
|
-
#endif
|
748
740
|
|
749
741
|
#define YYRECOVERING() (!!yyerrstatus)
|
750
742
|
|
@@ -801,7 +793,7 @@ while (YYID (0))
|
|
801
793
|
we won't break user code: when these are the locations we know. */
|
802
794
|
|
803
795
|
#ifndef YY_LOCATION_PRINT
|
804
|
-
# if
|
796
|
+
# if YYLTYPE_IS_TRIVIAL
|
805
797
|
# define YY_LOCATION_PRINT(File, Loc) \
|
806
798
|
fprintf (File, "%d.%d-%d.%d", \
|
807
799
|
(Loc).first_line, (Loc).first_column, \
|
@@ -1540,42 +1532,42 @@ yyreduce:
|
|
1540
1532
|
{
|
1541
1533
|
case 6:
|
1542
1534
|
|
1543
|
-
/* Line
|
1535
|
+
/* Line 1455 of yacc.c */
|
1544
1536
|
#line 104 "parser.y"
|
1545
1537
|
{concat("</h1>",5);}
|
1546
1538
|
break;
|
1547
1539
|
|
1548
1540
|
case 7:
|
1549
1541
|
|
1550
|
-
/* Line
|
1542
|
+
/* Line 1455 of yacc.c */
|
1551
1543
|
#line 105 "parser.y"
|
1552
1544
|
{concat("</h2>",5);}
|
1553
1545
|
break;
|
1554
1546
|
|
1555
1547
|
case 8:
|
1556
1548
|
|
1557
|
-
/* Line
|
1549
|
+
/* Line 1455 of yacc.c */
|
1558
1550
|
#line 106 "parser.y"
|
1559
1551
|
{concat("</h3>",5);}
|
1560
1552
|
break;
|
1561
1553
|
|
1562
1554
|
case 9:
|
1563
1555
|
|
1564
|
-
/* Line
|
1556
|
+
/* Line 1455 of yacc.c */
|
1565
1557
|
#line 107 "parser.y"
|
1566
1558
|
{concat("</h4>",5);}
|
1567
1559
|
break;
|
1568
1560
|
|
1569
1561
|
case 10:
|
1570
1562
|
|
1571
|
-
/* Line
|
1563
|
+
/* Line 1455 of yacc.c */
|
1572
1564
|
#line 108 "parser.y"
|
1573
1565
|
{concat("</h5>",5);}
|
1574
1566
|
break;
|
1575
1567
|
|
1576
1568
|
case 11:
|
1577
1569
|
|
1578
|
-
/* Line
|
1570
|
+
/* Line 1455 of yacc.c */
|
1579
1571
|
#line 109 "parser.y"
|
1580
1572
|
{
|
1581
1573
|
list_level=1;
|
@@ -1585,7 +1577,7 @@ yyreduce:
|
|
1585
1577
|
|
1586
1578
|
case 12:
|
1587
1579
|
|
1588
|
-
/* Line
|
1580
|
+
/* Line 1455 of yacc.c */
|
1589
1581
|
#line 112 "parser.y"
|
1590
1582
|
{
|
1591
1583
|
concat("</ul>",5);
|
@@ -1595,7 +1587,7 @@ yyreduce:
|
|
1595
1587
|
|
1596
1588
|
case 14:
|
1597
1589
|
|
1598
|
-
/* Line
|
1590
|
+
/* Line 1455 of yacc.c */
|
1599
1591
|
#line 116 "parser.y"
|
1600
1592
|
{
|
1601
1593
|
list_level=1;
|
@@ -1605,7 +1597,7 @@ yyreduce:
|
|
1605
1597
|
|
1606
1598
|
case 15:
|
1607
1599
|
|
1608
|
-
/* Line
|
1600
|
+
/* Line 1455 of yacc.c */
|
1609
1601
|
#line 119 "parser.y"
|
1610
1602
|
{
|
1611
1603
|
concat("</ol>",5);
|
@@ -1615,302 +1607,302 @@ yyreduce:
|
|
1615
1607
|
|
1616
1608
|
case 18:
|
1617
1609
|
|
1618
|
-
/* Line
|
1610
|
+
/* Line 1455 of yacc.c */
|
1619
1611
|
#line 125 "parser.y"
|
1620
1612
|
{concat("</li>",5);}
|
1621
1613
|
break;
|
1622
1614
|
|
1623
1615
|
case 19:
|
1624
1616
|
|
1625
|
-
/* Line
|
1617
|
+
/* Line 1455 of yacc.c */
|
1626
1618
|
#line 126 "parser.y"
|
1627
1619
|
{concat("</li>",5);}
|
1628
1620
|
break;
|
1629
1621
|
|
1630
1622
|
case 22:
|
1631
1623
|
|
1632
|
-
/* Line
|
1624
|
+
/* Line 1455 of yacc.c */
|
1633
1625
|
#line 131 "parser.y"
|
1634
1626
|
{concat("</li>",5);}
|
1635
1627
|
break;
|
1636
1628
|
|
1637
1629
|
case 23:
|
1638
1630
|
|
1639
|
-
/* Line
|
1631
|
+
/* Line 1455 of yacc.c */
|
1640
1632
|
#line 132 "parser.y"
|
1641
1633
|
{concat("</li>",5);}
|
1642
1634
|
break;
|
1643
1635
|
|
1644
1636
|
case 30:
|
1645
1637
|
|
1646
|
-
/* Line
|
1638
|
+
/* Line 1455 of yacc.c */
|
1647
1639
|
#line 142 "parser.y"
|
1648
1640
|
{concat2((yyvsp[(1) - (1)].svalue));}
|
1649
1641
|
break;
|
1650
1642
|
|
1651
1643
|
case 31:
|
1652
1644
|
|
1653
|
-
/* Line
|
1645
|
+
/* Line 1455 of yacc.c */
|
1654
1646
|
#line 143 "parser.y"
|
1655
1647
|
{process_url((yyvsp[(1) - (1)].svalue));}
|
1656
1648
|
break;
|
1657
1649
|
|
1658
1650
|
case 32:
|
1659
1651
|
|
1660
|
-
/* Line
|
1652
|
+
/* Line 1455 of yacc.c */
|
1661
1653
|
#line 144 "parser.y"
|
1662
1654
|
{process_email((yyvsp[(1) - (1)].svalue));}
|
1663
1655
|
break;
|
1664
1656
|
|
1665
1657
|
case 33:
|
1666
1658
|
|
1667
|
-
/* Line
|
1659
|
+
/* Line 1455 of yacc.c */
|
1668
1660
|
#line 145 "parser.y"
|
1669
1661
|
{(yyvsp[(1) - (1)].ivalue) ? concat(" <strong>",9) : concat("<strong>",8);}
|
1670
1662
|
break;
|
1671
1663
|
|
1672
1664
|
case 34:
|
1673
1665
|
|
1674
|
-
/* Line
|
1666
|
+
/* Line 1455 of yacc.c */
|
1675
1667
|
#line 146 "parser.y"
|
1676
1668
|
{concat("</strong>",9);}
|
1677
1669
|
break;
|
1678
1670
|
|
1679
1671
|
case 35:
|
1680
1672
|
|
1681
|
-
/* Line
|
1673
|
+
/* Line 1455 of yacc.c */
|
1682
1674
|
#line 147 "parser.y"
|
1683
1675
|
{(yyvsp[(1) - (1)].ivalue) ? concat(" <em>",5) : concat("<em>",4);}
|
1684
1676
|
break;
|
1685
1677
|
|
1686
1678
|
case 36:
|
1687
1679
|
|
1688
|
-
/* Line
|
1680
|
+
/* Line 1455 of yacc.c */
|
1689
1681
|
#line 148 "parser.y"
|
1690
1682
|
{concat("</em>",5);}
|
1691
1683
|
break;
|
1692
1684
|
|
1693
1685
|
case 37:
|
1694
1686
|
|
1695
|
-
/* Line
|
1687
|
+
/* Line 1455 of yacc.c */
|
1696
1688
|
#line 149 "parser.y"
|
1697
1689
|
{(yyvsp[(1) - (1)].ivalue) ? concat(" <strong><em>",13) : concat("<strong><em>",12);}
|
1698
1690
|
break;
|
1699
1691
|
|
1700
1692
|
case 38:
|
1701
1693
|
|
1702
|
-
/* Line
|
1694
|
+
/* Line 1455 of yacc.c */
|
1703
1695
|
#line 150 "parser.y"
|
1704
1696
|
{(yyvsp[(1) - (1)].ivalue) ? concat(" <em><strong>",13) : concat("<em><strong>",12);}
|
1705
1697
|
break;
|
1706
1698
|
|
1707
1699
|
case 39:
|
1708
1700
|
|
1709
|
-
/* Line
|
1701
|
+
/* Line 1455 of yacc.c */
|
1710
1702
|
#line 151 "parser.y"
|
1711
1703
|
{process_inline_code((yyvsp[(1) - (1)].svalue));}
|
1712
1704
|
break;
|
1713
1705
|
|
1714
1706
|
case 40:
|
1715
1707
|
|
1716
|
-
/* Line
|
1708
|
+
/* Line 1455 of yacc.c */
|
1717
1709
|
#line 152 "parser.y"
|
1718
1710
|
{revert_bold();}
|
1719
1711
|
break;
|
1720
1712
|
|
1721
1713
|
case 41:
|
1722
1714
|
|
1723
|
-
/* Line
|
1715
|
+
/* Line 1455 of yacc.c */
|
1724
1716
|
#line 153 "parser.y"
|
1725
1717
|
{revert_italic();}
|
1726
1718
|
break;
|
1727
1719
|
|
1728
1720
|
case 42:
|
1729
1721
|
|
1730
|
-
/* Line
|
1722
|
+
/* Line 1455 of yacc.c */
|
1731
1723
|
#line 155 "parser.y"
|
1732
1724
|
{process_ticket_link((yyvsp[(1) - (1)].svalue));}
|
1733
1725
|
break;
|
1734
1726
|
|
1735
1727
|
case 43:
|
1736
1728
|
|
1737
|
-
/* Line
|
1729
|
+
/* Line 1455 of yacc.c */
|
1738
1730
|
#line 156 "parser.y"
|
1739
1731
|
{process_svn_link((yyvsp[(1) - (1)].svalue),0);}
|
1740
1732
|
break;
|
1741
1733
|
|
1742
1734
|
case 44:
|
1743
1735
|
|
1744
|
-
/* Line
|
1736
|
+
/* Line 1455 of yacc.c */
|
1745
1737
|
#line 157 "parser.y"
|
1746
1738
|
{process_git_link((yyvsp[(1) - (1)].svalue),0);}
|
1747
1739
|
break;
|
1748
1740
|
|
1749
1741
|
case 45:
|
1750
1742
|
|
1751
|
-
/* Line
|
1743
|
+
/* Line 1455 of yacc.c */
|
1752
1744
|
#line 158 "parser.y"
|
1753
1745
|
{process_svn_link((yyvsp[(1) - (1)].svalue),1);}
|
1754
1746
|
break;
|
1755
1747
|
|
1756
1748
|
case 46:
|
1757
1749
|
|
1758
|
-
/* Line
|
1750
|
+
/* Line 1455 of yacc.c */
|
1759
1751
|
#line 159 "parser.y"
|
1760
1752
|
{process_git_link((yyvsp[(1) - (1)].svalue),1);}
|
1761
1753
|
break;
|
1762
1754
|
|
1763
1755
|
case 47:
|
1764
1756
|
|
1765
|
-
/* Line
|
1757
|
+
/* Line 1455 of yacc.c */
|
1766
1758
|
#line 160 "parser.y"
|
1767
1759
|
{process_url_link((yyvsp[(1) - (1)].svalue),NULL);}
|
1768
1760
|
break;
|
1769
1761
|
|
1770
1762
|
case 48:
|
1771
1763
|
|
1772
|
-
/* Line
|
1764
|
+
/* Line 1455 of yacc.c */
|
1773
1765
|
#line 161 "parser.y"
|
1774
1766
|
{process_url_link((yyvsp[(1) - (1)].svalue),"http://");}
|
1775
1767
|
break;
|
1776
1768
|
|
1777
1769
|
case 49:
|
1778
1770
|
|
1779
|
-
/* Line
|
1771
|
+
/* Line 1455 of yacc.c */
|
1780
1772
|
#line 162 "parser.y"
|
1781
1773
|
{process_wiki_link((yyvsp[(1) - (1)].svalue));}
|
1782
1774
|
break;
|
1783
1775
|
|
1784
1776
|
case 50:
|
1785
1777
|
|
1786
|
-
/* Line
|
1778
|
+
/* Line 1455 of yacc.c */
|
1787
1779
|
#line 163 "parser.y"
|
1788
1780
|
{process_anchor_link((yyvsp[(1) - (1)].svalue));}
|
1789
1781
|
break;
|
1790
1782
|
|
1791
1783
|
case 51:
|
1792
1784
|
|
1793
|
-
/* Line
|
1785
|
+
/* Line 1455 of yacc.c */
|
1794
1786
|
#line 164 "parser.y"
|
1795
1787
|
{process_file_link((yyvsp[(1) - (1)].svalue));}
|
1796
1788
|
break;
|
1797
1789
|
|
1798
1790
|
case 52:
|
1799
1791
|
|
1800
|
-
/* Line
|
1792
|
+
/* Line 1455 of yacc.c */
|
1801
1793
|
#line 165 "parser.y"
|
1802
1794
|
{process_image_link((yyvsp[(1) - (1)].svalue));}
|
1803
1795
|
break;
|
1804
1796
|
|
1805
1797
|
case 55:
|
1806
1798
|
|
1807
|
-
/* Line
|
1799
|
+
/* Line 1455 of yacc.c */
|
1808
1800
|
#line 170 "parser.y"
|
1809
1801
|
{concat_escaped_char((yyvsp[(1) - (1)].ivalue));}
|
1810
1802
|
break;
|
1811
1803
|
|
1812
1804
|
case 56:
|
1813
1805
|
|
1814
|
-
/* Line
|
1806
|
+
/* Line 1455 of yacc.c */
|
1815
1807
|
#line 177 "parser.y"
|
1816
1808
|
{concat("<h1 id=\"h-",10); process_header((yyvsp[(1) - (1)].svalue));}
|
1817
1809
|
break;
|
1818
1810
|
|
1819
1811
|
case 57:
|
1820
1812
|
|
1821
|
-
/* Line
|
1813
|
+
/* Line 1455 of yacc.c */
|
1822
1814
|
#line 178 "parser.y"
|
1823
1815
|
{concat("<h2 id=\"h-",10); process_header((yyvsp[(1) - (1)].svalue));}
|
1824
1816
|
break;
|
1825
1817
|
|
1826
1818
|
case 58:
|
1827
1819
|
|
1828
|
-
/* Line
|
1820
|
+
/* Line 1455 of yacc.c */
|
1829
1821
|
#line 179 "parser.y"
|
1830
1822
|
{concat("<h3 id=\"h-",10); process_header((yyvsp[(1) - (1)].svalue));}
|
1831
1823
|
break;
|
1832
1824
|
|
1833
1825
|
case 59:
|
1834
1826
|
|
1835
|
-
/* Line
|
1827
|
+
/* Line 1455 of yacc.c */
|
1836
1828
|
#line 180 "parser.y"
|
1837
1829
|
{concat("<h4 id=\"h-",10); process_header((yyvsp[(1) - (1)].svalue));}
|
1838
1830
|
break;
|
1839
1831
|
|
1840
1832
|
case 60:
|
1841
1833
|
|
1842
|
-
/* Line
|
1834
|
+
/* Line 1455 of yacc.c */
|
1843
1835
|
#line 181 "parser.y"
|
1844
1836
|
{concat("<h5 id=\"h-",10); process_header((yyvsp[(1) - (1)].svalue));}
|
1845
1837
|
break;
|
1846
1838
|
|
1847
1839
|
case 61:
|
1848
1840
|
|
1849
|
-
/* Line
|
1841
|
+
/* Line 1455 of yacc.c */
|
1850
1842
|
#line 183 "parser.y"
|
1851
1843
|
{process_oli((yyvsp[(1) - (1)].ivalue));}
|
1852
1844
|
break;
|
1853
1845
|
|
1854
1846
|
case 62:
|
1855
1847
|
|
1856
|
-
/* Line
|
1848
|
+
/* Line 1455 of yacc.c */
|
1857
1849
|
#line 184 "parser.y"
|
1858
1850
|
{process_uli((yyvsp[(1) - (1)].ivalue));}
|
1859
1851
|
break;
|
1860
1852
|
|
1861
1853
|
case 63:
|
1862
1854
|
|
1863
|
-
/* Line
|
1855
|
+
/* Line 1455 of yacc.c */
|
1864
1856
|
#line 185 "parser.y"
|
1865
1857
|
{concat("<br />",6);}
|
1866
1858
|
break;
|
1867
1859
|
|
1868
1860
|
case 64:
|
1869
1861
|
|
1870
|
-
/* Line
|
1862
|
+
/* Line 1455 of yacc.c */
|
1871
1863
|
#line 188 "parser.y"
|
1872
1864
|
{concat("<pre><code>",11);}
|
1873
1865
|
break;
|
1874
1866
|
|
1875
1867
|
case 65:
|
1876
1868
|
|
1877
|
-
/* Line
|
1869
|
+
/* Line 1455 of yacc.c */
|
1878
1870
|
#line 188 "parser.y"
|
1879
1871
|
{concat("</code></pre>",13);}
|
1880
1872
|
break;
|
1881
1873
|
|
1882
1874
|
case 67:
|
1883
1875
|
|
1884
|
-
/* Line
|
1876
|
+
/* Line 1455 of yacc.c */
|
1885
1877
|
#line 190 "parser.y"
|
1886
1878
|
{concat("<pre>",5);}
|
1887
1879
|
break;
|
1888
1880
|
|
1889
1881
|
case 68:
|
1890
1882
|
|
1891
|
-
/* Line
|
1883
|
+
/* Line 1455 of yacc.c */
|
1892
1884
|
#line 190 "parser.y"
|
1893
1885
|
{concat("</pre>",6);}
|
1894
1886
|
break;
|
1895
1887
|
|
1896
1888
|
case 69:
|
1897
1889
|
|
1898
|
-
/* Line
|
1890
|
+
/* Line 1455 of yacc.c */
|
1899
1891
|
#line 191 "parser.y"
|
1900
1892
|
{concat("<code>",6);}
|
1901
1893
|
break;
|
1902
1894
|
|
1903
1895
|
case 70:
|
1904
1896
|
|
1905
|
-
/* Line
|
1897
|
+
/* Line 1455 of yacc.c */
|
1906
1898
|
#line 191 "parser.y"
|
1907
1899
|
{concat("</code>",7);}
|
1908
1900
|
break;
|
1909
1901
|
|
1910
1902
|
|
1911
1903
|
|
1912
|
-
/* Line
|
1913
|
-
#line
|
1904
|
+
/* Line 1455 of yacc.c */
|
1905
|
+
#line 1906 "parser.tab.c"
|
1914
1906
|
default: break;
|
1915
1907
|
}
|
1916
1908
|
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
|
@@ -2121,7 +2113,7 @@ yyreturn:
|
|
2121
2113
|
|
2122
2114
|
|
2123
2115
|
|
2124
|
-
/* Line
|
2116
|
+
/* Line 1675 of yacc.c */
|
2125
2117
|
#line 195 "parser.y"
|
2126
2118
|
|
2127
2119
|
|
@@ -2290,24 +2282,26 @@ process_svn_link(const char*target, int numbered_repo){
|
|
2290
2282
|
const char *c;
|
2291
2283
|
// can use sprintf here.. but I think it's a way slower than raw concat
|
2292
2284
|
concat("<a href=\"",9);
|
2293
|
-
|
2294
|
-
|
2295
|
-
|
2296
|
-
|
2285
|
+
if( !concat_custom_vcs_url(target) ){
|
2286
|
+
concat_site_url();
|
2287
|
+
concat("/code/",6);
|
2288
|
+
concat(space_name,space_name_len);
|
2289
|
+
if( numbered_repo ){
|
2297
2290
|
concat("/subversion-",12);
|
2298
2291
|
while( *target >= '0' && *target <= '9' ) concat_raw_char(*target++);
|
2299
2292
|
while( *target == ':' ) target++;
|
2300
2293
|
concat("/changesets/",12);
|
2301
|
-
|
2294
|
+
} else {
|
2302
2295
|
concat("/subversion/changesets/",23);
|
2296
|
+
}
|
2297
|
+
for(c=target; *c && *c!=']' && *c!='|'; c++) concat_raw_char(*c);
|
2303
2298
|
}
|
2304
|
-
for(c=target; *c && *c!=']' && *c!='|'; c++) concat_raw_char(*c);
|
2305
2299
|
process_link_tail(target,NULL,"revision:");
|
2306
2300
|
}
|
2307
2301
|
|
2308
|
-
int
|
2302
|
+
int concat_custom_vcs_url(const char*rev){
|
2309
2303
|
const char *c,*p,*t;
|
2310
|
-
if(
|
2304
|
+
if( vcs_url && (c = StringValuePtr(vcs_url)) ){
|
2311
2305
|
size_t l = strlen(c);
|
2312
2306
|
if( l>0 ){
|
2313
2307
|
if( p=strstr(c, "$REV$") ){
|
@@ -2330,7 +2324,7 @@ process_git_link(const char*target, int numbered_repo){
|
|
2330
2324
|
const char *c;
|
2331
2325
|
// can use sprintf here.. but I think it's a way slower than raw concat
|
2332
2326
|
concat("<a href=\"",9);
|
2333
|
-
if( !
|
2327
|
+
if( !concat_custom_vcs_url(target) ){
|
2334
2328
|
concat_site_url();
|
2335
2329
|
concat("/code/",6);
|
2336
2330
|
concat(space_name,space_name_len);
|
@@ -2354,9 +2348,9 @@ process_wiki_link(const char*target){
|
|
2354
2348
|
for(c=target; *c && *c!=']' && *c!='|'; c++) concat_raw_char(*c);
|
2355
2349
|
concat("\" href=\"",8);
|
2356
2350
|
concat_site_url();
|
2357
|
-
concat("/
|
2351
|
+
concat("/spaces/",8);
|
2358
2352
|
concat(space_name,space_name_len);
|
2359
|
-
|
2353
|
+
concat("/wiki/",6);
|
2360
2354
|
for(c=target; *c && *c!=']' && *c!='|' && *c!='#'; c++) concat_raw_char( *c == ' ' ? '_' : *c );
|
2361
2355
|
if( *c == '#' ){
|
2362
2356
|
concat_raw_char('#');
|
@@ -1,9 +1,10 @@
|
|
1
|
-
|
1
|
+
|
2
|
+
/* A Bison parser, made by GNU Bison 2.4.1. */
|
2
3
|
|
3
4
|
/* Skeleton interface for Bison's Yacc-like parsers in C
|
4
5
|
|
5
|
-
Copyright (C) 1984, 1989
|
6
|
-
Foundation, Inc.
|
6
|
+
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
7
|
+
Free Software Foundation, Inc.
|
7
8
|
|
8
9
|
This program is free software: you can redistribute it and/or modify
|
9
10
|
it under the terms of the GNU General Public License as published by
|
@@ -90,7 +91,7 @@
|
|
90
91
|
typedef union YYSTYPE
|
91
92
|
{
|
92
93
|
|
93
|
-
/* Line
|
94
|
+
/* Line 1676 of yacc.c */
|
94
95
|
#line 70 "parser.y"
|
95
96
|
|
96
97
|
double dvalue;
|
@@ -99,8 +100,8 @@ typedef union YYSTYPE
|
|
99
100
|
|
100
101
|
|
101
102
|
|
102
|
-
/* Line
|
103
|
-
#line
|
103
|
+
/* Line 1676 of yacc.c */
|
104
|
+
#line 105 "parser.tab.h"
|
104
105
|
} YYSTYPE;
|
105
106
|
# define YYSTYPE_IS_TRIVIAL 1
|
106
107
|
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
@@ -24,7 +24,7 @@ size_t space_name_len = 0;
|
|
24
24
|
const char *site_url = NULL;
|
25
25
|
size_t site_url_len = 0;
|
26
26
|
|
27
|
-
extern VALUE
|
27
|
+
extern VALUE vcs_url;
|
28
28
|
|
29
29
|
int list_level = 1;
|
30
30
|
int absolute_urls = 0;
|
@@ -359,24 +359,26 @@ process_svn_link(const char*target, int numbered_repo){
|
|
359
359
|
const char *c;
|
360
360
|
// can use sprintf here.. but I think it's a way slower than raw concat
|
361
361
|
concat("<a href=\"",9);
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
362
|
+
if( !concat_custom_vcs_url(target) ){
|
363
|
+
concat_site_url();
|
364
|
+
concat("/code/",6);
|
365
|
+
concat(space_name,space_name_len);
|
366
|
+
if( numbered_repo ){
|
366
367
|
concat("/subversion-",12);
|
367
368
|
while( *target >= '0' && *target <= '9' ) concat_raw_char(*target++);
|
368
369
|
while( *target == ':' ) target++;
|
369
370
|
concat("/changesets/",12);
|
370
|
-
|
371
|
+
} else {
|
371
372
|
concat("/subversion/changesets/",23);
|
373
|
+
}
|
374
|
+
for(c=target; *c && *c!=']' && *c!='|'; c++) concat_raw_char(*c);
|
372
375
|
}
|
373
|
-
for(c=target; *c && *c!=']' && *c!='|'; c++) concat_raw_char(*c);
|
374
376
|
process_link_tail(target,NULL,"revision:");
|
375
377
|
}
|
376
378
|
|
377
|
-
int
|
379
|
+
int concat_custom_vcs_url(const char*rev){
|
378
380
|
const char *c,*p,*t;
|
379
|
-
if(
|
381
|
+
if( vcs_url && (c = StringValuePtr(vcs_url)) ){
|
380
382
|
size_t l = strlen(c);
|
381
383
|
if( l>0 ){
|
382
384
|
if( p=strstr(c, "$REV$") ){
|
@@ -399,7 +401,7 @@ process_git_link(const char*target, int numbered_repo){
|
|
399
401
|
const char *c;
|
400
402
|
// can use sprintf here.. but I think it's a way slower than raw concat
|
401
403
|
concat("<a href=\"",9);
|
402
|
-
if( !
|
404
|
+
if( !concat_custom_vcs_url(target) ){
|
403
405
|
concat_site_url();
|
404
406
|
concat("/code/",6);
|
405
407
|
concat(space_name,space_name_len);
|
@@ -423,9 +425,9 @@ process_wiki_link(const char*target){
|
|
423
425
|
for(c=target; *c && *c!=']' && *c!='|'; c++) concat_raw_char(*c);
|
424
426
|
concat("\" href=\"",8);
|
425
427
|
concat_site_url();
|
426
|
-
concat("/
|
428
|
+
concat("/spaces/",8);
|
427
429
|
concat(space_name,space_name_len);
|
428
|
-
|
430
|
+
concat("/wiki/",6);
|
429
431
|
for(c=target; *c && *c!=']' && *c!='|' && *c!='#'; c++) concat_raw_char( *c == ' ' ? '_' : *c );
|
430
432
|
if( *c == '#' ){
|
431
433
|
concat_raw_char('#');
|
@@ -22,7 +22,7 @@ extern size_t in_buf_len, bufsize, space_name_len;
|
|
22
22
|
extern const char *site_url;
|
23
23
|
extern size_t site_url_len;
|
24
24
|
|
25
|
-
VALUE
|
25
|
+
VALUE vcs_url;
|
26
26
|
|
27
27
|
extern int parse_links_only, absolute_urls;
|
28
28
|
|
@@ -48,9 +48,9 @@ VALUE do_parse(int argc, VALUE *argv, VALUE self) {
|
|
48
48
|
}
|
49
49
|
}
|
50
50
|
|
51
|
-
|
51
|
+
vcs_url = NULL;
|
52
52
|
if( argc > 3 && argv[3] != Qnil && argv[3] != Qfalse ){
|
53
|
-
|
53
|
+
vcs_url = argv[3];
|
54
54
|
}
|
55
55
|
|
56
56
|
absolute_urls = 0;
|
data/spec/parser_spec.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require 'breakout_parser'
|
2
3
|
require File.dirname(__FILE__) + '/obj_proxy'
|
3
4
|
|
@@ -808,12 +809,12 @@ describe 'BreakoutParser' do
|
|
808
809
|
|
809
810
|
describe "Assembla Links" do
|
810
811
|
a = {}
|
811
|
-
a["wiki:Name"] = '<a class="wiki_link" title="Name" href="/
|
812
|
-
a["wiki:Name With Space"] = '<a class="wiki_link" title="Name With Space" href="/
|
813
|
-
a["Name"] = '<a class="wiki_link" title="Name" href="/
|
814
|
-
a["Name With Space"] = '<a class="wiki_link" title="Name With Space" href="/
|
815
|
-
a["Name#Ref"] = '<a class="wiki_link" title="Name#Ref" href="/
|
816
|
-
a["Name#h-Ref"] = '<a class="wiki_link" title="Name#h-Ref" href="/
|
812
|
+
a["wiki:Name"] = '<a class="wiki_link" title="Name" href="/spaces/test_space/wiki/Name">Name</a>'
|
813
|
+
a["wiki:Name With Space"] = '<a class="wiki_link" title="Name With Space" href="/spaces/test_space/wiki/Name_With_Space">Name With Space</a>'
|
814
|
+
a["Name"] = '<a class="wiki_link" title="Name" href="/spaces/test_space/wiki/Name">Name</a>'
|
815
|
+
a["Name With Space"] = '<a class="wiki_link" title="Name With Space" href="/spaces/test_space/wiki/Name_With_Space">Name With Space</a>'
|
816
|
+
a["Name#Ref"] = '<a class="wiki_link" title="Name#Ref" href="/spaces/test_space/wiki/Name#h-Ref">Name#Ref</a>'
|
817
|
+
a["Name#h-Ref"] = '<a class="wiki_link" title="Name#h-Ref" href="/spaces/test_space/wiki/Name#h-h-Ref">Name#h-Ref</a>'
|
817
818
|
a["#Ref"] = '<a href="#h-Ref" title="#Ref" class="wiki_link">#Ref</a>'
|
818
819
|
a["#привет"] = %Q|<a href="#h-#{hex_string("привет")}" title="#привет" class="wiki_link">#привет</a>|
|
819
820
|
a["#with spc"] = %Q|<a href="#h-with__spc" title="#with spc" class="wiki_link">#with spc</a>|
|
@@ -849,6 +850,8 @@ describe 'BreakoutParser' do
|
|
849
850
|
a["file:cVJUz6ejWr35pEab_qKWB8"] =
|
850
851
|
'<a href="/spaces/test_space/documents/download/cVJUz6ejWr35pEab_qKWB8">file:cVJUz6ejWr35pEab_qKWB8</a>'
|
851
852
|
|
853
|
+
pat = Regexp.new('/code/test_space/(git|subversion)/changesets/')
|
854
|
+
|
852
855
|
a.each do |k,v|
|
853
856
|
it "parses [[#{k}]]" do
|
854
857
|
parse("[[#{k}]]").should == v
|
@@ -878,82 +881,81 @@ describe 'BreakoutParser' do
|
|
878
881
|
v.gsub('href="/',"href=\"#{site_url}/")
|
879
882
|
end
|
880
883
|
end
|
881
|
-
if v['/git/']
|
882
|
-
it "parses [[#{k}]] with custom
|
883
|
-
|
884
|
+
if v['/git/'] || v['/subversion/']
|
885
|
+
it "parses [[#{k}]] with custom vcs_url (String)" do
|
886
|
+
vcs_url = "http://www.ru/"
|
884
887
|
rev = k.split(':').last.tr(']','')
|
885
|
-
parse("[[#{k}]]", :
|
886
|
-
v.sub(
|
888
|
+
parse("[[#{k}]]", :vcs_url => vcs_url).should ==
|
889
|
+
v.sub(pat,vcs_url)
|
887
890
|
end
|
888
891
|
|
889
|
-
it "parses [[#{k}]] with custom
|
892
|
+
it "parses [[#{k}]] with custom vcs_url (ObjProxy)" do
|
890
893
|
rev = k.split(':').last.tr(']','')
|
891
894
|
@asdfg = 'http://mmm.us'
|
892
|
-
|
895
|
+
vcs_url = Breakout::ObjProxy.new do
|
893
896
|
@asdfg + '/'
|
894
897
|
end
|
895
|
-
parse("[[#{k}]]", :
|
896
|
-
v.sub(
|
898
|
+
parse("[[#{k}]]", :vcs_url => vcs_url).should ==
|
899
|
+
v.sub(pat,vcs_url)
|
897
900
|
end
|
898
901
|
|
899
|
-
it "parses [[#{k}]] with custom
|
900
|
-
|
902
|
+
it "parses [[#{k}]] with custom vcs_url (String) + $REV$" do
|
903
|
+
vcs_url = "http://www.ru/$REV$/show"
|
901
904
|
rev = k.split(':').last.tr(']','')
|
902
|
-
parse("[[#{k}]]", :
|
903
|
-
v.sub(
|
905
|
+
parse("[[#{k}]]", :vcs_url => vcs_url).should ==
|
906
|
+
v.sub(pat,vcs_url).sub(rev,'').sub('$REV$',rev)
|
904
907
|
|
905
|
-
|
906
|
-
parse("[[#{k}]]", :
|
907
|
-
v.sub(
|
908
|
+
vcs_url = "http://www.ru/$REV$"
|
909
|
+
parse("[[#{k}]]", :vcs_url => vcs_url).should ==
|
910
|
+
v.sub(pat,vcs_url).sub(rev,'').sub('$REV$',rev)
|
908
911
|
|
909
|
-
|
910
|
-
parse("[[#{k}]]", :
|
911
|
-
v.sub(
|
912
|
+
vcs_url = "$REV$"
|
913
|
+
parse("[[#{k}]]", :vcs_url => vcs_url).should ==
|
914
|
+
v.sub(pat,vcs_url).sub(rev,'').sub('$REV$',rev)
|
912
915
|
end
|
913
916
|
|
914
|
-
it "parses [[#{k}]] with custom
|
917
|
+
it "parses [[#{k}]] with custom vcs_url (ObjProxy) + $REV$" do
|
915
918
|
rev = k.split(':').last.tr(']','')
|
916
919
|
@asdfg = 'http://mmm.us/$REV$/show'
|
917
|
-
|
920
|
+
vcs_url = Breakout::ObjProxy.new do
|
918
921
|
@asdfg
|
919
922
|
end
|
920
|
-
parse("[[#{k}]]", :
|
921
|
-
v.sub(
|
923
|
+
parse("[[#{k}]]", :vcs_url => vcs_url).should ==
|
924
|
+
v.sub(pat,vcs_url).sub(rev,'').sub('$REV$',rev)
|
922
925
|
|
923
926
|
@asdfg = 'http://mmm.us/$REV$'
|
924
|
-
parse("[[#{k}]]", :
|
925
|
-
v.sub(
|
927
|
+
parse("[[#{k}]]", :vcs_url => vcs_url).should ==
|
928
|
+
v.sub(pat,vcs_url).sub(rev,'').sub('$REV$',rev)
|
926
929
|
|
927
930
|
@asdfg = '$REV$'
|
928
|
-
parse("[[#{k}]]", :
|
929
|
-
v.sub(
|
931
|
+
parse("[[#{k}]]", :vcs_url => vcs_url).should ==
|
932
|
+
v.sub(pat,vcs_url).sub(rev,'').sub('$REV$',rev)
|
930
933
|
end
|
931
934
|
|
932
|
-
it "parses [[#{k}]] with NULL
|
935
|
+
it "parses [[#{k}]] with NULL vcs_url (ObjProxy)" do
|
933
936
|
rev = k.split(':').last.tr(']','')
|
934
|
-
|
937
|
+
vcs_url = Breakout::ObjProxy.new do
|
935
938
|
nil
|
936
939
|
end
|
937
|
-
parse("[[#{k}]]", :
|
940
|
+
parse("[[#{k}]]", :vcs_url => vcs_url).should == v
|
938
941
|
end
|
939
942
|
|
940
|
-
it "parses [[#{k}]] with FALSE
|
943
|
+
it "parses [[#{k}]] with FALSE vcs_url (ObjProxy)" do
|
941
944
|
rev = k.split(':').last.tr(']','')
|
942
|
-
|
945
|
+
vcs_url = Breakout::ObjProxy.new do
|
943
946
|
false
|
944
947
|
end
|
945
|
-
parse("[[#{k}]]", :
|
948
|
+
parse("[[#{k}]]", :vcs_url => vcs_url).should == v
|
946
949
|
end
|
947
950
|
end
|
948
951
|
end
|
949
952
|
|
950
|
-
it "should not instantiate ObjProxy's internal object if there
|
951
|
-
|
953
|
+
it "should not instantiate ObjProxy's internal object if there are no git or svn links in text" do
|
954
|
+
vcs_url = Breakout::ObjProxy.new do
|
952
955
|
raise 'should not be raised'
|
953
956
|
end
|
954
957
|
lambda {
|
955
|
-
parse("
|
956
|
-
'<a href="/code/test_space/subversion/changesets/2345">revision:2345</a>'
|
958
|
+
parse("no revision tag", :vcs_url => vcs_url).should == 'no revision tag'
|
957
959
|
}.should_not raise_error
|
958
960
|
end
|
959
961
|
|
@@ -961,30 +963,30 @@ describe 'BreakoutParser' do
|
|
961
963
|
# 'true' values
|
962
964
|
[true, 1, 'x'].each do |v|
|
963
965
|
it "should NOT convert relative url to absolute when absolute_urls = #{v.inspect} AND site_url is NULL" do
|
964
|
-
parse("[[url:/rel]]", :absolute_urls => v).should ==
|
966
|
+
parse("[[url:/rel]]", :absolute_urls => v).should ==
|
965
967
|
'<a rel="nofollow" href="/rel">/rel</a>'
|
966
|
-
parse("[[url:/rel|text]]", :absolute_urls => v).should ==
|
968
|
+
parse("[[url:/rel|text]]", :absolute_urls => v).should ==
|
967
969
|
'<a rel="nofollow" href="/rel">text</a>'
|
968
970
|
end
|
969
971
|
it "should convert relative url to absolute when absolute_urls = #{v.inspect}" do
|
970
|
-
parse("[[url:/rel]]", :absolute_urls => v, :site_url => 'http://www.ru').should ==
|
972
|
+
parse("[[url:/rel]]", :absolute_urls => v, :site_url => 'http://www.ru').should ==
|
971
973
|
'<a rel="nofollow" href="http://www.ru/rel">/rel</a>'
|
972
|
-
parse("[[url:/rel|text]]", :absolute_urls => v, :site_url => 'http://www.ru').should ==
|
974
|
+
parse("[[url:/rel|text]]", :absolute_urls => v, :site_url => 'http://www.ru').should ==
|
973
975
|
'<a rel="nofollow" href="http://www.ru/rel">text</a>'
|
974
976
|
end
|
975
977
|
it "should strip redundant '/' when absolute_urls = #{v.inspect}" do
|
976
|
-
parse("[[url:/rel]]", :absolute_urls => v, :site_url => 'http://www.ru/').should ==
|
978
|
+
parse("[[url:/rel]]", :absolute_urls => v, :site_url => 'http://www.ru/').should ==
|
977
979
|
'<a rel="nofollow" href="http://www.ru/rel">/rel</a>'
|
978
|
-
parse("[[url:/rel|text]]", :absolute_urls => v, :site_url => 'http://www.ru/').should ==
|
980
|
+
parse("[[url:/rel|text]]", :absolute_urls => v, :site_url => 'http://www.ru/').should ==
|
979
981
|
'<a rel="nofollow" href="http://www.ru/rel">text</a>'
|
980
982
|
end
|
981
983
|
end
|
982
984
|
# 'false' values
|
983
985
|
[false, nil].each do |v|
|
984
986
|
it "should not convert relative url to absolute when absolute_urls = #{v.inspect}" do
|
985
|
-
parse("[[url:/rel]]", :absolute_urls => v).should ==
|
987
|
+
parse("[[url:/rel]]", :absolute_urls => v).should ==
|
986
988
|
'<a rel="nofollow" href="/rel">/rel</a>'
|
987
|
-
parse("[[url:/rel|text]]", :absolute_urls => v).should ==
|
989
|
+
parse("[[url:/rel|text]]", :absolute_urls => v).should ==
|
988
990
|
'<a rel="nofollow" href="/rel">text</a>'
|
989
991
|
end
|
990
992
|
end
|
@@ -1048,10 +1050,10 @@ describe 'BreakoutParser' do
|
|
1048
1050
|
|
1049
1051
|
def parse s, h = {}
|
1050
1052
|
h[:space_name] = "test_space" unless h.key?(:space_name)
|
1051
|
-
BreakoutParser.parse(s,
|
1052
|
-
h[:space_name],
|
1053
|
-
h[:site_url],
|
1054
|
-
h[:
|
1053
|
+
BreakoutParser.parse(s,
|
1054
|
+
h[:space_name],
|
1055
|
+
h[:site_url],
|
1056
|
+
h[:vcs_url],
|
1055
1057
|
h[:absolute_urls]
|
1056
1058
|
).strip
|
1057
1059
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: breakout_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 49
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 23
|
10
|
+
version: 0.0.23
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andrey "Zed" Zaikin
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-05-20 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -66,8 +66,8 @@ homepage: http://assembla.com
|
|
66
66
|
licenses: []
|
67
67
|
|
68
68
|
post_install_message:
|
69
|
-
rdoc_options:
|
70
|
-
|
69
|
+
rdoc_options: []
|
70
|
+
|
71
71
|
require_paths:
|
72
72
|
- lib
|
73
73
|
required_ruby_version: !ruby/object:Gem::Requirement
|