src/eric7/UI/Previewers/PreviewerHTML.py

branch
eric7
changeset 9624
b47dfa7a137d
parent 9573
9960d19d66b5
child 9653
e67609152c5e
equal deleted inserted replaced
9623:9c1f429cb56b 9624:b47dfa7a137d
27 QToolTip, 27 QToolTip,
28 QVBoxLayout, 28 QVBoxLayout,
29 QWidget, 29 QWidget,
30 ) 30 )
31 31
32 from eric7 import Preferences, Utilities 32 from eric7 import Preferences
33 from eric7.EricWidgets.EricApplication import ericApp 33 from eric7.EricWidgets.EricApplication import ericApp
34 from eric7.SystemUtilities import FileSystemUtilities
34 35
35 36
36 class PreviewerHTML(QWidget): 37 class PreviewerHTML(QWidget):
37 """ 38 """
38 Class implementing a previewer widget for HTML, Markdown and ReST files. 39 Class implementing a previewer widget for HTML, Markdown and ReST files.
252 @param html processed HTML text ready to be shown 253 @param html processed HTML text ready to be shown
253 @type str 254 @type str
254 @param rootPath path of the web site root 255 @param rootPath path of the web site root
255 @type str 256 @type str
256 """ 257 """
257 self.__previewedPath = Utilities.normcasepath( 258 self.__previewedPath = FileSystemUtilities.normcasepath(
258 Utilities.fromNativeSeparators(filePath) 259 FileSystemUtilities.fromNativeSeparators(filePath)
259 ) 260 )
260 self.__saveScrollBarPositions() 261 self.__saveScrollBarPositions()
261 self.previewView.page().loadFinished.connect(self.__restoreScrollBarPositions) 262 self.previewView.page().loadFinished.connect(self.__restoreScrollBarPositions)
262 if not filePath: 263 if not filePath:
263 filePath = "/" 264 filePath = "/"
550 incMatch = incRe.search(txt) 551 incMatch = incRe.search(txt)
551 if incMatch is None: 552 if incMatch is None:
552 break 553 break
553 554
554 if incMatch.group(1) == "virtual": 555 if incMatch.group(1) == "virtual":
555 incFile = Utilities.normjoinpath(docRoot, incMatch.group(2)) 556 incFile = FileSystemUtilities.normjoinpath(docRoot, incMatch.group(2))
556 elif incMatch.group(1) == "file": 557 elif incMatch.group(1) == "file":
557 incFile = Utilities.normjoinpath(baseDir, incMatch.group(2)) 558 incFile = FileSystemUtilities.normjoinpath(baseDir, incMatch.group(2))
558 else: 559 else:
559 incFile = "" 560 incFile = ""
560 if os.path.exists(incFile): 561 if os.path.exists(incFile):
561 try: 562 try:
562 with open(incFile, "r") as f: 563 with open(incFile, "r") as f:
583 @rtype str 584 @rtype str
584 """ 585 """
585 if not root: 586 if not root:
586 return txt 587 return txt
587 588
588 root = Utilities.fromNativeSeparators(root) 589 root = FileSystemUtilities.fromNativeSeparators(root)
589 if not root.endswith("/"): 590 if not root.endswith("/"):
590 root += "/" 591 root += "/"
591 rootLen = len(root) 592 rootLen = len(root)
592 593
593 refRe = re.compile(r"""(href|src)=[\\"']/([^\\"']+)[\\"']""", re.IGNORECASE) 594 refRe = re.compile(r"""(href|src)=[\\"']/([^\\"']+)[\\"']""", re.IGNORECASE)

eric ide

mercurial