@@ -92,17 +92,11 @@ 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 "
104
95
105
- main_foot = "\n return 0;\n }"
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"
106
100
107
101
def __init__ (self , * args , ** kwargs ):
108
102
super (CPPKernel , self ).__init__ (* args , ** kwargs )
@@ -148,8 +142,7 @@ def _write_to_stdout(self, contents):
148
142
'text/markdown' : contents
149
143
},
150
144
'metadata' : {}
151
- }
152
- )
145
+ })
153
146
154
147
def _write_to_stderr (self , contents ):
155
148
self .send_response (self .iopub_socket , 'stream' , {'name' : 'stderr' , 'text' : contents })
@@ -247,15 +240,14 @@ def _support_external_header(self, code):
247
240
def _add_main (self , magics , code ):
248
241
249
242
if "int main(" not in code :
250
- code = self . main_head + "\n " + code + "\n " + self . main_foot
243
+ code = "#include <iostream> \n " + "int main(){ \n \n " + code + "\n \n return 0; \n }"
251
244
252
245
# User input
253
246
code = re .sub (r'(std::)?cin *>>' , r'std::cout<<GET_INPUT_STREAM_JP;std::cin >>' , code )
254
247
code = re .sub (r'(std::)?getline *' , r'std::cout<<GET_INPUT_STREAM_JP;std::getline ' , code )
255
248
256
249
# Include Global header
257
- global_header = "#include" + "\" " + self .resDir + "/gcpph.hpp" + "\" "
258
- code = global_header + "\n " + code
250
+ code = "#include" + "\" " + self .resDir + "/gcpph.hpp" + "\" \n " + code
259
251
260
252
# Support External C/C++ header
261
253
code = self ._support_external_header (code )
0 commit comments