Text Processing Helpers
Clean and format text for Asana tasks.
Overview
Text processing helpers transform PR content to make it suitable for Asana. This includes removing conventional commit prefixes and cleaning markdown that doesn't render well in Asana.
Helpers
clean_title
Remove conventional commit prefixes from PR titles.
Syntax:
Parameters:
text- The title string to clean
Returns: Title with commit prefix removed
Removes these prefixes:
feat:,fix:,chore:,docs:,style:,refactor:,perf:,test:- Scoped variants:
feat(api):,fix(ui):, etc.
Example:
create_task:
title: '{{clean_title pr.title}}'sanitize_markdown
Clean markdown for Asana's text rendering.
Syntax:
Parameters:
text- The markdown text to sanitize
Returns: Cleaned text suitable for Asana
Removes/Cleans:
- Markdown images (
) - Linked images (
[](link)) - HTML comments (
[//]: # (comment)) <details>tags and content- Normalizes line endings and whitespace
Example:
create_task:
notes: '{{sanitize_markdown pr.body}}'Examples
clean_title
Basic Prefixes
Scoped Prefixes
No Prefix
sanitize_markdown
Remove Images
Clean HTML
Normalize Whitespace
Common Use Cases
Clean Task Titles
Create readable task titles from PR titles:
rules:
- when:
event: pull_request
action: opened
has_asana_tasks: false
author: 'dependabot[bot]'
then:
create_task:
project: '1234567890'
workspace: '0987654321'
title: '{{clean_title pr.title}}'Result:
- PR Title:
chore(deps): bump lodash from 4.17.19 to 4.17.21 - Task Title:
bump lodash from 4.17.19 to 4.17.21
Combine Both Helpers
Clean title and description together:
rules:
- when:
event: pull_request
action: opened
has_asana_tasks: false
then:
create_task:
project: '1234567890'
workspace: '0987654321'
title: '{{clean_title pr.title}}'
notes: |
{{sanitize_markdown pr.body}}
PR: {{pr.url}}Use in PR Comments
rules:
- when:
event: pull_request
action: opened
then:
post_pr_comment: |
Task created: {{clean_title pr.title}}Preserve Original in HTML Notes
Keep full formatting in HTML:
create_task:
title: '{{clean_title pr.title}}'
html_notes: |
<strong>{{pr.title}}</strong>
<br><br>
{{sanitize_markdown pr.body}}Why Use These Helpers?
clean_title Benefits
Without clean_title:
Task: "feat(api): Add user authentication endpoint"With clean_title:
Task: "Add user authentication endpoint"Asana tasks look cleaner without git-specific prefixes.
sanitize_markdown Benefits
Markdown issues in Asana:
- Images don't render (show as broken links)
<details>tags don't work (show raw HTML)- Inconsistent line endings cause formatting issues
- Extra whitespace looks unprofessional
After sanitization:
- Clean text without broken image references
- Proper line breaks
- Consistent formatting
- Professional appearance
Combining with Other Helpers
With Extraction
title: '{{clean_title pr.title}}'
notes: |
{{sanitize_markdown pr.body}}
Version: {{extract_from_body "Version: ([\\d.]+)"}}With OR
title: '{{or (clean_title pr.title) "Untitled PR"}}'With User Mapping
create_task:
title: '{{clean_title pr.title}}'
notes: '{{sanitize_markdown pr.body}}'
assignee: '{{map_github_to_asana pr.author}}'Edge Cases
Empty Input
Both helpers handle empty input gracefully:
Already Clean
If text doesn't need cleaning, it's returned unchanged:
Multiple Prefixes
Only the first prefix is removed:
HTML Notes Alternative
For rich formatting, use html_notes instead of notes:
create_task:
title: '{{clean_title pr.title}}'
html_notes: |
<strong>PR Description</strong>
<br><br>
{{sanitize_markdown pr.body}}
<br><br>
<a href="{{pr.url}}">View PR #{{pr.number}}</a>This gives you more control over formatting while still cleaning the markdown.
Performance
Both helpers are fast:
clean_title: Simple regex replacementsanitize_markdown: Multiple regex passes, but optimized
No noticeable performance impact even with large PR descriptions.
See Also
- extract_from_body - Extract specific content
- create_task - Where to use these helpers
- Context Variables - PR title and body variables
- Template System - Handlebars overview