Skip to content

Commit 4692079

Browse files
committed
Ignore heading-like lines in code and math blocks
1 parent d1f8415 commit 4692079

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/editor/EditorPlugin.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ class SectionWidget extends WidgetType {
113113
}
114114
}
115115

116-
const mdCommentRe = /%%/g;
117116
class SectionWordCountEditorPlugin implements PluginValue {
118117
decorations: DecorationSet;
119118
lineCounts: any[] = [];
@@ -243,7 +242,11 @@ class SectionWordCountEditorPlugin implements PluginValue {
243242
const b = new RangeSetBuilder<Decoration>();
244243
if (!plugin.settings.displaySectionCounts) return b.finish();
245244

245+
const tree = syntaxTree(view.state);
246246
const getHeaderLevel = (line: Line) => {
247+
const token = tree.resolve(line.from, 1);
248+
if (/code-?block|math/.test(token?.type?.name)) return null;
249+
247250
const match = line.text.match(/^(#+)[ \t]/);
248251
return match ? match[1].length : null;
249252
};

0 commit comments

Comments
 (0)