Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an "old" attribute to the pnum class to indicate pnum changes #103

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions TEST.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 7 additions & 2 deletions data/filters/wg21.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,15 +321,20 @@ 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})'

if doc.format == 'latex':
return pf.RawInline(f'\\pnum{{{num}}}', 'latex')
elif doc.format == 'html':
return pf.Span(
pf.RawInline(f'<a class="marginalized">{num}</a>', 'html'),
pf.RawInline(f'<a class="marginalized"{old_attribute if old_attribute != None else '' }>{num}</a>', 'html'),
classes=['marginalizedparent'])

return pf.Superscript(pf.Str(num))
Expand Down
13 changes: 13 additions & 0 deletions data/templates/wg21.html
Original file line number Diff line number Diff line change
Expand Up @@ -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$
</style>
$for(css)$
Expand Down
28 changes: 26 additions & 2 deletions generated/TEST.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" />
<meta name="generator" content="mpark/wg21" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<meta name="dcterms.date" content="2024-12-15" />
<meta name="dcterms.date" content="2024-12-22" />
<title>Test document for mpark/wg21</title>
<style>
code{white-space: pre-wrap;}
Expand Down Expand Up @@ -81,6 +81,19 @@
code.diff {color: #898887}
code.diff span.va {color: #006e28}
code.diff span.st {color: #bf0303}

.marginalized[data-old]::before {
text-decoration-line: line-through;
color: #bf0303;
content: attr(data-old);
}
.marginalized[data-old] {
color: #006e28;
}
.add .marginalized {
color: #006e28;
}

</style>
<style type="text/css">
body {
Expand Down Expand Up @@ -430,7 +443,7 @@ <h3 class="subtitle" style="text-align:center">Visual inspection of
</tr>
<tr>
<td>Date:</td>
<td>2024-12-15</td>
<td>2024-12-22</td>
</tr>
<tr>
<td style="vertical-align:top">Project:</td>
Expand Down Expand Up @@ -761,6 +774,17 @@ <h2 data-number="5.1" id="paragraph-numbers"><span class="header-section-number"
(7.6.1.1) with an array operand, the set contains the potential results
of that operand.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized" data-old>3</a></span>
We can indicate new paragraph numbers via an empty
<code class="sourceCode cpp">old</code> attribute</p>
<p><span class="marginalizedparent"><a class="marginalized" data-old="3">4</a></span>
And old paragraph numbers</p>
<p><span class="marginalizedparent"><a class="marginalized" data-old="4">(4.1)</a></span>
And changing the nesting</p>
<p><span class="marginalizedparent"><a class="marginalized" data-old="(5.1)">5</a></span>
And vice versa</p>
<p><span class="marginalizedparent"><a class="marginalized" data-old="(5.1)">(6.1)</a></span>
And both</p>
<h2 data-number="5.2" id="wording-changes"><span class="header-section-number">5.2</span> Wording Changes<a href="#wording-changes" class="self-link"></a></h2>
<p>Large changes are
<code class="sourceCode cpp"><span class="op">:::</span> add</code> for
Expand Down
Binary file added img/pnum-old.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.