466 (string) |
466 (string) |
467 @return processed HTML text (string) |
467 @return processed HTML text (string) |
468 """ |
468 """ |
469 if language == "HTML": |
469 if language == "HTML": |
470 if ssiEnabled: |
470 if ssiEnabled: |
471 return self.__processSSI(text, filePath, rootPath) |
471 html = self.__processSSI(text, filePath, rootPath) |
472 else: |
472 else: |
473 return text |
473 html = text |
|
474 return self.__processRootPath(html, rootPath) |
474 elif language == "Markdown": |
475 elif language == "Markdown": |
475 return self.__convertMarkdown(text, convertNewLineToBreak, |
476 return self.__convertMarkdown(text, convertNewLineToBreak, |
476 markdownHtmlFormat) |
477 markdownHtmlFormat) |
477 elif language == "ReST": |
478 elif language == "ReST": |
478 return self.__convertReST(text, useSphinx, restDocutilsHtmlFormat) |
479 return self.__convertReST(text, useSphinx, restDocutilsHtmlFormat) |
525 incTxt = "" |
526 incTxt = "" |
526 txt = txt[:incMatch.start(0)] + incTxt + txt[incMatch.end(0):] |
527 txt = txt[:incMatch.start(0)] + incTxt + txt[incMatch.end(0):] |
527 |
528 |
528 return txt |
529 return txt |
529 |
530 |
|
531 def __processRootPath(self, txt, root): |
|
532 """ |
|
533 Private method to adjust absolute references to the given root path. |
|
534 |
|
535 @param txt text to be processed |
|
536 @type str |
|
537 @param root directory of the document root |
|
538 @type str |
|
539 @return processed HTML |
|
540 @rtype str |
|
541 """ |
|
542 if not root: |
|
543 return txt |
|
544 |
|
545 root = Utilities.fromNativeSeparators(root) |
|
546 if not root.endswith("/"): |
|
547 root += "/" |
|
548 rootLen = len(root) |
|
549 |
|
550 refRe = re.compile( |
|
551 r"""(href|src)=[\\"']/([^\\"']+)[\\"']""", |
|
552 re.IGNORECASE) |
|
553 pos = 0 |
|
554 while True: |
|
555 refMatch = refRe.search(txt, pos) |
|
556 if refMatch is None: |
|
557 break |
|
558 |
|
559 txt = (txt[:refMatch.start(0)] + refMatch.group(1) + '="' + root + |
|
560 refMatch.group(2) + '"' + txt[refMatch.end(0):]) |
|
561 pos = refMatch.end(0) + rootLen |
|
562 |
|
563 return txt |
|
564 |
530 def __convertReST(self, text, useSphinx, restDocutilsHtmlFormat): |
565 def __convertReST(self, text, useSphinx, restDocutilsHtmlFormat): |
531 """ |
566 """ |
532 Private method to convert ReST text into HTML. |
567 Private method to convert ReST text into HTML. |
533 |
568 |
534 @param text text to be processed (string) |
569 @param text text to be processed (string) |