Skip to content

markdown

This directory provides voice commands and configuration to streamline editing and authoring Markdown documents in Talon. It scopes commands exclusively to files detected as Markdown.

The functionality is split across a Python file that defines language configurations and a Talon file that maps voice commands to specific editor actions and snippets.

How It Works

The files in this directory work together to provide context-aware Markdown formatting commands:

  • Context Filtering: Both files target the active context when code.language: markdown is set. This ensures these commands do not conflict with commands used in other programming languages or prose editors.
  • List Definitions: markdown.py defines a list of supported programming and markup languages, establishing a vocabulary that Talon can listen for inside Markdown-specific voice patterns.
  • Voice Command Mappings: markdown.talon implements the spoken rules, consuming the custom language list defined in the Python file to output fully formatted Markdown syntax like nested lists, headings, code fences, and hyperlinks.

File Breakdown

markdown.py

This script registers a custom Talon list, user.markdown_code_block_language, which maps natural spoken words to their respective syntax-highlighting language identifiers used in Markdown code fences. For example:

  • Speaking "python" resolves to python.
  • Speaking "are" resolves to r.
  • Speaking "code" outputs an unlabelled code block.

markdown.talon

This file contains the voice commands tailored for writing Markdown structures:

  • Headings: Commands like level one through level six (or alternatively heading/header one through six) automatically jump to the start of the line and insert the corresponding Markdown # syntax.
  • Lists: Commands like list [one] through list six handle automatic bullet placement (-) with correct, four-space indentation increments for nested lists.
  • Code Blocks: The command {user.markdown_code_block_language} block intercepts spoken language tags (configured in markdown.py) and inserts a snippet containing the language-specific Markdown code block fence: markdownpython [cursor position]
  • Links: The link command triggers a reusable snippet to quickly generate inline links.