You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
>>> import markdown
>>> text = "%%dc:author :: Sherry Turkle | Turkle's%% %%dc:title::Second Self%% was an early book on the social aspects of computation."
>>> html = markdown.markdown(text, ['semanticdata'])
>>> print(html)
<p><span content="Sherry Turkle" property="dc:author">Turkle's</span> <span content="Second Self" property="dc:title">Second Self</span> was an early book on the social aspects of computation.</p>
Custom tree element:
>>> def make_elt (md, rel, target, label):
... # `md` is the Markdown instance
... if rel == "dc:title":
... elt = markdown.util.etree.Element('cite')
... else:
... elt = markdown.util.etree.Element('span')
... elt.set('content', target)
... elt.text = label or target
... if rel:
... elt.set('property', rel)
... return elt
>>> md = markdown.Markdown(extensions=['semanticdata'],
... extension_configs={'semanticdata' : [('make_elt', make_elt)]})
>>> html = md.convert(text)
>>> print(html)
<p><span content="Sherry Turkle" property="dc:author">Turkle's</span> <cite content="Second Self" property="dc:title">Second Self</cite> was an early book on the social aspects of computation.</p>
Custom default namespace:
>>> text = "%%author :: Sherry Turkle | Turkle's%% %%title::Second Self%% was an early book on the social aspects of computation."
>>> md = markdown.Markdown(extensions=['semanticdata'],
... extension_configs={'semanticdata' : [('namespace', 'dc')]})
>>> html = md.convert(text)
>>> print(html)
<p><span content="Sherry Turkle" property="dc:author">Turkle's</span> <span content="Second Self" property="dc:title">Second Self</span> was an early book on the social aspects of computation.</p>