Added Smartypants render flag.
This commit is contained in:
@@ -5,6 +5,7 @@ News/Changelog
|
||||
0.2.0 (2011-05-??)
|
||||
------------------
|
||||
|
||||
* Added Smartypants render flag.
|
||||
* Added a ``toc`` function that outputs a table of contents.
|
||||
* Renamed ``markdown`` function to ``html``.
|
||||
* Updated Upskirt files;
|
||||
|
||||
@@ -82,3 +82,4 @@ Render flags:
|
||||
HTML_SKIP_IMAGES
|
||||
HTML_EXPAND_TABS
|
||||
HTML_USE_XHTML
|
||||
HTML_SMARTYPANTS
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
#include "upskirt/html.h"
|
||||
|
||||
|
||||
/* An extra flag to enabled Smartypants */
|
||||
unsigned int HTML_SMARTYPANTS = (1 << 12);
|
||||
|
||||
|
||||
/* The module doc strings */
|
||||
PyDoc_STRVAR(pantyshot_module__doc__, "Pantyshot is a Python binding for Upskirt!");
|
||||
PyDoc_STRVAR(pantyshot_markdown__doc__, "Render Markdown text into HTML.");
|
||||
@@ -36,6 +40,15 @@ pantyshot_render(const char *text, unsigned int extensions,
|
||||
ups_markdown(ob, ib, &renderer, extensions);
|
||||
upshtml_free_renderer(&renderer);
|
||||
|
||||
/* Smartypants actions */
|
||||
if (render_flags & HTML_SMARTYPANTS)
|
||||
{
|
||||
struct buf *sb = bufnew(1);
|
||||
upshtml_smartypants(sb, ob);
|
||||
ob = bufdup(sb, sb->size); /* Duplicate Smartypants buffer to output buffer */
|
||||
bufrelease(sb); /* Cleanup Smartypants buffer */
|
||||
}
|
||||
|
||||
/* Append a null terminator to the output buffer and make a Python string */
|
||||
bufnullterm(ob);
|
||||
PyObject *html = Py_BuildValue("s", ob->data);
|
||||
@@ -116,4 +129,5 @@ initpantyshot(void)
|
||||
PyModule_AddIntConstant(module, "HTML_HARD_WRAP", HTML_HARD_WRAP);
|
||||
PyModule_AddIntConstant(module, "HTML_GITHUB_BLOCKCODE", HTML_GITHUB_BLOCKCODE);
|
||||
PyModule_AddIntConstant(module, "HTML_USE_XHTML", HTML_USE_XHTML);
|
||||
PyModule_AddIntConstant(module, "HTML_SMARTYPANTS", HTML_SMARTYPANTS);
|
||||
}
|
||||
|
||||
9
test.py
9
test.py
@@ -8,7 +8,10 @@ text = '''
|
||||
|
||||
# Markdown extensions
|
||||
|
||||
Here are some demonstrations of Markdown extensions.
|
||||
Here are some demonstrations of Markdown "extensions".
|
||||
|
||||
|
||||
Test Smartypants: <3/4ths> -- Test test
|
||||
|
||||
|
||||
## MKDEXT_NO_INTRA_EMPHASIS
|
||||
@@ -61,7 +64,7 @@ Nullam tincidunt dui ~vitae~ nulla ~~tristique~~ ultricies.
|
||||
result = p.html(
|
||||
text,
|
||||
p.EXT_TABLES | p.EXT_STRIKETHROUGH | p.EXT_LAX_HTML_BLOCKS,
|
||||
p.HTML_SKIP_HTML | p.HTML_EXPAND_TABS | p.HTML_SKIP_LINKS | p.HTML_TOC
|
||||
p.HTML_SKIP_HTML | p.HTML_EXPAND_TABS | p.HTML_SKIP_LINKS | p.HTML_TOC | p.HTML_SMARTYPANTS
|
||||
)
|
||||
result = p.toc(text)
|
||||
#result = p.toc(text)
|
||||
print result
|
||||
|
||||
Reference in New Issue
Block a user