Skip to content

Commit 8f81e89

Browse files
committed
feat: update to README
1 parent 61c71c2 commit 8f81e89

File tree

5 files changed

+97
-82
lines changed

5 files changed

+97
-82
lines changed

README.md

+69-64
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,108 @@
1-
# qmd as md Obsidian plugin
1+
# QMD as Markdown Obsidian Plugin
22

3-
A plugin for [Obsidian](https://obsidian.md) which allows editing of qmd files as if they were markdown.
3+
A plugin for [Obsidian](https://obsidian.md) that allows seamless editing of QMD files as if they were Markdown.
44

5-
QMD files contain a combination of markdown and executable code cell, and are format supported by [Quarto](https://quarto.org/) open source publishing systems, they are supported in Rstudio and VSCode editors.
5+
QMD files combine Markdown with executable code cells and are supported by [Quarto](https://quarto.org/), an open-source publishing system. These files are compatible with editors like RStudio and VSCode.
66

7-
To be able to use linking with the quatro files you need to check the toggle "detect all files extension" in `Files & Links` section in Obsidian.
7+
This plugin began as a small tweak to a now-defunct plugin created by deathau: [deathau/txt-as-md-obsidian](https://github.com/deathau/txt-as-md-obsidian). It has since evolved with additional integrations.
88

9-
To hide additional files you might use this CSS chunk (save it as a file to your snippets folder and enable it in Obsidian in the Appeareance menu), you might add aditional filetypes.
9+
---
10+
11+
## Version History
12+
13+
### 0.0.3
14+
- Added an option to run Quarto preview for the current `qmd` file.
15+
16+
### 0.0.2
17+
- Repurposed the plugin to enable viewing and editing of QMD files.
18+
- Made the plugin available via BRAT and Obsidian.
19+
20+
### 0.0.1
21+
- Initial release by death_md, supporting `.txt` files.
22+
23+
---
24+
25+
## To-Do List
26+
27+
- [ ] Recognize `{language}` for code block syntax highlighting.
28+
- [ ] Add CSS support for callout blocks.
29+
- [ ] Enable the creation of new QMD files.
30+
- [ ] Add a render command.
31+
32+
---
33+
34+
## Enhancing Quarto File Integration in Obsidian
35+
36+
To enable linking with Quarto files, ensure the **"Detect all file extensions"** toggle is activated in the `Files & Links` section of Obsidian settings.
37+
38+
If you'd like to hide additional file types, use the following CSS snippet. Save it in your snippets folder and enable it via the Appearance menu in Obsidian. You can add more file extensions as needed.
1039

1140
```css
12-
div[data-path$='.Rproj']{
41+
div[data-path$='.Rproj'] {
1342
display: none;
1443
}
1544

16-
div[data-path$='.cls']{
45+
div[data-path$='.cls'] {
1746
display: none;
1847
}
1948

20-
div[data-path$='.yml']{
49+
div[data-path$='.yml'] {
2150
display: none;
2251
}
2352

24-
div[data-path$='.json']{
53+
div[data-path$='.json'] {
2554
display: none;
2655
}
2756
```
57+
---
2858

29-
Plugin is a small tweak of a plugin made by deathau: [deathau/txt-as-md-obsidian: Edit txt files in Obsidian.md as if they were markdown](https://github.com/deathau/txt-as-md-obsidian).
59+
## Compatibility
3060

31-
### Plugins for better editing experience
61+
This plugin requires Obsidian **v0.10.12** or later to work properly, as the necessary APIs were introduced in this version.
3262

33-
- Use [obsidian-shellcomands](obsidian://show-plugin?id=obsidian-shellcommands) with `quarto render {{file_path:absolute}} --to pdf` to render the file inside Obsidian
34-
- Use [HTML Reader](obsidian://show-plugin?id=obsidian-html-plugin) to render HTML output inside Obsidian, Obsidian natively supports pdfs.
35-
36-
37-
### To-do
38-
39-
- [ ] Creation of new qmd files
40-
- [ ] Currly braces `{language}` treated as language for codeblock
41-
- [ ] CSS for callout blocks
42-
- [ ] Better integration with Obsidian
43-
44-
### Compatibility
45-
46-
The required APIs were only added in Obsidian **0.10.12**, and as such, that is the minimum version of Obsidian required to use this plugin.
63+
---
4764

4865
## Installation
4966

50-
### From within Obsidian
67+
### From Within Obsidian
5168

52-
Plugin is accesible in the Obsidian n the community list. If you want to test beta releases, you can use [the BRAT plugin](https://github.com/TfTHacker/obsidian42-brat).
69+
The plugin is available in Obsidian's community plugin list.
70+
For beta releases, you can use the [BRAT plugin](https://github.com/TfTHacker/obsidian42-brat).
5371

5472
### From GitHub
55-
- Download the Latest Release from the Releases section of the GitHub Repository
56-
- Extract the plugin folder from the zip to your vault's plugins folder: `<vault>/.obsidian/plugins/`
57-
Note: On some machines the `.obsidian` folder may be hidden. On MacOS you should be able to press `Command+Shift+Dot` to show the folder in Finder.
58-
- Reload Obsidian
59-
- If prompted about Safe Mode, you can disable safe mode and enable the plugin.
60-
Otherwise head to Settings, third-party plugins, make sure safe mode is off and
61-
enable the plugin from there.
6273

63-
## Security
64-
> Third-party plugins can access files on your computer, connect to the internet, and even install additional programs.
74+
1. Download the latest release from the Releases section of the GitHub repository.
75+
2. Extract the plugin folder from the zip file to your vault's plugins directory: `<vault>/.obsidian/plugins/`
76+
- Note: On some systems, the `.obsidian` folder might be hidden. On macOS, press `Command + Shift + Dot` to reveal hidden folders in Finder.
77+
3. Reload Obsidian.
78+
4. If prompted about Safe Mode, disable it and enable the plugin.
79+
Alternatively, go to **Settings → Third-party plugins**, disable Safe Mode, and enable the plugin manually.
6580

66-
The source code of this plugin is available on GitHub for you to audit yourself, but installing plugins into Obsidian is currently a matter of trust.
81+
---
6782

68-
I can assure you here that I do nothing to collect your data, send information to the internet or otherwise do anything nefarious with your system. However, be aware that I *could*, and you only have my word that I don't.
83+
## Security
6984

70-
## Development
85+
> **Important:** Third-party plugins can access files on your computer, connect to the internet, and install additional programs.
7186
72-
This project uses Typescript to provide type checking and documentation.
73-
The repo depends on the latest [plugin API](https://github.com/obsidianmd/obsidian-api) in Typescript Definition format, which contains TSDoc comments describing what it does.
87+
The source code for this plugin is open and available on GitHub for audit. While I assure you that the plugin does not collect data or perform any malicious actions, installing plugins in Obsidian always involves a level of trust.
7488

75-
**Note:** The Obsidian API is still in early alpha and is subject to change at any time!
89+
---
90+
91+
## Development
7692

77-
If you want to contribute to development and/or just customize it with your own
78-
tweaks, you can do the following:
79-
- Clone this repo.
80-
- `npm i` or `yarn` to install dependencies
81-
- `npm run build` to compile.
82-
- Copy `manifest.json`, `main.js` and `styles.css` to a subfolder of your plugins
83-
folder (e.g, `<vault>/.obsidian/plugins/<plugin-name>/`)
84-
- Reload obsidian to see changes
93+
This project is built using TypeScript for type checking and documentation.
94+
It relies on the latest [Obsidian plugin API](https://github.com/obsidianmd/obsidian-api) in TypeScript Definition format, which includes TSDoc comments for documentation.
8595

86-
Alternately, you can clone the repo directly into your plugins folder and once
87-
dependencies are installed use `npm run dev` to start compilation in watch mode.
88-
You may have to reload obsidian (`ctrl+R`) to see changes.
96+
**Note:** The Obsidian API is in early alpha and may change at any time.
8997

90-
## Pricing
98+
To contribute or customize the plugin:
9199

92-
Plugin is completely free, but you might contribute to the author of the orginal plugin (deathau) via the following:
100+
1. Clone this repository.
101+
2. Run `npm i` or `yarn` to install dependencies.
102+
3. Use `npm run build` to compile the plugin.
103+
4. Copy `manifest.json`, `main.js`, and `styles.css` to a subfolder in your plugins directory: `<vault>/.obsidian/plugins/<plugin-name>/`
104+
5. Reload Obsidian to apply changes.
93105

94-
[![GitHub Sponsors](https://img.shields.io/github/sponsors/deathau?style=social)](https://github.com/sponsors/deathau)
95-
[![Paypal](https://img.shields.io/badge/paypal-deathau-yellow?style=social&logo=paypal)](https://paypal.me/deathau)
106+
Alternatively, clone the repository directly into your plugins folder. After installing dependencies, run `npm run dev` to enable watch mode for live compilation.
107+
Reload Obsidian (`Ctrl + R`) to view updates.
96108

97-
# Version History
98-
## 0.0.1
99-
Initial release by death_md supporting txt!
100-
## 0.0.2
101-
Repurposing this plugin to viev and edit qmd files, plugin available via BRAT.
102-
# 0.0.3
103-
Optopn to run preview

makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ zip:
22
zip qmd-as-md.zip main.js manifest.json
33

44
clean:
5-
rm -rf node_modules dist build .cache *.log *.tmp package-lock.json main.js
5+
rm -rf node_modules dist build .cache *.log *.tmp package-lock.json
66

77
build:
88
npm install && npm run build && make zip && make clean

qmd-as-md-working.zip

-9.06 KB
Binary file not shown.

qmd-as-md.zip

327 Bytes
Binary file not shown.

src/main.ts

+27-17
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ import * as path from 'path';
1313
interface QmdPluginSettings {
1414
quartoPath: string;
1515
enableQmdLinking: boolean;
16-
quartoTypst: string; // Add Quarto Typst variable
16+
quartoTypst: string;
17+
emitCompilationLogs: boolean; // New setting
1718
}
1819

1920
const DEFAULT_SETTINGS: QmdPluginSettings = {
2021
quartoPath: 'quarto',
2122
enableQmdLinking: true,
22-
quartoTypst: '', // Default is empty
23+
quartoTypst: '',
24+
emitCompilationLogs: true, // Default is to emit logs
2325
};
2426

2527
export default class QmdAsMdPlugin extends Plugin {
@@ -124,14 +126,12 @@ export default class QmdAsMdPlugin extends Plugin {
124126
console.log(`Working directory: ${workingDir}`);
125127

126128
const envVars: NodeJS.ProcessEnv = {
127-
...process.env, // inherit the existing environment
129+
...process.env,
128130
};
129131

130132
if (this.settings.quartoTypst.trim()) {
131133
envVars.QUARTO_TYPST = this.settings.quartoTypst.trim();
132134
console.log(`QUARTO_TYPST set to: ${envVars.QUARTO_TYPST}`);
133-
} else {
134-
console.log('QUARTO_TYPST not set (empty).');
135135
}
136136

137137
const quartoProcess = spawn(this.settings.quartoPath, ['preview', filePath], {
@@ -143,7 +143,9 @@ export default class QmdAsMdPlugin extends Plugin {
143143

144144
quartoProcess.stdout?.on('data', (data: Buffer) => {
145145
const output = data.toString();
146-
console.log(`Quarto Preview Output: ${output}`);
146+
if (this.settings.emitCompilationLogs) {
147+
console.log(`Quarto Preview Output: ${output}`);
148+
}
147149

148150
if (output.includes('Browse at')) {
149151
const match = output.match(/Browse at\s+(http:\/\/[^\s]+)/);
@@ -165,8 +167,9 @@ export default class QmdAsMdPlugin extends Plugin {
165167
});
166168

167169
quartoProcess.stderr?.on('data', (data: Buffer) => {
168-
console.error(`Quarto Preview Error: ${data}`);
169-
new Notice(`Quarto Preview Error: ${data}`);
170+
if (this.settings.emitCompilationLogs) {
171+
console.error(`Quarto Preview Error: ${data}`);
172+
}
170173
});
171174

172175
quartoProcess.on('close', (code: number | null) => {
@@ -239,26 +242,20 @@ class QmdSettingTab extends PluginSettingTab {
239242
);
240243

241244
new Setting(containerEl)
242-
.setName('Enable Linking to Quarto Files')
245+
.setName('Enable Editing Quarto Files')
243246
.setDesc(
244-
'Allow linking to `.qmd` files without enabling "Detect All File Extensions"'
247+
'By default it allows editing `.qmd` files, disable it case of conflict with `Custom File Extensionbs and Types` plugin'
245248
)
246249
.addToggle((toggle) =>
247250
toggle
248251
.setValue(this.plugin.settings.enableQmdLinking)
249252
.onChange(async (value) => {
250-
console.log(`Enable QMD Linking setting changed to: ${value}`);
253+
console.log(`Enable QMD Editing setting changed to: ${value}`);
251254
this.plugin.settings.enableQmdLinking = value;
252255

253256
if (value) {
254257
this.plugin.registerQmdExtension();
255-
} else {
256-
console.log(
257-
'.qmd linking disabled. Restart Obsidian if required.'
258-
);
259258
}
260-
261-
await this.plugin.saveSettings();
262259
})
263260
);
264261

@@ -276,6 +273,19 @@ class QmdSettingTab extends PluginSettingTab {
276273
})
277274
);
278275

276+
new Setting(containerEl)
277+
.setName('Emit Compilation Logs')
278+
.setDesc('Toggle whether to emit detailed compilation logs in the console')
279+
.addToggle((toggle) =>
280+
toggle
281+
.setValue(this.plugin.settings.emitCompilationLogs)
282+
.onChange(async (value) => {
283+
console.log(`Emit Compilation Logs set to: ${value}`);
284+
this.plugin.settings.emitCompilationLogs = value;
285+
await this.plugin.saveSettings();
286+
})
287+
);
288+
279289
console.log('Settings tab rendered successfully');
280290
}
281291
}

0 commit comments

Comments
 (0)