From e08894f5d74f1068bd35a52ee49e2e25e8939e77 Mon Sep 17 00:00:00 2001 From: Zach Siegel Date: Fri, 11 Dec 2020 14:17:06 -0800 Subject: [PATCH 1/8] viewers/chrome_viewer and a chrome/OpenFileInChrome_Page_Number.applescript utility --- .../OpenFileInChrome_Page_Number.applescript | 33 ++++ viewers/chrome_viewer.py | 145 ++++++++++++++++++ 2 files changed, 178 insertions(+) create mode 100644 chrome/OpenFileInChrome_Page_Number.applescript create mode 100644 viewers/chrome_viewer.py diff --git a/chrome/OpenFileInChrome_Page_Number.applescript b/chrome/OpenFileInChrome_Page_Number.applescript new file mode 100644 index 00000000..2bac9c15 --- /dev/null +++ b/chrome/OpenFileInChrome_Page_Number.applescript @@ -0,0 +1,33 @@ +on run argv + set finalDestination to item 1 of argv + set quotedPDFName to item 2 of argv + set defaultCmd to item 3 of argv + log quotedPDFName + tell application "Google Chrome" + set found to false + set windowList to every window + repeat with aWindow in windowList + if found then + exit repeat + end if + set tabList to every tab of aWindow + set tabIndex to 0 + repeat with atab in tabList + set tabIndex to tabIndex + 1 + if (URL of atab contains quotedPDFName) then + set found to true + set aWindow's active tab index to tabIndex + set index of aWindow to 1 + set URL of atab to finalDestination + delay 0.05 -- makes it not fail + delay 0.05 -- makes it not fail + tell atab to reload + exit repeat + end if + end repeat + end repeat + end tell + if not found then + do shell script defaultCmd + end if +end run diff --git a/viewers/chrome_viewer.py b/viewers/chrome_viewer.py new file mode 100644 index 00000000..4576111d --- /dev/null +++ b/viewers/chrome_viewer.py @@ -0,0 +1,145 @@ +from urllib.parse import quote +import subprocess as sp +import os + + +from base_viewer import BaseViewer +from latextools_utils import get_setting +from latextools_utils.external_command import external_command, check_output + +## TODO: remove defaultCmd from applescript - just return True or False, then run that default command from Python. +## TODO: GET CHROME PATH +## TODO: GET CURRENT FOLDER PATH (for osascript command) + +class ChromeViewer(BaseViewer): + + + def _get_applescript_folder(self): + return os.path.normpath( + os.path.join( + os.path.dirname(__file__), + '..', + 'chrome' + ) + ) + + def _get_chrome_dir(self,escaped=False): + viewer_location = check_output([ + 'osascript', + '-e', + 'POSIX path of ' + '(path to app id "com.google.Chrome")' + ], use_texpath=False) + if escaped: + return "{viewer_location}Contents/MacOS/Google\\ Chrome".format(viewer_location=viewer_location) + return "{viewer_location}Contents/MacOS/Google Chrome".format(viewer_location=viewer_location) + + + def _get_browser_filepath(self,tex_line_no,tex_col_no,tex_filename,pdf_filename,zoom=100): + try: + synctex_loc = '{tex_line_no}:{tex_col_no}:{tex_filename}'.format(tex_line_no=tex_line_no,tex_col_no=tex_col_no,tex_filename=tex_filename) + cmd = ['/Library/TeX/texbin/synctex', 'view', '-i', synctex_loc, '-o', pdf_filename] + # output_text = sp.run(cmd,capture_output=True,text=True).stdout.split("\n") + stdout = check_output(cmd) + output_text = stdout.split("\n") + page_no = next((e.lstrip('Page:') for e in output_text if e.startswith('Page:')), 1) + line_no = next((e.lstrip('x:') for e in output_text if e.startswith('x:')), 1) + col_no = next((e.lstrip('y:') for e in output_text if e.startswith('y:')), 1) + except Exception as e: + print("ERROR IN SYNCTEX") + print(e) + page_no = 1 + line_no = 1 + col_no = 0 + # print(f"{page_no = }, {line_no = }, {col_no = }") + + return "file://{pdf_filename}#page={page_no}&view=FitH,{line_no}".format(pdf_filename=pdf_filename,page_no=page_no,line_no=line_no) + + + def _get_run_command(self,pdf_filename,tex_filename=None,tex_line_no=None,tex_col_no=None,zoom=100): + if tex_filename is None: + chrome_dir = self._get_chrome_dir() + basic_cmd = [chrome_dir,pdf_filename] + return basic_cmd + # pdf_filename = tex_filename.rsplit(".",1)[0] + ".pdf" + + finalDestination = self._get_browser_filepath(tex_line_no,tex_col_no,tex_filename,pdf_filename) + quotedPDFName = quote(pdf_filename) + scriptName= "{}/OpenFileInChrome_Page_Number.applescript".format(self._get_applescript_folder()) + chrome_dir = self._get_chrome_dir(escaped=True) + defaultCmd = "{chrome_dir} '{finalDestination}'".format(chrome_dir=chrome_dir,finalDestination=finalDestination) + cmd = ['osascript', scriptName, finalDestination,quotedPDFName,defaultCmd] + return cmd + + + + def forward_sync(self, pdf_file, tex_file, line, col, **kwargs): + cmd = self._get_run_command(pdf_file,tex_file,line,col) + print("FORWARD SYNCING CHROME COMMAND IS:") + print(cmd) + external_command(cmd, use_texpath=True) + + def view_file(self, pdf_file, **kwargs): + tex_filename = pdf_file.rsplit(".",1)[0] + ".pdf" + cmd = self._get_run_command(pdf_file,tex_filename=tex_filename,tex_line_no=1,tex_col_no=1) + print("BASIC VIEWING CHROME") + external_command(cmd, use_texpath=False) + + + + # def _test_chrome_view(): + + # def get_browser_filepath(tex_line_no,tex_col_no,tex_filename,pdf_filename,zoom=100): + + # try: + + # output_text = sp.run(['synctex', 'view', '-i', f'{tex_line_no}:{tex_col_no}:{tex_filename}', '-o', pdf_filename],capture_output=True,text=True).stdout.split("\n") + + # page_no = next((e.lstrip('Page:') for e in output_text if e.startswith('Page:')), 1) + + # line_no = next((e.lstrip('x:') for e in output_text if e.startswith('x:')), 1) + + # col_no = next((e.lstrip('y:') for e in output_text if e.startswith('y:')), 1) + + # except: + + # page_no = 1 + + # line_no = 1 + + # col_no = 0 + + # print(f"{page_no = }, {line_no = }, {col_no = }") + + # return f"file://{pdf_filename}#page={page_no}&view=FitH,{line_no}" + + + + # def run_applescript(tex_line_no,tex_col_no,tex_filename,zoom=100): + + # pdf_filename = tex_filename.rsplit(".",1)[0] + ".pdf" + + # finalDestination = get_browser_filepath(tex_line_no,tex_col_no,tex_filename,pdf_filename) + + # quotedPDFName = quote(pdf_filename) + + # defaultCmd = "/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome '{finalDestination}'" + + # result = sp.run(['osascript', "/Users/zach/Library/Application Support/Sublime Text/Packages/LaTeXTools/viewers/OpenFileInChrome_Page_Number.applescript", finalDestination,quotedPDFName,defaultCmd],capture_output=True,text=True).stdout + + # print(result) + + + # if __name__=="__main__": + + # tex_line_no = 90 + + # tex_col_no = 0 + + # zoom = 100 + + # tex_filename = "/Users/zach/Documents/UCLA_classes/stats203/project/final/final.tex" + + + # run_applescript(tex_line_no,tex_col_no,tex_filename,zoom=100) + From 95cb9c41cd56bb947ff50b38e783795f757d3694 Mon Sep 17 00:00:00 2001 From: Zach Siegel Date: Fri, 11 Dec 2020 14:21:46 -0800 Subject: [PATCH 2/8] edited out comments --- viewers/chrome_viewer.py | 59 ---------------------------------------- 1 file changed, 59 deletions(-) diff --git a/viewers/chrome_viewer.py b/viewers/chrome_viewer.py index 4576111d..3ca16124 100644 --- a/viewers/chrome_viewer.py +++ b/viewers/chrome_viewer.py @@ -84,62 +84,3 @@ def view_file(self, pdf_file, **kwargs): cmd = self._get_run_command(pdf_file,tex_filename=tex_filename,tex_line_no=1,tex_col_no=1) print("BASIC VIEWING CHROME") external_command(cmd, use_texpath=False) - - - - # def _test_chrome_view(): - - # def get_browser_filepath(tex_line_no,tex_col_no,tex_filename,pdf_filename,zoom=100): - - # try: - - # output_text = sp.run(['synctex', 'view', '-i', f'{tex_line_no}:{tex_col_no}:{tex_filename}', '-o', pdf_filename],capture_output=True,text=True).stdout.split("\n") - - # page_no = next((e.lstrip('Page:') for e in output_text if e.startswith('Page:')), 1) - - # line_no = next((e.lstrip('x:') for e in output_text if e.startswith('x:')), 1) - - # col_no = next((e.lstrip('y:') for e in output_text if e.startswith('y:')), 1) - - # except: - - # page_no = 1 - - # line_no = 1 - - # col_no = 0 - - # print(f"{page_no = }, {line_no = }, {col_no = }") - - # return f"file://{pdf_filename}#page={page_no}&view=FitH,{line_no}" - - - - # def run_applescript(tex_line_no,tex_col_no,tex_filename,zoom=100): - - # pdf_filename = tex_filename.rsplit(".",1)[0] + ".pdf" - - # finalDestination = get_browser_filepath(tex_line_no,tex_col_no,tex_filename,pdf_filename) - - # quotedPDFName = quote(pdf_filename) - - # defaultCmd = "/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome '{finalDestination}'" - - # result = sp.run(['osascript', "/Users/zach/Library/Application Support/Sublime Text/Packages/LaTeXTools/viewers/OpenFileInChrome_Page_Number.applescript", finalDestination,quotedPDFName,defaultCmd],capture_output=True,text=True).stdout - - # print(result) - - - # if __name__=="__main__": - - # tex_line_no = 90 - - # tex_col_no = 0 - - # zoom = 100 - - # tex_filename = "/Users/zach/Documents/UCLA_classes/stats203/project/final/final.tex" - - - # run_applescript(tex_line_no,tex_col_no,tex_filename,zoom=100) - From 1fb8936804c91510486511feee86bdeac96be6e0 Mon Sep 17 00:00:00 2001 From: Zach Siegel Date: Fri, 11 Dec 2020 14:41:39 -0800 Subject: [PATCH 3/8] edited viewer --- chrome/OpenFileInChrome_Page_Number.applescript | 3 +++ viewers/chrome_viewer.py | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/chrome/OpenFileInChrome_Page_Number.applescript b/chrome/OpenFileInChrome_Page_Number.applescript index 2bac9c15..24d3db44 100644 --- a/chrome/OpenFileInChrome_Page_Number.applescript +++ b/chrome/OpenFileInChrome_Page_Number.applescript @@ -29,5 +29,8 @@ on run argv end tell if not found then do shell script defaultCmd + log defaultCmd end if end run + + diff --git a/viewers/chrome_viewer.py b/viewers/chrome_viewer.py index 3ca16124..e6e8b4c2 100644 --- a/viewers/chrome_viewer.py +++ b/viewers/chrome_viewer.py @@ -30,6 +30,7 @@ def _get_chrome_dir(self,escaped=False): 'POSIX path of ' '(path to app id "com.google.Chrome")' ], use_texpath=False) + viewer_location = viewer_location.replace(" ","\\ ") if escaped: return "{viewer_location}Contents/MacOS/Google\\ Chrome".format(viewer_location=viewer_location) return "{viewer_location}Contents/MacOS/Google Chrome".format(viewer_location=viewer_location) @@ -67,11 +68,11 @@ def _get_run_command(self,pdf_filename,tex_filename=None,tex_line_no=None,tex_co quotedPDFName = quote(pdf_filename) scriptName= "{}/OpenFileInChrome_Page_Number.applescript".format(self._get_applescript_folder()) chrome_dir = self._get_chrome_dir(escaped=True) - defaultCmd = "{chrome_dir} '{finalDestination}'".format(chrome_dir=chrome_dir,finalDestination=finalDestination) + defaultCmd = "{chrome_dir} {finalDestination}".format(chrome_dir=chrome_dir,finalDestination=finalDestination) cmd = ['osascript', scriptName, finalDestination,quotedPDFName,defaultCmd] return cmd - + # osascript '/Users/zach/Library/Application Support/Sublime Text/Packages/LaTeXTools/chrome/OpenFileInChrome_Page_Number.applescript' 'file:///Users/zach/Documents/UCLA_classes/stats203/project/presentation/presentation.pdf#page=33&view=FitH,28.346443' '/Users/zach/Documents/UCLA_classes/stats203/project/presentation/presentation.pdf' '/Applications/Google Chrome.app/Contents/MacOS/Google\ Chrome file:///Users/zach/Documents/UCLA_classes/stats203/project/presentation/presentation.pdf#page=33&view=FitH,28.346443' def forward_sync(self, pdf_file, tex_file, line, col, **kwargs): cmd = self._get_run_command(pdf_file,tex_file,line,col) From bbdbf2471824c96dd31f33db240257105fe832d6 Mon Sep 17 00:00:00 2001 From: Zach Siegel Date: Wed, 16 Dec 2020 21:01:24 -0800 Subject: [PATCH 4/8] added NOT EXPORTABLE aux dir support (just for my setup) --- viewers/chrome_viewer.py | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/viewers/chrome_viewer.py b/viewers/chrome_viewer.py index e6e8b4c2..18ce0ef5 100644 --- a/viewers/chrome_viewer.py +++ b/viewers/chrome_viewer.py @@ -6,7 +6,7 @@ from base_viewer import BaseViewer from latextools_utils import get_setting from latextools_utils.external_command import external_command, check_output - +# from delete_temp_files import DeleteTempFilesCommand ## TODO: remove defaultCmd from applescript - just return True or False, then run that default command from Python. ## TODO: GET CHROME PATH ## TODO: GET CURRENT FOLDER PATH (for osascript command) @@ -39,8 +39,7 @@ def _get_chrome_dir(self,escaped=False): def _get_browser_filepath(self,tex_line_no,tex_col_no,tex_filename,pdf_filename,zoom=100): try: synctex_loc = '{tex_line_no}:{tex_col_no}:{tex_filename}'.format(tex_line_no=tex_line_no,tex_col_no=tex_col_no,tex_filename=tex_filename) - cmd = ['/Library/TeX/texbin/synctex', 'view', '-i', synctex_loc, '-o', pdf_filename] - # output_text = sp.run(cmd,capture_output=True,text=True).stdout.split("\n") + cmd = ['/Library/TeX/texbin/synctex', 'view', '-i', synctex_loc, '-o', pdf_filename, '-d','aux'] stdout = check_output(cmd) output_text = stdout.split("\n") page_no = next((e.lstrip('Page:') for e in output_text if e.startswith('Page:')), 1) @@ -49,11 +48,23 @@ def _get_browser_filepath(self,tex_line_no,tex_col_no,tex_filename,pdf_filename, except Exception as e: print("ERROR IN SYNCTEX") print(e) - page_no = 1 - line_no = 1 - col_no = 0 + try: + synctex_loc = '{tex_line_no}:{tex_col_no}:{tex_filename}'.format(tex_line_no=tex_line_no,tex_col_no=tex_col_no,tex_filename=tex_filename) + cmd = ['/Library/TeX/texbin/synctex', 'view', '-i', synctex_loc, '-o', pdf_filename] + stdout = check_output(cmd) + output_text = stdout.split("\n") + page_no = next((e.lstrip('Page:') for e in output_text if e.startswith('Page:')), 1) + line_no = next((e.lstrip('x:') for e in output_text if e.startswith('x:')), 1) + col_no = next((e.lstrip('y:') for e in output_text if e.startswith('y:')), 1) + except Exception as ee: + print("ANOTHER ERROR IN SYNCTEX") + print(ee) + page_no = 1 + line_no = 1 + col_no = 0 # print(f"{page_no = }, {line_no = }, {col_no = }") + return "file://{pdf_filename}#page={page_no}&view=FitH,{line_no}".format(pdf_filename=pdf_filename,page_no=page_no,line_no=line_no) @@ -62,13 +73,14 @@ def _get_run_command(self,pdf_filename,tex_filename=None,tex_line_no=None,tex_co chrome_dir = self._get_chrome_dir() basic_cmd = [chrome_dir,pdf_filename] return basic_cmd - # pdf_filename = tex_filename.rsplit(".",1)[0] + ".pdf" + pdf_filename = tex_filename.rsplit(".",1)[0] + ".pdf" finalDestination = self._get_browser_filepath(tex_line_no,tex_col_no,tex_filename,pdf_filename) quotedPDFName = quote(pdf_filename) scriptName= "{}/OpenFileInChrome_Page_Number.applescript".format(self._get_applescript_folder()) chrome_dir = self._get_chrome_dir(escaped=True) - defaultCmd = "{chrome_dir} {finalDestination}".format(chrome_dir=chrome_dir,finalDestination=finalDestination) + defaultCmd = "{chrome_dir} '{finalDestination}'".format(chrome_dir=chrome_dir,finalDestination=finalDestination) + # defaultCmd = "{chrome_dir} {quotedPDFName}".format(chrome_dir=chrome_dir,finalDestination=finalDestination) cmd = ['osascript', scriptName, finalDestination,quotedPDFName,defaultCmd] return cmd @@ -79,6 +91,8 @@ def forward_sync(self, pdf_file, tex_file, line, col, **kwargs): print("FORWARD SYNCING CHROME COMMAND IS:") print(cmd) external_command(cmd, use_texpath=True) + # df = DeleteTempFilesCommand() + # df.run() def view_file(self, pdf_file, **kwargs): tex_filename = pdf_file.rsplit(".",1)[0] + ".pdf" From c2c65edcf6b2d3c18fe63f5f499d3707b1be64fd Mon Sep 17 00:00:00 2001 From: Zach Siegel Date: Wed, 16 Dec 2020 21:39:26 -0800 Subject: [PATCH 5/8] made view output_dir universal --- viewers/chrome_viewer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/viewers/chrome_viewer.py b/viewers/chrome_viewer.py index 18ce0ef5..f24a753e 100644 --- a/viewers/chrome_viewer.py +++ b/viewers/chrome_viewer.py @@ -5,6 +5,7 @@ from base_viewer import BaseViewer from latextools_utils import get_setting +from latextools_utils.output_directory import get_output_directory from latextools_utils.external_command import external_command, check_output # from delete_temp_files import DeleteTempFilesCommand ## TODO: remove defaultCmd from applescript - just return True or False, then run that default command from Python. @@ -22,7 +23,6 @@ def _get_applescript_folder(self): 'chrome' ) ) - def _get_chrome_dir(self,escaped=False): viewer_location = check_output([ 'osascript', @@ -39,7 +39,8 @@ def _get_chrome_dir(self,escaped=False): def _get_browser_filepath(self,tex_line_no,tex_col_no,tex_filename,pdf_filename,zoom=100): try: synctex_loc = '{tex_line_no}:{tex_col_no}:{tex_filename}'.format(tex_line_no=tex_line_no,tex_col_no=tex_col_no,tex_filename=tex_filename) - cmd = ['/Library/TeX/texbin/synctex', 'view', '-i', synctex_loc, '-o', pdf_filename, '-d','aux'] + relative_outputdir = os.path.relpath(get_output_directory(tex_filename),os.path.dirname(tex_filename)) + cmd = ['/Library/TeX/texbin/synctex', 'view', '-i', synctex_loc, '-o', pdf_filename, '-d',relative_outputdir] stdout = check_output(cmd) output_text = stdout.split("\n") page_no = next((e.lstrip('Page:') for e in output_text if e.startswith('Page:')), 1) From bb92d3958c48dfbff390fda2756fece382a17a87 Mon Sep 17 00:00:00 2001 From: Zach Siegel Date: Thu, 17 Dec 2020 08:46:10 -0800 Subject: [PATCH 6/8] made browser filepath function better --- viewers/chrome_viewer.py | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/viewers/chrome_viewer.py b/viewers/chrome_viewer.py index f24a753e..58b8d45c 100644 --- a/viewers/chrome_viewer.py +++ b/viewers/chrome_viewer.py @@ -38,9 +38,15 @@ def _get_chrome_dir(self,escaped=False): def _get_browser_filepath(self,tex_line_no,tex_col_no,tex_filename,pdf_filename,zoom=100): try: - synctex_loc = '{tex_line_no}:{tex_col_no}:{tex_filename}'.format(tex_line_no=tex_line_no,tex_col_no=tex_col_no,tex_filename=tex_filename) relative_outputdir = os.path.relpath(get_output_directory(tex_filename),os.path.dirname(tex_filename)) - cmd = ['/Library/TeX/texbin/synctex', 'view', '-i', synctex_loc, '-o', pdf_filename, '-d',relative_outputdir] + outputdir_command = ['-d',relative_outputdir] + except Exception as e: + print("ERROR GETTING 'output_directory'") + print(e) + outputdir_command = [] + synctex_loc = '{tex_line_no}:{tex_col_no}:{tex_filename}'.format(tex_line_no=tex_line_no,tex_col_no=tex_col_no,tex_filename=tex_filename) + cmd = ['/Library/TeX/texbin/synctex', 'view', '-i', synctex_loc, '-o', pdf_filename] + outputdir_command + try: stdout = check_output(cmd) output_text = stdout.split("\n") page_no = next((e.lstrip('Page:') for e in output_text if e.startswith('Page:')), 1) @@ -49,23 +55,9 @@ def _get_browser_filepath(self,tex_line_no,tex_col_no,tex_filename,pdf_filename, except Exception as e: print("ERROR IN SYNCTEX") print(e) - try: - synctex_loc = '{tex_line_no}:{tex_col_no}:{tex_filename}'.format(tex_line_no=tex_line_no,tex_col_no=tex_col_no,tex_filename=tex_filename) - cmd = ['/Library/TeX/texbin/synctex', 'view', '-i', synctex_loc, '-o', pdf_filename] - stdout = check_output(cmd) - output_text = stdout.split("\n") - page_no = next((e.lstrip('Page:') for e in output_text if e.startswith('Page:')), 1) - line_no = next((e.lstrip('x:') for e in output_text if e.startswith('x:')), 1) - col_no = next((e.lstrip('y:') for e in output_text if e.startswith('y:')), 1) - except Exception as ee: - print("ANOTHER ERROR IN SYNCTEX") - print(ee) - page_no = 1 - line_no = 1 - col_no = 0 - # print(f"{page_no = }, {line_no = }, {col_no = }") - - + page_no = 1 + line_no = 1 + col_no = 0 return "file://{pdf_filename}#page={page_no}&view=FitH,{line_no}".format(pdf_filename=pdf_filename,page_no=page_no,line_no=line_no) From 86d3847b957b4d7f2cbd6b9228e1b15db5c1a682 Mon Sep 17 00:00:00 2001 From: Zach Siegel Date: Fri, 18 Dec 2020 11:16:03 -0800 Subject: [PATCH 7/8] fixed forward-syncing y coordinate --- viewers/chrome_viewer.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/viewers/chrome_viewer.py b/viewers/chrome_viewer.py index 58b8d45c..e3da5cbf 100644 --- a/viewers/chrome_viewer.py +++ b/viewers/chrome_viewer.py @@ -48,10 +48,13 @@ def _get_browser_filepath(self,tex_line_no,tex_col_no,tex_filename,pdf_filename, cmd = ['/Library/TeX/texbin/synctex', 'view', '-i', synctex_loc, '-o', pdf_filename] + outputdir_command try: stdout = check_output(cmd) + with open('/Users/zach/Desktop/latexoutput','w') as f: + f.write(stdout) output_text = stdout.split("\n") page_no = next((e.lstrip('Page:') for e in output_text if e.startswith('Page:')), 1) - line_no = next((e.lstrip('x:') for e in output_text if e.startswith('x:')), 1) - col_no = next((e.lstrip('y:') for e in output_text if e.startswith('y:')), 1) + # page_no = int(page_no) + 1 #offset, see `synctex view help` + col_no = next((e.lstrip('x:') for e in output_text if e.startswith('x:')), 1) + line_no = next((e.lstrip('y:') for e in output_text if e.startswith('y:')), 1) except Exception as e: print("ERROR IN SYNCTEX") print(e) From ca28cd74a28a4c5d11486157a5891a68e0a58d4e Mon Sep 17 00:00:00 2001 From: Zach Siegel Date: Fri, 18 Dec 2020 11:33:39 -0800 Subject: [PATCH 8/8] commented out junk --- viewers/chrome_viewer.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/viewers/chrome_viewer.py b/viewers/chrome_viewer.py index e3da5cbf..b8c03053 100644 --- a/viewers/chrome_viewer.py +++ b/viewers/chrome_viewer.py @@ -48,8 +48,6 @@ def _get_browser_filepath(self,tex_line_no,tex_col_no,tex_filename,pdf_filename, cmd = ['/Library/TeX/texbin/synctex', 'view', '-i', synctex_loc, '-o', pdf_filename] + outputdir_command try: stdout = check_output(cmd) - with open('/Users/zach/Desktop/latexoutput','w') as f: - f.write(stdout) output_text = stdout.split("\n") page_no = next((e.lstrip('Page:') for e in output_text if e.startswith('Page:')), 1) # page_no = int(page_no) + 1 #offset, see `synctex view help`