transformed callouts to enable easy copy/pasting from code tabs

Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/6c0b14c0
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/6c0b14c0
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/6c0b14c0

Branch: refs/heads/TINKERPOP-1447
Commit: 6c0b14c009b4ba73106009f19b750ff5c7feb001
Parents: 9c7b5fc
Author: Daniel Kuppitz <[email protected]>
Authored: Wed Jan 3 10:13:06 2018 -0700
Committer: Daniel Kuppitz <[email protected]>
Committed: Wed Jan 24 14:14:11 2018 -0700

----------------------------------------------------------------------
 docs/preprocessor/awk/tabify.awk | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6c0b14c0/docs/preprocessor/awk/tabify.awk
----------------------------------------------------------------------
diff --git a/docs/preprocessor/awk/tabify.awk b/docs/preprocessor/awk/tabify.awk
index df92734..24d42a6 100644
--- a/docs/preprocessor/awk/tabify.awk
+++ b/docs/preprocessor/awk/tabify.awk
@@ -47,6 +47,10 @@ function print_tabs(next_id, tabs, blocks) {
   print "++++\n"
 }
 
+function transform_callouts(code, c) {
+  return gensub(/\s*((<[0-9]+>\s*)*<[0-9]+>)\s*\n/, " " c c " \\1\\2\n", "g", 
code)
+}
+
 BEGIN {
   id_part=systime()
   status = 0
@@ -98,7 +102,15 @@ BEGIN {
         i++
       }
       tabs[i] = lang
-      blocks[i] = "[source," lang "]" code "\n" $0 "\n"
+      switch (lang) {
+        case "python":
+          c = "#"
+          break
+        default:
+          c = "//"
+          break
+      }
+      blocks[i] = "[source," lang "]" transform_callouts(code, c) "\n" $0 "\n"
     }
   } else {
     if (status == 0) print

Reply via email to