fix: Code blocks nested in list do not get line numbers
This commit is contained in:
@@ -74,9 +74,10 @@ function getDecorations({
|
||||
lineNumbers?: boolean;
|
||||
}) {
|
||||
const decorations: Decoration[] = [];
|
||||
const blocks: { node: Node; pos: number }[] = findBlockNodes(doc).filter(
|
||||
(item) => item.node.type.name === name
|
||||
);
|
||||
const blocks: { node: Node; pos: number }[] = findBlockNodes(
|
||||
doc,
|
||||
true
|
||||
).filter((item) => item.node.type.name === name);
|
||||
|
||||
function parseNodes(
|
||||
nodes: refractor.RefractorNode[],
|
||||
|
||||
@@ -50,8 +50,9 @@ export function findChildren(
|
||||
* are blocks.
|
||||
*
|
||||
* @param node The node to iterate over
|
||||
* @param descend Whether to descend into a node
|
||||
* @returns Child nodes that are blocks
|
||||
*/
|
||||
export function findBlockNodes(node: Node): NodeWithPos[] {
|
||||
return findChildren(node, (child) => child.isBlock);
|
||||
export function findBlockNodes(node: Node, descend = false): NodeWithPos[] {
|
||||
return findChildren(node, (child) => child.isBlock, descend);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user