multimarkdown 4.5.0.r1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +75 -0
- data/MultiMarkdown-4/GLibFacade.c +294 -0
- data/MultiMarkdown-4/GLibFacade.h +95 -0
- data/MultiMarkdown-4/beamer.c +179 -0
- data/MultiMarkdown-4/beamer.h +11 -0
- data/MultiMarkdown-4/critic.c +111 -0
- data/MultiMarkdown-4/critic.h +15 -0
- data/MultiMarkdown-4/glib.h +11 -0
- data/MultiMarkdown-4/html.c +1060 -0
- data/MultiMarkdown-4/html.h +14 -0
- data/MultiMarkdown-4/latex.c +1137 -0
- data/MultiMarkdown-4/latex.h +16 -0
- data/MultiMarkdown-4/libMultiMarkdown.h +156 -0
- data/MultiMarkdown-4/lyx.c +2163 -0
- data/MultiMarkdown-4/lyx.h +36 -0
- data/MultiMarkdown-4/lyxbeamer.c +267 -0
- data/MultiMarkdown-4/lyxbeamer.h +11 -0
- data/MultiMarkdown-4/memoir.c +79 -0
- data/MultiMarkdown-4/memoir.h +10 -0
- data/MultiMarkdown-4/multimarkdown.c +483 -0
- data/MultiMarkdown-4/odf.c +1201 -0
- data/MultiMarkdown-4/odf.h +18 -0
- data/MultiMarkdown-4/opml.c +188 -0
- data/MultiMarkdown-4/opml.h +15 -0
- data/MultiMarkdown-4/parse_utilities.c +752 -0
- data/MultiMarkdown-4/parser.c +15582 -0
- data/MultiMarkdown-4/parser.h +186 -0
- data/MultiMarkdown-4/rng.c +117 -0
- data/MultiMarkdown-4/rtf.c +648 -0
- data/MultiMarkdown-4/rtf.h +17 -0
- data/MultiMarkdown-4/strtok.c +56 -0
- data/MultiMarkdown-4/strtok.h +9 -0
- data/MultiMarkdown-4/text.c +53 -0
- data/MultiMarkdown-4/text.h +11 -0
- data/MultiMarkdown-4/transclude.c +213 -0
- data/MultiMarkdown-4/transclude.h +26 -0
- data/MultiMarkdown-4/writer.c +576 -0
- data/MultiMarkdown-4/writer.h +34 -0
- data/README.md +70 -0
- data/Rakefile +85 -0
- data/bin/ruby_multi_markdown +128 -0
- data/ext/extconf.h +3 -0
- data/ext/extconf.rb +17 -0
- data/ext/multi_markdown.c +100 -0
- data/lib/multi_markdown.bundle +0 -0
- data/lib/multi_markdown.rb +88 -0
- data/lib/multi_markdown/version.rb +6 -0
- data/lib/multimarkdown.rb +1 -0
- data/multi_markdown.gemspec +37 -0
- data/test/multi_markdown_test.rb +64 -0
- metadata +119 -0
data/LICENSE
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
MultiMarkdown-4 in C
|
2
|
+
Copyright (c) 2010-2013 Fletcher T. Penney
|
3
|
+
Ruby Markdown Extension (rpeg-markdown) used as template for this gem
|
4
|
+
Copyright (c) 2008 Ryan Tomayko
|
5
|
+
Ruby MultiMarkdown Extension (rpeg-multimarkdown) used as another template
|
6
|
+
Copyright (c) 2009 Oliver ? (https://github.com/djungelvral)
|
7
|
+
Micro-optparse (included in bin/ruby_multi_markdown)
|
8
|
+
Copyright (c) 2011 Florian Pilz
|
9
|
+
|
10
|
+
Both multi_markdown and MultiMarkdown-4 are released under both the GPL
|
11
|
+
and MIT licenses. You may pick the license that best fits your needs.
|
12
|
+
|
13
|
+
Micro-optparse is released under the MIT license.
|
14
|
+
|
15
|
+
The GPL
|
16
|
+
|
17
|
+
This program is free software; you can redistribute it and/or modify
|
18
|
+
it under the terms of the GNU General Public License as published by
|
19
|
+
the Free Software Foundation; either version 2 of the License, or
|
20
|
+
(at your option) any later version.
|
21
|
+
|
22
|
+
This program is distributed in the hope that it will be useful,
|
23
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
24
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
25
|
+
GNU General Public License for more details.
|
26
|
+
|
27
|
+
You should have received a copy of the GNU General Public License
|
28
|
+
along with this program; if not, write to the Free Software
|
29
|
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
30
|
+
|
31
|
+
The MIT License
|
32
|
+
|
33
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
34
|
+
of this software and associated documentation files (the "Software"), to deal
|
35
|
+
in the Software without restriction, including without limitation the rights
|
36
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
37
|
+
copies of the Software, and to permit persons to whom the Software is
|
38
|
+
furnished to do so, subject to the following conditions:
|
39
|
+
|
40
|
+
The above copyright notice and this permission notice shall be included in
|
41
|
+
all copies or substantial portions of the Software.
|
42
|
+
|
43
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
44
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
45
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
46
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
47
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
48
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
49
|
+
THE SOFTWARE.
|
50
|
+
|
51
|
+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
52
|
+
|
53
|
+
my_getopt (included for convenience - http://www.geocities.com/bsittler/)
|
54
|
+
|
55
|
+
Copyright 1997, 2000, 2001, 2002, 2006, Benjamin Sittler
|
56
|
+
|
57
|
+
Permission is hereby granted, free of charge, to any person
|
58
|
+
obtaining a copy of this software and associated documentation
|
59
|
+
files (the "Software"), to deal in the Software without
|
60
|
+
restriction, including without limitation the rights to use, copy,
|
61
|
+
modify, merge, publish, distribute, sublicense, and/or sell copies
|
62
|
+
of the Software, and to permit persons to whom the Software is
|
63
|
+
furnished to do so, subject to the following conditions:
|
64
|
+
|
65
|
+
The above copyright notice and this permission notice shall be
|
66
|
+
included in all copies or substantial portions of the Software.
|
67
|
+
|
68
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
69
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
70
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
71
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
72
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
73
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
74
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
75
|
+
DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,294 @@
|
|
1
|
+
/*
|
2
|
+
* GLibFacade.c
|
3
|
+
* MultiMarkdown
|
4
|
+
*
|
5
|
+
* Created by Daniel Jalkut on 7/26/11.
|
6
|
+
* Modified by Fletcher T. Penney on 9/15/11 and 12/3/13.
|
7
|
+
* Modified by Dan Lowe on 1/3/12.
|
8
|
+
*
|
9
|
+
* License for original code by Daniel Jalkut:
|
10
|
+
*
|
11
|
+
* Copyright 2011 Daniel Jalkut. All rights reserved.
|
12
|
+
*
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
14
|
+
* this software and associated documentation files (the “Software”), to deal in
|
15
|
+
* the Software without restriction, including without limitation the rights to
|
16
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
17
|
+
* of the Software, and to permit persons to whom the Software is furnished to do
|
18
|
+
* so, subject to the following conditions:
|
19
|
+
*
|
20
|
+
* The above copyright notice and this permission notice shall be included in all
|
21
|
+
* copies or substantial portions of the Software.
|
22
|
+
*
|
23
|
+
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
24
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
25
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
26
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
27
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
28
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
29
|
+
* SOFTWARE.
|
30
|
+
*/
|
31
|
+
|
32
|
+
#include "GLibFacade.h"
|
33
|
+
|
34
|
+
#include <stdio.h>
|
35
|
+
#include <stdlib.h>
|
36
|
+
#include <string.h>
|
37
|
+
#include <stdarg.h>
|
38
|
+
|
39
|
+
/*
|
40
|
+
* The following section came from:
|
41
|
+
*
|
42
|
+
* http://lists-archives.org/mingw-users/12649-asprintf-missing-vsnprintf-
|
43
|
+
* behaving-differently-and-_vsncprintf-undefined.html
|
44
|
+
*
|
45
|
+
* and
|
46
|
+
*
|
47
|
+
* http://groups.google.com/group/jansson-users/browse_thread/thread/
|
48
|
+
* 76a88d63d9519978/041a7d0570de2d48?lnk=raot
|
49
|
+
*/
|
50
|
+
|
51
|
+
/* Solaris and Windows do not provide vasprintf() or asprintf(). */
|
52
|
+
#if defined(__WIN32) || (defined(__SVR4) && defined(__sun))
|
53
|
+
int vasprintf( char **sptr, char *fmt, va_list argv )
|
54
|
+
{
|
55
|
+
int wanted = vsnprintf( *sptr = NULL, 0, fmt, argv );
|
56
|
+
if( (wanted > 0) && ((*sptr = malloc( 1 + wanted )) != NULL) )
|
57
|
+
return vsprintf( *sptr, fmt, argv );
|
58
|
+
|
59
|
+
return wanted;
|
60
|
+
}
|
61
|
+
|
62
|
+
int asprintf( char **sptr, char *fmt, ... )
|
63
|
+
{
|
64
|
+
int retval;
|
65
|
+
va_list argv;
|
66
|
+
va_start( argv, fmt );
|
67
|
+
retval = vasprintf( sptr, fmt, argv );
|
68
|
+
va_end( argv );
|
69
|
+
return retval;
|
70
|
+
}
|
71
|
+
#endif
|
72
|
+
|
73
|
+
|
74
|
+
/* GString */
|
75
|
+
|
76
|
+
#define kStringBufferStartingSize 1024
|
77
|
+
#define kStringBufferGrowthMultiplier 2
|
78
|
+
|
79
|
+
GString* g_string_new(char *startingString)
|
80
|
+
{
|
81
|
+
GString* newString = malloc(sizeof(GString));
|
82
|
+
|
83
|
+
if (startingString == NULL) startingString = "";
|
84
|
+
|
85
|
+
size_t startingBufferSize = kStringBufferStartingSize;
|
86
|
+
size_t startingStringSize = strlen(startingString);
|
87
|
+
while (startingBufferSize < (startingStringSize + 1))
|
88
|
+
{
|
89
|
+
startingBufferSize *= kStringBufferGrowthMultiplier;
|
90
|
+
}
|
91
|
+
|
92
|
+
newString->str = malloc(startingBufferSize);
|
93
|
+
newString->currentStringBufferSize = startingBufferSize;
|
94
|
+
strncpy(newString->str, startingString, startingStringSize);
|
95
|
+
newString->str[startingStringSize] = '\0';
|
96
|
+
newString->currentStringLength = startingStringSize;
|
97
|
+
|
98
|
+
return newString;
|
99
|
+
}
|
100
|
+
|
101
|
+
char* g_string_free(GString* ripString, bool freeCharacterData)
|
102
|
+
{
|
103
|
+
if (ripString == NULL)
|
104
|
+
return NULL;
|
105
|
+
|
106
|
+
char* returnedString = ripString->str;
|
107
|
+
if (freeCharacterData)
|
108
|
+
{
|
109
|
+
if (ripString->str != NULL)
|
110
|
+
{
|
111
|
+
free(ripString->str);
|
112
|
+
}
|
113
|
+
returnedString = NULL;
|
114
|
+
}
|
115
|
+
|
116
|
+
free(ripString);
|
117
|
+
|
118
|
+
return returnedString;
|
119
|
+
}
|
120
|
+
|
121
|
+
static void ensureStringBufferCanHold(GString* baseString, size_t newStringSize)
|
122
|
+
{
|
123
|
+
size_t newBufferSizeNeeded = newStringSize + 1;
|
124
|
+
if (newBufferSizeNeeded > baseString->currentStringBufferSize)
|
125
|
+
{
|
126
|
+
size_t newBufferSize = baseString->currentStringBufferSize;
|
127
|
+
|
128
|
+
while (newBufferSizeNeeded > newBufferSize)
|
129
|
+
{
|
130
|
+
newBufferSize *= kStringBufferGrowthMultiplier;
|
131
|
+
}
|
132
|
+
|
133
|
+
char *temp;
|
134
|
+
temp = realloc(baseString->str, newBufferSize);
|
135
|
+
|
136
|
+
if (temp == NULL) {
|
137
|
+
/* realloc failed */
|
138
|
+
fprintf(stderr, "error reallocating memory\n");
|
139
|
+
|
140
|
+
exit(1);
|
141
|
+
}
|
142
|
+
baseString->str = temp;
|
143
|
+
baseString->currentStringBufferSize = newBufferSize;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
void g_string_append(GString* baseString, char* appendedString)
|
148
|
+
{
|
149
|
+
if ((appendedString != NULL) && (strlen(appendedString) > 0))
|
150
|
+
{
|
151
|
+
size_t appendedStringLength = strlen(appendedString);
|
152
|
+
size_t newStringLength = baseString->currentStringLength + appendedStringLength;
|
153
|
+
ensureStringBufferCanHold(baseString, newStringLength);
|
154
|
+
|
155
|
+
/* We already know where the current string ends, so pass that as the starting address for strncat */
|
156
|
+
strncat(baseString->str + baseString->currentStringLength, appendedString, appendedStringLength);
|
157
|
+
baseString->currentStringLength = newStringLength;
|
158
|
+
}
|
159
|
+
}
|
160
|
+
|
161
|
+
void g_string_append_c(GString* baseString, char appendedCharacter)
|
162
|
+
{
|
163
|
+
size_t newSizeNeeded = baseString->currentStringLength + 1;
|
164
|
+
ensureStringBufferCanHold(baseString, newSizeNeeded);
|
165
|
+
|
166
|
+
baseString->str[baseString->currentStringLength] = appendedCharacter;
|
167
|
+
baseString->currentStringLength++;
|
168
|
+
baseString->str[baseString->currentStringLength] = '\0';
|
169
|
+
}
|
170
|
+
|
171
|
+
void g_string_append_printf(GString* baseString, char* format, ...)
|
172
|
+
{
|
173
|
+
va_list args;
|
174
|
+
va_start(args, format);
|
175
|
+
|
176
|
+
char* formattedString = NULL;
|
177
|
+
vasprintf(&formattedString, format, args);
|
178
|
+
if (formattedString != NULL)
|
179
|
+
{
|
180
|
+
g_string_append(baseString, formattedString);
|
181
|
+
free(formattedString);
|
182
|
+
}
|
183
|
+
va_end(args);
|
184
|
+
}
|
185
|
+
|
186
|
+
void g_string_prepend(GString* baseString, char* prependedString)
|
187
|
+
{
|
188
|
+
if ((prependedString != NULL) && (strlen(prependedString) > 0))
|
189
|
+
{
|
190
|
+
size_t prependedStringLength = strlen(prependedString);
|
191
|
+
size_t newStringLength = baseString->currentStringLength + prependedStringLength;
|
192
|
+
ensureStringBufferCanHold(baseString, newStringLength);
|
193
|
+
|
194
|
+
memmove(baseString->str + prependedStringLength, baseString->str, baseString->currentStringLength);
|
195
|
+
strncpy(baseString->str, prependedString, prependedStringLength);
|
196
|
+
baseString->currentStringLength = newStringLength;
|
197
|
+
baseString->str[baseString->currentStringLength] = '\0';
|
198
|
+
}
|
199
|
+
}
|
200
|
+
|
201
|
+
void g_string_insert(GString* baseString, size_t pos, char * insertedString)
|
202
|
+
{
|
203
|
+
if ((insertedString != NULL) && (strlen(insertedString) > 0))
|
204
|
+
{
|
205
|
+
if (pos > baseString->currentStringLength)
|
206
|
+
pos = baseString->currentStringLength;
|
207
|
+
|
208
|
+
size_t insertedStringLength = strlen(insertedString);
|
209
|
+
size_t newStringLength = baseString->currentStringLength + insertedStringLength;
|
210
|
+
ensureStringBufferCanHold(baseString, newStringLength);
|
211
|
+
|
212
|
+
/* Shift following string to 'right' */
|
213
|
+
memmove(baseString->str + pos + insertedStringLength, baseString->str + pos, baseString->currentStringLength - pos);
|
214
|
+
strncpy(baseString->str + pos, insertedString, insertedStringLength);
|
215
|
+
baseString->currentStringLength = newStringLength;
|
216
|
+
baseString->str[baseString->currentStringLength] = '\0';
|
217
|
+
}
|
218
|
+
}
|
219
|
+
|
220
|
+
void g_string_insert_c(GString* baseString, size_t pos, char insertedCharacter)
|
221
|
+
{
|
222
|
+
if (pos > baseString->currentStringLength)
|
223
|
+
pos = baseString->currentStringLength;
|
224
|
+
|
225
|
+
size_t newSizeNeeded = baseString->currentStringLength + 1;
|
226
|
+
ensureStringBufferCanHold(baseString, newSizeNeeded);
|
227
|
+
|
228
|
+
/* Shift following string to 'right' */
|
229
|
+
memmove(baseString->str + pos + 1, baseString->str + pos, baseString->currentStringLength - pos);
|
230
|
+
|
231
|
+
baseString->str[pos] = insertedCharacter;
|
232
|
+
baseString->currentStringLength++;
|
233
|
+
baseString->str[baseString->currentStringLength] = '\0';
|
234
|
+
}
|
235
|
+
|
236
|
+
void g_string_erase(GString* baseString, size_t pos, size_t len)
|
237
|
+
{
|
238
|
+
if ((pos > baseString->currentStringLength) || (len <= 0))
|
239
|
+
return;
|
240
|
+
|
241
|
+
if ((pos + len) >= baseString->currentStringLength)
|
242
|
+
len = -1;
|
243
|
+
|
244
|
+
if (len == -1) {
|
245
|
+
baseString->currentStringLength = pos;
|
246
|
+
} else {
|
247
|
+
memmove(baseString->str + pos, baseString->str + pos + len, baseString->currentStringLength - pos - len);
|
248
|
+
baseString->currentStringLength -= len;
|
249
|
+
}
|
250
|
+
baseString->str[baseString->currentStringLength] = '\0';
|
251
|
+
}
|
252
|
+
|
253
|
+
/* GSList */
|
254
|
+
|
255
|
+
void g_slist_free(GSList* ripList)
|
256
|
+
{
|
257
|
+
GSList* thisListItem = ripList;
|
258
|
+
while (thisListItem != NULL)
|
259
|
+
{
|
260
|
+
GSList* nextItem = thisListItem->next;
|
261
|
+
|
262
|
+
/* I guess we don't release the data? Non-retained memory management is hard... let's figure it out later. */
|
263
|
+
free(thisListItem);
|
264
|
+
|
265
|
+
thisListItem = nextItem;
|
266
|
+
}
|
267
|
+
}
|
268
|
+
|
269
|
+
/* Currently only used for markdown_output.c endnotes printing */
|
270
|
+
GSList* g_slist_reverse(GSList* theList)
|
271
|
+
{
|
272
|
+
GSList* lastNodeSeen = NULL;
|
273
|
+
|
274
|
+
/* Iterate the list items, tacking them on to our new reversed List as we find them */
|
275
|
+
GSList* listWalker = theList;
|
276
|
+
while (listWalker != NULL)
|
277
|
+
{
|
278
|
+
GSList* nextNode = listWalker->next;
|
279
|
+
listWalker->next = lastNodeSeen;
|
280
|
+
lastNodeSeen = listWalker;
|
281
|
+
listWalker = nextNode;
|
282
|
+
}
|
283
|
+
|
284
|
+
return lastNodeSeen;
|
285
|
+
}
|
286
|
+
|
287
|
+
GSList* g_slist_prepend(GSList* targetElement, void* newElementData)
|
288
|
+
{
|
289
|
+
GSList* newElement = malloc(sizeof(GSList));
|
290
|
+
newElement->data = newElementData;
|
291
|
+
newElement->next = targetElement;
|
292
|
+
return newElement;
|
293
|
+
}
|
294
|
+
|
@@ -0,0 +1,95 @@
|
|
1
|
+
/*
|
2
|
+
* GLibFacade.h
|
3
|
+
* MultiMarkdown
|
4
|
+
*
|
5
|
+
* Created by Daniel Jalkut on 7/26/11.
|
6
|
+
* Modified by Fletcher T. Penney on 9/15/11 and 12/3/13.
|
7
|
+
* Modified by Dan Lowe on 1/3/12.
|
8
|
+
*
|
9
|
+
* License for original code by Daniel Jalkut:
|
10
|
+
*
|
11
|
+
* Copyright 2011 Daniel Jalkut. All rights reserved.
|
12
|
+
*
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
14
|
+
* this software and associated documentation files (the “Software”), to deal in
|
15
|
+
* the Software without restriction, including without limitation the rights to
|
16
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
17
|
+
* of the Software, and to permit persons to whom the Software is furnished to do
|
18
|
+
* so, subject to the following conditions:
|
19
|
+
*
|
20
|
+
* The above copyright notice and this permission notice shall be included in all
|
21
|
+
* copies or substantial portions of the Software.
|
22
|
+
*
|
23
|
+
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
24
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
25
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
26
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
27
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
28
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
29
|
+
* SOFTWARE.
|
30
|
+
*/
|
31
|
+
|
32
|
+
#ifndef __MARKDOWN_GLIB_FACADE__
|
33
|
+
#define __MARKDOWN_GLIB_FACADE__
|
34
|
+
|
35
|
+
/* peg_markdown uses the link symbol for its own purposes */
|
36
|
+
#define link MARKDOWN_LINK_IGNORED
|
37
|
+
#include <unistd.h>
|
38
|
+
#undef link
|
39
|
+
|
40
|
+
#include <stdbool.h>
|
41
|
+
#include <ctype.h>
|
42
|
+
|
43
|
+
typedef int gboolean;
|
44
|
+
typedef char gchar;
|
45
|
+
|
46
|
+
/* This style of bool is used in shared source code */
|
47
|
+
#define FALSE false
|
48
|
+
#define TRUE true
|
49
|
+
|
50
|
+
/* WE implement minimal mirror implementations of GLib's GString and GSList
|
51
|
+
* sufficient to cover the functionality required by MultiMarkdown.
|
52
|
+
*
|
53
|
+
* NOTE: THese are 100% clean, from-scratch implementations using only the
|
54
|
+
* GLib function prototype as guide for behavior.
|
55
|
+
*/
|
56
|
+
|
57
|
+
typedef struct
|
58
|
+
{
|
59
|
+
/* Current UTF8 byte stream this string represents */
|
60
|
+
char* str;
|
61
|
+
|
62
|
+
/* Where in the str buffer will we add new characters */
|
63
|
+
/* or append new strings? */
|
64
|
+
unsigned long currentStringBufferSize;
|
65
|
+
unsigned long currentStringLength;
|
66
|
+
} GString;
|
67
|
+
|
68
|
+
GString* g_string_new(char *startingString);
|
69
|
+
char* g_string_free(GString* ripString, bool freeCharacterData);
|
70
|
+
|
71
|
+
void g_string_append_c(GString* baseString, char appendedCharacter);
|
72
|
+
void g_string_append(GString* baseString, char *appendedString);
|
73
|
+
|
74
|
+
void g_string_prepend(GString* baseString, char* prependedString);
|
75
|
+
|
76
|
+
void g_string_append_printf(GString* baseString, char* format, ...);
|
77
|
+
|
78
|
+
void g_string_insert(GString* baseString, size_t pos, char * insertedString);
|
79
|
+
void g_string_insert_c(GString* baseString, size_t pos, char insertedCharacter);
|
80
|
+
|
81
|
+
void g_string_erase(GString* baseString, size_t pos, size_t len);
|
82
|
+
|
83
|
+
/* Just implement a very simple singly linked list. */
|
84
|
+
|
85
|
+
typedef struct _GSList
|
86
|
+
{
|
87
|
+
void* data;
|
88
|
+
struct _GSList* next;
|
89
|
+
} GSList;
|
90
|
+
|
91
|
+
void g_slist_free(GSList* ripList);
|
92
|
+
GSList* g_slist_prepend(GSList* targetElement, void* newElementData);
|
93
|
+
GSList* g_slist_reverse(GSList* theList);
|
94
|
+
|
95
|
+
#endif
|