@@ -92,11 +92,17 @@ class CPPKernel(Kernel):
92
92
'mimetype' : 'text/markdown' ,
93
93
'file_extension' : '.cpp'
94
94
}
95
+
96
+ introduction = "C++ 14 kernel for Jupyter (main), version 1.0.0a5\n \n "
97
+ cp_banner = "Copyright (C) 2023 shiroinekotfs\n Copyright (C) Brendan Rius\n Copyright (C) Free Software Foundation, Inc\n \n "
98
+ links_guide = "Legal information: https://github.com/shiroinekotfs/jupyter-cpp-kernel/blob/master/LICENSE\n Notebook tutorial: https://github.com/shiroinekotfs/jupyter-cpp-kernel-doc\n \n Author GitHub profile: https://github.com/shiroinekotfs\n "
99
+ reporting_links = "Reporting the issue: https://github.com/shiroinekotfs/jupyter-cpp-kernel/issues"
100
+
101
+ banner = introduction + cp_banner + links_guide + reporting_links
102
+
103
+ main_head = "#include <iostream>\n " + "int main(){\n "
95
104
96
- banner = "C++ 14 kernel for Jupyter (main), version 1.0.0a5\n \n "
97
- + "Copyright (C) 2023 shiroinekotfs\n Copyright (C) Brendan Rius\n Copyright (C) Free Software Foundation, Inc\n \n "
98
- + "Legal information: https://github.com/shiroinekotfs/jupyter-cpp-kernel/blob/master/LICENSE\n Notebook tutorial: https://github.com/shiroinekotfs/jupyter-cpp-kernel-doc\n \n Author GitHub profile: https://github.com/shiroinekotfs\n "
99
- + "Reporting the issue: https://github.com/shiroinekotfs/jupyter-cpp-kernel/issues"
105
+ main_foot = "\n return 0;\n }"
100
106
101
107
def __init__ (self , * args , ** kwargs ):
102
108
super (CPPKernel , self ).__init__ (* args , ** kwargs )
@@ -142,7 +148,8 @@ def _write_to_stdout(self, contents):
142
148
'text/markdown' : contents
143
149
},
144
150
'metadata' : {}
145
- })
151
+ }
152
+ )
146
153
147
154
def _write_to_stderr (self , contents ):
148
155
self .send_response (self .iopub_socket , 'stream' , {'name' : 'stderr' , 'text' : contents })
@@ -240,14 +247,15 @@ def _support_external_header(self, code):
240
247
def _add_main (self , magics , code ):
241
248
242
249
if "int main(" not in code :
243
- code = "#include <iostream> \n " + "int main(){ \n \n " + code + "\n \n return 0; \n }"
250
+ code = self . main_head + "\n " + code + "\n " + self . main_foot
244
251
245
252
# User input
246
253
code = re .sub (r'(std::)?cin *>>' , r'std::cout<<GET_INPUT_STREAM_JP;std::cin >>' , code )
247
254
code = re .sub (r'(std::)?getline *' , r'std::cout<<GET_INPUT_STREAM_JP;std::getline ' , code )
248
255
249
256
# Include Global header
250
- code = "#include" + "\" " + self .resDir + "/gcpph.hpp" + "\" \n " + code
257
+ global_header = "#include" + "\" " + self .resDir + "/gcpph.hpp" + "\" "
258
+ code = global_header + "\n " + code
251
259
252
260
# Support External C/C++ header
253
261
code = self ._support_external_header (code )
0 commit comments