Skip to content

Commit 0734a5f

Browse files
committed
fix: address off-by-one index bug
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
1 parent 5b30771 commit 0734a5f

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Absolute Value
2+
3+
<section class="intro">
4+
5+
The absolute value is defined as
6+
7+
<!-- <equation class="equation" label="eq:absolute_value" align="center" raw="|x| = \begin{cases} x & \textrm{if}\ x \geq 0 \\ -x & \textrm{if}\ x < 0\end{cases}" alt="Absolute value"> -->
8+
9+
```math
10+
|x| = \begin{cases} x & \textrm{if}\ x \geq 0 \\ -x & \textrm{if}\ x < 0\end{cases}
11+
```
12+
13+
<!-- <div class="equation" align="center" data-raw-text="|x| = \begin{cases} x & \textrm{if}\ x \geq 0 \\ -x & \textrm{if}\ x < 0\end{cases}" data-equation="eq:absolute_value">
14+
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/abs/docs/img/equation_abs.svg" alt="Absolute value">
15+
<br>
16+
</div> -->
17+
18+
<!-- </equation> -->
19+
20+
</section>
21+
22+
<!-- /.intro -->
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
var readFileSync = require( 'fs' ).readFileSync;
22+
var join = require( 'path' ).join;
23+
var remark = require( 'remark' );
24+
var insertEquations = require( './../lib' );
25+
26+
// Load a Markdown file...
27+
var fpath = join( __dirname, 'fixtures/math_markup.txt' );
28+
var opts = {
29+
'encoding': 'utf8'
30+
};
31+
var file = readFileSync( fpath, opts );
32+
33+
// Insert equations:
34+
remark().use( insertEquations ).process( file, done );
35+
36+
function done( error, out ) {
37+
if ( error ) {
38+
throw error;
39+
}
40+
// Output the processed Markdown file:
41+
console.log( out.contents );
42+
}

lib/node_modules/@stdlib/_tools/remark/plugins/remark-svg-equations/lib/transformer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ function transformer( tree, file, clbk ) {
203203

204204
// Note: we don't splice--we simply replace--in order to avoid invalidating the indices of the equation elements in the AST. If we were to remove children, a subsequent resolved equation index would no longer be accurate...
205205
parent.children[ i+1 ] = newNode;
206-
parent.children[ i+1 ] = {
206+
parent.children[ i+2 ] = {
207207
'type': 'html',
208208
'value': '<!-- -->'
209209
};

0 commit comments

Comments
 (0)