]> git.wincent.com - wikitext.git/blob - ext/token.h
Handle auto-linking in when followed by "special" URI characters
[wikitext.git] / ext / token.h
1 // Copyright 2008 Wincent Colaiuta
2 // This program is free software: you can redistribute it and/or modify
3 // it under the terms of the GNU General Public License as published by
4 // the Free Software Foundation, either version 3 of the License, or
5 // (at your option) any later version.
6 //
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 // GNU General Public License for more details.
11 //
12 // You should have received a copy of the GNU General Public License
13 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
14
15 #include "ruby_compat.h"
16 #include <stdint.h>     /* uint32_t */
17
18 #define TOKEN_TEXT(token)   rb_str_new((const char *)token->start, (token->stop - token->start))
19 #define TOKEN_LEN(token)    (token->stop - token->start)
20
21 typedef struct
22 {
23     char        *start;
24     char        *stop;
25     size_t      line_start;
26     size_t      line_stop;
27     size_t      column_start;
28     size_t      column_stop;
29     uint32_t    code_point;
30     int         type;
31 } token_t;
32
33 enum token_types {
34     NO_TOKEN,
35     P,              // imaginary token (never explicitly marked up)
36     LI,             // imaginary token (never explicitly marked up)
37     NESTED_LIST,    // imaginary token (never explicitly marked up)
38     PRE,
39     PRE_START,
40     PRE_END,
41     NO_WIKI_START,
42     NO_WIKI_END,
43     BLOCKQUOTE,
44     BLOCKQUOTE_START,
45     BLOCKQUOTE_END,
46     STRONG_EM,
47     STRONG_START,
48     STRONG_END,
49     STRONG,
50     EM_START,
51     EM_END,
52     EM,
53     TT_START,
54     TT_END,
55     TT,
56     OL,
57     UL,
58     H6_START,
59     H5_START,
60     H4_START,
61     H3_START,
62     H2_START,
63     H1_START,
64     H6_END,
65     H5_END,
66     H4_END,
67     H3_END,
68     H2_END,
69     H1_END,
70     URI,
71     MAIL,
72     LINK_START,
73     LINK_END,
74     EXT_LINK_START,
75     EXT_LINK_END,
76     SEPARATOR,
77     SPACE,
78     QUOT_ENTITY,
79     AMP_ENTITY,
80     NAMED_ENTITY,
81     HEX_ENTITY,
82     DECIMAL_ENTITY,
83     QUOT,
84     AMP,
85     LESS,
86     GREATER,
87     IMG_START,
88     IMG_END,
89     LEFT_CURLY,
90     RIGHT_CURLY,
91     CRLF,
92     SPECIAL_URI_CHARS,
93     PRINTABLE,
94     DEFAULT,
95     END_OF_FILE
96 };
97
98 VALUE Wikitext_parser_token_types(VALUE self);
99
100 VALUE _Wikitext_token(token_t *token);