diff --git a/main.py b/main.py index bfb98c9..43e56c8 100644 --- a/main.py +++ b/main.py @@ -9,6 +9,23 @@ from flowlauncher import FlowLauncher import webbrowser +_MARKDOWN_PREVIEW_EXAMPLE = """## Markdown Example + +**Bold** and *italic* text. + +A code block: +```python +def greet(name): + return "Hello " + name +``` +""" + + +def _build_markdown_preview(query): + if query: + return query + "\n\n---\n\n" + _MARKDOWN_PREVIEW_EXAMPLE + return _MARKDOWN_PREVIEW_EXAMPLE + class HelloWorld(FlowLauncher): @@ -21,7 +38,37 @@ def query(self, query): "JsonRPCAction": { "method": "open_url", "parameters": ["https://github.com/Flow-Launcher/Flow.Launcher"] - } + }, + }, + { + "Title": "This has a markdown preview with visibility set to \"always\"", + "SubTitle": "PreviewVisibility: always, ContentType: markdown", + "IcoPath": "Images/app.png", + "Preview": { + "ContentType": "markdown", + "Description": _build_markdown_preview(query) + }, + "PreviewVisibility": "always" + }, + { + "Title": "This has a markdown preview with visibility set to \"optional\"", + "SubTitle": "PreviewVisibility: optional (default), ContentType: markdown", + "IcoPath": "Images/app.png", + "Preview": { + "ContentType": "markdown", + "Description": _build_markdown_preview(query) + }, + "PreviewVisibility": "optional" + }, + { + "Title": "This has a markdown preview with visibility set to \"never\"", + "SubTitle": "PreviewVisibility: never, ContentType: markdown", + "IcoPath": "Images/app.png", + "Preview": { + "ContentType": "markdown", + "Description": _build_markdown_preview(query) + }, + "PreviewVisibility": "never" } ]