From 4aa0bc68a57f64350bda6da74c4d41640afc0493 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Sun, 22 Dec 2024 13:49:09 -0800 Subject: [PATCH] Add an "old" attribute to the pnum class to indicate paragraph number changes This does not effect the markup, and allows a purely css highlight model for the changes. We intentionally use the ::before pseudo element to inject the content so that it does not screw up selection of text (e.g. only the "real" text of the change is eligible for selection). --- README.md | 17 +++++++++++++++++ TEST.md | 11 +++++++++++ data/filters/wg21.py | 9 +++++++-- data/templates/wg21.html | 13 +++++++++++++ generated/TEST.html | 28 ++++++++++++++++++++++++++-- img/pnum-old.png | Bin 0 -> 51851 bytes 6 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 img/pnum-old.png diff --git a/README.md b/README.md index d9481a6..82c41e2 100644 --- a/README.md +++ b/README.md @@ -301,6 +301,23 @@ the set contains the potential results of that operand. ![](img/pnum.png) +If paragraph numbers are being added or changed we can use the `old` attribute: + +```markdown + +[3]{.pnum old=""} We can indicate new paragraph numbers via an empty `old` attribute + +[4]{.pnum old="3"} And old paragraph numbers + +[4.1]{.pnum old="4"} And changing the nesting + +[5]{.pnum old="5.1"} And vice versa + +[6.1]{.pnum old="5.1"} And both +``` + +![](img/pnum-old.png) + #### Code Changes ![](img/code-diff.png) diff --git a/TEST.md b/TEST.md index 8bb257f..c4fd88a 100644 --- a/TEST.md +++ b/TEST.md @@ -266,6 +266,17 @@ an expression `e` is defined as follows: - [2.2]{.pnum} If `e` is a subscripting operation (7.6.1.1) with an array operand, the set contains the potential results of that operand. +[3]{.pnum old=""} We can indicate new paragraph numbers via an empty `old` attribute + +[4]{.pnum old="3"} And old paragraph numbers + +[4.1]{.pnum old="4"} And changing the nesting + +[5]{.pnum old="5.1"} And vice versa + +[6.1]{.pnum old="5.1"} And both + + ## Wording Changes Large changes are `::: add` for additions, `::: rm` for removals. diff --git a/data/filters/wg21.py b/data/filters/wg21.py index c10c6b5..88b4385 100755 --- a/data/filters/wg21.py +++ b/data/filters/wg21.py @@ -321,7 +321,12 @@ def protect_code(elem, doc): def pnum(): num = pf.stringify(elem) - + old_attribute = None + if "old" in elem.attributes: + old = elem.attributes["old"] + if '.' in old: + old = f'({old})' + old_attribute = f' data-old="{old}"'; if '.' in num: num = f'({num})' @@ -329,7 +334,7 @@ def pnum(): return pf.RawInline(f'\\pnum{{{num}}}', 'latex') elif doc.format == 'html': return pf.Span( - pf.RawInline(f'{num}', 'html'), + pf.RawInline(f'{num}', 'html'), classes=['marginalizedparent']) return pf.Superscript(pf.Str(num)) diff --git a/data/templates/wg21.html b/data/templates/wg21.html index 5291d12..5194e73 100644 --- a/data/templates/wg21.html +++ b/data/templates/wg21.html @@ -32,6 +32,19 @@ code.diff {color: #$uccolor$} code.diff span.va {color: #$addcolor$} code.diff span.st {color: #$rmcolor$} + + .marginalized[data-old]::before { + text-decoration-line: line-through; + color: #$rmcolor$; + content: attr(data-old); + } + .marginalized[data-old] { + color: #$addcolor$; + } + .add .marginalized { + color: #$addcolor$; + } + $endif$ $for(css)$ diff --git a/generated/TEST.html b/generated/TEST.html index 507a1e0..d59c54d 100644 --- a/generated/TEST.html +++ b/generated/TEST.html @@ -4,7 +4,7 @@ - + Test document for mpark/wg21