summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2014-09-03 03:54:11 +0200
committerVicent Marti <tanoku@gmail.com>2014-09-09 03:39:15 +0200
commitbb6d7c4a394e61574f5f32db60da5c5f5a5e5002 (patch)
tree104a418e61972d3b18e617d2d26ae099363ae255 /src
parent460d46c62b0675f2fab6f103bb9f0d185a73eebb (diff)
342/99
Diffstat (limited to 'src')
-rw-r--r--src/html/html.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/html/html.c b/src/html/html.c
index 27ffe58..3bd5df0 100644
--- a/src/html/html.c
+++ b/src/html/html.c
@@ -102,9 +102,26 @@ void blocks_to_html(gh_buf *html, block *b, bool tight)
case indented_code:
case fenced_code:
- /* TODO: fenced code lang attributes */
cr(html);
- gh_buf_puts(html, "<pre><code>");
+
+ gh_buf_puts(html, "<pre");
+
+ if (b->tag == fenced_code) {
+ gh_buf *info = &b->attributes.fenced_code_data.info;
+
+ if (gh_buf_len(info) > 0) {
+ int first_tag = gh_buf_strchr(info, ' ', 0);
+ if (first_tag < 0)
+ first_tag = gh_buf_len(info);
+
+
+ gh_buf_puts(html, " class=\"");
+ escape_html(html, info->ptr, first_tag);
+ gh_buf_putc(html, '"');
+ }
+ }
+
+ gh_buf_puts(html, "><code>");
escape_html(html, b->string_content.ptr, b->string_content.size);
gh_buf_puts(html, "</code></pre>");
cr(html);