32#define rstartEl(x,y) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->startElement(x,y); } while(false)
33#define rendEl(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->endElement(x); } while(false)
34#define rchars(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(x); } while(false)
35#define runistr(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(x); } while(false)
36#define reucstr(x,y) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(OUString(x,y, RTL_TEXTENCODING_EUC_KR)); } while(false)
37#define padd(x,y,z) mxList->addAttribute(x,y,z)
40#define inds indent++; for(int i = 0 ; i < indent ; i++) fprintf(stderr," ")
41#define inde for(int i = 0 ; i < indent ; i++) fprintf(stderr," "); indent--
51 fprintf(stderr,
"<math:math xmlns:math=\"http://www.w3.org/1998/Math/MathML\">\n");
53 padd(
"xmlns:math",
"CDATA",
"http://www.w3.org/1998/Math/MathML");
54 rstartEl(
"math:math",
mxList);
56 rstartEl(
"math:semantics",
mxList);
63 fprintf(stderr,
"<math:semantics/>\n");
66 fprintf(stderr,
"</math:math>\n");
68 rendEl(
"math:semantics");
92 inds; fprintf(stderr,
"<math:mrow>\n");
94 rstartEl(
"math:mrow",
mxList);
99 inde; fprintf(stderr,
"</math:mrow>\n");
108 Node *tmp = res->child;
112 Node *next = tmp->next;
124 Node *tmp = res->child;
131 fprintf(stderr,
"<math:mrow>\n");
133 rstartEl(
"math:mrow",
mxList);
141 inde; fprintf(stderr,
"</math:mrow>\n");
188 if( !tmp->value )
return;
193 fprintf(stderr,
"<math:mi>%s</math:mi>\n",tmp->value.get());
196 rstartEl(
"math:mi",
mxList);
197 rchars(OUString::createFromAscii(tmp->value.get()));
205 rstartEl(
"math:mi",
mxList);
206 reucstr(tmp->value.get(), strlen(tmp->value.get()));
214 fprintf(stderr,
"<math:mi>%s</math:mi>\n",
218 rstartEl(
"math:mi",
mxList);
226 fprintf(stderr,
"<math:mn>%s</math:mn>\n",tmp->value.get());
229 rstartEl(
"math:mn",
mxList);
230 rchars(OUString::createFromAscii(tmp->value.get()));
238 inds; fprintf(stderr,
"<math:mo>%s</math:mo>\n",tmp->value.get());
indo;
240 rstartEl(
"math:mo",
mxList);
273 fprintf(stderr,
"<math:msub>\n");
275 fprintf(stderr,
"<math:msup>\n");
277 fprintf(stderr,
"<math:msubsup>\n");
280 rstartEl(
"math:msub",
mxList);
282 rstartEl(
"math:msup",
mxList);
284 rstartEl(
"math:msubsup",
mxList);
301 fprintf(stderr,
"</math:msub>\n");
303 fprintf(stderr,
"</math:msup>\n");
305 fprintf(stderr,
"</math:msubsup>\n");
312 rendEl(
"math:msubsup");
323 fprintf(stderr,
"<math:mfrac>\n");
325 rstartEl(
"math:mfrac",
mxList);
331 fprintf(stderr,
"<math:mrow>\n");
333 rstartEl(
"math:mrow",
mxList);
343 fprintf(stderr,
"</math:mrow>\n");
345 fprintf(stderr,
"<math:mrow>\n");
348 rstartEl(
"math:mrow",
mxList);
358 fprintf(stderr,
"</math:mrow>\n");
360 fprintf(stderr,
"</math:mfrac>\n");
363 rendEl(
"math:mfrac");
370 Node *tmp = res->child;
372 if( !strncmp(tmp->value.get(),
"under", 5) )
377 fprintf(stderr,
"<math:mover>\n");
379 fprintf(stderr,
"<math:munder>\n");
383 padd(
"accent",
"CDATA",
"true");
384 rstartEl(
"math:mover",
mxList);
387 padd(
"accentunder",
"CDATA",
"true");
388 rstartEl(
"math:munder",
mxList);
397 fprintf(stderr,
"<math:mo>%s</math:mo>\n",
401 rstartEl(
"math:mo",
mxList);
409 fprintf(stderr,
"</math:mover>\n");
411 fprintf(stderr,
"</math:munder>\n");
414 rendEl(
"math:mover");
416 rendEl(
"math:munder");
427 fprintf(stderr,
"<math:msqrt>\n");
429 fprintf(stderr,
"<math:mroot>\n");
432 rstartEl(
"math:msqrt",
mxList);
434 rstartEl(
"math:mroot",
mxList);
448 fprintf(stderr,
"</math:msqrt>\n");
450 fprintf(stderr,
"</math:mroot>\n");
453 rendEl(
"math:msqrt");
455 rendEl(
"math:mroot");
468 fprintf(stderr,
"<math:mrow>\n");
471 fprintf(stderr,
"<math:mo>(</math:mo>\n");
474 fprintf(stderr,
"<math:mo>|</math:mo>\n");
476 fprintf(stderr,
"<math:mrow>\n");
478 rstartEl(
"math:mrow",
mxList);
479 rstartEl(
"math:mo",
mxList);
485 rstartEl(
"math:mrow",
mxList);
493 fprintf(stderr,
"</math:mrow>\n");
496 fprintf(stderr,
"<math:mo>)</math:mo>\n");
498 fprintf(stderr,
"<math:mo>|</math:mo>\n");
501 fprintf(stderr,
"</math:mrow>\n");
504 rstartEl(
"math:mo",
mxList);
516 Node *tmp = res->child;
519 fprintf(stderr,
"<math:mfenced open=\"%s\" close=\"%s\">\n",
523 padd(
"open",
"CDATA",
525 padd(
"close",
"CDATA",
527 rstartEl(
"math:mfenced",
mxList);
535 fprintf(stderr,
"</math:mfenced>\n");
537 rendEl(
"math:mfenced");
550 fprintf(stderr,
"<math:mrow>\n");
552 rstartEl(
"math:mrow",
mxList);
560 fprintf(stderr,
"</math:mrow>\n");
575 int idx=
a.indexOf(
'\xff');
578 a =
a.replaceAt(
idx, 1,
"\x20");
579 idx =
a.indexOf(
'\xff',
idx + 1);
582 char *buf =
static_cast<char *
>(malloc(
a.getLength()+1));
585 for(
i = 0, j=0 ;
i <
a.getLength() ;
i++){
590 if(
a[
i] != 32 &&
a[
i] != 10 &&
a[
i] != 13){
597 for(
i = j-1 ;
i >= 0 ;
i++ ){
598 if( buf[
i] == 32 || buf[
i] == 10 || buf[
i] == 13 ){
619 int len = strlen(
eq);
620 char *buf =
static_cast<char *
>(malloc(len+1));
623 for(
i = 0, j=0 ;
i < len ;
i++){
628 if(
eq[
i] != 32 &&
eq[
i] != 10 &&
eq[
i] != 13){
635 for(
i = j-1 ;
i >= 0 ;
i++ ){
636 if( buf[
i] == 32 || buf[
i] == 10 || buf[
i] == 13 ){
std::vector< std::unique_ptr< Node > > nodelist
Node * mainParse(const char *_code)
void eq2latex(OString &outs, char const *s)
OUString fromHcharStringToOUString(hchar_string const &s)
::std::string getMathMLEntity(const char *tex)