From: Jean Privat Date: Thu, 10 Sep 2015 18:53:56 +0000 (-0400) Subject: Merge: nitiwiki: external highlighter X-Git-Tag: v0.7.8~32 X-Git-Url: http://nitlanguage.org?hp=-c Merge: nitiwiki: external highlighter This is a cleaned up version of what is currently doing the code highlighting and the table in the deployed http://nitlanguage.org The basic idea here is to delegate the job to some other program. The program has to be configured in the config.ini under the key `wiki.highlighter` This approach, while not pure nit, makes it quite easy to use whatever highlighter program the user prefer with whatever options (instead of hard-coding a specific external program in the nit source code). An advanced way is to delegate to a shell script that checks arguments then dispatches to a real program. ping maintainer: @Morriar Pull-Request: #1701 Reviewed-by: Lucas Bajolet --- 88a5940f938d045f767582e6dbf452a113ed5396 diff --combined src/testing/testing_doc.nit index 82518da,458e2c6..6bd8f0b --- a/src/testing/testing_doc.nit +++ b/src/testing/testing_doc.nit @@@ -290,11 -290,8 +290,8 @@@ private class NitunitDecorato var executor: NitUnitExecutor redef fun add_code(v, block) do - var code = code_from_block(block) - var meta = "nit" - if block isa BlockFence and block.meta != null then - meta = block.meta.to_s - end + var code = block.raw_content + 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 @@@ -321,26 -318,6 +318,6 @@@ # Add it to the file executor.blocks.last.append code end - - # Extracts code as String from a `BlockCode`. - fun code_from_block(block: BlockCode): String do - var infence = block isa BlockFence - var text = new FlatBuffer - var line = block.block.first_line - while line != null do - if not line.is_empty then - var str = line.value - if not infence and str.has_prefix(" ") then - text.append str.substring(4, str.length - line.trailing) - else - text.append str - end - end - text.append "\n" - line = line.next - end - return text.write_to_string - end end # A unit-test to run @@@ -381,10 -358,10 +358,10 @@@ redef class ModelBuilde # usualy, only the original module must be imported in the unit test. var o = mmodule var g = o.mgroup - if g != null and g.mproject.name == "core" then + if g != null and g.mpackage.name == "core" then # except for a unit test in a module of `core` # in this case, the whole `core` must be imported - o = get_mmodule_by_name(nmodule, g, g.mproject.name).as(not null) + o = get_mmodule_by_name(nmodule, g, g.mpackage.name).as(not null) end ts.attr("package", mmodule.full_name)