From b1784a7c82f65cc6f9798cc087c564b18871abbf Mon Sep 17 00:00:00 2001 From: Frans Bouma Date: Thu, 18 Feb 2016 12:04:29 +0100 Subject: [PATCH] Enabled Titled Image rendering. No CSS yet Titled image rendering is enabled by default, and is used if the image specification contains a title specification, like: ![alt text](image url "title"). If the title is omitted, the image is rendered normally. --- src/DocNet/Utils.cs | 1 + src/MarkdownDeep/MardownDeep.cs | 1 - src/MarkdownDeep/SpanFormatter.cs | 6 ++++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/DocNet/Utils.cs b/src/DocNet/Utils.cs index aeb20e4..4808056 100644 --- a/src/DocNet/Utils.cs +++ b/src/DocNet/Utils.cs @@ -50,6 +50,7 @@ namespace Docnet DocNetMode = true, DocumentLocation = documentPath, DocumentRoot = siteRoot, + HtmlClassTitledImages = "Figure", }; var toReturn = parser.Transform(toConvert); diff --git a/src/MarkdownDeep/MardownDeep.cs b/src/MarkdownDeep/MardownDeep.cs index abea7c9..d74c70b 100644 --- a/src/MarkdownDeep/MardownDeep.cs +++ b/src/MarkdownDeep/MardownDeep.cs @@ -1002,7 +1002,6 @@ namespace MarkdownDeep // Use CSS to style the figure and the caption public string HtmlClassTitledImages { - // TODO: get; set; } diff --git a/src/MarkdownDeep/SpanFormatter.cs b/src/MarkdownDeep/SpanFormatter.cs index db534e4..dafc4fa 100644 --- a/src/MarkdownDeep/SpanFormatter.cs +++ b/src/MarkdownDeep/SpanFormatter.cs @@ -35,8 +35,10 @@ namespace MarkdownDeep // Parse the string into a list of tokens Tokenize(str, start, len); - // Titled image? - if (m_Tokens.Count == 1 && m_Markdown.HtmlClassTitledImages != null && m_Tokens[0].type == TokenType.img) + // If the image is a titled image and there's a class defined for titled images, we'll render it using special markup, otherwise we'll render + // the image as-is. + if (m_Tokens.Count == 1 && !string.IsNullOrWhiteSpace(m_Markdown.HtmlClassTitledImages) && m_Tokens[0].type == TokenType.img && + m_Tokens[0].data is LinkInfo && !string.IsNullOrWhiteSpace(((LinkInfo)m_Tokens[0].data).def.title)) { // Grab the link info LinkInfo li = (LinkInfo)m_Tokens[0].data;