From 4570eb2bff2e1b71fa5b6408abbc69c98ff5ff24 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 22 Nov 2014 22:39:26 -0800 Subject: Revert "Remove distinction btw atx and setext header in AST." This reverts commit a71423f6ee1b77d9f79d42599ea00b4ca99f5da0. Not quite sure about this change, so reverting for now. Note that we still have a distinction between fenced and indented code blocks in the AST. These two distinctions seem to stand or fall together. --- commonmark.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'commonmark.rb') diff --git a/commonmark.rb b/commonmark.rb index 94744dd..0140c1b 100755 --- a/commonmark.rb +++ b/commonmark.rb @@ -11,7 +11,7 @@ module CMark typedef :pointer, :node enum :node_type, [:document, :blockquote, :list, :list_item, :fenced_code, :indented_code, :html, :paragraph, - :header, :hrule, :reference_def, + :atx_header, :setext_header, :hrule, :reference_def, :str, :softbreak, :linebreak, :code, :inline_html, :emph, :strong, :link, :image] enum :list_type, [:no_list, :bullet_list, :ordered_list] @@ -55,7 +55,7 @@ class Node b = CMark::cmark_node_next(b) end @string_content = CMark::cmark_node_get_string_content(pointer) - if @type == :header + if @type == :atx_header || @type == :setext_header @header_level = CMark::cmark_node_get_header_level(pointer) end if @type == :list @@ -195,6 +195,14 @@ class Renderer self.code_block(node) end + def setext_header(node) + self.header(node) + end + + def atx_header(node) + self.header(node) + end + def reference_def(node) end @@ -367,7 +375,7 @@ end # Capitalize strings in headers doc.walk do |node| - if node.type == :header + if node.type == :setext_header or node.type == :atx_header node.walk do |subnode| if subnode.type == :str subnode.string_content = subnode.string_content.upcase -- cgit v1.2.3