| 1 | # __SyncTeX__ |
| 2 | |
| 3 | This file is part of the __SyncTeX__ package. |
| 4 | |
| 5 | [//]: # (Version: 1.22) |
| 6 | [//]: # (Date: Mon May 11 16:05:02 UTC 2020) |
| 7 | |
| 8 | ## Important |
| 9 | |
| 10 | * Changes in version `1.22` |
| 11 | |
| 12 | * Typos fixed in code and printed comments |
| 13 | * Code cleaning (`static` keyword added) |
| 14 | * Bug fixed (Missing `va_end`) |
| 15 | |
| 16 | * Changes in version `1.21` |
| 17 | |
| 18 | * Remove a `\` character from the name ot 2 test files. |
| 19 | * Change variable name `class` to `class_` because the former is a reserved keyword in C++. |
| 20 | * Adding a more portable unused variable management. |
| 21 | * Various cosmetic changes in the source code, including explicit declaration of `void` in forward function declaration. |
| 22 | |
| 23 | |
| 24 | * Changes in version `1.20` |
| 25 | |
| 26 | One bug fixed in some initialization and different syntax to make some compilers happy. |
| 27 | |
| 28 | * Changes in version `1.19` |
| 29 | |
| 30 | A long standing bug affecting only pdftex has been fixed by adding support to pdf forms. As a side effect, the synchronization algorithm gains in accuracy for all the engines, especially from pdf to source. Of course, there is a small cost in both memory footprint and computational time, but none is noticeable. |
| 31 | |
| 32 | Some technical changes in the API. |
| 33 | * more consistent type naming convention |
| 34 | * `_s` suffix for struct's |
| 35 | * `_p` suffix for pointers |
| 36 | * `_t` suffix for standard types |
| 37 | * `_f` suffix for functions... |
| 38 | |
| 39 | thus `synctex_node_t` has become `synctex_node_p`. |
| 40 | |
| 41 | * supplemental argument in `synctex_display_query`. Set `page_hint` to the currently displayed pdf page number (0 based). If this info is not available, set `page_hint` to 0, it corresponds to the old behaviour. |
| 42 | * rename `synctex_next_result` to `synctex_scanner_next_result` |
| 43 | * additional `synctex_parser_private.h` header where |
| 44 | more API are exposed. For an advanced usage only (eg parallel synchronizations). |
| 45 | * `SYNCTEX_NO_UPDATER` preprocessor macro to deactivate some code useless to frontends. |
| 46 | |
| 47 | ## What is it ? |
| 48 | |
| 49 | The *Synchronization TeXnology* named __SyncTeX__ is a new feature |
| 50 | of recent __TeX__ engines designed by Jérôme Laurens. |
| 51 | It allows to synchronize between input and output, which means to |
| 52 | navigate from the source document to the typeset material and vice versa. |
| 53 | Browse the source code for more information. |
| 54 | |
| 55 | ## Contents |
| 56 | This package is mainly for developers, it contains the following files: |
| 57 | |
| 58 | * `synctex_parser_readme.md` (this file) |
| 59 | * `synctex_parser_version.txt` |
| 60 | * `synctex_parser_utils.c` |
| 61 | * `synctex_parser_utils.h` |
| 62 | * `synctex_parser_local.h` |
| 63 | * `synctex_parser.h` |
| 64 | * `synctex_parser_advanced.h` |
| 65 | * `synctex_parser.c` |
| 66 | |
| 67 | The file you are reading contains more informations about the __SyncTeX__ parser history. |
| 68 | |
| 69 | ## Source |
| 70 | |
| 71 | All stable sources are available from [TeXLive repository](http://www.tug.org/svn/texlive/trunk/Build/source/texk/web2c/synctexdir/). |
| 72 | |
| 73 | Latest development sources are available from GitHub. |
| 74 | |
| 75 | Please notice that due to the complexity of the TeXLive TeX distribution, there might be some delay before synchronization occurs between various repositories. |
| 76 | |
| 77 | ## Usage |
| 78 | |
| 79 | In order to support __SyncTeX__ in a viewer, it is sufficient to include |
| 80 | in the source the files `synctex_parser.c` and `synctex_parser_utils.c`. |
| 81 | The synctex parser usage is described in `synctex_parser.h` header file. |
| 82 | |
| 83 | More advanced usage is found in `synctex_parser_advanced.h` |
| 84 | |
| 85 | The other files are used by tex engines or by the synctex command line utility: |
| 86 | |
| 87 | ``` |
| 88 | ChangeLog |
| 89 | README.txt |
| 90 | am |
| 91 | man1 |
| 92 | man5 |
| 93 | synctex-common.h |
| 94 | synctex-convert.sh |
| 95 | synctex-e-mem.ch0 |
| 96 | synctex-e-mem.ch1 |
| 97 | synctex-e-rec.ch0 |
| 98 | synctex-e-rec.ch1 |
| 99 | synctex-etex.h |
| 100 | synctex-mem.ch0 |
| 101 | synctex-mem.ch1 |
| 102 | synctex-mem.ch2 |
| 103 | synctex-pdf-rec.ch2 |
| 104 | synctex-pdftex.h |
| 105 | synctex-rec.ch0 |
| 106 | synctex-rec.ch1 |
| 107 | synctex-rec.ch2 |
| 108 | synctex-tex.h |
| 109 | synctex-xe-mem.ch2 |
| 110 | synctex-xe-rec.ch2 |
| 111 | synctex-xe-rec.ch3 |
| 112 | synctex-xetex.h |
| 113 | synctex.c |
| 114 | synctex.defines |
| 115 | synctex.h |
| 116 | synctex_main.c |
| 117 | tests |
| 118 | ... |
| 119 | ``` |
| 120 | |
| 121 | ## Version: |
| 122 | |
| 123 | This is version 1, which refers to the synctex output file format. |
| 124 | |
| 125 | The files are identified by a build number. |
| 126 | In order to help developers to automatically manage the version and build numbers |
| 127 | and download the parser only when necessary, the `synctex_parser_version.txt` |
| 128 | is an ASCII text file just containing the current version and build numbers eg `1.19`. |
| 129 | |
| 130 | ## History: |
| 131 | |
| 132 | * 1.1: Thu Jul 17 09:28:13 UTC 2008 |
| 133 | - First official version available in TeXLive 2008 DVD. |
| 134 | Unfortunately, the backwards synchronization is not working properly mainly for ConTeXt users, see below. |
| 135 | * 1.2: Tue Sep 2 10:28:32 UTC 2008 |
| 136 | - Correction for ConTeXt support in the edit query. |
| 137 | The previous method was assuming that TeX boxes do not overlap, |
| 138 | which is reasonable for LaTeX but not for ConTeXt. |
| 139 | This assumption is no longer considered. |
| 140 | * 1.3: Fri Sep 5 09:39:57 UTC 2008 |
| 141 | - Local variable "read" renamed to "already_read" to avoid conflicts. |
| 142 | - "inline" compiler directive renamed to "SYNCTEX_INLINE" for code support and maintenance |
| 143 | - _synctex_error cannot be inlined due to variable arguments (thanks Christiaan Hofman) |
| 144 | - Correction in the display query, extra boundary nodes are used for a more precise forwards synchronization |
| 145 | * 1.4: Fri Sep 12 08:12:34 UTC 2008 |
| 146 | - For an unknown reason, the previous version was not the real 1.3 (as used in iTeXMac2 build 747). |
| 147 | As a consequence, a crash was observed. |
| 148 | - Some typos are fixed. |
| 149 | * 1.6: Mon Nov 3 20:20:02 UTC 2008 |
| 150 | - The bug that prevented synchronization with compressed files on windows has been fixed. |
| 151 | - New interface to allow system specific customization. |
| 152 | - Note that some APIs have changed. |
| 153 | * 1.8: Mer 8 jul 2009 11:32:38 UTC |
| 154 | Note that version 1.7 was delivered privately. |
| 155 | - bug fix: synctex was causing a memory leak in pdftex and xetex, thus some processing speed degradation |
| 156 | - bug fix: the synctex command line tool was broken when updating a .synctex file |
| 157 | - enhancement: better accuracy of the synchronization process |
| 158 | - enhancement: the pdf output file and the associated .synctex file no longer need to live in the same directory. |
| 159 | The new -d option of the synctex command line tool manages this situation. |
| 160 | This is handy when using something like tex -output-directory=DIR ... |
| 161 | * 1.9: Wed Nov 4 11:52:35 UTC 2009 |
| 162 | - Various typo fixed |
| 163 | - OutputDebugString replaced by OutputDebugStringA to deliberately disable unicode preprocessing |
| 164 | - New conditional created because OutputDebugStringA is only available since Windows 2K professional |
| 165 | * 1.10: Sun Jan 10 10:12:32 UTC 2010 |
| 166 | - Bug fix in synctex_parser.c to solve a synchronization problem with amsmath's gather environment. |
| 167 | Concerns the synctex tool. |
| 168 | * 1.11: Sun Jan 17 09:12:31 UTC 2010 |
| 169 | - Bug fix in synctex_parser.c, function synctex_node_box_visible_v: 'x' replaced by 'y'. |
| 170 | Only 3rd party tools are concerned. |
| 171 | * 1.12: Mon Jul 19 21:52:10 UTC 2010 |
| 172 | - Bug fix in synctex_parser.c, function __synctex_open: the io_mode was modified even in case of a non zero return, |
| 173 | causing a void .synctex.gz file to be created even if it was not expected. Reported by Marek Kasik concerning a bug on evince. |
| 174 | * 1.13: Fri Mar 11 07:39:12 UTC 2011 |
| 175 | - Bug fix in synctex_parser.c, better synchronization as suggested by Jan Sundermeyer (near line 3388). |
| 176 | - Stronger code design in synctex_parser_utils.c, function _synctex_get_name (really neutral behavior). |
| 177 | Only 3rd party tools are concerned. |
| 178 | * 1.14: Fri Apr 15 19:10:57 UTC 2011 |
| 179 | - taking output_directory into account |
| 180 | - Replaced FOPEN_WBIN_MODE by FOPEN_W_MODE when opening the text version of the .synctex file. |
| 181 | - Merging with LuaTeX's version of synctex.c |
| 182 | * 1.15: Fri Jun 10 14:10:17 UTC 2011 |
| 183 | This concerns the synctex command line tool and 3rd party developers. |
| 184 | TeX and friends are not concerned by these changes. |
| 185 | - Bug fixed in _synctex_get_io_mode_name, sometimes the wrong mode was returned |
| 186 | - Support for LuaTeX convention of './' file prefixing |
| 187 | * 1.16: Tue Jun 14 08:23:30 UTC 2011 |
| 188 | This concerns the synctex command line tool and 3rd party developers. |
| 189 | TeX and friends are not concerned by these changes. |
| 190 | - Better forward search (thanks Jose Alliste) |
| 191 | - Support for LuaTeX convention of './' file prefixing now for everyone, not only for Windows |
| 192 | * 1.17: Fri Oct 14 08:15:16 UTC 2011 |
| 193 | This concerns the synctex command line tool and 3rd party developers. |
| 194 | TeX and friends are not concerned by these changes. |
| 195 | - synctex_parser.c: cosmetic changes to enhance code readability |
| 196 | - Better forward synchronization. |
| 197 | The problem occurs for example with LaTeX \item command. |
| 198 | The fact is that this command creates nodes at parse time but these nodes are used only |
| 199 | after the text material of the \item is displayed on the page. The consequence is that sometimes, |
| 200 | forward synchronization spots an irrelevant point from the point of view of the editing process. |
| 201 | This was due to some very basic filtering policy, where a somehow arbitrary choice was made when |
| 202 | many different possibilities where offered for synchronisation. |
| 203 | Now, forward synchronization prefers nodes inside an hbox with as many acceptable spots as possible. |
| 204 | This is achieved with the notion of mean line and node weight. |
| 205 | - Adding support for the new file naming convention with './' |
| 206 | - function `synctex_ignore_leading_dot_slash_in_path replaces` `synctex_ignore_leading_dot_slash` |
| 207 | - function `_synctex_is_equivalent_file_name` is more permissive |
| 208 | Previously, the function synctex_scanner_get_tag would give an answer only when |
| 209 | the given file name was EXACTLY one of the file names listed in the synctex file. |
| 210 | The we added some changes accepting for example 'foo.tex' instead of './foo.tex'. |
| 211 | Now we have an even looser policy for dealing with file names. |
| 212 | If the given file name does not match exactly one the file names of the synctex file, |
| 213 | then we try to match the base names. If there is only one match of the base names, |
| 214 | then it is taken as a match for the whole names. |
| 215 | The base name is defined as following: |
| 216 | |
| 217 | `./foo => foo |
| 218 | /my///.////foo => foo |
| 219 | /foo => /foo |
| 220 | /my//.foo => /my//.foo` |
| 221 | |
| 222 | * 1.17: Tue Mar 13 10:10:03 UTC 2012 |
| 223 | - minor changes, no version changes |
| 224 | - syntax man pages are fixed as suggested by M. Shimata |
| 225 | see mail to [email protected] titled "syntax.5 has many warnings from groff" and "syntax.1 use invalid macro for mdoc" |
| 226 | - 1.17: Tue Jan 14 09:55:00 UTC 2014, fixed a segfault, patch from Sebastian Ramacher |
| 227 | - 1.17: Mon Aug 04, fixed a memory leak |
| 228 | * 1.18: Thu Jun 25 11:36:05 UTC 2015 |
| 229 | - nested sheets now fully supported (does it make sense in TeX) |
| 230 | - cosmetic changes: uniform indentation |
| 231 | - suppression of warnings, mainly long/int ones. In short, zlib likes ints when size_t likes longs. |
| 232 | - CLI synctex tool can build out of TeXLive (modulo appropriate options passed to the compiler) |
| 233 | * 1.19: Mon Jul 3 20:03:56 UTC 2017 |
| 234 | - the nested sheets patch was not a good solution. |
| 235 | It has been moved from the parser to the engine. |
| 236 | See the `synctex.c` source file for detailed explanations. |
| 237 | - there is a new synctex format specification. |
| 238 | We can see that a `.synctex` file can contain many times |
| 239 | the same vertical position because many objects belong |
| 240 | to the same line. When the options read `-synctex=±2` or more, |
| 241 | a very basic compression algorithm is used: |
| 242 | if synctex is about to write the same number then it writes |
| 243 | an `=` sign instead. This saves approximately 10% of the |
| 244 | synctex output file, either compressed or not. |
| 245 | The new synctex parser has been updated accordingly. |
| 246 | Actual tex frontend won't see any difference with the |
| 247 | TeX engines that include this new feature. |
| 248 | Frontends with the new parser won't see any difference |
| 249 | with the older TeX engines. |
| 250 | Frontends with the new parser will only see a difference |
| 251 | with new TeX engines if `-synctex=±2` or more is used. |
| 252 | |
| 253 | ## Acknowledgments: |
| 254 | |
| 255 | The author received useful remarks from the __pdfTeX__ developers, especially Hahn The Thanh, |
| 256 | and significant help from __XeTeX__ developer Jonathan Kew. |
| 257 | |
| 258 | ## Nota Bene: |
| 259 | |
| 260 | If you include or use a significant part of the __SyncTeX__ package into a software, |
| 261 | I would appreciate to be listed as contributor and see __SyncTeX__" highlighted. |
| 262 | |
| 263 | Copyright (c) 2008-2017 jerome DOT laurens AT u-bourgogne DOT fr |
| 264 |