bypass-core-1.0
Main Page
Namespaces
Data Structures
Files
File List
Globals
parser.h
Go to the documentation of this file.
1
//
2
// Copyright 2013 Uncodin, Inc.
3
//
4
// Licensed under the Apache License, Version 2.0 (the "License");
5
// you may not use this file except in compliance with the License.
6
// You may obtain a copy of the License at
7
//
8
// http://www.apache.org/licenses/LICENSE-2.0
9
//
10
// Unless required by applicable law or agreed to in writing, software
11
// distributed under the License is distributed on an "AS IS" BASIS,
12
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
// See the License for the specific language governing permissions and
14
// limitations under the License.
15
//
16
17
#ifndef _BYPASS_PARSER_H_
18
#define _BYPASS_PARSER_H_
19
20
#include <iostream>
21
#include <string>
22
#include <vector>
23
#include <sstream>
24
#include <cstdio>
25
#include <cstdlib>
26
#include <map>
27
#include "
document.h
"
28
#include "
element.h
"
29
30
extern
"C"
{
31
#include "markdown.h"
32
}
33
34
#include "
document.h
"
35
#include "
element.h
"
36
37
#define INPUT_UNIT 1024
38
#define OUTPUT_UNIT 64
39
40
namespace
Bypass {
41
63
class
Parser
{
64
public
:
65
69
Parser
();
70
74
~Parser
();
75
82
Document
parse
(
const
char
* markdown);
83
89
Document
parse
(
const
std::string &markdown);
90
98
void
split
(std::vector<std::string> &tokens,
const
std::string &text,
char
sep);
99
100
// Block Element Callbacks
101
111
void
parsedBlockCode
(
struct
buf *ob,
struct
buf *text);
112
122
void
parsedBlockQuote
(
struct
buf *ob,
struct
buf *text);
123
134
void
parsedHeader
(
struct
buf *ob,
struct
buf *text,
int
level);
135
146
void
parsedList
(
struct
buf *ob,
struct
buf *text,
int
flags);
147
157
void
parsedListItem
(
struct
buf *ob,
struct
buf *text,
int
flags);
158
168
void
parsedParagraph
(
struct
buf *ob,
struct
buf *text);
169
170
// Span Element Callbacks
171
182
int
parsedCodeSpan
(
struct
buf *ob,
struct
buf *text);
183
196
int
parsedDoubleEmphasis
(
struct
buf *ob,
struct
buf *text,
char
c);
197
210
int
parsedEmphasis
(
struct
buf *ob,
struct
buf *text,
char
c);
211
224
int
parsedTripleEmphasis
(
struct
buf *ob,
struct
buf *text,
char
c);
225
237
int
parsedLinebreak
(
struct
buf *ob);
238
255
int
parsedLink
(
struct
buf *ob,
struct
buf *link,
struct
buf *title,
struct
buf *content);
256
257
// Low Level Callbacks
258
273
void
parsedNormalText
(
struct
buf *ob,
struct
buf *text);
274
275
// Debugging
276
277
void
printBuf
(
struct
buf *b);
278
279
private
:
280
Document
document;
281
std::map<int, Element> elementSoup;
282
int
elementCount;
283
void
handleBlock(
Type
,
struct
buf *ob,
struct
buf *text,
int
extra = -1);
284
void
handleSpan(
Type
,
struct
buf *ob,
struct
buf *text,
struct
buf *extra = NULL,
struct
buf *extra2 = NULL,
bool
output =
true
);
285
void
createSpan(
const
Element
&,
struct
buf *ob);
286
void
eraseTrailingControlCharacters(
const
std::string& controlCharacters);
287
};
288
289
}
290
291
#endif // _BYPASS_PARSER_H_
src
parser.h
Generated on Fri Jul 26 2013 16:01:35 for bypass-core-1.0 by
1.8.2