texdiff 0.2.3__py3-none-any.whl → 0.2.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
texdiff/__init__.py CHANGED
@@ -42,4 +42,4 @@ __all__ = [
42
42
  "word_diff",
43
43
  ]
44
44
 
45
- __version__ = "0.2.2"
45
+ __version__ = "0.2.4"
texdiff/emit.py CHANGED
@@ -1556,7 +1556,13 @@ def _is_safe_inline(text: str) -> bool:
1556
1556
  return False
1557
1557
  if "\n" in text:
1558
1558
  return False
1559
- if _ARG_MACRO_RE.search(text) or _ARG_MACRO_BR_RE.search(text):
1559
+ # decoration macros (\\emph, \\textbf, ...) with pure-text
1560
+ # arguments are LR-safe inside \\DIFdel/\\DIFadd - font commands
1561
+ # survive \\sout/\\uwave. Mask them before the macro-argument
1562
+ # probe or cells like ``\\emph{valid\\_min} to \\emph{valid\\_max}``
1563
+ # degrade to the colour-only fallback: red but never struck.
1564
+ probe = _SAFE_DECOR_RE.sub(lambda m: m.group(2), text)
1565
+ if _ARG_MACRO_RE.search(probe) or _ARG_MACRO_BR_RE.search(probe):
1560
1566
  return False
1561
1567
  if _LIST_ITEM_RE.search(text):
1562
1568
  # \item / \par inside a strikeout/wave is LR-mode illegal
@@ -2239,6 +2245,11 @@ def _escape_cell_pair(old_cell: str, new_cell: str) -> str:
2239
2245
  if _is_safe_inline(new_cell):
2240
2246
  return f"\\DIFadd{{{new_cell}}}"
2241
2247
  return f"\\DIFaddbegin{{}} {new_cell} \\DIFaddend{{}}"
2248
+ if not new_cell:
2249
+ # text -> empty: strike the old cell (blue adds nothing)
2250
+ if _is_safe_inline(old_cell):
2251
+ return f"\\DIFdel{{{old_cell}}}"
2252
+ return f"\\DIFdelbegin{{}} {old_cell} \\DIFdelend{{}}"
2242
2253
  # underscore-escape-only difference: the OLD ADS generator emits
2243
2254
  # raw ``_`` in variable paths while the NEW one escapes it as
2244
2255
  # ``\_`` - both render identically in LaTeX. A cell pair that
@@ -2459,7 +2470,9 @@ def _merge_keyed_rows(
2459
2470
  parts: list[str] = []
2460
2471
  for oc, nc in zip(old_cells, new_cells):
2461
2472
  oc_s, nc_s = oc.strip(), nc.strip()
2462
- if oc_s == nc_s or not nc_s:
2473
+ if oc_s == nc_s:
2474
+ parts.append(oc)
2475
+ elif not nc_s and not oc_s:
2463
2476
  parts.append(oc)
2464
2477
  else:
2465
2478
  parts.append(_escape_cell_pair(oc_s, nc_s))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: texdiff
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: AST-driven semantic diff for LaTeX documents
5
5
  Author: GoBobr
6
6
  License: MIT License
@@ -1,9 +1,9 @@
1
- texdiff/__init__.py,sha256=gGXeJqv_mMsYbP-Fv5QpVzZbO0Y8Qvd1FKKAsON5qMI,1023
1
+ texdiff/__init__.py,sha256=tTAxf2W2OBnMy-hsMS4qyo9AJg5EenSoufH9GUHMWYA,1023
2
2
  texdiff/align.py,sha256=wznQWea3fAt6DUzWbfxpaP8IfxTJyu8e6T_oCsgx_r0,35554
3
3
  texdiff/api.py,sha256=FG8VT2YNRBp6LiAFLFNBld_-RI8wi-cyUVDM1mUTvlw,13675
4
4
  texdiff/check.py,sha256=Wpqst1nbGh2RYZPUWmXrsYfNX0zECo5SRmkrfOcOwOE,1820
5
5
  texdiff/cli.py,sha256=xFiaLutQu9hdFVJz6QWKgLuK_XTCCXv-MPkkdwaxW8E,2560
6
- texdiff/emit.py,sha256=kUQKO-Ljpqn0LF8T_0Zv5Rp81GnL5R1hs6qemeuJqeA,133332
6
+ texdiff/emit.py,sha256=A_AOHR4PpJWJwtf-EaaeT6r5VAVUttZlHLyCxHMmMwQ,134014
7
7
  texdiff/flatten.py,sha256=qfizn6-uhxmAjyNPdJbImPyA875ZwufagFz7x9mHQqY,6804
8
8
  texdiff/newlines.py,sha256=-vpU7tGPVTZsJmXB-shSJP1dwYQa740efRZH6CkGYxw,2053
9
9
  texdiff/nodes.py,sha256=Itvgh7ekz_www-nz5gPXQSWzSUKP_h9bZ9nlhbAXkww,6460
@@ -12,9 +12,9 @@ texdiff/parse.py,sha256=TuhC5jtDgE6HueGu91RbyjnBN72vbHTs9kTAUffrdsQ,18790
12
12
  texdiff/preamble.py,sha256=IA2A4GELdK8wEtR70FIkPakHKprgXP-lpmFViPvpHxU,15957
13
13
  texdiff/tables.py,sha256=CpUpveVyyhoc9O0tDQWlX-PHCAgPugbsjEpTvqf7ctk,23210
14
14
  texdiff/textdiff.py,sha256=gs8HeLA8__ts-NvQWJCqOS-wtXtQbxaPZk459qKdJvE,5199
15
- texdiff-0.2.3.dist-info/licenses/LICENSE,sha256=fUppg5evqA2g0mRPkqN6nZf05_CMWDbB7eCJLLm77LI,1063
16
- texdiff-0.2.3.dist-info/METADATA,sha256=8oAKUG2trY5YkPxXDDaYwMNwiJsI6o8ARV9GBx8i02c,4950
17
- texdiff-0.2.3.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
18
- texdiff-0.2.3.dist-info/entry_points.txt,sha256=dwCa4uRkbpmQY1DySP66BMbj45-zNRPufkY3fJ19OIs,45
19
- texdiff-0.2.3.dist-info/top_level.txt,sha256=_h2FYJPSZ88JDmjQNW15BoBM4-XaosFBS8UAAyveSok,8
20
- texdiff-0.2.3.dist-info/RECORD,,
15
+ texdiff-0.2.4.dist-info/licenses/LICENSE,sha256=fUppg5evqA2g0mRPkqN6nZf05_CMWDbB7eCJLLm77LI,1063
16
+ texdiff-0.2.4.dist-info/METADATA,sha256=4k5e2OXdmhW17cgPyYG55rOgjb1MHp675XTnok1kPlE,4950
17
+ texdiff-0.2.4.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
18
+ texdiff-0.2.4.dist-info/entry_points.txt,sha256=dwCa4uRkbpmQY1DySP66BMbj45-zNRPufkY3fJ19OIs,45
19
+ texdiff-0.2.4.dist-info/top_level.txt,sha256=_h2FYJPSZ88JDmjQNW15BoBM4-XaosFBS8UAAyveSok,8
20
+ texdiff-0.2.4.dist-info/RECORD,,