Skip to content

Commit cc47335

Browse files
committed
Adds configuration for using bold as highlights
1 parent 6737d15 commit cc47335

File tree

7 files changed

+45
-15
lines changed

7 files changed

+45
-15
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ The output is a markdown-block titled "Highlights" with a bullet-list of the hig
5858
- [x] allow to change text in heading `## My Custom Highlights`
5959
- [x] allow to include note-name in heading such as `## From: $NOTE_TITLE`
6060
- [x] allow to add footnotes for each highlight and include link to source-note
61+
- [x] allow to optionally enable bold for highlights
62+
- [x] allow for Command Palette to trigger copying (Works sort of, bug in Electron)
6163

6264
#### Outputs
6365
- [x] my clipboard

data.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"headlineText":"Summary $NOTE_TITLE","addFootnotes":true}
1+
{"headlineText":"Summary $NOTE_TITLE","addFootnotes":false,"useBoldForHighlights":false}

main.js

Lines changed: 18 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"id": "extract-highlights-plugin",
33
"name": "Extract Highlights",
4-
"version": "0.0.8",
5-
"description": "Allows to extracts all ==highlights== in a note into your clipboard",
4+
"version": "0.0.9",
5+
"description": "Allows to extracts all highlights in a note into your clipboard",
66
"author": "Alexis Rondeau",
77
"authorUrl": "https://publish.obsidian.md/alexisrondeau",
88
"js": "main.js"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
export default class ExtractHighlightsPluginSettings {
22
public headlineText: string;
33
public addFootnotes: boolean;
4+
public useBoldForHighlights: boolean;
45

56
constructor() {
67
this.headlineText = "";
78
this.addFootnotes = false;
9+
this.useBoldForHighlights = false;
810
}
911
}

src/ExtractHighlightsPluginSettingsTab.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ export default class ExtractHighlightsPluginSettingsTab extends PluginSettingTab
2929
})
3030
);
3131

32+
new Setting(containerEl)
33+
.setName('Use bold for highlights')
34+
.setDesc(
35+
'If enabled, will include classic markdown bold (**) sections as highlights',
36+
)
37+
.addToggle((toggle) =>
38+
toggle.setValue(this.plugin.settings.useBoldForHighlights).onChange((value) => {
39+
this.plugin.settings.useBoldForHighlights = value;
40+
this.plugin.saveData(this.plugin.settings);
41+
}),
42+
);
43+
3244

3345
new Setting(containerEl)
3446
.setName('Enable Footnotes')

src/main.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ export default class ExtractHighlightsPlugin extends Plugin {
5555

5656
try {
5757
if (activeLeaf?.view?.data) {
58-
// console.log(activeLeaf);
59-
// console.log(activeLeaf.view.file.basename);
60-
// console.log(activeLeaf.view);
61-
// console.log(activeLeaf.view.data);
62-
6358
let highlightsText = this.processHighlights(activeLeaf.view);
6459
let saveStatus = this.saveToClipboard(highlightsText);
6560
new Notice(saveStatus);
@@ -72,7 +67,14 @@ export default class ExtractHighlightsPlugin extends Plugin {
7267
}
7368

7469
processHighlights(view: any): string {
75-
let re = /(==|\<mark\>|\*\*)([\s\S]*?)(==|\<\/mark\>|\*\*)/g;
70+
71+
var re;
72+
73+
if(this.settings.useBoldForHighlights) {
74+
re = /(==|\<mark\>|\*\*)([\s\S]*?)(==|\<\/mark\>|\*\*)/g;
75+
} else {
76+
re = /(==|\<mark\>)([\s\S]*?)(==|\<\/mark\>)/g;
77+
}
7678

7779
let data = view.data;
7880
let basename = view.file.basename;

0 commit comments

Comments
 (0)