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, cleaning markdown, and converting markdown to HTML for rich formatting in Asana tasks.
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}}'markdown_to_html
Convert markdown to HTML for use in Asana's html_notes field.
Syntax:
Parameters:
text- The markdown text to convert
Returns: HTML string suitable for Asana html_notes
Converts:
- Headings (
#,##) →<h1>,<h2>(h3–h6 downgraded to<h2>) - Bold/italic/strikethrough →
<strong>,<em>,<s> - Unordered/ordered lists →
<ul>/<ol>with<li> - Links →
<a href="..."> - Code blocks and inline code →
<pre><code>,<code> - Blockquotes →
<blockquote> - Horizontal rules →
<hr> - Tables →
<table>/<tr>/<td>(normalizes away<thead>,<tbody>,<th>)
Strips (unsupported by Asana):
- Images (
and linked images) - HTML comments (
[//]: # (...)) - Raw HTML tags in the input (e.g.
<script>, event handler attributes) — only markdown-generated HTML is emitted classattributes (e.g. syntax highlighting classes)
Unwraps (tags removed, content preserved):
<details>/<summary>— collapse behavior is lost but the text is kept
Example:
create_task:
html_notes: '<body>{{markdown_to_html pr.body}}</body>'Body wrapper required
Asana requires html_notes to be wrapped in <body> tags. The helper returns the inner HTML content only — you must wrap it yourself.
sanitize_markdown
Clean markdown for Asana's plain 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
markdown_to_html
Headings
h1 and h2 pass through unchanged. h3–h6 are downgraded to h2 since Asana only supports those two levels.
Inline Formatting
Lists
Links
Code
The class attribute (added by marked for syntax highlighting) is stripped since Asana doesn't use it.
Tables
<thead>, <tbody>, and <th> are normalized to the subset Asana supports (<table>, <tr>, <td>).
Images
Images are stripped — Asana's html_notes only supports images attached to the task, not external URLs.
details blocks
The <details> and <summary> tags are removed but their text content is preserved — collapse behavior is lost but nothing is dropped.
HTML comments
Empty input
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}}Rich HTML Notes from PR Body
Use markdown_to_html to get full rich text rendering in Asana:
create_task:
title: '{{clean_title pr.title}}'
html_notes: '<body>{{markdown_to_html pr.body}}</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
All 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:
notes vs html_notes
Use notes with sanitize_markdown for plain text, or html_notes with markdown_to_html for rich formatting:
# Plain text — headings and lists show as raw markdown
create_task:
notes: '{{sanitize_markdown pr.body}}'# Rich text — headings, lists, tables, and links render properly in Asana
create_task:
html_notes: '<body>{{markdown_to_html pr.body}}</body>'You can also mix static HTML with the helper output:
create_task:
html_notes: |
<body>
{{markdown_to_html pr.body}}
<hr/>
<a href="{{pr.url}}">View PR #{{pr.number}}</a>
</body>Performance
All helpers are fast:
clean_title: Single regex replacementsanitize_markdown: Multiple regex passes, but optimizedmarkdown_to_html: Markdown parse + regex post-processing; negligible overhead even for 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