lib/markdown: promote `BlockFence::meta` to `BlockCode` to simplify clients
authorJean Privat <jean@pryen.org>
Thu, 10 Sep 2015 01:29:30 +0000 (21:29 -0400)
committerJean Privat <jean@pryen.org>
Thu, 10 Sep 2015 10:27:27 +0000 (06:27 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

lib/markdown/markdown.nit
src/doc/doc_down.nit
src/testing/testing_doc.nit

index 9124ad7..613e1a4 100644 (file)
@@ -1233,6 +1233,9 @@ end
 class BlockCode
        super Block
 
+       # Any string found after fence token.
+       var meta: nullable Text
+
        # Number of char to skip at the beginning of the line.
        #
        # Block code lines start at 4 spaces.
@@ -1259,9 +1262,6 @@ end
 class BlockFence
        super BlockCode
 
-       # Any string found after fence token.
-       var meta: nullable Text
-
        # Fence code lines start at 0 spaces.
        redef var line_start = 0
 end
index 6482032..e04abb9 100644 (file)
@@ -99,10 +99,8 @@ private class NitdocDecorator
        var toolcontext = new ToolContext
 
        redef fun add_code(v, block) do
-               var meta = "nit"
-               if block isa BlockFence and block.meta != null then
-                       meta = block.meta.to_s
-               end
+               var meta = block.meta or else "nit"
+
                # Do not try to highlight non-nit code.
                if meta != "nit" and meta != "nitish" then
                        v.add "<pre class=\"{meta}\"><code>"
index b5b0f5d..458e2c6 100644 (file)
@@ -291,10 +291,7 @@ private class NitunitDecorator
 
        redef fun add_code(v, block) do
                var code = block.raw_content
-               var meta = "nit"
-               if block isa BlockFence and block.meta != null then
-                       meta = block.meta.to_s
-               end
+               var meta = block.meta or else "nit"
                # Do not try to test non-nit code.
                if meta != "nit" then return
                # Try to parse code blocks