### Install pycmarkgfm Source: https://github.com/zopieux/pycmarkgfm/blob/master/README.md Install the package using pip. ```bash $ pip install pycmarkgfm ``` -------------------------------- ### Apply Rendering Options Source: https://github.com/zopieux/pycmarkgfm/blob/master/README.md Use the options module to apply flags like unsafe or hardbreaks via bitwise-or. ```python text = "hello\n" print(pycmarkgfm.markdown_to_html(text)) #

hello #

from pycmarkgfm import options print(pycmarkgfm.markdown_to_html(text, options=options.unsafe | options.hardbreaks)) #

hello
#

``` -------------------------------- ### Convert Markdown to HTML Source: https://github.com/zopieux/pycmarkgfm/blob/master/README.md Use markdown_to_html for CommonMark or gfm_to_html for GitHub Flavored Markdown. ```python import pycmarkgfm # CommonMark (not GitHub flavored): html = pycmarkgfm.markdown_to_html("Hello *world*") # GitHub flavored Markdown: html = pycmarkgfm.gfm_to_html("Hello ~world~") ``` -------------------------------- ### Parse and Toggle Task Lists Source: https://github.com/zopieux/pycmarkgfm/blob/master/README.md Use parse_gfm to access task objects and update their checked state. ```python import pycmarkgfm md = """ - [ ] eggs - [x] milk """ with pycmarkgfm.parse_gfm(md) as document: eggs, milk = document.get_tasks() assert not eggs.checked assert milk.checked # Toggle! eggs.checked = True print(document.to_commonmark()) # - [x] eggs # - [x] milk ``` -------------------------------- ### Toggle Tasks via HTML Attributes Source: https://github.com/zopieux/pycmarkgfm/blob/master/README.md Use the data-gfm-task attribute to identify and toggle tasks programmatically. ```python import pycmarkgfm md = """ - [ ] eggs - [x] milk """ print(pycmarkgfm.gfm_to_html(md)) # # When user clicks a checkbox, get the parent 'data-gfm-task', then on the server, do: new_md = pycmarkgfm.gfm_toggle_task_by_id(md, "2:1-2:10", checked=pycmarkgfm.TOGGLE) print(new_md) # - [x] eggs # - [x] milk ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.