diff --git a/docs/advanced.md b/docs/advanced.md index 67d5553c..3a0172e7 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -38,6 +38,9 @@ and can be edited with a plain text editor. controls the width of the output. Set to `false` if you don't want to wrap long lines. - `colors` dictionary that controls the colors used to display journal entries. It has four subkeys, which are: `body`, `date`, `tags`, and `title`. Current valid values are: `BLACK`, `RED`, `GREEN`, `YELLOW`, `BLUE`, `MAGENTA`, `CYAN`, `WHITE`, and `NONE`. `colorama.Fore` is used for colorization, and you can find the [docs here](https://github.com/tartley/colorama#colored-output). To disable colored output, set the value to `NONE`. If you set the value of any color subkey to an invalid color, no color will be used. + - `display_format` + specifies formatter to use, formatters available are: + `boxed`, `fancy`, `json`, `markdown`, `md`, `tags`, `text`, `txt`, `xml`, or `yaml`. !!! note Although it seems intuitive to use the `#` diff --git a/jrnl/Journal.py b/jrnl/Journal.py index a6bf35d0..2028666b 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -35,6 +35,7 @@ class Journal: "highlight": True, "linewrap": 80, "indent_character": "|", + "display_format": "text", } self.config.update(kwargs) # Set up date parser diff --git a/jrnl/install.py b/jrnl/install.py index 5f5f0032..8347d27c 100644 --- a/jrnl/install.py +++ b/jrnl/install.py @@ -49,6 +49,7 @@ default_config = { "linewrap": 79, "indent_character": "|", "colors": {"date": "none", "title": "none", "body": "none", "tags": "none",}, + "display_format": "text", } diff --git a/jrnl/jrnl.py b/jrnl/jrnl.py index 33eabdd0..97886928 100644 --- a/jrnl/jrnl.py +++ b/jrnl/jrnl.py @@ -290,7 +290,7 @@ def _delete_search_results(journal, old_entries, **kwargs): journal.write() -def _display_search_results(args, journal, **kwargs): +def _display_search_results(args, journal, config, **kwargs): if args.short: print(journal.pprint(short=True)) @@ -300,7 +300,8 @@ def _display_search_results(args, journal, **kwargs): elif args.export: exporter = plugins.get_exporter(args.export) print(exporter.export(journal, args.filename)) - else: - # Default display mode - print(journal.pprint()) + # Display according display_format config option + config_selected = config.get("display_format", journal.config["display_format"]) + exporter = plugins.get_exporter(config_selected) + print(exporter.export(journal, args.filename))