Skip to content

Commit f54c74c

Browse files
committed
Capture special cases in convert-adoc.js
1 parent 72ec1d2 commit f54c74c

8 files changed

Lines changed: 43 additions & 29 deletions

File tree

content/community-contracts/crosschain.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function sendMessage(
9595
// Post on all gateways
9696
Outbox[] memory outbox = new Outbox[](_gateways.length());
9797
bool needsId = false;
98-
for (uint256 i = 0; i < outbox.length; `i) {
98+
for (uint256 i = 0; i < outbox.length; ++i) {
9999
address gateway = _gateways.at(i);
100100
// send message
101101
bytes32 id = IERC7786GatewaySource(gateway).sendMessage(
@@ -132,7 +132,7 @@ function receiveMessage(
132132
if (_gateways.contains(msg.sender) && !tracker.receivedBy[msg.sender]) {
133133
// Count number of time received
134134
tracker.receivedBy[msg.sender] = true;
135-
`tracker.countReceived;
135+
++tracker.countReceived;
136136
emit Received(id, msg.sender);
137137
138138
// if already executed, leave gracefully
@@ -162,4 +162,4 @@ function receiveMessage(
162162
}
163163
```
164164

165-
The bridge is designed to be configurable. As an `Ownable` contract, it allows the owner to manage the list of trusted gateways and adjust the confirmation threshold. The `_gateways` list and threshold are initially set during contract deployment using the [`+_addGateway+`](/community-contracts/api/crosschain#ERC7786OpenBridge-_addGateway-address-) and [`+_setThreshold+`](/community-contracts/api/crosschain#ERC7786OpenBridge-_setThreshold-uint8-) functions. The owner can update these settings as needed to adapt to changing requirements or add new gateways.
165+
The bridge is designed to be configurable. As an `Ownable` contract, it allows the owner to manage the list of trusted gateways and adjust the confirmation threshold. The `_gateways` list and threshold are initially set during contract deployment using the [`_addGateway`](/community-contracts/api/crosschain#ERC7786OpenBridge-_addGateway-address-) and [`_setThreshold`](/community-contracts/api/crosschain#ERC7786OpenBridge-_setThreshold-uint8-) functions. The owner can update these settings as needed to adapt to changing requirements or add new gateways.

content/community-contracts/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ Contracts in the community library are provided as is, with no particular guaran
4242

4343
Similarly, the code has no backward compatibility guarantees.
4444

45-
We kindly ask to report any issue directly to our security mailto:security@openzeppelin.org[contact]. The team will do its best to assist and mitigate any potential misuses of the library. However, keep in mind the flexibility assumed for this repository may relax our assessment.
45+
We kindly ask to report any issue directly to our security [contact](mailto:security@openzeppelin.org). The team will do its best to assist and mitigate any potential misuses of the library. However, keep in mind the flexibility assumed for this repository may relax our assessment.

content/confidential-contracts/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ Contracts in the confidential contracts library are provided as is, with no part
1414

1515
Similarly, the code has no backward compatibility guarantees.
1616

17-
We kindly ask to report any issue directly to our security mailto:security@openzeppelin.org[contact]. The team will do its best to assist and mitigate any potential misuses of the library. However, keep in mind the flexibility assumed for this repository may relax our assessment.
17+
We kindly ask to report any issue directly to our security [contact](mailto:security@openzeppelin.org). The team will do its best to assist and mitigate any potential misuses of the library. However, keep in mind the flexibility assumed for this repository may relax our assessment.

content/confidential-contracts/token.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Setting an operator for any amount of time allows the operator to _***take all o
4141

4242
The token standard exposes transfer functions with and without callbacks. It is up to the caller to decide if a callback is necessary for the transfer. For smart contracts that support it, callbacks allow the operator approval step to be skipped and directly invoke the receiver contract via a callback.
4343

44-
Smart contracts that are the target of a callback must implement [`+IERC7984Receiver+`](/confidential-contracts/api/interfaces#IERC7984Receiver). After balances are updated for a transfer, the callback is triggered by calling the [`+onConfidentialTransferReceived+`](/confidential-contracts/api/interfaces#IERC7984Receiver-onConfidentialTransferReceived-address-address-euint64-bytes-) function. The function must either revert or return an `ebool` indicating success. If the callback returns false, the token transfer is reversed.
44+
Smart contracts that are the target of a callback must implement [`IERC7984Receiver`](/confidential-contracts/api/interfaces#IERC7984Receiver). After balances are updated for a transfer, the callback is triggered by calling the [`onConfidentialTransferReceived`](/confidential-contracts/api/interfaces#IERC7984Receiver-onConfidentialTransferReceived-address-address-euint64-bytes-) function. The function must either revert or return an `ebool` indicating success. If the callback returns false, the token transfer is reversed.
4545

4646
## Examples
4747

content/contracts/5.x/access-control.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ These can be used to iterate over the accounts that have been granted a role:
9696
const minterCount = await myToken.getRoleMemberCount(MINTER_ROLE);
9797

9898
const members = [];
99-
for (let i = 0; i < minterCount; i) {
99+
for (let i = 0; i < minterCount; ++i) {
100100
members.push(await myToken.getRoleMember(MINTER_ROLE, i));
101101
}
102102
```
@@ -282,7 +282,7 @@ This adds function that can be queried to iterate over the accounts that have be
282282
const minterCount = await accessManager.getRoleMemberCount(MINTER_ROLE);
283283

284284
const members = [];
285-
for (let i = 0; i < minterCount; `i) {
285+
for (let i = 0; i < minterCount; ++i) {
286286
members.push(await accessManager.getRoleMember(MINTER_ROLE, i));
287287
}
288288

@@ -292,7 +292,7 @@ const target = await myToken.getAddress();
292292
const functionCount = await accessManager.getRoleTargetFunctionCount(MINTER_ROLE, target);
293293

294294
const functions = [];
295-
for (let i = 0; i < functionCount; `i) {
295+
for (let i = 0; i < functionCount; ++i) {
296296
functions.push(await accessManager.getRoleTargetFunction(MINTER_ROLE, target, i));
297297
}
298298

content/contracts/5.x/erc1155.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ The metadata uri can be obtained:
7171
"https://game.example/api/item/{id}.json"
7272
```
7373

74-
The `uri` can include the string `+id+` which clients must replace with the actual token ID, in lowercase hexadecimal (with no 0x prefix) and leading zero padded to 64 hex characters.
74+
The `uri` can include the string `id` which clients must replace with the actual token ID, in lowercase hexadecimal (with no 0x prefix) and leading zero padded to 64 hex characters.
7575

76-
For token ID `2` and uri `+https://game.example/api/item/id.json+` clients would replace `+id+` with `0000000000000000000000000000000000000000000000000000000000000002` to retrieve JSON at `https://game.example/api/item/0000000000000000000000000000000000000000000000000000000000000002.json`.
76+
For token ID `2` and uri `https://game.example/api/item/id.json` clients would replace `id` with `0000000000000000000000000000000000000000000000000000000000000002` to retrieve JSON at `https://game.example/api/item/0000000000000000000000000000000000000000000000000000000000000002.json`.
7777

7878
The JSON document for token ID 2 might look something like:
7979

content/contracts/5.x/utilities.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ The [`Memory`](/contracts/5.x/api/utils#Memory) library provides functions for a
493493

494494
```solidity
495495
function processMultipleItems(uint256[] memory items) internal {
496-
for (uint256 i = 0; i < items.length; i`) {
496+
for (uint256 i = 0; i < items.length; i++) {
497497
bytes memory tempData = abi.encode(items[i], block.timestamp);
498498
// Process tempData...
499499
}
@@ -505,7 +505,7 @@ Note that each iteration allocates new memory for `tempData`, causing the memory
505505
```solidity
506506
function processMultipleItems(uint256[] memory items) internal {
507507
Memory.Pointer ptr = Memory.getFreeMemoryPointer(); // Cache pointer
508-
for (uint256 i = 0; i < items.length; i`) {
508+
for (uint256 i = 0; i < items.length; i++) {
509509
bytes memory tempData = abi.encode(items[i], block.timestamp);
510510
// Process tempData...
511511
Memory.unsafeSetFreeMemoryPointer(ptr); // Reset pointer for reuse

scripts/convert-adoc.js

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -188,22 +188,36 @@ async function convertAdocFiles(directory, apiRoute = "contracts/5.x/api") {
188188
mdContent = mdContent.replace(/<dl>/g, "");
189189
mdContent = mdContent.replace(/<\/dl>/g, "");
190190

191-
// Fix AsciiDoc monospace formatting (++ to backticks)
192-
// Handle ++text++ -> `text`
193-
mdContent = mdContent.replace(/\+\+([^+]+)\+\+/g, "`$1`");
194-
195-
// Fix any remaining ++ that might be standalone
196-
mdContent = mdContent.replace(/\+\+/g, "");
197-
198-
// Escape bare < that aren't HTML/JSX tag starts (e.g., "<1 share",
199-
// "< 0x80") to prevent MDX parse errors. Skip code blocks and
200-
// inline code — content there is rendered verbatim, so escaping
201-
// would corrupt it (e.g. `<4.6 to >=4.6`).
202-
const ltSplit = mdContent.split(/(```[\s\S]*?```|`[^`\n]*`)/g);
203-
mdContent = ltSplit
204-
.map((part, idx) =>
205-
idx % 2 === 1 ? part : part.replace(/(<)(\s+\w|\d)/g, "&lt;$2"),
206-
)
191+
// AsciiDoc passthrough `+name+` that downdoc preserved inside backticks
192+
// (e.g. ``+IERC7984Receiver+``) — strip the leading/trailing + signs.
193+
// Run before the code-aware split below so we can match across the
194+
// backticks; restricted to identifier-like content so legitimate
195+
// `a + b` style code is left alone.
196+
mdContent = mdContent.replace(/`\+([^\s`+]+)\+`/g, "`$1`");
197+
198+
// AsciiDoc inline mailto: `mailto:URL[label]` → `[label](mailto:URL)`
199+
// Run before the code-aware split since mailto in code blocks is
200+
// rare and would render fine either way.
201+
mdContent = mdContent.replace(
202+
/mailto:([^\s[]+)\[([^\]]+)\]/g,
203+
"[$2](mailto:$1)",
204+
);
205+
206+
// Code-aware processing: skip triple-backtick blocks and inline code.
207+
// Inside non-code regions:
208+
// - ++text++ → `text` (AsciiDoc passthrough monospace, single-line,
209+
// identifier-like content so we don't mangle Solidity ++i in code
210+
// blocks that downdoc may have left fenced incorrectly)
211+
// - bare < before digit/whitespace-word → &lt; (MDX-safe, e.g.
212+
// "<1 share", "< 0x80")
213+
const codeSplit = mdContent.split(/(```[\s\S]*?```|`[^`\n]*`)/g);
214+
mdContent = codeSplit
215+
.map((part, idx) => {
216+
if (idx % 2 === 1) return part;
217+
return part
218+
.replace(/\+\+([^+\n]+)\+\+/g, "`$1`")
219+
.replace(/(<)(\s+\w|\d)/g, "&lt;$2");
220+
})
207221
.join("");
208222
// Extract title
209223
const headerMatch = mdContent.match(/^#+\s+(.+)$/m);

0 commit comments

Comments
 (0)