mirror of
https://github.com/Ellpeck/ObsidianJustSharePlease.git
synced 2024-05-30 14:23:37 +02:00
Compare commits
5 commits
1b0f3bf67a
...
4178371c46
Author | SHA1 | Date | |
---|---|---|---|
Ell | 4178371c46 | ||
Ell | b1370b772e | ||
Ell | 6537a84562 | ||
Ell | 5ae82374ff | ||
Ell | 6ca424eb47 |
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "just-share-please",
|
||||
"name": "Just Share Please",
|
||||
"version": "0.1.4",
|
||||
"version": "0.1.5",
|
||||
"minAppVersion": "1.3.7",
|
||||
"description": "Quickly and easily share individual notes online using an anonymized link. Also easy to self-host!",
|
||||
"author": "Ellpeck",
|
||||
|
|
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "just-share-please",
|
||||
"version": "0.1.4",
|
||||
"version": "0.1.5",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "just-share-please",
|
||||
"version": "0.1.4",
|
||||
"version": "0.1.5",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "^16.11.6",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "just-share-please",
|
||||
"version": "0.1.4",
|
||||
"version": "0.1.5",
|
||||
"description": "Quickly and easily share individual notes online using an anonymized link. Also easy to self-host!",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -85,3 +85,9 @@ h1:hover .header-anchor, h2:hover .header-anchor, h3:hover .header-anchor, h4:ho
|
|||
background-color: #242424;
|
||||
}
|
||||
}
|
||||
|
||||
@media print {
|
||||
#footer {
|
||||
position: relative;
|
||||
}
|
||||
}
|
||||
|
|
17
src/main.ts
17
src/main.ts
|
@ -227,22 +227,29 @@ export default class JustSharePleasePlugin extends Plugin {
|
|||
let text = await this.app.vault.cachedRead(file);
|
||||
|
||||
// strip frontmatter
|
||||
let frontmatter = /^(---\s*\n.*?\n---)\s*\n(.*)$/s;
|
||||
if (this.settings.stripFrontmatter)
|
||||
text = text.replace(/^---\s*\n.*?\n---\s*\n(.*)$/s, "$1");
|
||||
text = text.replace(frontmatter, "$2");
|
||||
|
||||
// strip comments
|
||||
text = text.replace(/%%.*?%%/sg, "");
|
||||
|
||||
// include note name
|
||||
if (this.settings.includeNoteName)
|
||||
text = `# ${file.basename}\n\n${text}`;
|
||||
// include note name (after frontmatter!)
|
||||
if (this.settings.includeNoteName) {
|
||||
let title = `# ${file.basename}\n\n`;
|
||||
if (frontmatter.test(text)) {
|
||||
text = text.replace(frontmatter, `$1\n\n${title}$2`);
|
||||
} else {
|
||||
text = title + text;
|
||||
}
|
||||
}
|
||||
|
||||
// embed attachments directly
|
||||
let attachments = /!\[(.*)]\((.+)\)|!\[\[(.+)]]/g;
|
||||
let match: RegExpExecArray;
|
||||
while ((match = attachments.exec(text)) != null) {
|
||||
let alt = match[1] ?? "";
|
||||
let url = match[2] ?? match[3];
|
||||
let url = decodeURI(match[2] ?? match[3]);
|
||||
if (url.startsWith("http"))
|
||||
continue;
|
||||
try {
|
||||
|
|
|
@ -30,12 +30,12 @@ export class JSPSettingsTab extends PluginSettingTab {
|
|||
});
|
||||
});
|
||||
new Setting(this.containerEl)
|
||||
.setName("Strip frontmatter")
|
||||
.setDesc("Whether document frontmatter (also known as properties) should be removed from the uploaded share.")
|
||||
.setName("Include file properties")
|
||||
.setDesc("Whether the file properties of the shared note should be included in the share as visible frontmatter.")
|
||||
.addToggle(t => {
|
||||
t.setValue(this.plugin.settings.stripFrontmatter);
|
||||
t.setValue(!this.plugin.settings.stripFrontmatter);
|
||||
t.onChange(async v => {
|
||||
this.plugin.settings.stripFrontmatter = v;
|
||||
this.plugin.settings.stripFrontmatter = !v;
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
"path": "Cool Test Note.md"
|
||||
}
|
||||
],
|
||||
"stripFrontmatter": true,
|
||||
"stripFrontmatter": false,
|
||||
"includeNoteName": true,
|
||||
"unshareDeletedFiles": false,
|
||||
"autoUpdateShares": false
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
---
|
||||
test: yes
|
||||
---
|
||||
|
||||
This is a cool test note%%with an inline comment%%, my friends!
|
||||
|
||||
Chemistry!
|
||||
|
@ -61,6 +57,13 @@ wikilink image!
|
|||
|
||||
![[Pasted image 20230816130420.png]]
|
||||
|
||||
image but with spaces in the name!
|
||||
|
||||
![](Pasted%20image%2020230816130420.png)
|
||||
|
||||
online image!
|
||||
![](https://ellpeck.de/res/me.jpeg)
|
||||
|
||||
nice
|
||||
|
||||
[^1]: Normal footnote!
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{
|
||||
"0.1.0": "1.3.7"
|
||||
"0.1.0": "1.3.7",
|
||||
"0.1.5": "1.4.0"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue