├── .npmrc ├── .github ├── FUNDING.yml └── workflows │ ├── version.yml │ └── release.yml ├── .gitignore ├── src └── main.ts ├── manifest.json ├── tsconfig.json ├── rollup.config.js ├── package.json ├── LICENCE └── README.md /.npmrc: -------------------------------------------------------------------------------- 1 | tag-version-prefix = "" -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: deathau 2 | custom: ["https://www.paypal.me/deathau"] 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Intellij 2 | *.iml 3 | .idea 4 | 5 | # npm 6 | node_modules 7 | package-lock.json 8 | 9 | # build 10 | main.js 11 | styles.css 12 | *.js.map 13 | data.json 14 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { Plugin } from 'obsidian'; 2 | 3 | export default class TxtAsMdPlugin extends Plugin { 4 | 5 | async onload() { 6 | super.onload(); 7 | 8 | // register the view and extensions 9 | this.registerExtensions(["txt"], "markdown"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "txt-as-md-obsidian", 3 | "version": "0.0.1", 4 | "description": "Edit txt files as if they were markdown", 5 | "name": "txt as md", 6 | "author": "death_au", 7 | "authorUrl": "https://github.com/deathau", 8 | "isDesktopOnly": false, 9 | "minAppVersion": "0.10.12" 10 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "inlineSourceMap": true, 5 | "inlineSources": true, 6 | "module": "ESNext", 7 | "target": "es5", 8 | "allowJs": true, 9 | "noImplicitAny": true, 10 | "moduleResolution": "node", 11 | "importHelpers": true, 12 | "lib": [ 13 | "dom", 14 | "es5", 15 | "scripthost", 16 | "es2015" 17 | ] 18 | }, 19 | "include": [ 20 | "**/*.ts" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import typescript from '@rollup/plugin-typescript'; 2 | import {nodeResolve} from '@rollup/plugin-node-resolve'; 3 | import commonjs from '@rollup/plugin-commonjs'; 4 | 5 | export default { 6 | input: 'src/main.ts', 7 | output: { 8 | dir: '.', 9 | sourcemap: 'inline', 10 | format: 'cjs', 11 | exports: 'default' 12 | }, 13 | external: ['obsidian'], 14 | plugins: [ 15 | typescript(), 16 | nodeResolve({browser: true}), 17 | commonjs() 18 | ] 19 | }; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "txt-as-md-obsidian", 3 | "version": "0.0.1", 4 | "description": "Edit txt files as if they were markdown", 5 | "main": "main.js", 6 | "scripts": { 7 | "install-deps": "npm install", 8 | "dev": "rollup --config rollup.config.js -w", 9 | "build": "rollup --config rollup.config.js" 10 | }, 11 | "keywords": [], 12 | "author": "", 13 | "license": "MIT", 14 | "devDependencies": { 15 | "@rollup/plugin-commonjs": "^15.1.0", 16 | "@rollup/plugin-node-resolve": "^9.0.0", 17 | "@rollup/plugin-typescript": "^6.0.0", 18 | "@types/node": "^14.14.22", 19 | "obsidian": "https://github.com/obsidianmd/obsidian-api/tarball/master", 20 | "rollup": "^2.38.0", 21 | "tslib": "^2.1.0", 22 | "typescript": "^4.1.3" 23 | }, 24 | "dependencies": {} 25 | } 26 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /.github/workflows/version.yml: -------------------------------------------------------------------------------- 1 | name: Bump Version 2 | on: 3 | workflow_dispatch: 4 | inputs: 5 | type: 6 | description: 'Type of version (`major`, `minor`, `patch`)' 7 | required: true 8 | default: 'patch' 9 | jobs: 10 | bump: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | with: 15 | persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token 16 | fetch-depth: 0 # otherwise, you will failed to push refs to dest repo 17 | token: ${{secrets.PAT}} # use a personal acces token so that other actions can trigger 18 | - name: Use Node.js 19 | uses: actions/setup-node@v1 20 | with: 21 | node-version: '14.x' # You might need to adjust this value to your own version 22 | - name: Update version 23 | id: version 24 | run: | 25 | git config --local user.email "action@github.com" 26 | git config --local user.name "GitHub Action" 27 | npm version ${{ github.event.inputs.type }} 28 | echo "::set-output name=tag::$(git describe --abbrev=0)" 29 | # update the manifest.json with the tag version 30 | - name: Update manifest version 31 | uses: jossef/action-set-json-field@v1 32 | with: 33 | file: manifest.json 34 | field: version 35 | value: ${{ steps.version.outputs.tag }} 36 | - name: Commit manifest 37 | run: | 38 | git branch --show-current 39 | git add -u 40 | git commit --amend --no-edit 41 | git tag -fa ${{ steps.version.outputs.tag }} -m "${{ steps.version.outputs.tag }}" 42 | # push the commit 43 | - name: Push changes 44 | uses: ad-m/github-push-action@v0.6.0 45 | with: 46 | github_token: ${{secrets.PAT}} 47 | tags: true 48 | branch: ${{ github.ref }} -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release Obsidian Plugin 2 | on: 3 | workflow_dispatch: 4 | push: 5 | # Sequence of patterns matched against refs/tags 6 | tags: 7 | - '*' # Push events to matching any tag format, i.e. 1.0, 20.15.10 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | with: 14 | fetch-depth: 0 # otherwise, you will failed to push refs to dest repo 15 | - name: Use Node.js 16 | uses: actions/setup-node@v1 17 | with: 18 | node-version: '14.x' # You might need to adjust this value to your own version 19 | # Get the version number and put it in a variable 20 | - name: Get Version 21 | id: version 22 | run: | 23 | echo "::set-output name=tag::$(git describe --abbrev=0)" 24 | # Build the plugin 25 | - name: Build 26 | id: build 27 | run: | 28 | npm install 29 | npm run build --if-present 30 | # Package the required files into a zip 31 | - name: Package 32 | run: | 33 | mkdir ${{ github.event.repository.name }} 34 | cp main.js manifest.json README.md ${{ github.event.repository.name }} 35 | zip -r ${{ github.event.repository.name }}.zip ${{ github.event.repository.name }} 36 | # Create the release on github 37 | - name: Create Release 38 | id: create_release 39 | uses: actions/create-release@v1 40 | env: 41 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 42 | VERSION: ${{ github.ref }} 43 | with: 44 | tag_name: ${{ github.ref }} 45 | release_name: ${{ github.ref }} 46 | draft: false 47 | prerelease: false 48 | # Upload the packaged release file 49 | - name: Upload zip file 50 | id: upload-zip 51 | uses: actions/upload-release-asset@v1 52 | env: 53 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 54 | with: 55 | upload_url: ${{ steps.create_release.outputs.upload_url }} 56 | asset_path: ./${{ github.event.repository.name }}.zip 57 | asset_name: ${{ github.event.repository.name }}-${{ steps.version.outputs.tag }}.zip 58 | asset_content_type: application/zip 59 | # Upload the main.js 60 | - name: Upload main.js 61 | id: upload-main 62 | uses: actions/upload-release-asset@v1 63 | env: 64 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 65 | with: 66 | upload_url: ${{ steps.create_release.outputs.upload_url }} 67 | asset_path: ./main.js 68 | asset_name: main.js 69 | asset_content_type: text/javascript 70 | # Upload the manifest.json 71 | - name: Upload manifest.json 72 | id: upload-manifest 73 | uses: actions/upload-release-asset@v1 74 | env: 75 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 76 | with: 77 | upload_url: ${{ steps.create_release.outputs.upload_url }} 78 | asset_path: ./manifest.json 79 | asset_name: manifest.json 80 | asset_content_type: application/json 81 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > [!IMPORTANT] 2 | > This plugin has been superceeded by [Unitade](https://github.com/Falcion/UnitadeOBSIDIAN), which allows not only opening .txt files as markdown by default, but allows you to specify any arbitrary extension to open as markdown. Check it out! 3 | 4 | # txt as md Obsidian plugin 5 | [![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/deathau/txt-as-md-obsidian?style=for-the-badge&sort=semver)](https://github.com/deathau/txt-as-md-obsidian/releases/latest) 6 | ![GitHub All Releases](https://img.shields.io/github/downloads/deathau/txt-as-md-obsidian/total?style=for-the-badge) 7 | 8 | A plugin for [Obsidian](https://obsidian.md) which allows editing of txt files as if they were markdown. 9 | 10 | ![Screenshot](https://github.com/deathau/txt-as-md-obsidian/raw/main/screenshot.png) 11 | 12 | ### Compatibility 13 | 14 | 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. 15 | 16 | ## Installation 17 | 18 | ### From within Obsidian 19 | From Obsidian v0.9.8, you can activate this plugin within Obsidian by doing the following: 20 | - Open Settings > Third-party plugin 21 | - Make sure Safe mode is **off** 22 | - Click Browse community plugins 23 | - Search for this plugin 24 | - Click Install 25 | - Once installed, close the community plugins window and activate the newly installed plugin 26 | #### Updates 27 | You can follow the same procedure to update the plugin 28 | 29 | ### From GitHub 30 | - Download the Latest Release from the Releases section of the GitHub Repository 31 | - Extract the plugin folder from the zip to your vault's plugins folder: `/.obsidian/plugins/` 32 | 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. 33 | - Reload Obsidian 34 | - If prompted about Safe Mode, you can disable safe mode and enable the plugin. 35 | Otherwise head to Settings, third-party plugins, make sure safe mode is off and 36 | enable the plugin from there. 37 | 38 | ## Security 39 | > Third-party plugins can access files on your computer, connect to the internet, and even install additional programs. 40 | 41 | 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. 42 | 43 | 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. 44 | 45 | ## Development 46 | 47 | This project uses Typescript to provide type checking and documentation. 48 | 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. 49 | 50 | **Note:** The Obsidian API is still in early alpha and is subject to change at any time! 51 | 52 | If you want to contribute to development and/or just customize it with your own 53 | tweaks, you can do the following: 54 | - Clone this repo. 55 | - `npm i` or `yarn` to install dependencies 56 | - `npm run build` to compile. 57 | - Copy `manifest.json`, `main.js` and `styles.css` to a subfolder of your plugins 58 | folder (e.g, `/.obsidian/plugins//`) 59 | - Reload obsidian to see changes 60 | 61 | Alternately, you can clone the repo directly into your plugins folder and once 62 | dependencies are installed use `npm run dev` to start compilation in watch mode. 63 | You may have to reload obsidian (`ctrl+R`) to see changes. 64 | 65 | ## Pricing 66 | Huh? This is an open-source plugin I made *for fun*. It's completely free. 67 | However, if you absolutely *have* to send me money because you like it that 68 | much, feel free to throw some coins in my hat via the following: 69 | 70 | [![GitHub Sponsors](https://img.shields.io/github/sponsors/deathau?style=social)](https://github.com/sponsors/deathau) 71 | [![Paypal](https://img.shields.io/badge/paypal-deathau-yellow?style=social&logo=paypal)](https://paypal.me/deathau) 72 | 73 | # Version History 74 | ## 0.0.1 75 | Initial release! 76 | --------------------------------------------------------------------------------