Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kalvn committed Oct 26, 2024
0 parents commit aff8106
Show file tree
Hide file tree
Showing 16 changed files with 5,752 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# vscode
.vscode

# Intellij
*.iml
.idea

# npm
node_modules

# Don't include the compiled main.js file in the repo.
# They should be uploaded to GitHub releases instead.
main.js

# Exclude sourcemaps
*.map

# obsidian
data.json

# Exclude macOS Finder (System Explorer) View States
.DS_Store
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 kalvn

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Obsidian Export to HTML
This [Obsidian](https://obsidian.md) plugin allows you to export the content of a note as HTML, either to the clipboard or to a new HTML file.

During the export, images will be copied over in base 64 format.

This plugin is a work in progress but it already works great in most cases. Some edge cases with inline image exports will be improved.

## Installation
Follow the steps below to install **Obsidian Export to HTML**.

1. Search for *Export to HTML* in Obsidian's community plugins browser
2. Enable the plugin in your Obsidian settings (find *Export to HTML* under *Community plugins*).
3. (Optional) If you plan to use it often, in the *Hotkeys* settings, search for *Export to HTML* and bind actions to keyboard shortcuts.

## How to use
Open the command palette (press <key>CTRL+P</key> if you use a keyboard) and type *Export to HTML*.

- Select *Export to HTML: Copy to clipboard as HTML* to copy your note as HTML in your clipboard. You can then paste it in an email or in a Word document and the style will be kept.
- Select *Export to HTML: Download as HTML* to download your note as an HTML file.

## Manual installation
- Download [the latest release](https://github.com/kalvn/obsidian-export-to-html/releases) and unzip it.
- Copy over `main.js`, `manifest.json` to your vault `VaultFolder/.obsidian/plugins/export-to-html/`.

## How to contribute
- Clone this repo.
- Make sure your NodeJS is at least v16 (`node --version`).
- `npm i` or `yarn` to install dependencies.
- `npm run dev` to start compilation in watch mode.

## External packages used
- Starter template: [Obsidian sample plugin](https://github.com/obsidianmd/obsidian-sample-plugin)
- Markdown to HTML: [Marked](https://github.com/markedjs/marked)
- CSS: [Github Markdown CSS](https://github.com/sindresorhus/github-markdown-css)
49 changes: 49 additions & 0 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import esbuild from 'esbuild';
import process from 'process';
import builtins from 'builtin-modules';

const banner =
`/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
`;

const prod = (process.argv[2] === 'production');

const context = await esbuild.context({
banner: {
js: banner,
},
entryPoints: ['src/main.ts'],
bundle: true,
external: [
'obsidian',
'electron',
'@codemirror/autocomplete',
'@codemirror/collab',
'@codemirror/commands',
'@codemirror/language',
'@codemirror/lint',
'@codemirror/search',
'@codemirror/state',
'@codemirror/view',
'@lezer/common',
'@lezer/highlight',
'@lezer/lr',
...builtins],
format: 'cjs',
target: 'es2018',
logLevel: 'info',
sourcemap: prod ? false : 'inline',
treeShaking: true,
outfile: 'main.js',
minify: prod,
});

if (prod) {
await context.rebuild();
process.exit(0);
} else {
await context.watch();
}
14 changes: 14 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import neostandard from 'neostandard';

export default [
...neostandard({
semi: true,
ts: true
}),
{
ignores: [
'main.js',
'node_modules/*'
]
}
];
11 changes: 11 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"id": "export-to-html",
"name": "Export to HTML",
"version": "1.0.0",
"minAppVersion": "0.15.0",
"description": "Export your Markdown notes as HTML, directly in the clipboard or as a file.",
"author": "kalvn",
"authorUrl": "https://kalvn.net",
"fundingUrl": "https://paypal.me/kalvn/5",
"isDesktopOnly": false
}
Loading

0 comments on commit aff8106

Please sign in to comment.