Skip to content

Commit

Permalink
fix #13, support yaml frontmatter
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean10 committed Oct 27, 2021
1 parent dbcf5f3 commit 4454335
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,19 @@ function bootstrap(context) {
return (start, end, node) => {
// console.log("Heading node", node);
// console.log("node.depth:", node.depth, "state.fontSize: ", state.fontSize, "size: ", state.fontSize + Math.ceil(state.fontSize) / 6 * (7 - node.depth));
addDecoration(getEnlargeDecoration(state.fontSize + Math.ceil(state.fontSize) / 6 * (7 - node.depth)), start + node.depth + 1, end);
addDecoration(hideDecoration, start, start + node.depth + 1);
let editor = vscode.window.activeTextEditor;
// remark's position.start.line index is from 1 , not from 0, thus, need to minus 1 is the actual line number in vscode.editor.
let range = new vscode.Range(editor.document.lineAt(node.position.start.line - 1).range.start, editor.document.lineAt(node.position.start.line - 1).range.end);
let value = editor.document.getText(range);
// console.log("range:", range, "content:", value);
let endSymbolNeedDecoration = 0;
if (value.startsWith("#")){
endSymbolNeedDecoration = start + node.depth + 1;
} else {
endSymbolNeedDecoration = start;
}
addDecoration(getEnlargeDecoration(state.fontSize + Math.ceil(state.fontSize) / 6 * (7 - node.depth)), endSymbolNeedDecoration, end);
addDecoration(hideDecoration, start, endSymbolNeedDecoration);
};
})()]],
["horizontalRule", ["thematicBreak", (() => {
Expand Down

0 comments on commit 4454335

Please sign in to comment.