Compare commits

...

5 commits

Author SHA1 Message Date
Ell 4178371c46 0.1.5 2023-10-26 11:56:55 +02:00
Ell b1370b772e fixed note name being included before frontmatter 2023-10-26 11:55:17 +02:00
Ell 6537a84562 overhaul file properties setting
closes #6
2023-10-26 11:47:58 +02:00
Ell 5ae82374ff fixed url encoded image links not being converted correctly
closes #4
2023-10-26 11:44:54 +02:00
Ell 6ca424eb47 display footer at the bottom when printing 2023-10-26 11:37:55 +02:00
9 changed files with 36 additions and 19 deletions

View file

@ -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
View file

@ -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",

View file

@ -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": {

View file

@ -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;
}
}

View file

@ -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 {

View file

@ -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();
});
});

View file

@ -7,7 +7,7 @@
"path": "Cool Test Note.md"
}
],
"stripFrontmatter": true,
"stripFrontmatter": false,
"includeNoteName": true,
"unshareDeletedFiles": false,
"autoUpdateShares": false

View file

@ -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!

View file

@ -1,3 +1,4 @@
{
"0.1.0": "1.3.7"
"0.1.0": "1.3.7",
"0.1.5": "1.4.0"
}