Skip to content

Commit

Permalink
Support .asciidoctorconfig at root of the workspace
Browse files Browse the repository at this point in the history
part of asciidoctor#380

TODO:
- provide test
- provide documentation
- support other places
  • Loading branch information
apupier committed Sep 9, 2022
1 parent 2f1a078 commit 1f62c12
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/asciidocParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as vscode from 'vscode'
import * as fs from 'fs'
import * as path from 'path'
import { AsciidoctorWebViewConverter } from './asciidoctorWebViewConverter'
import { Asciidoctor } from '@asciidoctor/core'
Expand Down Expand Up @@ -172,6 +173,14 @@ export class AsciidocParser {
}

try {
const workspaceFolder = vscode.workspace.getWorkspaceFolder(doc.uri)
if (workspaceFolder !== undefined) {
const asciiDoctorConfig = vscode.Uri.joinPath(workspaceFolder.uri, '.asciidoctorconfig')
if (fs.existsSync(asciiDoctorConfig.fsPath)) {
const asciiDoctorConfigContent = await vscode.workspace.fs.readFile(asciiDoctorConfig)
text = asciiDoctorConfigContent + '\n' + text
}
}
const document = processor.load(text, options)
const blocksWithLineNumber = document.findBy(function (b) {
return typeof b.getLineNumber() !== 'undefined'
Expand Down

0 comments on commit 1f62c12

Please sign in to comment.