Highhight code
H6 tháng 4, 2024
TABLE OF CONTENTS
Typescript
import { visit } from 'unist-util-visit'
export default function remarkHighlightBlock() {
/**
* Transform.
*
* @param {Root} tree
* Tree.
* @returns {undefined}
* Nothing.
*/
return function (tree: any) {
visit(tree, function (node: any, index, parent: any) {
const blocks = ["quote-info", "quote-success", "quote-warning", "quote-danger"]
if (node.type === 'code' && blocks.includes(node.lang)) {
const content = node.value; // Extract content
// Create a new paragraph element with the desired class
const newParagraph = {
type: 'blockquote',
// depth: 2,
properties: { mdastId: "block", className: `md-quote ${node.lang}`},
value: content,
};
// Replace the code block with the new paragraph
parent.children.splice(parent.children.indexOf(node), 1, newParagraph);
}
})
}
}
Java
/*
* Copyright (c) 2007 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package org.mockito.codegen;
/**
* This class is required to resolve a method handle lookup for the {@code org.mockito.codegen} package what requires a preexisting class for the package.
* By defining this class, the JVM (starting from Java 9) assures that this package is a part of the Mockito module such that we gain full access rights.
*/
public class InjectionBase {
private InjectionBase() {
throw new UnsupportedOperationException();
}
}