Skip to content

Commit 2f366e9

Browse files
committed
Fix for issue: #6
1 parent d81ec65 commit 2f366e9

File tree

4 files changed

+74
-12
lines changed

4 files changed

+74
-12
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Record of bug fixes, enhancements, and changes.
44

5+
## [1.2.2] - 2025-05-04
6+
7+
- Fixed bug caused the callout to apply all the callout to every line it matched, rather than just the first occurrence.
8+
59
## [1.2.1] – 2022-09-16
610

711
### Fixed

asciidoctor-external-callout.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,18 +218,16 @@ module.exports = function (registry) {
218218
search_term = new RegExp(phrase)
219219
}
220220

221-
222-
owner_block.getSourceLines().forEach((line, index) => {
223-
221+
const sourceLines = owner_block.getSourceLines();
222+
for (let i = 0; i < sourceLines.length; i++) {
223+
const line = sourceLines[i];
224224
if (line.match(search_term) != null) {
225-
226-
found_line_numbers.add(index)
227-
}
228-
229-
if (!global_search) {
230-
return found_line_numbers
225+
found_line_numbers.add(i);
226+
if (!global_search) {
227+
break;
228+
}
231229
}
232-
})
230+
}
233231

234232
return found_line_numbers
235233
}
@@ -290,4 +288,4 @@ module.exports = function (registry) {
290288
}
291289
})
292290

293-
}
291+
}

asciidoctor-external-simon.test.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
const asciidoctor = require('@asciidoctor/core')()
2+
const registry = asciidoctor.Extensions.create()
3+
require('./asciidoctor-external-callout.js')(registry)
4+
5+
6+
require('./asciidoctor-external-callout')
7+
8+
test('Load Simon Dew test file', () => {
9+
10+
let input_document = `
11+
:source-highlighter: highlight.js
12+
:icons: font
13+
[source, c]
14+
----
15+
typedef struct CBLExternalKeyCallbacks
16+
{
17+
/** Provides the public key's raw data as an ASN.1 DER sequence of [modulus, exponent]. */
18+
bool (*publicKeyData)(void* externalKey,
19+
void* output,
20+
size_t outputMaxLen,
21+
size_t* outputLen);
22+
23+
/** Decrypts data using the private key. */
24+
bool (*decrypt)(void* externalKey,
25+
FLSlice input,
26+
void* output,
27+
size_t outputMaxLen,
28+
size_t* outputLen);
29+
30+
/** Uses the private key to generate a signature of input data. */
31+
bool (*sign)(void* externalKey,
32+
CBLSignatureDigestAlgorithm digestAlgorithm,
33+
FLSlice inputData,
34+
void* outSignature);
35+
36+
/** ( Optional ) For freeing any resource when the callbacks are no longer needed.*/
37+
void (*_cbl_nullable free)(void* externalKey);
38+
} CBLKeyPairCallbacks;
39+
----
40+
. The public key is part of an RSA key pair generated by a secure key storage or cryptographic API. @/publicKeyData/
41+
42+
. \`externalKey\` is an opaque pointer passed to {url-api-references-tlsidentity}#ga78d47a8c2157dad4347709d1adec6b39[CBLKeyPair_CreateWithExternalKey()], typically representing a reference or token used to access the public / private key within the secure storage system. @/externalKey/
43+
44+
. Use \`outputMaxLen\` as a guardrail to ensure the public key data size is within the expected range. @/outputMaxLen/
45+
46+
. Use RSA with PKCS#1 v1.5 padding.
47+
Algorithm names may vary -- for example, RSA/ECB/PKCS1Padding on Java or Android.
48+
Note that depending on the selected key exchange method, the \`decrypt()\` function may not be invoked during the TLS handshake. @/decrypt/
49+
50+
. You must use PKCS#1 v1.5 padding algorithm when generating the signature. @/CBLSignatureDigestAlgorithm/
51+
52+
. Ensure that the input data, which is already hashed based on the specified digest algorithm, is encoded as an ASN.1 DigestInfo structure in DER format before performing the signing operation.
53+
Some cryptographic libraries may handle the DigestInfo formatting internally. @/inputData/
54+
`
55+
let converted_doc = asciidoctor.convert(input_document,{safe: 'safe', standalone: true,
56+
extension_registry: registry})
57+
58+
59+
console.log(converted_doc)
60+
})

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "asciidoctor-external-callout",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"description": "Asciidoctor extension that adds support for callouts added outside the listing block.",
55
"main": "asciidoctor-external-callout.js",
66
"scripts": {

0 commit comments

Comments
 (0)