├── m2o.sh ├── LICENSE └── README.md /m2o.sh: -------------------------------------------------------------------------------- 1 | m2o () { 2 | echo "Convert chat in markdown into org-mode. Uses pandoc." 3 | echo "Takes only the filestem of the markdown file." 4 | if [ $# -lt 1 ] 5 | then 6 | echo "$0: not enough arguments" >&1 7 | echo "Supply the mp3 file stem." 8 | echo "Usage: m2o fileStem" 9 | return 2 10 | elif [ $# -gt 1 ] 11 | then 12 | echo "$0: too many arguments" >&1 13 | echo "Supply the mp3 file stem." 14 | echo "Usage: m2o fileStem" 15 | fi 16 | pandoc -f markdown -t org $1.md -o $1.org 17 | ( 18 | echo "#+Title: $1." 19 | echo "#+Date: $(date +%Y-%m-%d)" 20 | echo "#+Author: Claude 3.5 Sonnet" 21 | echo "\n" 22 | cat $1.org 23 | ) > temp 24 | mv temp $1.org 25 | } 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Blaine Mooers and the University of Oklahoma Board of Regents 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Version](https://img.shields.io/static/v1?label=markdown-chat-to-org-mode&message=0.1&color=brightcolor) 2 | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) 3 | 4 | # markdown-chat-to-org-mode 5 | 6 | ## Problem addressed 7 | Most of the chatbots generate chats in markdown. 8 | If you want to save these chats and store them as org-mode files that you may include in a knowledge graph under the subfolder called *projects*, *protocols*, *resources*, or *code*, you have to carry out the conversion of the org file format. 9 | The program pandoc does a good job of this, but I have trouble remembering the syntax for the pandoc command, and pandoc does not add the frontmatter of the org file. 10 | 11 | ## My solution 12 | I developed a bash function that runs pandoc and adds the front matter to the file. 13 | Other solutions out there enable this operation to be done from inside of Emacs while running a chatbot inside Emacs (e.g., gptel). 14 | However, if you run a chatbot outside of Emacs, you will probably handle the downloaded file outside of Emacs. 15 | Because you are already outside of the Emacs, you could use a little Bash. 16 | 17 | This bash function takes the single argument of the markdown file's filestem. 18 | To incorporate this new note into the org-roam database, you must run the command `M-x org-id-get-create` to add a unique identifier to this file. 19 | 20 | ```bash 21 | m2o () { 22 | echo "Convert chat in markdown into org-mode. Uses pandoc." 23 | echo "Takes only the filestem of the markdown file." 24 | if [ $# -lt 1 ] 25 | then 26 | echo "$0: not enough arguments" >&1 27 | echo "Supply the mp3 file stem." 28 | echo "Usage: m2o fileStem" 29 | return 2 30 | elif [ $# -gt 1 ] 31 | then 32 | echo "$0: too many arguments" >&1 33 | echo "Supply the mp3 file stem." 34 | echo "Usage: m2o fileStem" 35 | fi 36 | pandoc -f markdown -t org $1.md -o $1.org 37 | ( 38 | echo "#+Title: $1." 39 | echo "#+Date: $(date +%Y-%m-%d)" 40 | echo "#+Author: Claude 3.5 Sonnet" 41 | echo "\n" 42 | cat $1.org 43 | ) > temp 44 | mv temp $1.org 45 | } 46 | ``` 47 | 48 | Save the function where you save your bash aliases or, better yet, a dedicated `~/.bashFunctions` file. 49 | Source this file from your .bashrc or .zshrc file so it is always available. 50 | You can display the code in the terminal from any directory by entering `which m2o`. 51 | I call this a bash function, but I use it in zsh. 52 | 53 | This trivial function was generated ab inito. 54 | 55 | 56 | ## Update history 57 | 58 | |Version | Changes | Date | 59 | |:-----------|:------------------------------------------------------------------------------------------------------------------------------------------|:--------------------| 60 | | Version 0.1 | Added badges, funding, and update table. Initial commit. | 2025 March 14 | 61 | 62 | ## Sources of funding 63 | 64 | - NIH: R01 CA242845 65 | - NIH: R01 AI088011 66 | - NIH: P30 CA225520 (PI: R. Mannel) 67 | - NIH: P20 GM103640 and P30 GM145423 (PI: A. West) 68 | --------------------------------------------------------------------------------