<?xml version="1.0"?>

<action-recipes>
	
	<!-- Formatting actions -->
	
	<action id="com.macrabbit.sugars.markdown.wrap-bold" category="actions.markdown/markdown.format/1">
		<script>format_text.js</script>
		<language-context>markdown</language-context>
		<key-equivalent>command shift b</key-equivalent>
		<setup>
			<characters>**</characters>
			<selector>bold</selector>
		</setup>
	</action>
	
	<action id="com.macrabbit.sugars.markdown.wrap-italics" category="actions.markdown/markdown.format/2">
		<script>format_text.js</script>
		<language-context>markdown</language-context>
		<key-equivalent>command shift i</key-equivalent>
		<setup>
			<characters>_</characters>
			<selector>italic</selector>
		</setup>
	</action>
	
	<action id="com.macrabbit.sugars.markdown.wrap-code" category="actions.markdown/markdown.format/3">
		<script>format_text.js</script>
		<language-context>markdown</language-context>
		<key-equivalent>command shift c</key-equivalent>
		<setup>
			<characters>`</characters>
			<selector>code.inline</selector>
		</setup>
	</action>
	
	<action id="com.macrabbit.sugars.markdown.wrap-selection-in-image" category="actions.markdown/markdown.format/4">
		<class>TEAInsertURLSnippet</class>
		<language-context>markdown</language-context>
		<key-equivalent>control shift i</key-equivalent>
		<setup>
			<snippet><![CDATA[![${EDITOR_SELECTION:${1:Alt text}}](${2:$URL})]]></snippet>
			<fallbackURL>path/to/image.jpg</fallbackURL>
		</setup>
	</action>

	<action id="com.macrabbit.sugars.markdown.wrap-selection-in-link" category="actions.markdown/markdown.format/4">
		<class>TEAInsertURLSnippet</class>
		<language-context>markdown</language-context>
		<key-equivalent>control shift l</key-equivalent>
		<setup>
			<snippet><![CDATA[[${EDITOR_SELECTION:$1}](${2:$URL})]]></snippet>
		</setup>
	</action>
	
	<!-- Header actions -->
	
	<action id="com.macrabbit.sugars.markdown.increase-header" category="actions.markdown/markdown.headers/1">
		<script>change_header_level.js</script>
		<language-context>markdown</language-context>
		<key-equivalent>command shift h</key-equivalent>
		<setup>
			<increment>1</increment>
		</setup>
	</action>
	
	<action id="com.macrabbit.sugars.markdown.decrease-header" category="actions.markdown/markdown.headers/2">
		<script>change_header_level.js</script>
		<language-context>markdown</language-context>
		<key-equivalent>command shift option h</key-equivalent>
		<setup>
			<increment>-1</increment>
		</setup>
	</action>
	
	<action id="com.macrabbit.sugars.markdown.setext-header-1" category="actions.markdown/markdown.headers/3">
		<script>insert_setext_header.js</script>
		<language-context>markdown</language-context>
		<text-trigger>=</text-trigger>
		<setup>
			<character>=</character>
		</setup>
	</action>
	
	<action id="com.macrabbit.sugars.markdown.setext-header-2" category="actions.markdown/markdown.headers/4">
		<script>insert_setext_header.js</script>
		<language-context>markdown</language-context>
		<text-trigger>-</text-trigger>
		<setup>
			<character>-</character>
		</setup>
	</action>
	
	<action id="com.macrabbit.sugars.markdown.setext-header-update" category="actions.markdown/markdown.headers/5">
		<script>update_setext_header.js</script>
		<language-context>markdown</language-context>
		<key-equivalent>command control option h</key-equivalent>
	</action>
	
	<!-- Horizontal rules -->
		
	<action id="com.macrabbit.sugars.markdown.hr-asterisk" category="actions.markdown/markdown.headers/markdown.hr/1">
		<script>insert_hr.js</script>
		<language-context>markdown</language-context>
		<text-trigger>*</text-trigger>
		<setup>
			<snippet>* * *

$0</snippet>
		</setup>
	</action>

	<action id="com.macrabbit.sugars.markdown.hr-hyphen" category="actions.markdown/markdown.headers/markdown.hr/2">
		<script>insert_hr.js</script>
		<language-context>markdown</language-context>
		<text-trigger>-</text-trigger>
		<setup>
			<snippet>- - -

$0</snippet>
		</setup>
	</action>

	<action id="com.macrabbit.sugars.markdown.hr-underscore" category="actions.markdown/markdown.headers/markdown.hr/3">
		<script>insert_hr.js</script>
		<language-context>markdown</language-context>
		<text-trigger>_</text-trigger>
		<setup>
			<snippet>_____

$0</snippet>
		</setup>
	</action>
	
	<!-- List/Blockquote actions -->
	
	<action id="com.macrabbit.sugars.markdown.insert-blockquote" category="actions.markdown/markdown.lists/1">
		<script>insert_blockquote.js</script>
		<language-context>markdown</language-context>
		<key-equivalent>command "</key-equivalent>
	</action>

	<action id="com.macrabbit.sugars.markdown.list-insert-unordered" category="actions.markdown/markdown.lists/2">
		<script>list_insert.js</script>
		<language-context>markdown</language-context>
		<key-equivalent>command shift u</key-equivalent>
		<setup>
			<type>unordered</type>
		</setup>
	</action>
	
	<action id="com.macrabbit.sugars.markdown.list-insert-ordered" category="actions.markdown/markdown.lists/3">
		<script>list_insert.js</script>
		<language-context>markdown</language-context>
		<key-equivalent>command shift o</key-equivalent>
		<setup>
			<type>ordered</type>
		</setup>
	</action>
	
	<action id="com.macrabbit.sugars.markdown.list-update-ordered-elements" category="actions.markdown/markdown.lists/4">
		<script>list_update_elements.js</script>
		<language-context>markdown</language-context>
		<key-equivalent>command control option o</key-equivalent>
	</action>
	
	<action id="com.macrabbit.sugars.markdown.list-newline" category="hidden">
		<script>list_newline.js</script>
		<language-context>markdown</language-context>
		<syntax-context>list.element, list.element *:not(code.block)</syntax-context>
		<text-trigger key-equivalent="enter"></text-trigger>
	</action>
	
	<!-- Other actions -->
	
	<action id="com.macrabbit.sugars.markdown.convert-in-place" category="actions.markdown/markdown.convert">
		<script>convert_markdown.js</script>
		<language-context>markdown</language-context>
	</action>
	
</action-recipes>